babylonjs-toolkit 9.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/lib/babylon.toolkit.d.ts +10524 -0
- package/lib/babylon.toolkit.js +1 -0
- package/lib/index.d.ts +10524 -0
- package/package.json +55 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TOOLKIT=t():e.TOOLKIT=t()}(this,()=>(()=>{"use strict";var e={d:(t,i)=>{for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>h});var i,n,r,o=(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),a=function(){return a=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},a.apply(this,arguments)},s=function(e,t,i,n){return new(i||(i=Promise))(function(r,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},l=function(e,t){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},u=function(e,t,i){if(i||2===arguments.length)for(var n,r=0,o=t.length;r<o;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))};!function(e){var t=function(){function t(){}return Object.defineProperty(t,"Version",{get:function(){return"9.10.1 - R1"},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Copyright",{get:function(){return"All rights reserved (c) 2024 Mackey Kinard"},enumerable:!1,configurable:!0}),t.GetEngine=function(e){var t=null,i=e.getEngine();return null!=i&&(i instanceof BABYLON.Engine||i instanceof BABYLON.WebGPUEngine)&&(t=i),t},t.GetClass=function(e){return BABYLON.GetClass(e)},t.RegisterClass=function(e,t){BABYLON.RegisterClass(e,t)},t.GetAuxiliaryData=function(e){var t;return null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.auxiliary},t.SetAuxiliaryData=function(e,t){e.metadata=a(a({},e.metadata),{auxiliary:t})},Object.defineProperty(t,"EventBus",{get:function(){return null==e.SceneManager._EventBus&&(e.SceneManager._EventBus=new e.GlobalMessageBus),e.SceneManager._EventBus},enumerable:!1,configurable:!0}),Object.defineProperty(t,"PlaygroundCdn",{get:function(){return"https://cdn.jsdelivr.net/gh/BabylonJS/BabylonToolkit@master/Runtime/"},enumerable:!1,configurable:!0}),Object.defineProperty(t,"PlaygroundRepo",{get:function(){return"https://www.babylontoolkit.com/playground/"},enumerable:!1,configurable:!0}),t.InitializePlayground=function(t){return s(this,arguments,void 0,function(t,i,n,r){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===r&&(r=null),l(this,function(o){return[2,e.SceneManager.InitializeRuntime(t,i,n,r)]})})},t.InitializeRuntime=function(t){return s(this,arguments,void 0,function(t,i,n,r){var o,a,s,u,h,c,d,m,p;return void 0===i&&(i=null),void 0===n&&(n=null),void 0===r&&(r=null),l(this,function(l){switch(l.label){case 0:BABYLON.Tools.Log("Babylon.js Toolkit v"+e.SceneManager.Version),e.AudioSource.IsLegacyEngine()&&BABYLON.Tools.Log("Legacy audio engine detected"),o=null!=i&&null!=i.hardwareScalingLevel?i.hardwareScalingLevel:e.WindowManager.GetHardwareScalingLevel(),null==i||null==i.initSceneFileLoaders||i.initSceneFileLoaders,null==i||null==i.loadAsyncRuntimeLibs||i.loadAsyncRuntimeLibs,a=null!=i&&null!=i.enableUserInput&&i.enableUserInput,s=e.SceneManager.PlaygroundCdn+"default.playground.js",u=null!=i&&null!=i.loadProjectScriptBundle&&i.loadProjectScriptBundle,h=null!=i&&null!=i.projectScriptBundleUrl?i.projectScriptBundleUrl:s,c=null!=i&&null!=i.showDefaultLoadingScreen&&i.showDefaultLoadingScreen,d=null==i||null==i.hideLoadingUIWithEngine||i.hideLoadingUIWithEngine,m=null!=i&&null!=i.defaultLoadingUIMarginTop?i.defaultLoadingUIMarginTop:"150px",!0===c&&e.SceneManager.ShowLoadingScreen(t,d,m),null!=o&&o>0&&t.setHardwareScalingLevel(o),!0===a&&e.InputController.EnableUserInput(t,n,r),e.SceneManager.UniversalModuleDefinition=!0;try{e.SceneManager.InitializeSceneLoaderPlugin()}catch(e){console.warn("Babylon Toolkit: Failed to initialize loader plugin:",e)}try{BABYLON&&BABYLON.GLTF2&&BABYLON.GLTF2.registerGLTFExtension?(e.SceneManager.CVTOOLS_NAME_REGISTERED||(BABYLON.GLTF2.registerGLTFExtension(e.SceneManager.CVTOOLS_NAME,!0,function(t){return e.CVTOOLS_unity_metadata.CreateExtensionAsync(t)}),e.SceneManager.CVTOOLS_NAME_REGISTERED=!0),e.SceneManager.CVTOOLS_MESH_REGISTERED||(BABYLON.GLTF2.registerGLTFExtension(e.SceneManager.CVTOOLS_MESH,!0,function(t){return new e.CVTOOLS_babylon_mesh(t)}),e.SceneManager.CVTOOLS_MESH_REGISTERED=!0),e.SceneManager.CVTOOLS_HAND_REGISTERED||(BABYLON.GLTF2.registerGLTFExtension(e.SceneManager.CVTOOLS_HAND,!0,function(t){return new e.CVTOOLS_left_handed(t)}),e.SceneManager.CVTOOLS_HAND_REGISTERED=!0)):console.warn("Babylon Toolkit: UMD GLTF Parser not registered because BABYLON.GLTF2 or RegisterGLTFExtension is not available.")}catch(e){console.warn("Babylon Toolkit: Failed to initialize GLTF extensions:",e)}return!0!==u||null==h||""===h?[3,2]:(p=h.substring(h.lastIndexOf("/")+1).toLowerCase(),[4,BABYLON.Tools.LoadScriptAsync(h,p)]);case 1:l.sent(),l.label=2;case 2:return[2]}})})},t.InitializePhysicsEngine=function(e){return s(this,arguments,void 0,function(e,t,i,n,r,o){var a,s,u,h;return void 0===t&&(t=null),void 0===i&&(i=!0),l(this,function(l){switch(l.label){case 0:return null!=(a=globalThis).HK&&null!=a.HKP?[3,2]:(s=a,[4,a.HavokPhysics()]);case 1:s.HK=l.sent(),a.HKP=new BABYLON.HavokPlugin(n,r,o),l.label=2;case 2:return e.isDisposed||null==a.HK||null==a.HKP||(u=null!=t?t:new BABYLON.Vector3(0,-9.81,0),e.enablePhysics(u,a.HKP)),h=function(){!0===i&&(a.HKP&&delete a.HKP,a.HK&&delete a.HK)},e.isDisposed?h():e.onDisposeObservable.addOnce(h),[2]}})})},t.InitializeSceneLoaderPlugin=function(){BABYLON.SceneLoader.OnPluginActivatedObservable.add(function(t){null!=t&&"gltf"===t.name&&t instanceof BABYLON.GLTFFileLoader&&(t.extensions,t.animationStartMode=e.SceneManager.AnimationStartMode,t.targetFps=e.SceneManager.AnimationTargetFps,t.onSkinLoadedObservable&&t.onSkinLoadedObservable.add(function(e){if(null!=e){try{null!=e.skinnedNode&&(e.skinnedNode.id+=".Skin")}catch(e){console.warn(e)}try{null!=e.skinnedNode&&(e.skinnedNode.name+=".Skin")}catch(e){console.warn(e)}try{if(null!=e.node&&null!=e.skinnedNode){var t=BABYLON.Tags.GetTags(e.node);null!=t&&BABYLON.Tags.AddTagsTo(e.skinnedNode,t),e.node._skinnedMesh=e.skinnedNode}else console.warn("Babylon Toolkit: Skinned node not found in scene loader plugin: ",e)}catch(e){console.warn(e)}}}))})},t.LoadRuntimeAssets=function(t,i,n){return s(this,arguments,void 0,function(t,i,n,r,o){return void 0===r&&(r=60),void 0===o&&(o=!1),l(this,function(a){switch(a.label){case 0:return e.SceneManager.SetOnSceneReadyHandler(i,n,r,o),null==t?[3,2]:[4,t.loadAsync()];case 1:a.sent(),a.label=2;case 2:return[2]}})})},t.ShowLoadingScreen=function(t,i,n){if(void 0===i&&(i=!0),void 0===n&&(n="150px"),null!=t.loadingScreen){e.SceneManager._HideLoadingScreen=t.loadingScreen.hideLoadingUI.bind(t.loadingScreen),!1===i&&(t.loadingScreen.hideLoadingUI=function(){});var r=t.loadingScreen;r._loadingDivBackgroundColor="#2A2342",t.displayLoadingUI(),null!=r._loadingTextDiv&&null!=r._loadingTextDiv.style&&(r._loadingTextDiv.style.marginTop=n)}},t.HideLoadingScreen=function(t,i){if(void 0===i&&(i=!0),null!=t.loadingScreen){if(!1===i){var n=t.loadingScreen;n._loadingDivToRenderingCanvasMap&&n._loadingDivToRenderingCanvasMap.forEach(function(e,t){t&&t.style&&(t.style.transition="none",t.style.opacity="0")})}null!=e.SceneManager._HideLoadingScreen?e.SceneManager._HideLoadingScreen():t.hideLoadingUI()}else e.SceneManager.ForceHideLoadingScreen()},t.ForceHideLoadingScreen=function(){try{e.SceneManager.DoForceHideLoadingScreen()}catch(e){console.warn(e)}finally{try{e.SceneManager.DoForceHideLoadingScreen()}catch(e){console.warn(e)}finally{try{e.SceneManager.DoForceHideLoadingScreen()}catch(e){console.warn(e)}}}},t.DoForceHideLoadingScreen=function(){var e=document.getElementById("babylonjsLoadingDiv"),t=document.getElementById("babylonjsLoadingText"),i=document.getElementById("babylonjsLoadingDivStyle");try{null!=t&&(t.remove(),t=null)}catch(e){console.warn(e)}try{null!=e&&(e.remove(),e=null)}catch(e){console.warn(e)}try{null!=i&&i.remove()}catch(e){console.warn(e)}},t.FocusRenderCanvas=function(e){e.getEngine().getRenderingCanvas().focus()},t.ShowSplashScreen=function(){try{var e=document.getElementById("xbabylonjsSplashScreen");e&&(e.style.display="block")}catch(e){console.warn(e)}},t.HideSplashScreen=function(t,i){void 0===t&&(t=null),void 0===i&&(i=0),e.WindowManager.SetTimeout(i,function(){if(null!=t&&!t.isDisposed){try{e.SceneManager.HideLoadingScreen(t.getEngine())}catch(e){console.warn(e)}try{e.SceneManager.FocusRenderCanvas(t)}catch(e){console.warn(e)}}try{var i=document.getElementById("xbabylonjsSplashScreen");if(i){i.style.opacity="0";var n=function(){i.style.display="none",i.removeEventListener("transitionend",n)};i.addEventListener("transitionend",n)}}catch(e){console.warn(e)}})},t.UpdateSplashScreenStatus=function(e){try{var t=document.getElementById("xbabylonjsSplashScreen");if(t){t.style.display="block";var i=t.querySelector("#xbabylonjsStatusTextDiv");i&&(i.textContent=e)}}catch(e){console.warn(e)}},t.SetOnSceneReadyHandler=function(t,i,n,r){void 0===n&&(n=60),void 0===r&&(r=!1),e.SceneManager.SceneLoaderPropertyBag={},e.SceneManager.SceneLoaderHandledFlag=!1,e.SceneManager.SceneLoaderFileNames=t,e.SceneManager.SceneLoaderFileNames.forEach(function(t){e.SceneManager.SceneLoaderPropertyBag[t.toLowerCase()]=!1}),e.SceneManager.OnSceneReadyObservable.clear(),e.SceneManager.OnSceneReadyObservable.add(function(t){if(!0===r&&console.log("OnSceneReady(): "+t),e.SceneManager.SceneLoaderPropertyBag[t.toLowerCase()]=!0,!0===Object.values(e.SceneManager.SceneLoaderPropertyBag).every(function(e){return!0===e}))try{i&&i()}catch(e){console.warn(e)}finally{e.SceneManager.SceneLoaderHandledFlag=!0}}),e.WindowManager.SetTimeout(1e3*n,function(){if(!1===e.SceneManager.SceneLoaderHandledFlag)try{i&&i()}catch(e){console.warn(e)}finally{e.SceneManager.SceneLoaderHandledFlag=!0,e.SceneManager.ForceHideLoadingScreen()}})},t.EnableSceneParsing=function(t){e.SceneManager.SceneParsingEnabled=t},t.IsSceneParsingEnabled=function(){return e.SceneManager.SceneParsingEnabled},t.HasSceneBeenPreLoaded=function(e){var t=e;return null!=t._preloaded&&!0===t._preloaded},t.GetDefaultSkybox=function(e){return e.getMeshById("Default Skybox")},t.GetIntensityFactor=function(){return null!=e.SceneManager.GlobalOptions.intensityFactor?e.SceneManager.GlobalOptions.intensityFactor:2},t.GetRenderQuality=function(){var t=e.RenderQuality.High,i=e.SceneManager.GlobalOptions.renderQuality;return null!=i&&(t=i),t},t.SetRenderQuality=function(t){e.SceneManager.GlobalOptions.renderQuality=t},t.GetEngineVersionString=function(t){var i="Unknown",n=t||BABYLON.EngineStore.LastCreatedScene;if(null!=n){var r=e.SceneManager.GetEngine(n);if(null!=r){var o=r.getInfo();null!=o&&(i=o.version+" - "+o.renderer)}}return i},t.GetImageBasedLighting=function(e){return e.globalSphericalPolynomial},t.SetWindowState=function(t,i){e.SceneManager.WindowState[t]=i},t.GetWindowState=function(t){var i=e.SceneManager.WindowState[t];return null!=i?i:null},t.IsDebugMode=function(){return!0},t.ConsoleLog=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];e.SceneManager.IsDebugMode()&&console.log.apply(console,t)},t.ConsoleInfo=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];e.SceneManager.IsDebugMode()&&console.info.apply(console,t)},t.ConsoleWarn=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];e.SceneManager.IsDebugMode()&&console.warn.apply(console,t)},t.ConsoleError=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,e)},t.LogMessage=function(t){e.SceneManager.IsDebugMode()&&BABYLON.Tools.Log(t)},t.LogWarning=function(t){e.SceneManager.IsDebugMode()&&BABYLON.Tools.Warn(t)},t.LogError=function(e){BABYLON.Tools.Error(e)},t.GetTime=function(){return.001*e.SceneManager.GetTimeMilliseconds()},t.GetTimeMs=function(){return e.SceneManager.GetTimeMilliseconds()},t.GetGameTime=function(){return.001*(e.SceneManager.GetTimeMilliseconds()-e.SceneManager.GameTimeMilliseconds)},t.GetGameTimeMs=function(){return e.SceneManager.GetTimeMilliseconds()-e.SceneManager.GameTimeMilliseconds},t.GetDeltaTime=function(t,i){return void 0===i&&(i=!1),e.SceneManager.GetDeltaSeconds(t,i)},t.GetDeltaSeconds=function(e,t){void 0===t&&(t=!1);var i=e||BABYLON.EngineStore.LastCreatedScene,n=.001*Math.max(BABYLON.Scene.MinDeltaTime,Math.min(i.getEngine().getDeltaTime(),BABYLON.Scene.MaxDeltaTime));return!0===t&&(n*=i.getAnimationRatio()),n},t.GetDeltaMilliseconds=function(e,t){void 0===t&&(t=!1);var i=e||BABYLON.EngineStore.LastCreatedScene,n=Math.max(BABYLON.Scene.MinDeltaTime,Math.min(i.getEngine().getDeltaTime(),BABYLON.Scene.MaxDeltaTime));return!0===t&&(n*=i.getAnimationRatio()),n},t.GetTimeMilliseconds=function(){var e=0;return"undefined"!=typeof window&&window.performance?e=window.performance.now():"undefined"!=typeof window&&window.Date?e=window.Date.now():null!=Date&&(e=Date.now()),e},t.GetAnimationRatio=function(e){return(e||BABYLON.EngineStore.LastCreatedScene).getAnimationRatio()},t.SetScenePlaying=function(t,i){void 0===i&&(i=null),e.SceneManager.ScenePlaying=t;var n=i||BABYLON.EngineStore.LastCreatedScene;if(null!=n){var r=n.getPhysicsEngine();null!=r&&(!0===t?r.setTimeStep(e.SceneManager.PhysicsTimeStep):(e.SceneManager.PhysicsTimeStep=r.getTimeStep(),r.setTimeStep(0)))}!0===t&&(e.SceneManager.GameTimeMilliseconds=e.SceneManager.GetTimeMilliseconds())},t.RunOnce=function(e,t,i){e.executeOnceBeforeRender(t,i)},t.DisposeScene=function(e,t){void 0===t&&(t=new BABYLON.Color4(0,0,0,1));var i=e.getEngine();e.dispose(),i.clear(t,!0,!0,!0)},t.SafeDestroy=function(t,i,n){void 0===i&&(i=5),void 0===n&&(n=!1),i>0?(!0===n&&t.setEnabled(!1),e.WindowManager.SetTimeout(i,function(){t.dispose(!1,!1)})):t.dispose(!1,!1)},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.AddShadowCaster=function(e,t,i){void 0===i&&(i=!1);var n=null==e?void 0:e.getShadowGenerator();if(null!=n){var r=n.getShadowMap();if(null!=r&&(null==r.renderList&&(r.renderList=[]),t instanceof BABYLON.AbstractMesh&&r.renderList.indexOf(t)<0&&r.renderList.push(t),!0===i)){var o=t.getChildMeshes(!1);null!=o&&o.forEach(function(e){r.renderList.indexOf(e)<0&&r.renderList.push(e)})}}},t.AddShadowCastersToLight=function(e,t,i){void 0===i&&(i=!1);var n=e.getShadowGenerator();if(null!=n){var r=n.getShadowMap();if(null!=r)for(var o=0;o<t.length;o++){var a=t[o];if(a instanceof BABYLON.AbstractMesh&&(null!=e.includedOnlyMeshes&&e.includedOnlyMeshes.length>0&&e.includedOnlyMeshes.indexOf(a)<0&&e.includedOnlyMeshes.push(a),null==r.renderList&&(r.renderList=[]),r.renderList.indexOf(a)<0&&r.renderList.push(a)),!0===i){var s=a.getChildMeshes();null!=s&&s.length>0&&s.forEach(function(t){null!=e.includedOnlyMeshes&&e.includedOnlyMeshes.length>0&&e.includedOnlyMeshes.indexOf(t)<0&&e.includedOnlyMeshes.push(t),null==r.renderList&&(r.renderList=[]),r.renderList.indexOf(t)<0&&r.renderList.push(t)})}}}},t.RefreshShadowCascades=function(e){var t=null==e?void 0:e.getShadowGenerator();if(null!=t&&t instanceof BABYLON.CascadedShadowGenerator){try{t.shadowMaxZ++}catch(e){}try{t.shadowMaxZ--}catch(e){}}},t.RefreshAllShadowCascades=function(t){null!=t.lights&&t.lights.length>0&&t.lights.forEach(function(t){t instanceof BABYLON.ShadowLight&&e.SceneManager.RefreshShadowCascades(t)})},t.IsPhysicsViewerEnabled=function(){return e.SceneManager.PhysicsViewersEnabled},t.TogglePhysicsViewer=function(t){if(e.SceneManager.PhysicsViewersEnabled=!e.SceneManager.PhysicsViewersEnabled,e.SceneManager.PhysicsViewersEnabled){var i=new BABYLON.Debug.PhysicsViewer(t);null==t.reservedDataStore&&(t.reservedDataStore={}),t.reservedDataStore.physicsViewer=i;for(var n=0,r=t.meshes;n<r.length;n++){var o=r[n];o.physicsImpostor?(l=i.showImpostor(o.physicsImpostor,o))&&(l.reservedDataStore={hidden:!0},l.material&&(l.material.reservedDataStore={hidden:!0})):o.physicsBody&&(l=i.showBody(o.physicsBody))&&(l.reservedDataStore={hidden:!0},l.material&&(l.material.reservedDataStore={hidden:!0}))}for(var a=0,s=t.transformNodes;a<s.length;a++){var l,u=s[a];u.physicsBody&&(l=i.showBody(u.physicsBody))&&(l.reservedDataStore={hidden:!0},l.material&&(l.material.reservedDataStore={hidden:!0}))}}else t.reservedDataStore&&t.reservedDataStore.physicsViewer&&(t.reservedDataStore.physicsViewer.dispose(),t.reservedDataStore.physicsViewer=null)},t.GetImportMeshes=function(e,t){return null==e||null==t||""===t?null:null!=e.importMeshes?e.importMeshes.get(t.toLowerCase()):null},t.GetImportMeshesMap=function(e){return null==e?null:null!=e.importMeshes?e.importMeshes:null},t.ClearImportMeshes=function(e){if(null==e)return null;e.importMeshes,e.importMeshes=new Map},t.RegisterImportMeshes=function(e,t,i){null!=e&&null!=t&&""!==t&&null!=i&&(null==e.importMeshes&&(e.importMeshes=new Map),e.importMeshes.set(t.toLowerCase(),i))},t.LoadImportMeshes=function(t,i,n,r,o,a,s,l,u){var h=null,c=i+n,d=e.SceneManager.GetImportMeshes(r,c);return null!=d?o&&o(d):h=BABYLON.SceneLoader.ImportMesh(t,i,n,r,function(t){e.SceneManager.RegisterImportMeshes(r,c,t),o&&o(t)},a,s,l,u),h},t.LoadImportMeshesAsync=function(t,i,n,r,o,a,u){return s(this,void 0,void 0,function(){var s,h,c,d;return l(this,function(l){switch(l.label){case 0:return s=i+n,null==(h=e.SceneManager.GetImportMeshes(r,s))?[3,1]:[2,h];case 1:return c=null,[4,BABYLON.SceneLoader.ImportMeshAsync(t,i,n,r,o,a,u)];case 2:return null!=(d=l.sent())&&null!=d.meshes&&(c=d.meshes),e.SceneManager.RegisterImportMeshes(r,s,c),[2,c]}})})},t.GetAssetContainer=function(e,t){return null==e||null==t||""===t?null:null!=e.assetContainers?e.assetContainers.get(t.toLowerCase()):null},t.GetAssetContainerMap=function(e){return null==e?null:null!=e.assetContainers?e.assetContainers:null},t.ClearAssetContainers=function(e){if(null==e)return null;e.assetContainers,e.assetContainers=new Map},t.RegisterAssetContainer=function(e,t,i){null!=e&&null!=t&&""!==t&&null!=i&&(null==e.assetContainers&&(e.assetContainers=new Map),e.assetContainers.set(t.toLowerCase(),i))},t.LoadAssetContainer=function(t,i,n,r,o,a,s,l){var u=t+i,h=e.SceneManager.GetAssetContainer(n,u);null!=h?r&&r(h):BABYLON.SceneLoader.LoadAssetContainer(t,i,n,function(t){e.SceneManager.RegisterAssetContainer(n,u,t),r&&r(t)},o,a,s,l)},t.LoadAssetContainerAsync=function(t,i,n,r,o,a){return s(this,void 0,void 0,function(){var s,u,h;return l(this,function(l){switch(l.label){case 0:return s=t+i,null==(u=e.SceneManager.GetAssetContainer(n,s))?[3,1]:[2,u];case 1:return[4,BABYLON.SceneLoader.LoadAssetContainerAsync(t,i,n,r,o,a)];case 2:return h=l.sent(),e.SceneManager.RegisterAssetContainer(n,s,h),[2,h]}})})},t.GetMesh=function(e,t){return null==e?null:e.getNodeByName(t)},t.GetMeshByID=function(e,t){return null==e?null:e.getNodeById(t)},t.GetAbstractMesh=function(e,t){return null==e?null:e.getNodeByName(t)},t.GetAbstractMeshByID=function(e,t){return null==e?null:e.getNodeById(t)},t.GetTransformNode=function(e,t){return null==e?null:e.getNodeByName(t)},t.GetTransformNodeByID=function(e,t){return null==e?null:e.getNodeById(t)},t.GetTransformDetailMesh=function(e){var t=null,i=e.name+".Detail",n=e.getChildren(function(e){return e.name===i&&e instanceof BABYLON.AbstractMesh},!0);return null!=n&&n.length>0&&(t=n[0]),t},t.GetSkinnedMesh=function(e){return null!=e._skinnedMesh?e._skinnedMesh:null},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.toolkit&&null!=e.metadata.toolkit.layer?e.metadata.toolkit.layer:0},t.GetTransformLayerMask=function(e){return null!=e.metadata&&null!=e.metadata.toolkit&&null!=e.metadata.toolkit.layermask?e.metadata.toolkit.layermask:1},t.GetTransformLayerName=function(e){return null!=e.metadata&&null!=e.metadata.toolkit&&null!=e.metadata.toolkit.layername&&""!==e.metadata.toolkit.layername?e.metadata.toolkit.layername:"Default"},t.GetTransformTag=function(e){return null!=e.metadata&&null!=e.metadata.toolkit&&null!=e.metadata.toolkit.group&&""!==e.metadata.toolkit.group?e.metadata.toolkit.group:"Untagged"},t.HasTransformTags=function(e,t){return BABYLON.Tags.MatchesQuery(e,t)},t.HasSoundManager=function(){return null!=r&&null!=r.SceneSoundSystem},t.IsSoundEffectPlaying=function(e){return null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.SFX&&r.SceneSoundSystem.SFX.isPlaying(e)},t.IsMusicTrackPlaying=function(e){return null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.MUSIC&&r.SceneSoundSystem.MUSIC.isPlaying(e)},t.PlayOneShot=function(e,t,i,n){return s(this,void 0,void 0,function(){return l(this,function(o){return null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.SFX?[2,r.SceneSoundSystem.SFX.playTrack(e,t,i,n)]:[2,!1]})})},t.PlayMusicTrack=function(e,t,i,n){return s(this,void 0,void 0,function(){return l(this,function(o){return null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.MUSIC?[2,r.SceneSoundSystem.MUSIC.playTrack(e,t,i,n)]:[2,!1]})})},t.PauseMusicTrack=function(e){return null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.MUSIC&&r.SceneSoundSystem.MUSIC.pauseTrack(e)},t.MuteMusicTrack=function(e,t){return null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.MUSIC&&r.SceneSoundSystem.MUSIC.muteTrack(e,t,offset,length)},t.UnmuteMusicTrack=function(e,t){return null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.MUSIC&&r.SceneSoundSystem.MUSIC.unmuteTrack(e,t)},t.StopMusicTrack=function(e,t){return null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.MUSIC&&r.SceneSoundSystem.MUSIC.stopTrack(e,t)},t.StopAllMusicTracks=function(){null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.MUSIC&&r.SceneSoundSystem.MUSIC.stopAllTracks()},t.PauseAllMusicTracks=function(){null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.MUSIC&&r.SceneSoundSystem.MUSIC.pauseAllTracks()},t.MuteAllMusicTracks=function(e){null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.MUSIC&&r.SceneSoundSystem.MUSIC.muteAllTracks(e)},t.UnmuteAllMusicTracks=function(e){null!=r&&null!=r.SceneSoundSystem&&null!=r.SceneSoundSystem.MUSIC&&r.SceneSoundSystem.MUSIC.unmuteAllTracks(e)},t.TextureFloatSupported=function(e){var t=!1,i=!1,n=e.getEngine().getCaps();return n.textureHalfFloatRender&&n.textureHalfFloatLinearFiltering?t=!0:n.textureFloatRender&&n.textureFloatLinearFiltering&&(i=!0),t||i},t.RegisterClickAction=function(e,t,i){var n=null;return null!=t&&(t.isPickable=!0,null==t.actionManager&&(t.actionManager=new BABYLON.ActionManager(e)),n=t.actionManager.registerAction(new BABYLON.ExecuteCodeAction({trigger:BABYLON.ActionManager.OnPickTrigger},i))),n},t.UnregisterClickAction=function(e,t){var i=!1;return null!=e&&null!=t&&(i=e.actionManager.unregisterAction(t)),i},t.GetMaterialWithName=function(e,t){var i=null;if(null!=e.materials&&e.materials.length>0){e.materials.length;for(var n=0;n<e.materials.length;n++){var r=e.materials[n];if(r.name.startsWith(t)){i=r;break}}}return i},t.GetAllMaterialsWithName=function(e,t){var i=null;if(null!=e.materials&&e.materials.length>0){e.materials.length;for(var n=0;n<e.materials.length;n++){var r=e.materials[n];r.name.startsWith(t)&&(null==i&&(i=[]),i.push(r))}}return i},t.InstantiatePrefabFromScene=function(t,i,n,r,o,a,s,l){void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),void 0===l&&(l=!0);var u=null;if(null!=t&&null!=i&&""!==i){var h=t.getNodeByName(i);if(null!=h)if(null!=(u=h.clone(n,r,!1))){null!=o&&(u.position=o.clone()),null!=a&&(u.rotationQuaternion=a.clone()),null!=s&&(u.scaling=s.clone());var c=null,d=u.getChildren(null,!1);null!=d&&(c=d),null==c?c=[u]:c.unshift(u),c.forEach(function(e){if(e.setEnabled(!0),e instanceof BABYLON.AbstractMesh&&null!=e.metadata&&null!=e.metadata.shadowCastingMode&&0!==e.metadata.shadowCastingMode&&t.lights.forEach(function(t){var i=t.getShadowGenerator();if(null!=i&&!1==(null!=t.includedOnlyMeshes&&t.includedOnlyMeshes.length>0)){var n=i.getShadowMap();null==n.renderList&&(n.renderList=[]),n.renderList.indexOf(e)<0&&n.renderList.push(e)}}),e instanceof BABYLON.Mesh)if(null!=e.source){if(null==e.skeleton&&null!=e.source.skeleton){var i=e.source.skeleton.name+".Skeleton",n=i+"."+e.source.skeleton.id;if(e.skeleton=e.source.skeleton.clone(i,n),null!=e.skeleton&&null!=e.skeleton.bones&&null!=e.source.skeleton.bones&&e.skeleton.bones.length===e.source.skeleton.bones.length)for(var r=e.skeleton.bones.length,o=0;o<r;o++)null==e.skeleton.bones[o].metadata&&null!=e.source.skeleton.bones[o].metadata&&(e.skeleton.bones[o].metadata=e.source.skeleton.bones[o].metadata)}}else BABYLON.Tools.Warn("Babylon.js encountered a null clone source for: "+e.name)});var m=[];if(c.forEach(function(e){m.push(e)}),null!=m&&m.length>0){var p=[];e.Utilities.PostParseSceneComponents(t,m,null,p),t.onAfterRenderObservable.addOnce(function(){if(null!=p&&p.length>0)for(var e=0;e<p.length;e++){var t=p[e];null!=t&&t.delayComponentInstance&&t.delayComponentInstance(t)}})}}else BABYLON.Tools.Warn("Failed to create prefab of: "+i);else BABYLON.Tools.Warn("Failed to lookup prefab map: "+i)}else BABYLON.Tools.Warn("Unable to locate prefab master: "+i);return u},t.InstantiatePrefabFromContainer=function(t,i,n,r,o,a,s,l,u){void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),void 0===l&&(l=!0),void 0===u&&(u=!1);var h=e.Utilities.CloneAssetContainerItem(t,i,function(e){return e},r,u,l);if(null!=h){null!=n&&""!==n&&(h.name=n),null!=o&&(h.position=o.clone()),null!=a&&(h.rotationQuaternion=a.clone()),null!=s&&(h.scaling=s.clone());var c=[];c.push(h);var d=h.getChildren(null,!1);null!=d&&d.length>0&&d.forEach(function(e){c.push(e)}),c.forEach(function(t){t.id=e.Utilities.CreateGuid(),t.setEnabled(!0)});var m=[];e.Utilities.PostParseSceneComponents(t.scene,c,null,m),t.scene.onAfterRenderObservable.addOnce(function(){if(null!=m&&m.length>0)for(var e=0;e<m.length;e++){var t=m[e];null!=t&&t.delayComponentInstance&&t.delayComponentInstance(t)}})}return h},t.InstantiateModelsFromContainer=function(t,i,n,r,o,a){void 0===i&&(i=null),void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=null);var s=null,l=t.instantiateModelsToScene(i,r,{doNotInstantiate:!n,predicate:a});if(null!=l&&null!=l.rootNodes&&l.rootNodes.length>0){var h=l.rootNodes[0],c=h.getChildren(null,!1);!0===o&&e.SceneManager.RebuildBoundingBoxInfo(c),s=u([h],c,!0)}return s},t.CreateInstancedModelsFromContainer=function(t,i,n,r,o,a,s,l,u){void 0===i&&(i=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=!0),void 0===l&&(l=!1),void 0===u&&(u=!1);var h=null,c=null,d=null,m=t.instantiateModelsToScene(function(e){return e},l,{doNotInstantiate:!1});if(null!=m&&(null!=m.rootNodes&&m.rootNodes.length>0&&(c=m.rootNodes[0].getChildren(null,!1),!0===u&&e.SceneManager.RebuildBoundingBoxInfo(c)),null!=m.animationGroups&&(d=m.animationGroups)),null!=c){if(h=c[0],null!=n&&(h.parent=n),null!=i&&""!==i&&(h.name=i),null!=r&&(h.position=r.clone()),null!=o&&(h.rotationQuaternion=o.clone()),null!=a&&(h.scaling=a.clone()),c.forEach(function(t){t.id=e.Utilities.CreateGuid(),t.setEnabled(!0)}),!0===s){var p=null;d.forEach(function(e){var t=e,i=null!=t.metadata&&null!=t.metadata.toolkit&&null!=t.metadata.toolkit.source&&""!==t.metadata.toolkit.source?t.metadata.toolkit.source:null;if(null!=i&&""!==i){var n=e.clone(e.name),r=i;null!=t.metadata&&(n.metadata={},n.metadata.toolkit={},n.metadata.toolkit.id=t.metadata.toolkit.id,n.metadata.toolkit.clip=t.metadata.toolkit.clip,n.metadata.toolkit.source=r,n.metadata.toolkit.legacy=t.metadata.toolkit.legacy,n.metadata.toolkit.length=t.metadata.toolkit.length,n.metadata.toolkit.looping=t.metadata.toolkit.looping,n.metadata.toolkit.settings=t.metadata.toolkit.settings,n.metadata.toolkit.behavior=t.metadata.toolkit.behavior,n.metadata.toolkit.wrapmode=t.metadata.toolkit.wrapmode,n.metadata.toolkit.framerate=t.metadata.toolkit.framerate,n.metadata.toolkit.humanmotion=t.metadata.toolkit.humanmotion,n.metadata.toolkit.averagespeed=t.metadata.toolkit.averagespeed,n.metadata.toolkit.averageduration=t.metadata.toolkit.averageduration,n.metadata.toolkit.averageangularspeed=t.metadata.toolkit.averageangularspeed),null==p&&(p=[]),p.push(n)}}),null!=h&&null!=p&&e.Utilities.AssignAnimationGroupsToInstance(h,p)}var f=[];e.Utilities.PostParseSceneComponents(t.scene,c,null,f),t.scene.onAfterRenderObservable.addOnce(function(){if(null!=f&&f.length>0)for(var e=0;e<f.length;e++){var t=f[e];null!=t&&t.delayComponentInstance&&t.delayComponentInstance(t)}})}return m},t.CloneTransformNode=function(t,i,n,r,o,a,s){void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null);var l=e.Utilities.GetAssetContainerNode(t,i).clone(n,r,!0);return null!=l&&(null!=o&&(l.position=o.clone()),null!=a&&(l.rotationQuaternion=a.clone()),null!=s&&(l.scaling=s.clone()),l.setEnabled(!0)),l},t.CloneAbstractMesh=function(t,i,n,r,o,a,s){void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null);var l=e.Utilities.GetAssetContainerMesh(t,i).clone(n,r,!0);return null!=l&&(null!=o&&(l.position=o.clone()),null!=a&&(l.rotationQuaternion=a.clone()),null!=s&&(l.scaling=s.clone()),l.setEnabled(!0)),l},t.CreateInstancedMesh=function(t,i,n,r,o,a,s){void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null);var l=e.Utilities.GetAssetContainerMesh(t,i).createInstance(n);return null!=l&&(null!=r&&(l.parent=r),null!=o&&(l.position=o.clone()),null!=a&&(l.rotationQuaternion=a.clone()),null!=s&&(l.scaling=s.clone()),l.setEnabled(!0)),l},t.RebuildBoundingBoxInfo=function(e){null!=e&&e.length>0&&e.forEach(function(e){var t,i;if(e instanceof BABYLON.InstancedMesh){var n=null===(t=e.sourceMesh.getBoundingInfo())||void 0===t?void 0:t.boundingBox;null!=n&&null!=n.minimum&&null!=n.maximum&&e.setBoundingInfo(new BABYLON.BoundingInfo(n.minimum,n.maximum))}else if(e instanceof BABYLON.AbstractMesh){var r=null===(i=e.getBoundingInfo())||void 0===i?void 0:i.boundingBox;null!=r&&null!=r.minimum&&null!=r.maximum&&e.setBoundingInfo(new BABYLON.BoundingInfo(r.minimum,r.maximum))}})},t.AttachScriptComponent=function(e,t,i){void 0===i&&(i=!0),null!=e&&e.registerComponentInstance&&e.registerComponentInstance(e,t,i)},t.DestroyScriptComponent=function(e){null!=e&&e.destroyComponentInstance&&e.destroyComponentInstance(e)},t.DestroyGameObject=function(t){if(null!=t){var i=e.SceneManager.FindScriptComponents(t,!0);if(null!=i&&i.length>0)for(var n=0;n<i.length;n++){var r=i[n];e.SceneManager.DestroyScriptComponent(r)}e.SceneManager.SafeDestroy(t)}},t.GetComponent=function(t,i,n){return void 0===n&&(n=!1),e.SceneManager.FindScriptComponent(t,i,n)},t.GetComponents=function(t,i){return void 0===i&&(i=!1),e.SceneManager.FindScriptComponents(t,i)},t.FindGameObject=function(e,t){if(!t||""===t.trim())return null;var i=t.split("/").filter(function(e){return""!==e.trim()});if(0===i.length)return null;for(var n=null,r=e.rootNodes,o=function(e){var t=i[e];if(0===e)n=r.find(function(e){return e.name===t})||null;else{if(!n)return"break";var o=n.getChildren(null,!1);n=o.find(function(e){return e.name===t})||null}if(!n)return"break"},a=0;a<i.length&&"break"!==o(a);a++);if(n&&n instanceof BABYLON.TransformNode)return n;for(var s=0,l=r;s<l.length;s++){var u=l[s];if(u.name&&u.getChildren){var h,c="".concat(u.name,"/").concat(t);if(c!==t&&(h=this.FindGameObjectExactPath(e,c)))return h}}return 1===i.length&&(h=this.FindGameObjectRecursive(e,i[0]))?h:null},t.FindGameObjectExactPath=function(e,t){for(var i=t.split("/").filter(function(e){return""!==e.trim()}),n=null,r=e.rootNodes,o=function(e){var t=i[e];if(0===e)n=r.find(function(e){return e.name===t})||null;else{if(!n)return{value:null};var o=n.getChildren(null,!1);n=o.find(function(e){return e.name===t})||null}if(!n)return{value:null}},a=0;a<i.length;a++){var s=o(a);if("object"==typeof s)return s.value}return n instanceof BABYLON.TransformNode?n:null},t.FindGameObjectRecursive=function(e,t){for(var i=function(e){if(e.name===t&&e instanceof BABYLON.TransformNode)return e;if(e.getChildren)for(var n=0,r=e.getChildren(null,!1);n<r.length;n++){var o=r[n],a=i(o);if(a)return a}return null},n=0,r=e.rootNodes;n<r.length;n++){var o=r[n],a=i(o);if(a)return a}return null},t.DebugSceneHierarchy=function(e,t){void 0===t&&(t=3),console.log("=== SCENE HIERARCHY DEBUG ===");var i=function(e,n,r){if(void 0===r&&(r=""),!(n>t)){var o=" ".repeat(n),a=e instanceof BABYLON.TransformNode?"TransformNode":e instanceof BABYLON.AbstractMesh?"Mesh":e instanceof BABYLON.Camera?"Camera":e instanceof BABYLON.Light?"Light":e.constructor.name;if(console.log("".concat(o).concat(r).concat(e.name," (").concat(a,")")),e instanceof BABYLON.TransformNode||e instanceof BABYLON.AbstractMesh){var s=e.getChildren(null,!1);s.forEach(function(e,t){var r=t===s.length-1;i(e,n+1,r?"└─ ":"├─ ")})}}};console.log("Root nodes:"),e.rootNodes.forEach(function(t,n){var r=n===e.rootNodes.length-1;i(t,0,r?"└─ ":"├─ ")}),console.log("=== END HIERARCHY DEBUG ===")},t.LegacySearchForGameObject=function(e,t){for(var i=t.split("/"),n=null,r=e.rootNodes,o=function(e){var t=i[e];if(0===e)n=r.find(function(e){return e.name===t})||null;else{if(!(n&&n instanceof BABYLON.TransformNode))return{value:null};n=n.getChildren(function(e){return e.name===t},!1)[0]||null}if(!n)return{value:null}},a=0;a<i.length;a++){var s=o(a);if("object"==typeof s)return s.value}return n},t.FindGameObjectWithTag=function(t,i){for(var n=function(t){if(e.SceneManager.GetTransformTag(t)===i)return t;if(t instanceof BABYLON.TransformNode)for(var r=0,o=t.getChildren();r<o.length;r++){var a=o[r];if(a instanceof BABYLON.TransformNode){var s=n(a);if(s)return s}}return null},r=0,o=t.rootNodes;r<o.length;r++){var a=o[r];if(a instanceof BABYLON.TransformNode){var s=n(a);if(s)return s}}return null},t.FindGameObjectsWithTag=function(t,i){for(var n=[],r=function(t){if(e.SceneManager.GetTransformTag(t)===i&&n.push(t),t instanceof BABYLON.TransformNode)for(var o=0,a=t.getChildren();o<a.length;o++){var s=a[o];s instanceof BABYLON.TransformNode&&r(s)}},o=0,a=t.rootNodes;o<a.length;o++){var s=a[o];s instanceof BABYLON.TransformNode&&r(s)}return n},t.FindScriptComponents=function(t,i){if(void 0===i&&(i=!1),null==t)return null;var n=null;if(null!=t.metadata&&t.metadata.toolkit){var r=t.metadata.toolkit;if(null!=r.components&&r.components.length>0)for(var o=0;o<r.components.length;o++){var a=r.components[o];null==n&&(n=[]),n.push(a.instance)}}if(!0===i){var s=t.getChildren(null,!1);if(null!=s)for(var l=0;l<s.length;l++){var u=s[l],h=e.SceneManager.FindScriptComponents(u,!1);null!=h&&(null==n&&(n=[]),n.push.apply(n,h))}}return null!=n?n:null},t.FindScriptComponent=function(t,i,n){if(void 0===n&&(n=!1),null==t)return null;var r=null,o=i.substring(0);if(!0===e.SceneManager.AutoStripNamespacePrefix&&!1===e.SceneManager.UniversalModuleDefinition&&(0===o.indexOf("BABYLON.")||0===o.indexOf("TOOLKIT.")||0===o.indexOf("PROJECT."))){var a=o.lastIndexOf(".");-1!==a&&(o=o.substring(a+1))}if(null!=t.metadata&&t.metadata.toolkit){var s=t.metadata.toolkit;if(null!=s.components&&s.components.length>0)for(var l=0;l<s.components.length;l++){var u=s.components[l];if(null!=u.instance&&(u.klass===i||u.klass===o)){r=u.instance;break}}}if(null==r&&!0===n){var h=t.getChildren(null,!1);if(null!=h)for(var c=0;c<h.length;c++){var d=h[c];if(null!=(r=e.SceneManager.FindScriptComponent(d,i,!1)))break}}return null!=r?r:null},t.FindAllScriptComponents=function(t,i,n){if(void 0===n&&(n=!1),null==t)return null;var r=null,o=i.substring(0);if(!0===e.SceneManager.AutoStripNamespacePrefix&&!1===e.SceneManager.UniversalModuleDefinition&&(0===o.indexOf("BABYLON.")||0===o.indexOf("TOOLKIT.")||0===o.indexOf("PROJECT."))){var a=o.lastIndexOf(".");-1!==a&&(o=o.substring(a+1))}if(null!=t.metadata&&t.metadata.toolkit){var s=t.metadata.toolkit;if(null!=s.components&&s.components.length>0)for(var l=0;l<s.components.length;l++){var u=s.components[l];null==u.instance||u.klass!==i&&u.klass!==o||(null==r&&(r=[]),r.push(u.instance))}}if(!0===n){var h=t.getChildren(null,!1);if(null!=h)for(var c=0;c<h.length;c++){var d=h[c],m=e.SceneManager.FindAllScriptComponents(d,i,!1);null!=m&&(null==r&&(r=[]),r.push.apply(r,m))}}return null!=r?r:null},t.FindSceneMetadata=function(e){return null==e?null:null!=e.metadata&&e.metadata.toolkit?e.metadata.toolkit:null},t.FindSceneCameraRig=function(e){return null==e?null:null!=e.cameraRig?e.cameraRig:null},t.FindSceneLightRig=function(e){return null==e?null:null!=e.lightRig?e.lightRig:null},t.FindTransformWithScript=function(t,i){var n=t.getNodes();return e.Utilities.SearchTransformNodeForScript(i,n)},t.FindAllTransformsWithScript=function(t,i){var n=t.getNodes();return e.Utilities.SearchAllTransformNodesForScript(i,n)},t.FindChildTransformNode=function(t,i,n,r,o){if(void 0===n&&(n=e.SearchType.ExactMatch),void 0===r&&(r=!0),void 0===o&&(o=null),null==t)return null;var a=null!=n?n:e.SearchType.ExactMatch,s=t.getChildren(o,r);return e.Utilities.SearchTransformNodes(i,s,a)},t.FindChildTransformWithTags=function(t,i,n,r){if(void 0===n&&(n=!0),void 0===r&&(r=null),null==t)return null;var o=t.getChildren(r,n);return e.Utilities.SearchTransformNodeForTags(i,o)},t.FindAllChildTransformsWithTags=function(t,i,n,r){if(void 0===n&&(n=!0),void 0===r&&(r=null),null==t)return null;var o=t.getChildren(r,n);return e.Utilities.SearchAllTransformNodesForTags(i,o)},t.FindChildTransformWithScript=function(t,i,n,r){if(void 0===n&&(n=!0),void 0===r&&(r=null),null==t)return null;var o=t.getChildren(r,n);return e.Utilities.SearchTransformNodeForScript(i,o)},t.FindAllChildTransformsWithScript=function(t,i,n,r){if(void 0===n&&(n=!0),void 0===r&&(r=null),null==t)return null;var o=t.getChildren(r,n);return e.Utilities.SearchAllTransformNodesForScript(i,o)},t.FindComponentInParent=function(t,i,n){var r=null!=i.parent?[i,i.parent]:[i],o=e.Utilities.SearchTransformNodeForScript(n,r);return e.SceneManager.FindScriptComponent(o,n)},t.FindComponentsInParent=function(t,i,n){var r=null,o=i.getChildren(null,!1),a=null!=o?u([i],o,!0):[i],s=e.Utilities.SearchAllTransformNodesForScript(n,a);return null!=s&&s.length>0&&s.forEach(function(t){var i=e.SceneManager.FindScriptComponent(t,n);null!=i&&(null==r&&(r=[]),r.push(i))}),null!=r?r:null},t.FindComponentInChildren=function(t,i,n){var r=i.getChildren(null,!1),o=null!=r?u([i],r,!0):[i],a=e.Utilities.SearchTransformNodeForScript(n,o);return e.SceneManager.FindScriptComponent(a,n)},t.FindComponentsInChildren=function(t,i,n){var r=null,o=i.getChildren(null,!1),a=null!=o?u([i],o,!0):[i],s=e.Utilities.SearchAllTransformNodesForScript(n,a);return null!=s&&s.length>0&&s.forEach(function(t){var i=e.SceneManager.FindScriptComponent(t,n);null!=i&&(null==r&&(r=[]),r.push(i))}),null!=r?r:null},t.SearchForScriptComponentByName=function(t,i){var n=t.getNodes(),r=e.Utilities.SearchTransformNodeForScript(i,n);return e.SceneManager.FindScriptComponent(r,i)},t.SearchForAllScriptComponentsByName=function(t,i){var n=null,r=t.getNodes(),o=e.Utilities.SearchAllTransformNodesForScript(i,r);return null!=o&&o.length>0&&o.forEach(function(t){var r=e.SceneManager.FindScriptComponent(t,i);null!=r&&(null==n&&(n=[]),n.push(r))}),null!=n?n:null},t.MoveWithCollisions=function(e,t){if(null==e)return null;null!=t&&e.moveWithCollisions(t)},t.MoveWithTranslation=function(e,t){if(null==e)return null;null!=t&&e.position.addInPlace(t)},t.TurnWithRotation=function(e,t,i){if(void 0===i&&(i=BABYLON.Space.LOCAL),null==e)return null;0!=t&&e.rotate(BABYLON.Axis.Y,t,i)},t.HasNavigationData=function(){return null!=e.SceneManager.NavMeshPlugin&&null!=e.SceneManager.NavMeshPlugin.navMesh},t.GetNavigationData=function(){return null!=e.SceneManager.NavMeshPlugin&&null!=e.SceneManager.NavMeshPlugin.navMesh?e.SceneManager.NavMeshPlugin.navMesh:null},t.GetNavigationMesh=function(){return null!=e.SceneManager.NavMeshSurface?e.SceneManager.NavMeshSurface:null},t.GetNavigationDebug=function(){return null!=e.SceneManager.NavMeshDebugger?e.SceneManager.NavMeshDebugger:null},t.GetNavigationPlugin=function(){return null!=e.SceneManager.NavMeshPlugin?e.SceneManager.NavMeshPlugin:null},t.GetCrowdInterface=function(t){if(null!=e.SceneManager.NavMeshPlugin&&null!=e.SceneManager.NavMeshPlugin.navMesh){var i=e.SceneManager.GetNavigationPlugin();return null!=i&&null==e.SceneManager.CrowdInterface&&(e.SceneManager.CrowdInterface=i.createCrowd(e.SceneManager.MAX_AGENT_COUNT,e.SceneManager.MAX_AGENT_RADIUS,t)),e.SceneManager.CrowdInterface}return null},t.LoadNavigationMeshDataAsync=function(t,i){return s(this,arguments,void 0,function(t,i,n,r){var o,a,u=this;return void 0===n&&(n=null),void 0===r&&(r=!1),l(this,function(h){switch(h.label){case 0:return e.SceneManager.DestroyNavigationMeshData(),o=new BABYLON.AssetsManager(t),(a=o.addBinaryFileTask("System.NavigationMeshTask",i)).onSuccess=function(o){return s(u,void 0,void 0,function(){var a;return l(this,function(s){switch(s.label){case 0:return null==o.data?[3,2]:(a=new Uint8Array(o.data),[4,e.SceneManager.BuildNavigationMeshDataAsync(t,a,n,r)]);case 1:return s.sent(),[3,3];case 2:console.error("Failed to load navigation mesh task: "+i),s.label=3;case 3:return[2]}})})},a.onError=function(e,t,i){console.error(t,i)},[4,o.loadAsync()];case 1:return h.sent(),[2]}})})},t.BuildNavigationMeshDataAsync=function(t,i){return s(this,arguments,void 0,function(t,i,n,r){var o;return void 0===n&&(n=null),void 0===r&&(r=!1),l(this,function(a){switch(a.label){case 0:return null==i?[2]:(e.SceneManager.DestroyNavigationMeshData(),e.SceneManager.NavMeshSurface=n,null!=e.SceneManager.NavMeshPlugin?[3,2]:(o=e.SceneManager,[4,ADDONS.CreateNavigationPluginAsync()]));case 1:o.NavMeshPlugin=a.sent(),a.label=2;case 2:return null!=e.SceneManager.NavMeshPlugin&&(e.SceneManager.NavMeshPlugin.buildFromNavmeshData(i),!0===r&&(e.SceneManager.NavMeshDebugger=e.SceneManager.NavMeshPlugin.createDebugNavMesh(t),null!=e.SceneManager.NavMeshDebugger&&(e.SceneManager.NavMeshDebugger.checkCollisions=!1,e.SceneManager.NavMeshDebugger.isPickable=!1,e.SceneManager.NavMeshDebugger.isVisible=!0,e.SceneManager.NavMeshDebugger.visibility=1,null==e.SceneManager.NavMeshMaterial&&(e.SceneManager.NavMeshMaterial=new BABYLON.StandardMaterial("Navmesh-Debug-Material",t),e.SceneManager.NavMeshMaterial.transparencyMode=BABYLON.Material.MATERIAL_ALPHABLEND,e.SceneManager.NavMeshMaterial.backFaceCulling=!1,e.SceneManager.NavMeshMaterial.diffuseColor=new BABYLON.Color3(0,.75,1),e.SceneManager.NavMeshMaterial.alpha=.5),e.SceneManager.NavMeshDebugger.material=e.SceneManager.NavMeshMaterial)),e.SceneManager.OnNavMeshReadyObservable.hasObservers()&&e.SceneManager.OnNavMeshReadyObservable.notifyObservers(e.SceneManager.GetNavigationMesh())),[2]}})})},t.BuildNavigationMeshTileCacheAsync=function(t,i){return s(this,arguments,void 0,function(t,i,n,r,o){var a;return void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=!1),l(this,function(s){switch(s.label){case 0:return null==i?[2]:(e.SceneManager.DestroyNavigationMeshData(),e.SceneManager.NavMeshSurface=r,null!=e.SceneManager.NavMeshPlugin?[3,2]:(a=e.SceneManager,[4,ADDONS.CreateNavigationPluginAsync()]));case 1:a.NavMeshPlugin=s.sent(),s.label=2;case 2:return null!=e.SceneManager.NavMeshPlugin&&(null==n&&(n=function(e,t,i){for(var n=0;n<e.polyCount();n++)t.set(n,0),i.set(n,1)}),e.SceneManager.NavMeshPlugin.buildFromTileCacheData(i,n),!0===o&&(e.SceneManager.NavMeshDebugger=e.SceneManager.NavMeshPlugin.createDebugNavMesh(t),null!=e.SceneManager.NavMeshDebugger&&(e.SceneManager.NavMeshDebugger.checkCollisions=!1,e.SceneManager.NavMeshDebugger.isPickable=!1,e.SceneManager.NavMeshDebugger.isVisible=!0,e.SceneManager.NavMeshDebugger.visibility=1,null==e.SceneManager.NavMeshMaterial&&(e.SceneManager.NavMeshMaterial=new BABYLON.StandardMaterial("Navmesh-Debug-Material",t),e.SceneManager.NavMeshMaterial.transparencyMode=BABYLON.Material.MATERIAL_ALPHABLEND,e.SceneManager.NavMeshMaterial.backFaceCulling=!1,e.SceneManager.NavMeshMaterial.diffuseColor=new BABYLON.Color3(0,.75,1),e.SceneManager.NavMeshMaterial.alpha=.5),e.SceneManager.NavMeshDebugger.material=e.SceneManager.NavMeshMaterial)),e.SceneManager.OnNavMeshReadyObservable.hasObservers()&&e.SceneManager.OnNavMeshReadyObservable.notifyObservers(e.SceneManager.GetNavigationMesh())),[2]}})})},t.CreateNavigationMeshSceneDataAsync=function(t,i,n){return s(this,arguments,void 0,function(t,i,n,r,o){var a,s;return void 0===r&&(r=null),void 0===o&&(o=!1),l(this,function(l){switch(l.label){case 0:return null==i||null==n||0===n.length?[2]:(e.SceneManager.DestroyNavigationMeshData(),e.SceneManager.NavMeshSurface=r,null!=e.SceneManager.NavMeshPlugin?[3,2]:(a=e.SceneManager,[4,ADDONS.CreateNavigationPluginAsync()]));case 1:a.NavMeshPlugin=l.sent(),l.label=2;case 2:return null==e.SceneManager.NavMeshPlugin?[3,4]:(null!=(s={cs:i.cs||.2,ch:i.ch||.2,walkableSlopeAngle:i.walkableslopeangle||45,walkableHeight:i.walkableheight||2,walkableClimb:i.walkableclimb||1,walkableRadius:i.walkableradius||.5,maxEdgeLen:i.maxedgelen||12,maxSimplificationError:i.maxsimplificationerror||1.3,minRegionArea:i.minregionarea||2,mergeRegionArea:i.mergeregionarea||20,maxVertsPerPoly:i.maxvertsperpoly||6,detailSampleDist:i.detailsampledist||6,detailSampleMaxError:i.detailsamplemaxerror||1,tileSize:i.tilesize||32,borderSize:0,offMeshConnections:null,keepIntermediates:!1,maxObstacles:0,expectedLayersPerTile:32,tileCacheMeshProcess:null,doNotReverseIndices:!1}).tileSize&&s.tileSize>0&&(s.borderSize=(s.walkableRadius||0)+3),[4,e.SceneManager.NavMeshPlugin.createNavMeshAsync(n,s)]);case 3:l.sent(),!0===o&&(e.SceneManager.NavMeshDebugger=e.SceneManager.NavMeshPlugin.createDebugNavMesh(t),null!=e.SceneManager.NavMeshDebugger&&(e.SceneManager.NavMeshDebugger.checkCollisions=!1,e.SceneManager.NavMeshDebugger.isPickable=!1,e.SceneManager.NavMeshDebugger.isVisible=!0,e.SceneManager.NavMeshDebugger.visibility=1,null==e.SceneManager.NavMeshMaterial&&(e.SceneManager.NavMeshMaterial=new BABYLON.StandardMaterial("Navmesh-Debug-Material",t),e.SceneManager.NavMeshMaterial.transparencyMode=BABYLON.Material.MATERIAL_ALPHABLEND,e.SceneManager.NavMeshMaterial.backFaceCulling=!1,e.SceneManager.NavMeshMaterial.diffuseColor=new BABYLON.Color3(0,.75,1),e.SceneManager.NavMeshMaterial.alpha=.5),e.SceneManager.NavMeshDebugger.material=e.SceneManager.NavMeshMaterial)),e.SceneManager.OnNavMeshReadyObservable.hasObservers()&&e.SceneManager.OnNavMeshReadyObservable.notifyObservers(e.SceneManager.GetNavigationMesh()),l.label=4;case 4:return[2]}})})},t.DestroyNavigationMeshData=function(t){void 0===t&&(t=null),e.SceneManager.NavMeshSurface=null;try{e.SceneManager.OnNavMeshDestroyObservable.notifyObservers(t)}catch(e){console.warn("NavMesh destroy observers threw: ",e)}if(null!=e.SceneManager.CrowdInterface){try{e.SceneManager.CrowdInterface.dispose()}catch(e){console.warn("Failed to dispose global crowd interface: ",e)}e.SceneManager.CrowdInterface=null}if(null!=e.SceneManager.NavMeshDebugger){try{e.SceneManager.NavMeshDebugger.dispose()}catch(e){console.warn("Failed to dispose previous NavMesh debugger: ",e)}e.SceneManager.NavMeshDebugger=null}if(null!=e.SceneManager.NavMeshPlugin&&null!=e.SceneManager.NavMeshPlugin.navMeshQuery){try{e.SceneManager.NavMeshPlugin.navMeshQuery.destroy()}catch(e){console.warn("Failed to destroy previous navMesh query object: ",e)}try{e.SceneManager.NavMeshPlugin._navMeshQuery=null}catch(e){console.warn("Failed to null cached navMesh query object: ",e)}}if(null!=e.SceneManager.NavMeshPlugin&&null!=e.SceneManager.NavMeshPlugin.navMesh){try{e.SceneManager.NavMeshPlugin.navMesh.destroy()}catch(e){console.warn("Failed to destroy previous navMesh data object: ",e)}e.SceneManager.NavMeshPlugin.navMesh=null}},t.ToggleFullscreenMode=function(e,t){void 0===t&&(t=!0),e.getEngine().switchFullscreen(t)},t.EnterFullscreenMode=function(t,i){void 0===i&&(i=!0),e.SceneManager.GotoFullscreenBrowser(t,i)},t.ExitFullscreenMode=function(t){e.SceneManager.ExitFromFullscreenBrowser(t)},t.GotoFullscreenBrowser=function(t,i){void 0===i&&(i=!0);var n=document.documentElement;n.requestFullscreen?n.requestFullscreen().then(function(){!0===i&&e.SceneManager.RequestBrowserPointerLock(n)}).catch(function(e){console.error("Error attempting to enable full-screen mode: ".concat(e.message," (").concat(e.name,")"))}):n.mozRequestFullScreen?(n.mozRequestFullScreen(),!0===i&&e.SceneManager.RequestBrowserPointerLock(n)):n.webkitRequestFullscreen?(n.webkitRequestFullscreen(),!0===i&&e.SceneManager.RequestBrowserPointerLock(n)):n.msRequestFullscreen?(n.msRequestFullscreen(),!0===i&&e.SceneManager.RequestBrowserPointerLock(n)):t.getEngine().enterFullscreen(i)},t.RequestBrowserPointerLock=function(e){e.requestPointerLock?e.requestPointerLock():e.mozRequestPointerLock?e.mozRequestPointerLock():e.webkitRequestPointerLock&&e.webkitRequestPointerLock()},t.ExitFromFullscreenBrowser=function(e){var t=document;t.exitFullscreen?t.exitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.webkitExitFullscreen?t.webkitExitFullscreen():t.msExitFullscreen?t.msExitFullscreen():e.getEngine().exitFullscreen()},t.CreateEasingFunction=function(e){if(!e)return null;if("string"==typeof e){var t=void 0;switch(e.toLowerCase()){case"linear":case"sineout":default:return(t=new BABYLON.SineEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT),t;case"sinein":return(t=new BABYLON.SineEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEIN),t;case"sineinout":return(t=new BABYLON.SineEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT),t;case"quadin":return(t=new BABYLON.QuadraticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEIN),t;case"quadout":return(t=new BABYLON.QuadraticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT),t;case"quadinout":return(t=new BABYLON.QuadraticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT),t;case"cubicin":return(t=new BABYLON.CubicEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEIN),t;case"cubicout":return(t=new BABYLON.CubicEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT),t;case"cubicinout":return(t=new BABYLON.CubicEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT),t;case"quartin":return(t=new BABYLON.QuarticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEIN),t;case"quartout":return(t=new BABYLON.QuarticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT),t;case"quartinout":return(t=new BABYLON.QuarticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT),t;case"quintin":return(t=new BABYLON.QuinticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEIN),t;case"quintout":return(t=new BABYLON.QuinticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT),t;case"quintinout":return(t=new BABYLON.QuinticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT),t;case"expoin":return(t=new BABYLON.ExponentialEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEIN),t;case"expoout":return(t=new BABYLON.ExponentialEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT),t;case"expoinout":return(t=new BABYLON.ExponentialEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT),t;case"circlein":return(t=new BABYLON.CircleEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEIN),t;case"circleout":return(t=new BABYLON.CircleEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT),t;case"circleinout":return(t=new BABYLON.CircleEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT),t;case"backin":return(t=new BABYLON.BackEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEIN),t;case"backout":return(t=new BABYLON.BackEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT),t;case"backinout":return(t=new BABYLON.BackEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT),t;case"elasticin":return(t=new BABYLON.ElasticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEIN),t;case"elasticout":return(t=new BABYLON.ElasticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT),t;case"elasticinout":return(t=new BABYLON.ElasticEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT),t;case"bouncein":return(t=new BABYLON.BounceEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEIN),t;case"bounceout":return(t=new BABYLON.BounceEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT),t;case"bounceinout":return(t=new BABYLON.BounceEase).setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT),t}}return e},t.GetPropertyValue=function(e,t){for(var i=e,n=0,r=t.split(".");n<r.length;n++){var o=r[n];if(!i||"object"!=typeof i||!(o in i))return;i=i[o]}return i},t.SetPropertyValue=function(e,t,i){for(var n=t.split("."),r=e,o=0;o<n.length-1;o++){var a=n[o];a in r&&"object"==typeof r[a]||(r[a]={}),r=r[a]}r[n[n.length-1]]=i},t.IsGUIControl=function(e){if(!e)return!1;if(e.getClassName&&"function"==typeof e.getClassName){var t=e.getClassName();if(t&&t.includes("GUI"))return!0}return!!(e._host&&e._currentMeasure&&e._markAsDirty)||!!(e.constructor&&e.constructor.name&&e.constructor.name.includes("Control"))},t.IsGUIPositionProperty=function(e){return["left","top","width","height","paddingLeft","paddingTop","paddingRight","paddingBottom"].includes(e)},t.ExtractGUINumericValue=function(e,t){if(!e||!t)return 0;var i=t+"InPixels";if(void 0!==e[i]){var n=e[i];if("number"==typeof n&&!isNaN(n))return n}var r=e[t];return"string"==typeof r?r.endsWith("px")||r.endsWith("%")?parseFloat(r):parseFloat(r)||0:"number"==typeof r?r:0},t.CreateGUIAnimationProxy=function(t,i){var n={_control:t,_property:i,animations:[]};return Object.defineProperty(n,i,{get:function(){return e.SceneManager.ExtractGUINumericValue(n._control,n._property)},set:function(e){var t=n._property+"InPixels";void 0!==n._control[t]?n._control[t]=e:n._control[n._property]=e+"px"},enumerable:!0,configurable:!0}),n},t.GetAnimationType=function(e){if("number"==typeof e)return BABYLON.Animation.ANIMATIONTYPE_FLOAT;if(e&&"object"==typeof e){if(void 0!==e.x&&void 0!==e.y)return void 0!==e.z?BABYLON.Animation.ANIMATIONTYPE_VECTOR3:BABYLON.Animation.ANIMATIONTYPE_VECTOR2;if(void 0!==e.r&&void 0!==e.g&&void 0!==e.b)return BABYLON.Animation.ANIMATIONTYPE_COLOR3;if(void 0!==e.w&&void 0!==e.x&&void 0!==e.y&&void 0!==e.z)return BABYLON.Animation.ANIMATIONTYPE_QUATERNION}return BABYLON.Animation.ANIMATIONTYPE_FLOAT},t.CreateTweenAnimations=function(t,i,n,r,o){var a=[],s=[],l=60*(r.duration||1),u=e.SceneManager.IsGUIControl(t);for(var h in r.yoyo&&r.loop||r.yoyo&&r.yoyoCount&&r.yoyoCount>0&&r.yoyoCount,n){var c=n[h],d=i?i[h]:e.SceneManager.GetPropertyValue(t,h),m=t,p=h;if(u&&e.SceneManager.IsGUIPositionProperty(h)){m=e.SceneManager.CreateGUIAnimationProxy(t,h),p=h,d=i?"string"==typeof i[h]?parseFloat(i[h]):i[h]:e.SceneManager.ExtractGUINumericValue(t,h);var f="string"==typeof c?parseFloat(c):c,g=BABYLON.Animation.ANIMATIONTYPE_FLOAT,y=new BABYLON.Animation("tween_".concat(h),p,60,g,r.loop?BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE:BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT),v=e.SceneManager.CreateEasingFunction(r.ease);v&&y.setEasingFunction(v);var S=[],_=0;if(S.push({frame:_,value:d}),_+=l,S.push({frame:_,value:f}),r.yoyo&&r.loop)_+=l,S.push({frame:_,value:d});else if(r.yoyo&&r.yoyoCount&&r.yoyoCount>0){_+=l,S.push({frame:_,value:d});for(var b=1;b<r.yoyoCount;b++)_+=l,S.push({frame:_,value:f}),_+=l,S.push({frame:_,value:d})}y.setKeys(S),a.push(y),s.push(m)}else if(void 0!==d&&void 0!==c){var B=e.SceneManager.GetAnimationType(c),C=new BABYLON.Animation("tween_".concat(h),h,60,B,r.loop?BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE:BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT),A=e.SceneManager.CreateEasingFunction(r.ease);A&&C.setEasingFunction(A);var T=[],M=0;if(T.push({frame:M,value:d}),M+=l,T.push({frame:M,value:c}),r.yoyo&&r.loop)M+=l,T.push({frame:M,value:d});else if(r.yoyo&&r.yoyoCount&&r.yoyoCount>0)for(M+=l,T.push({frame:M,value:d}),b=1;b<r.yoyoCount;b++)M+=l,T.push({frame:M,value:c}),M+=l,T.push({frame:M,value:d});C.setKeys(T),a.push(C),s.push(m)}}return{animations:a,targets:s}},t.TweenTo=function(t,i,n,r){var o;void 0===n&&(n={}),r=r||BABYLON.EngineStore.LastCreatedScene;var a,s=e.SceneManager.CreateTweenAnimations(t,null,i,n,r),l=s.animations,u=s.targets,h=e.SceneManager.IsGUIControl(t);if(h)for(var c=0;c<l.length;c++){var d=l[c];(b=u[c])!==t?(b.animations=b.animations||[],b.animations.push(d)):(t.animations=t.animations||[],t.animations.push(d))}else t.animations=t.animations||[],(o=t.animations).push.apply(o,l);var m,p=new Promise(function(e){a=e}),f=function(){n.onComplete&&n.onComplete(),a()},g=1e3*(n.delay||0),y=n.speed||1,v=60*(n.duration||1);n.yoyo&&n.loop?v*=2:n.yoyo&&n.yoyoCount&&n.yoyoCount>0&&(v*=1+n.yoyoCount);var S=[];if(h&&u.some(function(e){return e!==t})){var _=[];if(g>0)setTimeout(function(){n.onStart&&n.onStart();for(var e=0;e<u.length;e++){var t=u[e],i=r.beginAnimation(t,0,v,n.loop||!1,y,e===u.length-1?f:void 0);i&&(_.push(i),S.push(i))}m=_[0]},g);else{for(n.onStart&&n.onStart(),c=0;c<u.length;c++){var b=u[c],B=r.beginAnimation(b,0,v,n.loop||!1,y,c===u.length-1?f:void 0);B&&(_.push(B),S.push(B))}m=_[0]}}else g>0?setTimeout(function(){n.onStart&&n.onStart(),(m=r.beginAnimation(t,0,v,n.loop||!1,y,f))&&S.push(m)},g):(n.onStart&&n.onStart(),(m=r.beginAnimation(t,0,v,n.loop||!1,y,f))&&S.push(m));return{animations:S,finished:p}},t.TweenToAsync=function(t,i){return s(this,arguments,void 0,function(t,i,n,r){return void 0===n&&(n={}),l(this,function(o){return[2,e.SceneManager.TweenTo(t,i,n,r).finished]})})},t.TweenFromTo=function(t,i,n,r,o){for(var a in void 0===r&&(r={}),i)e.SceneManager.SetPropertyValue(t,a,i[a]);return e.SceneManager.TweenTo(t,n,r,o)},t.TweenFromToAsync=function(t,i,n){return s(this,arguments,void 0,function(t,i,n,r,o){return void 0===r&&(r={}),l(this,function(a){return[2,e.SceneManager.TweenFromTo(t,i,n,r,o).finished]})})},t.TweenGroupAsync=function(e){return s(this,arguments,void 0,function(e,t,i){var n,r,o,a,s,u,h,c,d;return void 0===t&&(t={}),l(this,function(l){switch(l.label){case 0:if(i=i||BABYLON.EngineStore.LastCreatedScene,n=t.mode||"all",r=t.stagger||0,"sequence"!==n)return[3,7];o=0,a=e,l.label=1;case 1:return o<a.length?(s=a[o],(u=s())&&u.finished?[4,u.finished]:[3,3]):[3,6];case 2:return l.sent(),[3,5];case 3:return u&&u.then?[4,u]:[3,5];case 4:l.sent(),l.label=5;case 5:return o++,[3,1];case 6:return[3,9];case 7:for(h=[],c=function(t){var i=e[t];if(r>0&&t>0)h.push(new Promise(function(e){setTimeout(function(){var t=i();t&&t.finished?t.finished.then(e):t&&t.then?t.then(e):e()},t*r)}));else{var n=i();n&&n.finished?h.push(n.finished):n&&n.then&&h.push(n)}},d=0;d<e.length;d++)c(d);return[4,Promise.all(h)];case 8:l.sent(),l.label=9;case 9:return t.onComplete&&t.onComplete(),[2]}})})},t.GlobalOptions={},t.WindowState={},t.ServerEndPoint="http://127.0.0.1:2567",t.EnableDebugMode=!1,t.EnableUserInput=!0,t.RenderLoopReady=!0,t.PauseRenderLoop=!1,t.ScenePlaying=!0,t.PhysicsTimeStep=1/60,t.LostRenderContext=!1,t.AutoUpdateProgress=!0,t.PhysicsCapsuleShape=0,t.SupportSRGBBuffers=!1,t.AnimationStartMode=0,t.AnimationTargetFps=60,t.DefaultConvexHullMargin=.001,t.DefaultHeightFieldMargin=.001,t.AmbientLightIntensity=1,t.PointLightIntensity=1,t.SpotLightIntensity=1,t.DirectionalLightIntensity=1,t.FogExpDensityScale=1,t.FogExp2DensityScale=1,t.FogLinearDensityScale=1,t.TerrainColorCorrection=2.2,t.AllowCameraMovement=!0,t.AllowCameraRotation=!0,t.VirtualJoystickEnabled=!1,t.GameTimeMilliseconds=0,t.ParseScriptComponents=!0,t.AutoLoadScriptBundles=!0,t.AutoStripNamespacePrefix=!0,t.UniversalModuleDefinition=!0,t.WaitForSeconds=function(t){return new Promise(function(i){return e.WindowManager.SetTimeout(1e3*t,i)})},t.OnPreRenderLoopObservable=new BABYLON.Observable,t.OnPostRenderLoopObservable=new BABYLON.Observable,t.OnSceneReadyObservable=new BABYLON.Observable,t.OnEngineResizeObservable=new BABYLON.Observable,t.OnLoadCompleteObservable=new BABYLON.Observable,t.OnRebuildContextObservable=new BABYLON.Observable,t.OnAssetManagerProgress=null,t.AllLayerMask=4294967295,t.DefaultLayerMask=268435455,t.HiddenLayerMask=268435456,t._HideLoadingScreen=null,t.CVTOOLS_NAME="CVTOOLS_unity_metadata",t.CVTOOLS_MESH="CVTOOLS_babylon_mesh",t.CVTOOLS_HAND="CVTOOLS_left_handed",t.CVTOOLS_NAME_REGISTERED=!1,t.CVTOOLS_MESH_REGISTERED=!1,t.CVTOOLS_HAND_REGISTERED=!1,t._EventBus=null,t.SceneLoaderFileNames=[],t.SceneLoaderPropertyBag={},t.SceneLoaderHandledFlag=!1,t.SceneParsingEnabled=!0,t.PhysicsViewersEnabled=!1,t.MAX_AGENT_COUNT=200,t.MAX_AGENT_RADIUS=2,t.OnNavMeshReadyObservable=new BABYLON.Observable,t.OnNavMeshDestroyObservable=new BABYLON.Observable,t.NavMeshPlugin=null,t.NavMeshSurface=null,t.NavMeshDebugger=null,t.NavMeshMaterial=null,t.CrowdInterface=null,t}();e.SceneManager=t}(n||(n={})),n.SceneManager.GameTimeMilliseconds=n.SceneManager.GetTimeMilliseconds(),function(e){var t=function(){function t(t,i,n,r){if(void 0===n&&(n={}),void 0===r&&(r=null),this._update=null,this._late=null,this._step=null,this._fixed=null,this._after=null,this._ready=null,this._lateUpdate=!1,this._properties=null,this._awoken=!1,this._started=!1,this._scene=null,this._delyed=!1,this._transform=null,this._scriptReady=!1,this._registeredClassname=null,this._registerComponentAlias=!0,this._lateUpdateObserver=null,this.resetScriptComponent=null,this._bodyCollisionObserver=null,this._bodyCollisionEndedObserver=null,this._worldTriggerEventObserver=null,this.onCollisionEnterObservable=new BABYLON.Observable,this.onCollisionStayObservable=new BABYLON.Observable,this.onCollisionExitObservable=new BABYLON.Observable,this.onTriggerEnterObservable=new BABYLON.Observable,this.onTriggerExitObservable=new BABYLON.Observable,null==t)throw new Error("Null transform object specified.");if(null==i)throw new Error("Null host scene object specified.");this._scene=i,this._transform=t,this._properties=n||{},null!=this._properties._scriptComponentAlias&&""!==this._properties._scriptComponentAlias?this._registeredClassname=this._properties._scriptComponentAlias:this._registeredClassname=r||this.constructor.name||"Unknown",null!=this._properties._registerComponentAlias?this._registerComponentAlias=this._properties._registerComponentAlias:this._registerComponentAlias=!0;var o=this;o._update=function(){e.ScriptComponent.UpdateInstance(o)},o._late=function(){e.ScriptComponent.LateInstance(o)},o._step=function(){e.ScriptComponent.StepInstance(o)},o._fixed=function(){e.ScriptComponent.FixedInstance(o)},o._after=function(){e.ScriptComponent.AfterInstance(o)},o._ready=function(){e.ScriptComponent.ReadyInstance(o)},o.resetScriptComponent=function(){e.ScriptComponent.ResetInstance(o)},o.registerComponentInstance&&o.destroyComponentInstance||BABYLON.Tools.Warn("Invalid component registration handlers for: "+this._transform.name),!0===this._registerComponentAlias&&null!=o.registerComponentInstance&&o.registerComponentInstance(o,this._registeredClassname,!0)}return t.prototype.isReady=function(){return this._scriptReady},Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transform",{get:function(){return this._transform},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){},t.prototype.getClassName=function(){return this._registeredClassname},t.prototype.getProperties=function(){return this._properties},t.prototype.getProperty=function(e,t){void 0===t&&(t=null);var i=null;return null!=this._properties&&null==(i=this._properties[e])&&(i=this._properties["auto__"+e]),null==i&&(i=t),null!=i?i:null},t.prototype.setProperty=function(e,t){null==this._properties&&(this._properties={}),this._properties[e]=t},t.prototype.getTime=function(){return e.SceneManager.GetTime()},t.prototype.getTimeMs=function(){return e.SceneManager.GetTimeMs()},t.prototype.getGameTime=function(){return e.SceneManager.GetGameTime()},t.prototype.getGameTimeMs=function(){return e.SceneManager.GetGameTimeMs()},t.prototype.getDeltaTime=function(){return e.SceneManager.GetDeltaTime(this.scene)},t.prototype.getDeltaSeconds=function(){return e.SceneManager.GetDeltaSeconds(this.scene)},t.prototype.getDeltaMilliseconds=function(){return e.SceneManager.GetDeltaMilliseconds(this.scene)},t.prototype.getAnimationRatio=function(){return e.SceneManager.GetAnimationRatio(this.scene)},t.prototype.hasSkinnedMesh=function(){return null!=this.getSkinnedMesh()},t.prototype.getSkinnedMesh=function(){return e.SceneManager.GetSkinnedMesh(this.transform)},t.prototype.getTransformMesh=function(){return this._transform instanceof BABYLON.Mesh?this._transform:null},t.prototype.getAbstractMesh=function(){return this._transform instanceof BABYLON.AbstractMesh?this._transform:null},t.prototype.getInstancedMesh=function(){return this._transform instanceof BABYLON.InstancedMesh?this._transform:null},t.prototype.getPrimitiveMeshes=function(){return e.SceneManager.GetPrimitiveMeshes(this.transform)},t.prototype.getMetadata=function(){return e.SceneManager.FindSceneMetadata(this._transform)},t.prototype.getComponent=function(t,i){void 0===i&&(i=!1);var n=e.SceneManager.FindScriptComponent(this._transform,t,i);return null!=n?n:null},t.prototype.getComponents=function(t,i){void 0===i&&(i=!1);var n=e.SceneManager.FindAllScriptComponents(this._transform,t,i);return null!=n?n:null},t.prototype.getLightRig=function(){return e.SceneManager.FindSceneLightRig(this._transform)},t.prototype.getCameraRig=function(){return e.SceneManager.FindSceneCameraRig(this._transform)},t.prototype.getTransformTag=function(){return e.SceneManager.GetTransformTag(this.transform)},t.prototype.hasTransformTags=function(t){return e.SceneManager.HasTransformTags(this._transform,t)},t.prototype.getChildNode=function(t,i,n,r){return void 0===i&&(i=e.SearchType.ExactMatch),void 0===n&&(n=!0),void 0===r&&(r=null),e.SceneManager.FindChildTransformNode(this._transform,t,i,n,r)},t.prototype.getChildWithTags=function(t,i,n){return void 0===i&&(i=!0),void 0===n&&(n=null),e.SceneManager.FindChildTransformWithTags(this._transform,t,i,n)},t.prototype.getChildrenWithTags=function(t,i,n){return void 0===i&&(i=!0),void 0===n&&(n=null),e.SceneManager.FindAllChildTransformsWithTags(this._transform,t,i,n)},t.prototype.getChildWithScript=function(t,i,n){return void 0===i&&(i=!0),void 0===n&&(n=null),e.SceneManager.FindChildTransformWithScript(this._transform,t,i,n)},t.prototype.getChildrenWithScript=function(t,i,n){return void 0===i&&(i=!0),void 0===n&&(n=null),e.SceneManager.FindAllChildTransformsWithScript(this._transform,t,i,n)},t.prototype.enableCollisionEvents=function(){var t=this,i=e.Utilities.GetHavokPlugin();if(null!=i&&null!=this.transform.physicsBody){if(this.transform.physicsBody.setCollisionCallbackEnabled(!0),this.transform.physicsBody.setCollisionEndedCallbackEnabled(!0),null==this._bodyCollisionObserver){var n=this.transform.physicsBody.getCollisionObservable();null!=n&&(this._bodyCollisionObserver=n.add(function(e){null!=e.collidedAgainst&&null!=e.collidedAgainst.transformNode&&("COLLISION_STARTED"===e.type?t.onCollisionEnterObservable.notifyObservers(e.collidedAgainst.transformNode):"COLLISION_CONTINUED"===e.type&&t.onCollisionStayObservable.notifyObservers(e.collidedAgainst.transformNode))}))}if(null==this._bodyCollisionEndedObserver){var r=this.transform.physicsBody.getCollisionEndedObservable();null!=r&&(this._bodyCollisionEndedObserver=r.add(function(e){null!=e.collidedAgainst&&null!=e.collidedAgainst.transformNode&&"COLLISION_FINISHED"===e.type&&t.onCollisionExitObservable.notifyObservers(e.collidedAgainst.transformNode)}))}null==this._worldTriggerEventObserver&&(this._worldTriggerEventObserver=i.onTriggerCollisionObservable.add(function(e){if(e.collider===t.transform.physicsBody||e.collidedAgainst===t.transform.physicsBody){var i=e.collider===t.transform.physicsBody?e.collidedAgainst:e.collider;"TRIGGER_ENTERED"===e.type?t.onTriggerEnterObservable.notifyObservers(i.transformNode):"TRIGGER_EXITED"===e.type&&t.onTriggerExitObservable.notifyObservers(i.transformNode)}}))}},t.prototype.disableCollisionEvents=function(){null!=e.Utilities.GetHavokPlugin()&&null!=this.transform.physicsBody&&(this.transform.physicsBody.setCollisionCallbackEnabled(!1),this.transform.physicsBody.setCollisionEndedCallbackEnabled(!1))},t.prototype.setTransformPosition=function(e){this.transform.physicsBody&&0!=this.transform.physicsBody.disablePreStep&&(this.transform.physicsBody.disablePreStep=!1),null!=this.transform.position&&this.transform.position.copyFrom(e)},t.prototype.setTransformRotation=function(e){this.transform.physicsBody&&0!=this.transform.physicsBody.disablePreStep&&(this.transform.physicsBody.disablePreStep=!1),null!=this.transform.rotationQuaternion&&this.transform.rotationQuaternion.copyFrom(e)},t.prototype.registerOnClickAction=function(t){var i=null;return this.transform instanceof BABYLON.AbstractMesh&&(i=e.SceneManager.RegisterClickAction(this.scene,this.transform,t)),i},t.prototype.unregisterOnClickAction=function(t){var i=!1;return this.transform instanceof BABYLON.AbstractMesh&&(i=e.SceneManager.UnregisterClickAction(this.transform,t)),i},t.prototype.registerComponentInstance=function(t,i,n){if(void 0===n&&(n=!0),null!=i&&""!==i&&"Unknown"!==i){if(!0===n){e.Utilities.ValidateTransformMetadata(this._transform);var r={alias:"script",order:0,klass:i,properties:null,instance:t};null==this._transform.metadata.toolkit.components&&(this._transform.metadata.toolkit.components=[]),this._transform.metadata.toolkit.components.push(r)}e.ScriptComponent.RegisterInstance(t),!0===n&&t.scene.onAfterRenderObservable.addOnce(function(){t.delayComponentInstance(t)})}else console.warn("Failed to register unknown component instance: ",t)},t.prototype.delayComponentInstance=function(t){e.WindowManager.SetTimeout(100,function(){t._delyed=!0})},t.prototype.destroyComponentInstance=function(t){e.ScriptComponent.DestroyInstance(t)},t.prototype.setupStepComponentInstance=function(e){e.scene.onBeforePhysicsObservable&&e.scene.onBeforePhysicsObservable.add(e._step)},t.prototype.removeStepComponentInstance=function(e){e.scene.onBeforePhysicsObservable&&e.scene.onBeforePhysicsObservable.removeCallback(e._step)},t.prototype.setupFixedComponentInstance=function(e){e.scene.onAfterPhysicsObservable&&e.scene.onAfterPhysicsObservable.add(e._fixed)},t.prototype.removeFixedComponentInstance=function(e){e.scene.onAfterPhysicsObservable&&e.scene.onAfterPhysicsObservable.removeCallback(e._fixed)},t.RegisterInstance=function(e){null!=e&&(null!=e._update&&e.scene.registerBeforeRender(e._update),e.late&&null!=e._late&&null!=e.scene.onBeforeRenderTargetsRenderObservable&&(e._lateUpdateObserver=e.scene.onBeforeRenderTargetsRenderObservable.add(e._late)),e.after&&null!=e._after&&e.scene.registerAfterRender(e._after),e.step&&null!=e._step&&e.setupStepComponentInstance(e),e.fixed&&null!=e._fixed&&e.setupFixedComponentInstance(e))},t.UpdateInstance=function(t){!0===e.SceneManager.ScenePlaying&&null!=t&&null!=t.transform&&t.transform.isEnabled(!1)&&(!1===t._awoken?(t._awoken=!0,e.ScriptComponent.ParseAutoProperties(t),t.awake&&t.awake()):!1===t._started?(t._started=!0,t.start&&t.start()):!0===t._awoken&&!0===t._started&&(!0===t._delyed&&(t._delyed=!1,e.ScriptComponent.ReadyInstance(t)),t.update&&t.update(),t._lateUpdate=!0))},t.LateInstance=function(t){!0===e.SceneManager.ScenePlaying&&null!=t&&null!=t.transform&&t.transform.isEnabled(!1)&&!0===t._lateUpdate&&(t._lateUpdate=!1,!0===t._started&&t.late&&t.late())},t.AfterInstance=function(t){!0===e.SceneManager.ScenePlaying&&null!=t&&null!=t.transform&&t.transform.isEnabled(!1)&&!0===t._started&&t.after&&t.after()},t.StepInstance=function(t){!0===e.SceneManager.ScenePlaying&&null!=t&&null!=t.transform&&!0===t._started&&t.step&&t.step()},t.FixedInstance=function(t){!0===e.SceneManager.ScenePlaying&&null!=t&&null!=t.transform&&!0===t._started&&t.fixed&&t.fixed()},t.ReadyInstance=function(e){null!=e&&null!=e.transform&&!1===e._scriptReady&&(e._scriptReady=!0,e.ready&&e.ready())},t.ResetInstance=function(e){null!=e&&null!=e.transform&&!0===e._started&&e.reset&&e.reset()},t.DestroyInstance=function(t){if(null!=t){t.scene.unregisterBeforeRender(t._update),null!=t._lateUpdateObserver&&null!=t.scene.onBeforeRenderTargetsRenderObservable&&t.scene.onBeforeRenderTargetsRenderObservable.remove(t._lateUpdateObserver),t.after&&null!=t._after&&t.scene.unregisterAfterRender(t._after),t.step&&null!=t._step&&t.removeStepComponentInstance(t),t.fixed&&null!=t._fixed&&t.removeFixedComponentInstance(t);var i=e.Utilities.GetHavokPlugin();if(null!=i){if(null!=t._bodyCollisionObserver)try{t._bodyCollisionObserver.remove()}catch(e){}if(null!=t._bodyCollisionEndedObserver)try{t._bodyCollisionEndedObserver.remove()}catch(e){}if(null!=t._worldTriggerEventObserver)try{i.onTriggerCollisionObservable.remove(t._worldTriggerEventObserver)}catch(e){}}try{t.onCollisionEnterObservable.clear()}catch(e){}try{t.onCollisionStayObservable.clear()}catch(e){}try{t.onCollisionExitObservable.clear()}catch(e){}try{t.onTriggerEnterObservable.clear()}catch(e){}try{t.onTriggerExitObservable.clear()}catch(e){}try{t.destroy&&t.destroy()}catch(e){}t._scriptReady=!1,t._transform=null,t._properties=null,t._started=!1,t._delyed=!1,t._update=null,t._late=null,t._step=null,t._fixed=null,t._after=null,t._ready=null,t._scene=null}},t.ParseAutoProperties=function(t){var i=Object.keys(t._properties);if(null!=i&&i.length>0)for(var n=function(n){var r=i[n];if(e.Utilities.StartsWith(r,"auto__")){var o=r.replace("auto__","");if(e.Utilities.HasOwnProperty(t,o)){var a=t.getProperty(r);if(null!=a){var s=typeof a;if(null!=s&&""!==s)if("object"===s)if(Array.isArray(a)){var l=[];a.forEach(function(i){null!=i&&("object"==typeof i?l.push(e.ScriptComponent.UnpackObjectProperty(i,t.scene)):l.push(i))}),t[o]=l}else{var u=t[o],h=e.ScriptComponent.UnpackObjectProperty(a,t.scene);u instanceof BABYLON.Color3&&h instanceof BABYLON.Color4?t[o]=new BABYLON.Color3(h.r,h.g,h.b):t[o]=h}else t[o]=a;else t[o]=a}else t[o]=a}else BABYLON.Tools.Warn(t.getClassName()||"Unregistered Class: Auto property '"+o+"' not found for transform '"+t.transform.name+"'")}},r=0;r<i.length;r++)n(r)},t.UnpackObjectProperty=function(t,i){var n=null;if(null!=t)if(void 0!==t.x&&void 0!==t.y)n=void 0!==t.z?void 0!==t.w?new BABYLON.Vector4(t.x,t.y,t.z,t.w):new BABYLON.Vector3(t.x,t.y,t.z):new BABYLON.Vector2(t.x,t.y);else if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b){var r=1;void 0!==t.a&&(r=t.a),n=new BABYLON.Color4(t.r,t.g,t.b,r)}else if(void 0!==t.type)switch(t.type){case"UnityEngine.AnimationCurve":var o=t;n=BABYLON.Animation.Parse(o.animation);break;case"UnityEngine.Transform":var a=t;n=e.Utilities.ParseTransformByID(a,i);break;case"UnityEngine.Material":var s=t;n=i.getMaterialByName(s.name);break;case"UnityEngine.Texture2D":var l=t;n=e.Utilities.ParseTexture(l,i);break;case"UnityEngine.Cubemap":var u=t;n=e.Utilities.ParseCubemap(u,i);break;case"UnityEngine.AudioClip":case"UnityEngine.Video.VideoClip":case"UnityEngine.Font":default:n=t;break;case"UnityEngine.TextAsset":var h=t;n=null!=h.base64?!0===h.json?JSON.parse(e.WindowManager.Atob(h.base64)):e.WindowManager.Atob(h.base64):h;break;case"UnityEditor.DefaultAsset":var c=t;n=null!=c.base64?!0===c.json?JSON.parse(e.WindowManager.Atob(c.base64)):e.WindowManager.Atob(c.base64):c}else n=t;return n},t}();e.ScriptComponent=t;var i=function(t){function i(e,i,n,r){void 0===n&&(n={}),void 0===r&&(r=null);var o=t.call(this,e,i,n,r)||this;return o.autoHideSplashScreen=!0,o.postCreateSceneDelayMs=1e3,o.hideSplashScreenDelayMs=3e3,o.createSceneHandled=!1,o}return o(i,t),i.prototype.preCreateScene=function(t){return s(this,void 0,void 0,function(){var i=this;return l(this,function(n){return this.createSceneHandled||(this.createSceneHandled=!0,e.WindowManager.SetTimeout(this.postCreateSceneDelayMs,function(){return s(i,void 0,void 0,function(){return l(this,function(e){switch(e.label){case 0:return[4,this.postCreateScene(t)];case 1:return e.sent(),[2]}})})})),[2]})})},i.prototype.postCreateScene=function(t){return s(this,void 0,void 0,function(){var i;return l(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),this.createScene?[4,this.createScene(t)]:[3,2];case 1:n.sent(),n.label=2;case 2:return[3,5];case 3:return i=n.sent(),console.error("Failed to initialize scene",i),[3,5];case 4:return this.autoHideSplashScreen&&e.SceneManager.HideSplashScreen(this.scene,this.hideSplashScreenDelayMs),[7];case 5:return[2]}})})},i}(e.ScriptComponent);e.SceneController=i}(n||(n={})),function(e){var t,i,n,r,a,s,l,u,h,c,d,m,p,f,g,y,v;(v=e.System||(e.System={}))[v.Deg2Rad=2*Math.PI/360]="Deg2Rad",v[v.Rad2Deg=1/e.System.Deg2Rad]="Rad2Deg",v[v.Epsilon=1e-6]="Epsilon",v[v.SingleEpsilon=1401298e-51]="SingleEpsilon",v[v.EpsilonNormalSqrt=1e-15]="EpsilonNormalSqrt",v[v.Kph2Mph=.621371]="Kph2Mph",v[v.Mph2Kph=1.60934]="Mph2Kph",v[v.Mps2Kph=3.6]="Mps2Kph",v[v.Mps2Mph=2.23694]="Mps2Mph",v[v.Meter2Inch=39.3701]="Meter2Inch",v[v.Inch2Meter=.0254]="Inch2Meter",v[v.Gravity=9.81]="Gravity",v[v.Gravity3G=29.400000000000002]="Gravity3G",v[v.SkidFactor=.25]="SkidFactor",v[v.MaxInteger=2147483647]="MaxInteger",v[v.WalkingVelocity=4.4]="WalkingVelocity",v[v.TerminalVelocity=55]="TerminalVelocity",v[v.SmoothDeltaFactor=.2]="SmoothDeltaFactor",v[v.ToLinearSpace=2.2]="ToLinearSpace",v[v.ToGammaSpace=.45454545454545453]="ToGammaSpace",(y=e.Handedness||(e.Handedness={}))[y.Default=-1]="Default",y[y.Right=0]="Right",y[y.Left=1]="Left",(g=e.SearchType||(e.SearchType={}))[g.ExactMatch=0]="ExactMatch",g[g.StartsWith=1]="StartsWith",g[g.EndsWith=2]="EndsWith",g[g.IndexOf=3]="IndexOf",(f=e.PlayerNumber||(e.PlayerNumber={}))[f.Auto=0]="Auto",f[f.One=1]="One",f[f.Two=2]="Two",f[f.Three=3]="Three",f[f.Four=4]="Four",(p=e.PlayerControl||(e.PlayerControl={}))[p.FirstPerson=0]="FirstPerson",p[p.ThirdPerson=1]="ThirdPerson",(m=e.RenderQuality||(e.RenderQuality={}))[m.High=0]="High",m[m.Medium=1]="Medium",m[m.Low=2]="Low",(d=e.GamepadType||(e.GamepadType={}))[d.None=-1]="None",d[d.Generic=0]="Generic",d[d.Xbox360=1]="Xbox360",d[d.DualShock=2]="DualShock",d[d.PoseController=3]="PoseController",(c=e.Xbox360Trigger||(e.Xbox360Trigger={}))[c.Left=0]="Left",c[c.Right=1]="Right",(h=e.MovementType||(e.MovementType={}))[h.DirectVelocity=0]="DirectVelocity",h[h.AppliedForces=1]="AppliedForces",(u=e.CollisionContact||(e.CollisionContact={}))[u.Top=0]="Top",u[u.Left=1]="Left",u[u.Right=2]="Right",u[u.Bottom=3]="Bottom",(l=e.IntersectionPrecision||(e.IntersectionPrecision={}))[l.AABB=0]="AABB",l[l.OBB=1]="OBB",(s=e.CollisionFilters||(e.CollisionFilters={}))[s.DefaultFilter=1]="DefaultFilter",s[s.StaticFilter=2]="StaticFilter",s[s.KinematicFilter=4]="KinematicFilter",s[s.DebrisFilter=8]="DebrisFilter",s[s.SensorTrigger=16]="SensorTrigger",s[s.CharacterFilter=32]="CharacterFilter",s[s.AllFilter=-1]="AllFilter",(a=e.CollisionState||(e.CollisionState={}))[a.ACTIVE_TAG=1]="ACTIVE_TAG",a[a.ISLAND_SLEEPING=2]="ISLAND_SLEEPING",a[a.WANTS_DEACTIVATION=3]="WANTS_DEACTIVATION",a[a.DISABLE_DEACTIVATION=4]="DISABLE_DEACTIVATION",a[a.DISABLE_SIMULATION=5]="DISABLE_SIMULATION",(r=e.CollisionFlags||(e.CollisionFlags={}))[r.CF_STATIC_OBJECT=1]="CF_STATIC_OBJECT",r[r.CF_KINEMATIC_OBJECT=2]="CF_KINEMATIC_OBJECT",r[r.CF_NO_CONTACT_RESPONSE=4]="CF_NO_CONTACT_RESPONSE",r[r.CF_CUSTOM_MATERIAL_CALLBACK=8]="CF_CUSTOM_MATERIAL_CALLBACK",r[r.CF_CHARACTER_OBJECT=16]="CF_CHARACTER_OBJECT",r[r.CF_DISABLE_VISUALIZE_OBJECT=32]="CF_DISABLE_VISUALIZE_OBJECT",r[r.CF_DISABLE_SPU_COLLISION_PROCESSING=64]="CF_DISABLE_SPU_COLLISION_PROCESSING",r[r.CF_HAS_CONTACT_STIFFNESS_DAMPING=128]="CF_HAS_CONTACT_STIFFNESS_DAMPING",r[r.CF_HAS_CUSTOM_DEBUG_RENDERING_COLOR=256]="CF_HAS_CUSTOM_DEBUG_RENDERING_COLOR",r[r.CF_HAS_FRICTION_ANCHOR=512]="CF_HAS_FRICTION_ANCHOR",r[r.CF_HAS_COLLISION_SOUND_TRIGGER=1024]="CF_HAS_COLLISION_SOUND_TRIGGER",(n=e.UserInputPointer||(e.UserInputPointer={}))[n.Left=0]="Left",n[n.Middle=1]="Middle",n[n.Right=2]="Right",(i=e.UserInputAxis||(e.UserInputAxis={}))[i.Horizontal=0]="Horizontal",i[i.Vertical=1]="Vertical",i[i.ClientX=2]="ClientX",i[i.ClientY=3]="ClientY",i[i.MouseX=4]="MouseX",i[i.MouseY=5]="MouseY",i[i.Wheel=6]="Wheel",(t=e.UserInputKey||(e.UserInputKey={}))[t.BackSpace=8]="BackSpace",t[t.Tab=9]="Tab",t[t.Enter=13]="Enter",t[t.Shift=16]="Shift",t[t.Ctrl=17]="Ctrl",t[t.Alt=18]="Alt",t[t.Pause=19]="Pause",t[t.Break=19]="Break",t[t.CapsLock=20]="CapsLock",t[t.Escape=27]="Escape",t[t.SpaceBar=32]="SpaceBar",t[t.PageUp=33]="PageUp",t[t.PageDown=34]="PageDown",t[t.End=35]="End",t[t.Home=36]="Home",t[t.LeftArrow=37]="LeftArrow",t[t.UpArrow=38]="UpArrow",t[t.RightArrow=39]="RightArrow",t[t.DownArrow=40]="DownArrow",t[t.Insert=45]="Insert",t[t.Delete=46]="Delete",t[t.Num0=48]="Num0",t[t.Num1=49]="Num1",t[t.Num2=50]="Num2",t[t.Num3=51]="Num3",t[t.Num4=52]="Num4",t[t.Num5=53]="Num5",t[t.Num6=54]="Num6",t[t.Num7=55]="Num7",t[t.Num8=56]="Num8",t[t.Num9=57]="Num9",t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.I=73]="I",t[t.J=74]="J",t[t.K=75]="K",t[t.L=76]="L",t[t.M=77]="M",t[t.N=78]="N",t[t.O=79]="O",t[t.P=80]="P",t[t.Q=81]="Q",t[t.R=82]="R",t[t.S=83]="S",t[t.T=84]="T",t[t.U=85]="U",t[t.V=86]="V",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.Z=90]="Z",t[t.LeftWindowKey=91]="LeftWindowKey",t[t.RightWindowKey=92]="RightWindowKey",t[t.SelectKey=93]="SelectKey",t[t.Numpad0=96]="Numpad0",t[t.Numpad1=97]="Numpad1",t[t.Numpad2=98]="Numpad2",t[t.Numpad3=99]="Numpad3",t[t.Numpad4=100]="Numpad4",t[t.Numpad5=101]="Numpad5",t[t.Numpad6=102]="Numpad6",t[t.Numpad7=103]="Numpad7",t[t.Numpad8=104]="Numpad8",t[t.Numpad9=105]="Numpad9",t[t.Multiply=106]="Multiply",t[t.Add=107]="Add",t[t.Subtract=109]="Subtract",t[t.DecimalPoint=110]="DecimalPoint",t[t.Divide=111]="Divide",t[t.F1=112]="F1",t[t.F2=113]="F2",t[t.F3=114]="F3",t[t.F4=115]="F4",t[t.F5=116]="F5",t[t.F6=117]="F6",t[t.F7=118]="F7",t[t.F8=119]="F8",t[t.F9=120]="F9",t[t.F10=121]="F10",t[t.F11=122]="F11",t[t.F12=123]="F12",t[t.NumLock=144]="NumLock",t[t.ScrollLock=145]="ScrollLock",t[t.SemiColon=186]="SemiColon",t[t.EqualSign=187]="EqualSign",t[t.Comma=188]="Comma",t[t.Dash=189]="Dash",t[t.Period=190]="Period",t[t.ForwardSlash=191]="ForwardSlash",t[t.GraveAccent=192]="GraveAccent",t[t.OpenBracket=219]="OpenBracket",t[t.BackSlash=220]="BackSlash",t[t.CloseBraket=221]="CloseBraket",t[t.SingleQuote=222]="SingleQuote";var S=function(){function e(){}return e.KeyboardSmoothing=!1,e.KeyboardMoveSensibility=3,e.KeyboardArrowSensibility=1,e.KeyboardMoveDeadZone=.001,e.GamepadDeadStickValue=.15,e.GamepadLStickXInverted=!1,e.GamepadLStickYInverted=!1,e.GamepadRStickXInverted=!1,e.GamepadRStickYInverted=!0,e.GamepadLStickSensibility=1,e.GamepadRStickSensibility=1,e.SupportedInputDevices=null,e.BabylonAngularSensibility=2e3,e.DefaultAngularSensibility=.5,e.PointerWheelDeadZone=.1,e.PointerMouseDeadZone=.1,e.PointerMouseInverted=!0,e.UseCanvasElement=!0,e.UseArrowKeyRotation=!1,e.EnableBabylonRotation=!1,e}();e.UserInputOptions=S;e.RequestHeader=function(){};e.TriggerVolume=function(){this.mesh=null,this.state=0};e.RoomErrorMessage=function(){};var _=function(){function e(e,t,i,n,r){void 0===i&&(i=!0),void 0===n&&(n=null),void 0===r&&(r=null),this.loadingDivId=e,this.loadingUIText=t,this.hideLoadingUIWithEngine=i,this.customInnerHtml=n,this.customInnerCss=r,this.loadingUIBackgroundColor="#000000",null!=this.loadingDivId&&""!==this.loadingDivId||(this.loadingDivId="customLoadingScreen"),null!=this.loadingUIText&&""!==this.loadingUIText||(this.loadingUIText="Please Wait")}return e.prototype.displayLoadingUI=function(){if(this.hasLoadingDiv())this.showLoadingDiv(!0);else{var e=document.createElement("style");e.type="text/css",e.innerHTML=this.customInnerCss||"",document.getElementsByTagName("head")[0].appendChild(e);var t=this.loadingUIText,i=document.createElement("div");i.id=this.loadingDivId,i.innerHTML=this.customInnerHtml||t,document.body.appendChild(i)}},e.prototype.hideLoadingUI=function(){!0===this.hideLoadingUIWithEngine&&this.showLoadingDiv(!1)},e.prototype.showLoadingDiv=function(e){var t=this.getLoadingDiv();null!=t&&(t.style.display=e?"initial":"none")},e.prototype.getLoadingDiv=function(){return document.getElementById(this.loadingDivId)},e.prototype.hasLoadingDiv=function(){return null!=document.getElementById(this.loadingDivId)},e}();e.CustomLoadingScreen=_;var b=function(){function e(){this.ListenerDictionary={}}return e.prototype.OnMessage=function(e,t){var i;null==this.ListenerDictionary[e]?(i=[],this.ListenerDictionary[e]=i):i=this.ListenerDictionary[e],i.findIndex(function(e){return t==e})<0&&i.push(t)},e.prototype.PostMessage=function(e,t){void 0===t&&(t=null);var i=this.ListenerDictionary[e];null!=i&&i.forEach(function(e){try{e&&e(t)}catch(e){console.warn(e)}})},e.prototype.RemoveHandler=function(e,t){var i=this.ListenerDictionary[e];if(null!=i){var n=i.findIndex(function(e){return t==e});n>=0&&i.splice(n,1)}},e.prototype.ResetHandlers=function(){this.ListenerDictionary={}},e.prototype.Dispose=function(){this.ResetHandlers()},e}();e.LocalMessageBus=b;var B=function(){function e(){this.ListenerDictionary={},window&&window.top?(this.HandleWindowMessage=this.HandleWindowMessage.bind(this),window.top.addEventListener("message",this.HandleWindowMessage)):console.warn("GlobalMessageBus: No Top Window Available")}return e.prototype.OnMessage=function(e,t){var i;null==this.ListenerDictionary[e]?(i=[],this.ListenerDictionary[e]=i):i=this.ListenerDictionary[e],i.findIndex(function(e){return t==e})<0&&i.push(t)},e.prototype.PostMessage=function(e,t,i,n){void 0===t&&(t=null),void 0===i&&(i="*"),window&&window.top?window.top.postMessage({source:"eventbus",message:e,data:t},i,n):console.warn("GlobalMessageBus: No Top Window Available")},e.prototype.RemoveHandler=function(e,t){var i=this.ListenerDictionary[e];if(null!=i){var n=i.findIndex(function(e){return t==e});n>=0&&i.splice(n,1)}},e.prototype.ResetHandlers=function(){this.ListenerDictionary={}},e.prototype.Dispose=function(){this.ResetHandlers(),window&&window.top&&window.top.removeEventListener("message",this.HandleWindowMessage)},e.prototype.HandleWindowMessage=function(e){null!=e&&null!=e.data&&null!=e.data.message&&null!=e.data.source&&"eventbus"==e.data.source&&this.OnDispatchMessage(e.data.message,null!=e.data.data?e.data.data:null)},e.prototype.OnDispatchMessage=function(e,t){void 0===t&&(t=null);var i=this.ListenerDictionary[e];null!=i&&i.forEach(function(e){try{e&&e(t)}catch(e){console.warn(e)}})},e}();e.GlobalMessageBus=B;var C=function(){function t(e,t,i,n,r,o){void 0===i&&(i=1),void 0===n&&(n=!0),void 0===r&&(r=!1),void 0===o&&(o=!0),this.prefabName=null,this.allowGrowth=!0,this.assetContainer=null,this.cloneAnimations=!0,this.makeNewMaterials=!1,this.availableInstances=null,this.prefabName=t,this.allowGrowth=n,this.assetContainer=e,this.cloneAnimations=o,this.makeNewMaterials=r,this.availableInstances=[],this.populatePool(i)}return t.prototype.getAvailableCount=function(){return this.availableInstances.length},t.prototype.populatePool=function(e){if(e>0)for(var t=0;t<e;t++){var i=this.createNewInstance();null!=i&&this.freeInstance(i)}},t.prototype.getInstance=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var i=this.availableInstances.length>0?this.availableInstances.pop():this.appendNewInstance();return null!=i&&(null!=e?i.position.copyFrom(e):i.position.set(0,0,0),null!=t?null!=i.rotationQuaternion?i.rotationQuaternion.copyFrom(t):i.rotationQuaternion=t.clone():null!=i.rotationQuaternion?i.rotationQuaternion.set(0,0,0,1):i.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1),i.name=this.prefabName+".Instance",i.setEnabled(!0)),i},t.prototype.freeInstance=function(e){null!=e&&(e.setEnabled(!1),e.position.set(0,0,0),null!=e.rotationQuaternion?e.rotationQuaternion.set(0,0,0,1):e.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1),null!=e.metadata&&null!=e.metadata.toolkit&&null!=e.metadata.toolkit.components&&e.metadata.toolkit.components.forEach(function(e){if(null!=e)try{e.resetScriptComponent()}catch(e){}}),e.name=this.prefabName+".Unassigned",this.availableInstances.push(e))},t.prototype.appendNewInstance=function(){var e=null;return!0===this.allowGrowth&&(e=this.createNewInstance()),e},t.prototype.createNewInstance=function(t,i,n,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=null;return null!=this.assetContainer&&null!=this.prefabName&&""!==this.prefabName&&(this.assetContainer instanceof BABYLON.AssetContainer?o=e.SceneManager.InstantiatePrefabFromContainer(this.assetContainer,this.prefabName,this.prefabName+".Instance",t,i,n,r,this.cloneAnimations,this.makeNewMaterials):this.assetContainer instanceof BABYLON.Scene&&(o=e.SceneManager.InstantiatePrefabFromScene(this.assetContainer,this.prefabName,this.prefabName+".Instance",t,i,n,r,this.cloneAnimations))),o},t}();e.PrefabObjectPool=C;var A=function(){function e(){this._hit=!1,this._dest=new BABYLON.Vector3(0,0,0),this._origin=new BABYLON.Vector3(0,0,0),this._hitPoint=new BABYLON.Vector3(0,0,0),this._hitNormal=new BABYLON.Vector3(0,0,0),this._hitDistance=0,this._collisionObject=null,this.reset(BABYLON.Vector3.Zero(),BABYLON.Vector3.Zero())}return Object.defineProperty(e.prototype,"hasHit",{get:function(){return this._hit},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hitPoint",{get:function(){return this._hitPoint},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hitNormal",{get:function(){return this._hitNormal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hitDistance",{get:function(){return this._hitDistance},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"collisionObject",{get:function(){return this._collisionObject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rayDestination",{get:function(){return this._dest},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rayOrigin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),e.prototype.reset=function(e,t){this._hit=!1,this._hitPoint.set(0,0,0),this._hitNormal.set(0,0,0),this._hitDistance=0,this._collisionObject=null,this._origin.copyFrom(e),this._dest.copyFrom(t)},e.prototype.update=function(e,t,i,n,r,o,a,s){void 0===s&&(s=null),this._hit=e,this._hitPoint.set(t,i,n),this._hitNormal.set(r,o,a),this._hitDistance=BABYLON.Vector3.Distance(this._origin,this.hitPoint),this._collisionObject=s},e}();e.RaycastHitResult=A;var T=function(){function t(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=.5),this._numPoints=-1,this._pointMesh=null,this._pointSize=.5,this._pointType=0,this._linesName="MeshLines",this._linesMesh=null,this._babylonScene=null,this._pointMesh=null,this._linesMesh=null,this._linesName=e,this._babylonScene=t,this._pointType=i,this._pointSize=n}return Object.defineProperty(t.prototype,"pointMesh",{get:function(){return this._pointMesh},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linesMesh",{get:function(){return this._linesMesh},enumerable:!1,configurable:!0}),t.prototype.dispose=function(e){void 0===e&&(e=!0),this._babylonScene=null,this._linesName=null,null!=this._pointMesh&&(this._pointMesh.dispose(e),this._pointMesh=null),null!=this._linesMesh&&(this._linesMesh.dispose(e),this._linesMesh=null)},t.prototype.hidePoint=function(e){void 0===e&&(e=!0),null!=this._pointMesh&&(this._pointMesh.isVisible=!e)},t.prototype.drawPoint=function(t){null==this._pointMesh&&(1===this._pointType?(this._pointMesh=BABYLON.MeshBuilder.CreateBox(this._linesName+".EndPoint",{size:2*this._pointSize},this._babylonScene),this._pointMesh.renderingGroupId=e.Utilities.DefaultRenderGroup(),this._pointMesh.visibility=.25):(this._pointMesh=BABYLON.MeshBuilder.CreateSphere(this._linesName+".EndPoint",{segments:24,diameter:2*this._pointSize},this._babylonScene),this._pointMesh.renderingGroupId=e.Utilities.DefaultRenderGroup(),this._pointMesh.visibility=.25)),null!=this._pointMesh&&(this._pointMesh.isVisible=!0,this._pointMesh.position.copyFrom(t))},t.prototype.drawLine=function(t,i){void 0===i&&(i=null),null==this._linesMesh?(this._numPoints=t.length,this._linesMesh=BABYLON.MeshBuilder.CreateLines(this._linesName,{points:t,updatable:!0},this._babylonScene),this._linesMesh.renderingGroupId=e.Utilities.DefaultRenderGroup(),null!=i&&(this._linesMesh.color=i),this._linesMesh.refreshBoundingInfo(!1)):t.length===this._numPoints?(this._linesMesh=BABYLON.MeshBuilder.CreateLines(this._linesName,{points:t,instance:this._linesMesh},this._babylonScene),this._linesMesh.renderingGroupId=e.Utilities.DefaultRenderGroup(),null!=i&&(this._linesMesh.color=i),this._linesMesh.refreshBoundingInfo(!1)):BABYLON.Tools.Warn("Dynamic line mesh point count mismatch for "+this._linesName)},t}();e.LinesMeshRenderer=T;var M=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return o(i,t),i.prototype.addContainerTask=function(e,t,i,n){var r=this,o=new BABYLON.ContainerAssetTask(e,t,i,n),a=o;return a._lengthComputable=0,a._loaded=0,a._total=0,a.runTask=function(e,t,i){BABYLON.SceneLoader.LoadAssetContainer(o.rootUrl,o.sceneFilename,e,function(e){o.loadedContainer=e,o.loadedMeshes=e.meshes,o.loadedParticleSystems=e.particleSystems,o.loadedSkeletons=e.skeletons,o.loadedAnimationGroups=e.animationGroups,t()},function(e){a._lengthComputable=e.lengthComputable,a._loaded=e.loaded,a._total=e.total,r.handlePreloadingProgress()},function(e,t,n){i(t,n)})},this._tasks.push(o),o},i.prototype.addMeshTask=function(e,t,i,n){var r=this,o=new BABYLON.MeshAssetTask(e,t,i,n),a=o;return a._lengthComputable=0,a._loaded=0,a._total=0,a.runTask=function(e,t,i){BABYLON.SceneLoader.ImportMesh(o.meshesNames,o.rootUrl,o.sceneFilename,e,function(e,i,n,r){o.loadedMeshes=e,o.loadedParticleSystems=i,o.loadedSkeletons=n,o.loadedAnimationGroups=r,t()},function(e){a._lengthComputable=e.lengthComputable,a._loaded=e.loaded,a._total=e.total,r.handlePreloadingProgress()},function(e,t,n){i(t,n)})},this._tasks.push(o),o},i.prototype.addTextFileTask=function(e,t){var i=this,n=new BABYLON.TextFileAssetTask(e,t),r=n;return r._lengthComputable=0,r._loaded=0,r._total=0,r.runTask=function(e,t,o){e._loadFile(n.url,function(e){n.text=e,t()},function(e){r._lengthComputable=e.lengthComputable,r._loaded=e.loaded,r._total=e.total,i.handlePreloadingProgress()},!1,!1,function(e,t){e&&o(e.status+" "+e.statusText,t)})},this._tasks.push(n),n},i.prototype.addBinaryFileTask=function(e,t){var i=this,n=new BABYLON.BinaryFileAssetTask(e,t),r=n;return r._lengthComputable=0,r._loaded=0,r._total=0,r.runTask=function(e,t,o){e._loadFile(n.url,function(e){n.data=e,t()},function(e){r._lengthComputable=e.lengthComputable,r._loaded=e.loaded,r._total=e.total,i.handlePreloadingProgress()},!0,!0,function(e,t){e&&o(e.status+" "+e.statusText,t)})},this._tasks.push(n),n},i.prototype.addImageTask=function(e,t){var i=this,n=new BABYLON.ImageAssetTask(e,t),r=n;return r._lengthComputable=0,r._loaded=0,r._total=0,r.runTask=function(e,t,o){var a=new HTMLImageElement;BABYLON.Tools.SetCorsBehavior(n.url,a),a.onload=function(){n.image=a,t()},a.onerror=function(e){o("Error loading image",e)},a.onprogress=function(e){r._lengthComputable=e.lengthComputable,r._loaded=e.loaded,r._total=e.total,i.handlePreloadingProgress()},a.src=n.url},this._tasks.push(n),n},i.prototype.handlePreloadingProgress=function(){var t=!0,i=0,n=0;if(null!=this._tasks&&this._tasks.length>0)for(var r=0;r<this._tasks.length;r++){var o=this._tasks[r];null!=o._lengthComputable&&null!=o._loaded&&null!=o._total&&(t=t&&o._lengthComputable,i+=o._loaded,n+=o._total)}if(null!=e.SceneManager.OnAssetManagerProgress){var a={lengthComputable:t,loaded:i,total:t?n:0};e.SceneManager.OnAssetManagerProgress(a)}},i}(BABYLON.AssetsManager);e.PreloadAssetsManager=M;var L=function(){function e(){}return e.HasNetworkEntity=function(e){return null!=e&&null!=e.networkEntity},e.GetNetworkEntityId=function(e){return null==e?null:null!=e.networkEntity?e.networkEntity.id:null},e.GetNetworkEntityType=function(e){return null==e?0:null!=e.networkEntityType?e.networkEntityType:0},e.GetNetworkEntitySessionId=function(e){return null==e?null:null!=e.networkEntity?e.networkEntity.ownerId:null},e.QueryNetworkAttribute=function(e,t){var i=null;return null!=e&&null!=e.networkEntity&&null!=e.networkEntity.attributes&&(i=e.networkEntity.attributes.get(t)),i},e.QueryBufferedAttribute=function(e,t){var i=0;return null!=e&&null!=e.networkEntityAttributeBuffer&&(i=e.networkEntityAttributeBuffer[t.toFixed(0)]),i},e.PostBufferedAttribute=function(e,t,i){null==e.networkEntityBatch&&(e.networkEntityBatch={}),e.networkEntityBatch[t.toFixed(0)]=i},e}();e.EntityController=L}(n||(n={})),BABYLON.Bone.prototype.linkTransformNode=function(e){e._linkedBone=this,this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode--,this._linkedTransformNode=e,this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode++},function(e){var t;(t=e.MaterialAlphaMode||(e.MaterialAlphaMode={})).OPAQUE="OPAQUE",t.MASK="MASK",t.BLEND="BLEND";e.CubeTextureLoader=function(){};var i=function(){function t(t){this.name=e.SceneManager.CVTOOLS_NAME,this.enabled=!1,this._webgpu=!1,this._babylonScene=null,this._metadataParser=null,this._loaderScene=null,this._assetsManager=null,this._materialMap=null,this._lightmapMap=null,this._reflectionMap=null,this._reflectionCache=null,this._assetContainer=!1,this._activeMeshes=!1,this._parseScene=!1,this._leftHanded=!1,this._disposeRoot=!1,this._sceneParsed=!1,this._preWarmTime=1,this._hideLoader=!1,this._rootUrl=null,this._fileName="Unknown",this._licenseName="Unknown",this._licenseType="standard",this._pendingReflectionTextures=null,this._loader=t,this._pendingReflectionTextures=new Map,this.enabled=this._loader.isExtensionUsed(e.SceneManager.CVTOOLS_NAME)||this._loader.isExtensionUsed(e.SceneManager.CVTOOLS_HAND)||this._loader.isExtensionUsed(e.SceneManager.CVTOOLS_MESH),this._parseScene=this._leftHanded=this._disposeRoot=this._sceneParsed=!1,this._rootUrl=null,this._masterList=null,this._detailList=null,this._parserList=null,this._shaderList=null,this._readyList=null,this._preloadList=null,this._materialMap=null,this._lightmapMap=null,this._preWarmTime=1,this._hideLoader=!1,this._loaderScene=null,this._assetsManager=null,this._reflectionMap=null,this._reflectionCache=null,this._animationGroups=null,this._metadataParser=null,this._babylonScene=null,this.order=100}return t.prototype.dispose=function(){delete this._loader},t.CreateExtensionAsync=function(t){return s(this,void 0,void 0,function(){var i;return l(this,function(n){switch(n.label){case 0:return!0!==(i=new e.CVTOOLS_unity_metadata(t)).enabled?[3,2]:[4,i.preloadProjectScriptBundleAsync()];case 1:return n.sent(),[3,2];case 2:return[2,i]}})})},t.prototype.preloadProjectScriptBundleAsync=function(){return s(this,void 0,void 0,function(){var i,n,r,o,a,s,u,h,c,d,m;return l(this,function(l){switch(l.label){case 0:if(!0!==e.SceneManager.AutoLoadScriptBundles)return[2];l.label=1;case 1:if(l.trys.push([1,6,,7]),null==(i=null!=this._loader?this._loader._gltf||this._loader.gltf:null)||null==i.scenes||0===i.scenes.length)return[2];if(n=null!=i.scene?i.scene:0,r=i.scenes[n]||i.scenes[0],null==(o=null!=r&&null!=r.extras&&null!=r.extras.metadata?r.extras.metadata:null))return[2];if(a=null!=o.script?o.script:null,s=null!=o.project?o.project:null,null==a||""===a||null==s||""===s)return[2];if(u=null!=this._loader.rootUrl&&""!==this._loader.rootUrl?this._loader.rootUrl:"/",h=s.toLocaleLowerCase(),c=u+s,!0===t.ScriptBundleCache[h]||null!=globalThis[h])return[2];t.ScriptBundleCache[h]=!0,l.label=2;case 2:return l.trys.push([2,4,,5]),[4,BABYLON.Tools.LoadScriptAsync(c)];case 3:return l.sent(),[3,5];case 4:return d=l.sent(),delete t.ScriptBundleCache[h],BABYLON.Tools.Warn("FAILED to load project script bundle: "+c+"\n"+d),[3,5];case 5:return[3,7];case 6:return m=l.sent(),BABYLON.Tools.Warn("Error preloading project script bundle: \n"+m),[3,7];case 7:return[2]}})})},t.prototype.onLoading=function(){var t=this;e.Utilities.LoadingState=0,this._assetContainer=null!=this._loader._assetContainer,this._metadataParser=null,this._babylonScene=this._loader.babylonScene,this._loaderScene=null,this._assetsManager=null,this._rootUrl=this._loader.rootUrl?this._loader.rootUrl:"/",this._fileName=this._loader._fileName?this._loader._fileName:"Unknown",this._fileName.indexOf("?")>=0&&(this._fileName=this._fileName.split("?")[0]),e.SceneManager.SetRootUrl(this._babylonScene,this._rootUrl),e.SceneManager.SetSceneFile(this._babylonScene,this._fileName),this._loader.parent.onCompleteObservable.addOnce(function(){t.onComplete()}),this._loader.parent.onValidatedObservable.addOnce(function(){t.onValidate()}),this._parseScene=this._loader.isExtensionUsed(e.SceneManager.CVTOOLS_NAME)&&!0===e.SceneManager.IsSceneParsingEnabled(),this._leftHanded=this._loader.isExtensionUsed(e.SceneManager.CVTOOLS_HAND),this._disposeRoot=this._sceneParsed=!1,this._animationGroups=[],this._masterList=[],this._detailList=[],this._parserList=[],this._shaderList=[],this._readyList=[],this._preloadList=[],this._materialMap=new Map,this._lightmapMap=new Map,this._preWarmTime=1,this._hideLoader=!1,this._reflectionMap={},this._reflectionCache={},e.Utilities.ResetLoaderItemsMarkedForDisposal(),this._webgpu=this._babylonScene.getEngine()instanceof BABYLON.WebGPUEngine,this._babylonScene.getEngine().getCaps().supportSRGBBuffers=e.SceneManager.SupportSRGBBuffers,!0===this._leftHanded&&null!=this._loader.rootBabylonMesh&&(this._loader.rootBabylonMesh.rotationQuaternion=BABYLON.Quaternion.Identity(),this._loader.rootBabylonMesh.scaling=BABYLON.Vector3.One()),!0===this._parseScene&&(e.SceneManager.RenderLoopReady=!1,null!=this._loader.rootBabylonMesh&&(this._loader.rootBabylonMesh.name="Root."+this._fileName.replace(".gltf","").replace(".glb","")),this.setupLoader())},t.prototype.onReady=function(){!0===this._parseScene&&!0===this._disposeRoot&&null!=this._loader.rootBabylonMesh&&this._loader.rootBabylonMesh.dispose(!0)},t.prototype.onComplete=function(){this.finishComplete()},t.prototype.getScriptBundleTag=function(){var e=null,t=this._loaderScene,i=null!=t&&null!=t.extras&&null!=t.extras.metadata?t.extras.metadata:null;if(null!=i){null!=this._rootUrl&&this._rootUrl;var n=null!=i.script?i.script:null,r=null!=i.project?i.project:null;null!=n&&""!==n&&null!=r&&""!==r&&(e=r.toLocaleLowerCase())}return e},t.prototype.getScriptBundleUrl=function(){var e=null,t=this._loaderScene,i=null!=t&&null!=t.extras&&null!=t.extras.metadata?t.extras.metadata:null;if(null!=i){var n=null!=this._rootUrl?this._rootUrl:"/",r=null!=i.script?i.script:null,o=null!=i.project?i.project:null;null!=r&&""!==r&&null!=o&&""!==o&&(e=n+o)}return e},t.prototype.finishComplete=function(){var t=this;!0===this._parseScene&&(this.startParsing(),e.SceneManager.RenderLoopReady=!0,this._babylonScene.onAfterRenderObservable.addOnce(function(){e.Utilities.LoadingState=3,t._processPreloadTimeout()}))},t.prototype.onValidate=function(){this._parseScene},t.prototype.onCleanup=function(){this._fileName=null,this._rootUrl=null,this._parseScene=this._leftHanded=this._disposeRoot=this._sceneParsed=!1,this._masterList=null,this._detailList=null,this._parserList=null,this._shaderList=null,this._preWarmTime=1,this._readyList=null,this._preloadList=null,this._hideLoader=!1,this._animationGroups=null,null!=this._materialMap&&(this._materialMap.clear(),this._materialMap=null),null!=this._lightmapMap&&(this._lightmapMap.clear(),this._lightmapMap=null),this._loaderScene=null,this._assetsManager=null,this._reflectionMap=null,this._reflectionCache=null,this._metadataParser=null,this._babylonScene=null,null!=this._pendingReflectionTextures&&(this._pendingReflectionTextures.clear(),this._pendingReflectionTextures=null)},t.prototype.setupLoader=function(){var t=this,i=this._fileName;!0===this._parseScene&&(this._assetsManager=new e.PreloadAssetsManager(this._babylonScene),this._assetsManager.onProgress=function(t,i,n){if(!0===e.SceneManager.AutoUpdateProgress){var r="LOADING "+(i-t)+" OF "+i+(1===i?" ASSET":" ASSETS");e.WindowManager.UpdateLoaderDetails(r,e.Utilities.LoadingState)}else null!=e.Utilities.OnPreloaderProgress&&e.Utilities.OnPreloaderProgress(t,i,n)},this._assetsManager.onFinish=function(n){e.WindowManager.SetTimeout(100,function(){e.Utilities.LoadingState=4,!0===e.SceneManager.AutoUpdateProgress&&e.WindowManager.UpdateLoaderStatus("PLEASE WAIT","PREPARING SCENE VIEW",e.Utilities.LoadingState);var r=t._preWarmTime>0?1e3*t._preWarmTime:100;e.WindowManager.SetTimeout(r,function(){if(null!=e.Utilities.OnPreloaderComplete&&e.Utilities.OnPreloaderComplete(n),t._processShaderMaterials(t._babylonScene,t._shaderList),e.Utilities.RemoveLoaderItemsMarkedForDisposal(),null!=t._readyList&&t._readyList.length>0)for(var r=0;r<t._readyList.length;r++){var o=t._readyList[r];null!=o&&o._ready&&o._ready()}t._babylonScene.onAfterRenderObservable.addOnce(function(){var n=null!=i&&""!==i?i:"Unknown";null!=e.SceneManager.OnSceneReadyObservable&&e.SceneManager.OnSceneReadyObservable.notifyObservers(n),1==t._hideLoader&&e.WindowManager.HideSceneLoader(),t.onCleanup()})})})})},t.prototype.startParsing=function(){!0===this._parseScene&&(e.Utilities.LoadingState=2,this._processLevelOfDetail(this._babylonScene,this._detailList),this._processActiveMeshes(this._babylonScene,this._activeMeshes),this._processUnityMeshes(this._masterList),null!=this._loaderScene&&(this.preProcessSceneProperties(this._loaderScene,this._babylonScene),this.postProcessSceneProperties(this._rootUrl,this._loaderScene,this._babylonScene)),!1===this._assetContainer&&null!=this._parserList&&this._parserList.length>0&&(this._metadataParser=e.Utilities.PostParseSceneComponents(this._babylonScene,this._parserList,this._preloadList,this._readyList)),null!=this._loaderScene&&this.lateProcessSceneProperties(this._rootUrl,this._loaderScene,this._babylonScene))},t.prototype._processActiveMeshes=function(e,t){!0===t&&e.freeActiveMeshes()},t.prototype._processUnityMeshes=function(t){null!=t&&t.length>0&&t.forEach(function(t){e.Utilities.RegisterInstancedMeshBuffers(t)})},t.prototype._processPreloadTimeout=function(){if(null!=this._assetsManager){if(null!=this._preloadList&&this._preloadList.length>0)for(var e=0;e<this._preloadList.length;e++){var t=this._preloadList[e];null!=t&&t.addPreloaderTasks&&t.addPreloaderTasks(this._assetsManager)}this._babylonScene._preloaded=!0,this._assetsManager.load()}},t.prototype.loadSceneAsync=function(t,i){var n;return!0===this._parseScene&&(this._loaderScene=i,e.Utilities.LoadingState=1),this._parseScene&&(null===(n=i.extras)||void 0===n?void 0:n.metadata)?this._loadSceneInternalAsync(t,i):null},t.prototype._loadSceneInternalAsync=function(e,t){return s(this,void 0,void 0,function(){var i,n,r;return l(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),i=t.extras.metadata,(null===(r=null==i?void 0:i.skybox)||void 0===r?void 0:r.environment)&&this.updateSkyboxEnvironment(i.skybox,this._babylonScene),[4,this._loader.loadSceneAsync(e,t)];case 1:return o.sent(),[4,this._loadSceneExAsync(e,t)];case 2:return o.sent(),[3,4];case 3:return n=o.sent(),console.error("CVTOOLS: Error in loadSceneAsync:",n),[3,4];case 4:return[2]}})})},t.prototype._loadSceneExAsync=function(t,i){return s(this,void 0,void 0,function(){var t,i,n,r,o,a,s,u,h,c=this;return l(this,function(l){if(t=this._loader,i=new Array,t._gltf.nodes)for(n=0,r=t._gltf.nodes;n<r.length;n++)(o=r[n])._babylonTransformNode&&this._animationGroups&&e.Utilities.AssignAnimationGroupsToNode(o._babylonTransformNode,this._animationGroups);if(null!=this._reflectionMap&&null!=this._reflectionCache)for(h in a=0,s=function(t){if(a++,u._reflectionMap.hasOwnProperty(t)){var i=t;if(null!=u._assetsManager){var n=u._assetsManager.addBinaryFileTask("Material.ReflectionTextureTask"+a.toFixed(0),i);n.onSuccess=function(t){if(null!=t.data){new Blob([t.data]);var n=c._reflectionMap[i];null!=n&&n.forEach(function(n){if(null!=n&&null!=n.mapkey){var r=c._reflectionCache[n.mapkey];if(null!=r)null!=n.material&&e.Utilities.HasOwnProperty(n.material,"reflectionTexture")&&(n.material.reflectionTexture=r);else{var o=c._babylonScene,a=t.data instanceof ArrayBuffer?new Uint8Array(t.data):t.data,s=".env"===(n.extension||"").toLowerCase()||n.mapkey&&n.mapkey.toLowerCase().endsWith(".env")?".env":".dds",l=new BABYLON.CubeTexture(i,o,{buffer:a,prefiltered:!0,forcedExtension:s,createPolynomials:!0,onLoad:function(){},onError:function(e,t){return console.error(e,t)}});l.name=n.name,l.level=n.reflectionProbePower*e.CVTOOLS_unity_metadata.IBL_PROBE_FACTOR,l.gammaSpace=!1,null!=n.boundingBoxSize&&(l.boundingBoxSize=n.boundingBoxSize),null!=n.boundingBoxPosition&&(l.boundingBoxPosition=n.boundingBoxPosition),c._reflectionCache[n.mapkey]=l,null!=n.material&&e.Utilities.HasOwnProperty(n.material,"reflectionTexture")&&(n.material.reflectionTexture=l)}}})}else console.error("Failed to load reflection texture task: "+i)},n.onError=function(e,t,i){console.error(t,i)}}}},u=this,this._reflectionMap)s(h);return t.logClose(),[2,Promise.all(i).then(function(){})]})})},t.prototype.loadNodeAsync=function(t,i,n){var r,o=this;if(!this._parseScene||!(null===(r=i.extras)||void 0===r?void 0:r.metadata))return null;try{return this._loader.loadNodeAsync(t,i,function(t){try{var r=t,a=i.extras.metadata;null==r.metadata&&(r.metadata={}),r.metadata.toolkit=a,e.Utilities.ValidateTransformGuid(r),e.Utilities.ValidateTransformMetadata(r),e.Utilities.ValidateTransformQuaternion(r),r.layerMask=null!=r.metadata.toolkit.layermask?r.metadata.toolkit.layermask:e.SceneManager.DefaultLayerMask,r.isVisible=null==r.metadata.toolkit.visible||r.metadata.toolkit.visible,r.visibility=null!=r.metadata.toolkit.visibility?r.metadata.toolkit.visibility:1,r.billboardMode=null!=r.metadata.toolkit.billboard?r.metadata.toolkit.billboard:0,!0===o._assetContainer&&(r.metadata.toolkit.prefab=!0),!0===r.metadata.toolkit.prefab?r.setEnabled(!1):(o._parserList.push(r),null!=i.extras.metadata.lods&&null!=i.extras.metadata.distances&&null!=o._detailList&&o._detailList.push(r)),o._masterList.push(r),n(r)}catch(e){console.error("CVTOOLS: Error in node assignment callback:",e),n(t)}})}catch(e){return console.error("CVTOOLS: Error in loadNodeAsync:",e),null}},t.prototype.loadMaterialPropertiesAsync=function(e,t,i){var n=this;return this.enabled?this._loader.loadMaterialPropertiesAsync(e,t,i).then(function(){var r,o=[];try{n._parseCommonConstantProperties(o,e,t,i)}catch(e){BABYLON.Tools.Warn("[CVTOOLS] _parseCommonConstantProperties threw for ".concat(null!==(r=null==t?void 0:t.name)&&void 0!==r?r:"material",": ").concat(e))}if(0!==o.length)return Promise.all(o.map(function(e){return e.catch(function(e){var i;BABYLON.Tools.Warn("[CVTOOLS] Extra material async failed for ".concat(null!==(i=null==t?void 0:t.name)&&void 0!==i?i:"material",": ").concat(e))})})).then(function(){})}):null},t.prototype._getCachedMaterialByIndex=function(e){var t=null;return e>=0&&null!=this._materialMap&&(t=this._materialMap.get(e)||null),t},t.prototype._getCachedLightmapByIndex=function(e){var t=null;return e>=0&&null!=this._lightmapMap&&(t=this._lightmapMap.get(e)||null),t},t.prototype.createMaterial=function(t,i,n){if(!0===this._parseScene&&i.index){var r=i.index;if(r>=0){var o=this._getCachedMaterialByIndex(r);if(null!=o)return o}}if(!0===this._parseScene){var a=null,s=i.name||"No Name";if(null!=i.extras&&null!=i.extras.metadata&&null!=i.extras.metadata.customMaterial){var l=i.extras.metadata,u=l.customMaterial,h=(l.customShader,e.Utilities.InstantiateClass(u));if(null!=h){var c=new h(s,this._loader.babylonScene);null!=c?!0==c instanceof BABYLON.Material?(a=c).fillMode=n:BABYLON.Tools.Warn("Non material instantiated class: "+u):BABYLON.Tools.Warn("Failed to instantiate material class: "+u)}else BABYLON.Tools.Warn("CVTOOLS: Custom material class not found (project bundle missing or class not registered): "+u)}return null==a&&((a=new e.UniversalShaderMaterial(s,this._loader.babylonScene)).fillMode=n),null!=a&&this._parseUniformAndSamplerProperties(t,i,a),a}return null},t.prototype.loadAnimationAsync=function(e,t){if(!0===this._parseScene){this._loader;var i=t;this._babylonScene._blockEntityCollection=!!this._assetContainer;var n=new BABYLON.AnimationGroup(t.name||"animation".concat(i.index),this._babylonScene);n._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,i._babylonAnimationGroup=n,this._animationGroups.push(n);var r=new Array;BABYLON.GLTF2.ArrayItem.Assign(i.channels),BABYLON.GLTF2.ArrayItem.Assign(i.samplers);for(var o=0,a=t.channels;o<a.length;o++){var s=a[o],l=s;r.push(this._loader._loadAnimationChannelAsync("".concat(e,"/channels/").concat(l.index),e,t,s,function(e,t){e.animations=e.animations||[],e.animations.push(t),n.addTargetedAnimation(t,e)}))}return Promise.all(r).then(function(){if(null!=t.extras&&null!=t.extras.metadata){var e={};e.toolkit=t.extras.metadata,n.metadata=e,null!=e.label&&""!==e.label&&(n.name=e.label)}return n.normalize(0),n})}return null},t.prototype._loadMeshPrimitiveAsync=function(e,t,i,n,r,o){var a=this;if(!0===this._parseScene){var s=this._loader;s.logOpen("".concat(e));var l,u=0===s._disableInstancedMesh&&s._parent.createInstances&&null==i.skin&&!n.primitives[0].targets,h=void 0;if(u&&r._instanceData)s._babylonScene._blockEntityCollection=!!s._assetContainer,(l=r._instanceData.babylonSourceMesh.createInstance(t))._parentContainer=s._assetContainer,s._babylonScene._blockEntityCollection=!1,h=r._instanceData.promise;else{var c=new Array;s._babylonScene._blockEntityCollection=!!s._assetContainer;var d=new BABYLON.Mesh(t,s._babylonScene);d._parentContainer=s._assetContainer,s._babylonScene._blockEntityCollection=!1,!0===this._leftHanded?d.sideOrientation=BABYLON.Material.CounterClockWiseSideOrientation:d.sideOrientation=s._babylonScene.useRightHandedSystem?BABYLON.Material.ClockWiseSideOrientation:BABYLON.Material.CounterClockWiseSideOrientation,s._createMorphTargets(e,i,n,r,d),c.push(s._loadVertexDataAsync(e,r,d).then(function(t){return s._loadMorphTargetsAsync(e,r,d,t).then(function(){s._disposed||(s._babylonScene._blockEntityCollection=!!s._assetContainer,t.applyToMesh(d),a._setupBabylonMesh(d,i,n,r),t._parentContainer=s._assetContainer,s._babylonScene._blockEntityCollection=!1)})}));var m=BABYLON.GLTF2.GLTFLoader._GetDrawMode(e,r.mode);if(null!=r.extras&&null!=r.extras.metadata&&null!=r.extras.metadata.multimaterial&&null!=r.extras.metadata.submeshes)this._setupBabylonMultiMaterials(e,c,m,d,n,r);else if(null==r.material){var p=s._defaultBabylonMaterialData[m];if(!p){var f="function"==typeof s._getDefaultImpl?s._getDefaultImpl():void 0;p=void 0!==f?s._createDefaultMaterial("__GLTFLoader._default",m,f):s._createDefaultMaterial("__GLTFLoader._default",m),s._parent.onMaterialLoadedObservable.notifyObservers(p),s._defaultBabylonMaterialData[m]=p}d.material=p}else if(!s.parent.skipMaterials){var g=BABYLON.GLTF2.ArrayItem.Get("".concat(e,"/material"),s._gltf.materials,r.material);c.push(s._loadMaterialAsync("/materials/".concat(g.index),g,d,m,function(e){d.material=e}))}h=Promise.all(c),u&&(r._instanceData={babylonSourceMesh:d,promise:h}),l=d}return BABYLON.GLTF2.GLTFLoader.AddPointerMetadata(l,e),s._parent.onMeshLoadedObservable.notifyObservers(l),o(l),s.logClose(),h.then(function(){return l})}return null},t.prototype._setupBabylonMesh=function(e,t,i,n){if(!0===this._parseScene){if(this._loader,null!=n.extras&&null!=n.extras.metadata&&null!=n.extras.metadata.multimaterial&&null!=n.extras.metadata.submeshes){var r=n.extras.metadata.submeshes;e.subMeshes=[];for(var o=0;o<r.length;o++){var a=r[o];BABYLON.SubMesh.AddToMesh(a.materialIndex,a.verticesStart,a.verticesCount,a.indexStart,a.indexCount,e)}}e.computeWorldMatrix(!0)}},t.prototype._setupBabylonMultiMaterials=function(e,t,i,n,r,o){if(!0===this._parseScene){var a=this._loader,s=o.extras.metadata.multimaterial,l=s.materials,u=[],h=s.id||"MM_"+r.name,c=s.name||"MM_"+r.name,d=new BABYLON.MultiMaterial("["+c+"]",a._babylonScene);d.id=h,l.forEach(function(t){if(null!=t){var i=parseInt(t);if(i>=0){var r=BABYLON.GLTF2.ArrayItem.Get("".concat(e,"/material"),a._gltf.materials,i);u.push(r)}else console.warn("Invalid Submesh Material Index Encountered For: "+n.name)}else console.warn("Null Submesh Material Encountered For: "+n.name)}),t.push(this._parseMultiMaterialAsync("/materials/".concat(c),u,n,i,function(e){d.subMaterials=e,n.material=d}))}},t.prototype._processLevelOfDetail=function(e,t){null!=t&&t.length>0&&t.forEach(function(e){})},t.prototype._processShaderMaterials=function(e,t){null!=t&&t.length>0&&t.forEach(function(e){e.freeze()})},t.prototype.preProcessSceneProperties=function(t,i){var n,r,o;if(!0!==this._assetContainer&&!1===this._sceneParsed&&null!=t.extras&&null!=t.extras.metadata&&null!=t.extras.metadata.properties&&!0===t.extras.metadata.properties){this._sceneParsed=!0,null!=this._rootUrl&&this._rootUrl;var a=t.extras.metadata;if(null==i.metadata&&(i.metadata={}),null==i.metadata.toolkit&&(i.metadata.toolkit={}),i.metadata.toolkit=a,this._disposeRoot=null!=a.disposeroot&&!0===a.disposeroot,this._hideLoader=null!=a.hideloader&&!0===a.hideloader,this._preWarmTime=null!=a.prewarmup?a.prewarmup:0,this._licenseType=null!=a.license?a.license:"standard",this._licenseName=null!=a.licensee?a.licensee:"Unknown",e.SceneManager.EnableUserInput=!0,null!=this._licenseName&&""!==this._licenseName&&"Unknown"!==this._licenseName&&"DefaultCompany"!==this._licenseName&&"Default Company"!==this._licenseName&&BABYLON.Tools.Log(e.Utilities.MakeProper(this._fileName)+" licensed to "+this._licenseName),e.SceneManager.GlobalOptions.ktxtextures=null!=a.ktxtextures&&a.ktxtextures,e.SceneManager.GlobalOptions.ktxlightmaps=null!=a.ktxlightmaps&&a.ktxlightmaps,e.SceneManager.GlobalOptions.intensityFactor=null!=a.intensity?a.intensity:1,e.SceneManager.GlobalOptions.debugModeEnabled=null!=a.debugging&&a.debugging,e.SceneManager.GlobalOptions.showDebugColliders=null!=a.showdebugcolliders&&a.showdebugcolliders,e.SceneManager.GlobalOptions.colliderVisibility=null!=a.collidervisibility?a.collidervisibility:0,e.SceneManager.GlobalOptions.colliderRenderGroup=null!=a.colliderrendergroup?a.colliderrendergroup:0,e.SceneManager.GlobalOptions.defaultRenderGroup=null!=a.defaultrendergroup?a.defaultrendergroup:0,e.SceneManager.GlobalOptions.collisionWireframe=null!=a.collisionwireframe&&a.collisionwireframe,e.SceneManager.GlobalOptions.useTriangleNormals=null!=a.trianglenormals&&a.trianglenormals,e.SceneManager.GlobalOptions.useConvexTriangles=null==a.convextriangles||a.convextriangles,e.SceneManager.GlobalOptions.colliderInstances=null==a.colliderinstances||a.colliderinstances,e.SceneManager.GlobalOptions.reparentColliders=null==a.reparentcolliders||a.reparentcolliders,e.SceneManager.GlobalOptions.enablelegacyaudio=null!=a.enablelegacyaudio&&a.enablelegacyaudio,e.SceneManager.GlobalOptions.globalillumination=null!=a.globalillumination&&a.globalillumination,null!=a.clearcolor&&(i.clearColor=e.Utilities.ParseColor4(a.clearcolor)),null!=a.autoclear&&!0===a.autoclear&&(i.autoClear=!0,i.autoClearDepthAndStencil=!0),null!=a.rendergroups&&(BABYLON.RenderingManager.MAX_RENDERINGGROUPS=a.rendergroups),null!=a.imageprocessing){var s=a.imageprocessing,l=null!=s.contrast?s.contrast:1,u=null!=s.exposure?s.exposure:1;null!=i.imageProcessingConfiguration&&(i.imageProcessingConfiguration.contrast=l,i.imageProcessingConfiguration.exposure=u)}var h=null!=a.ambientlightmap?a.ambientlightmap:0;if(null!=a.ambientcoloring&&(i.ambientColor=e.Utilities.ParseColor3(a.ambientcoloring)),null!=a.ambientlighting&&1===a.ambientlighting){var c=i;if(null==c._AmbientLight)switch(c._AmbientLight=new BABYLON.HemisphericLight("Ambient Lighting",new BABYLON.Vector3(0,1,0),i),c._AmbientLight.falloffType=BABYLON.Light.FALLOFF_STANDARD,h){case 2:c._AmbientLight.lightmapMode=BABYLON.Light.LIGHTMAP_SHADOWSONLY;break;case 1:c._AmbientLight.lightmapMode=BABYLON.Light.LIGHTMAP_SPECULAR;break;default:c._AmbientLight.lightmapMode=BABYLON.Light.LIGHTMAP_DEFAULT}null!=c._AmbientLight&&("skybox"===a.ambientskymode||!1===a.ambientoverride?(c._AmbientLight.name="Ambient Blacklight",c._AmbientLight.diffuse=BABYLON.Color3.Black(),c._AmbientLight.specular=BABYLON.Color3.Black(),c._AmbientLight.groundColor=BABYLON.Color3.Black(),null!=a.ambientlightintensity&&(c._AmbientLight.intensity=a.ambientlightintensity),c._AmbientLight.intensity*=e.SceneManager.AmbientLightIntensity,c._AmbientLight.intensityMode=BABYLON.Light.INTENSITYMODE_ILLUMINANCE):(null!=a.ambientskycolor&&(c._AmbientLight.diffuse=e.Utilities.ParseColor3(a.ambientskycolor,BABYLON.Color3.Gray())),null!=a.ambientspecularcolor&&(c._AmbientLight.specular=e.Utilities.ParseColor3(a.ambientspecularcolor,BABYLON.Color3.Black())),null!=a.ambientgroundcolor&&(c._AmbientLight.groundColor=e.Utilities.ParseColor3(a.ambientgroundcolor,BABYLON.Color3.Gray())),null!=a.ambientlightintensity&&(c._AmbientLight.intensity=a.ambientlightintensity),c._AmbientLight.intensity*=e.SceneManager.AmbientLightIntensity,c._AmbientLight.intensityMode=BABYLON.Light.INTENSITYMODE_ILLUMINANCE))}if(null!=a.fogmode){var d=a.fogmode,m=1,p=BABYLON.Scene.FOGMODE_NONE;switch(d){case 1:p=BABYLON.Scene.FOGMODE_EXP,m=null!==(n=e.SceneManager.FogExpDensityScale)&&void 0!==n?n:1;break;case 2:p=BABYLON.Scene.FOGMODE_EXP2,m=null!==(r=e.SceneManager.FogExp2DensityScale)&&void 0!==r?r:1;break;case 3:p=BABYLON.Scene.FOGMODE_LINEAR,m=null!==(o=e.SceneManager.FogLinearDensityScale)&&void 0!==o?o:1;break;default:p=BABYLON.Scene.FOGMODE_NONE}p!==BABYLON.Scene.FOGMODE_NONE?(i.fogMode=p,i.fogEnabled=!0,null==a.fogdensity||p!==BABYLON.Scene.FOGMODE_EXP&&p!==BABYLON.Scene.FOGMODE_EXP2||(i.fogDensity=Math.max(0,a.fogdensity*m)),p===BABYLON.Scene.FOGMODE_LINEAR&&(null!=a.fogstart&&(i.fogStart=a.fogstart||0),null!=a.fogend&&(i.fogEnd=2*(a.fogend||300))),null!=a.fogcolor&&(i.fogColor=e.Utilities.ParseColor3(a.fogcolor))):i.fogEnabled=!1}var f=new BABYLON.Vector3(0,-9.81,0),g=null!=a.defaultgravity?e.Utilities.ParseVector3(a.defaultgravity,f):f;if(i.gravity=g.clone(),i.collisionsEnabled=!0,null!=a.enablephysics&&!0===a.enablephysics){var y=null==a.ccdenabled||a.ccdenabled,v=null!=a.ccdpenetration?a.ccdpenetration:1e-4,S=null!=a.subtimestep?a.subtimestep:0,_=null!=a.maxworldsweep?a.maxworldsweep:0,b=null==a.deltaworldstep||a.deltaworldstep;e.RigidbodyPhysics.ConfigurePhysicsEngine(i,!b,S,_,y,v,g)}if(null!=a.userinput){var B=a.userinput;e.UserInputOptions.KeyboardSmoothing=B.keyboardSmoothing,e.UserInputOptions.KeyboardMoveSensibility=B.keyboardSensitivity,e.UserInputOptions.KeyboardArrowSensibility=1,e.UserInputOptions.KeyboardMoveDeadZone=B.keyboardDeadZone,e.UserInputOptions.GamepadDeadStickValue=B.padDeadStick,e.UserInputOptions.GamepadLStickXInverted=B.padLStickXInvert,e.UserInputOptions.GamepadLStickYInverted=B.padLStickYInvert,e.UserInputOptions.GamepadRStickXInverted=B.padRStickXInvert,e.UserInputOptions.GamepadRStickYInverted=B.padRStickYInvert,e.UserInputOptions.GamepadLStickSensibility=B.padLStickLevel,e.UserInputOptions.GamepadRStickSensibility=B.padRStickLevel,e.UserInputOptions.SupportedInputDevices=B.supportedDevices,e.UserInputOptions.BabylonAngularSensibility=2e3,e.UserInputOptions.DefaultAngularSensibility=B.mouseSensitivity,e.UserInputOptions.PointerWheelDeadZone=B.wheelDeadZone,e.UserInputOptions.PointerMouseDeadZone=B.mouseDeadZone,e.UserInputOptions.PointerMouseInverted=B.mouseMoveInvert,e.UserInputOptions.UseCanvasElement=B.useCanvasElement,e.UserInputOptions.UseArrowKeyRotation=B.arrowKeyRotation,e.UserInputOptions.EnableBabylonRotation=!1}if(null!=a.enableinput&&!0===a.enableinput){var C={contextMenu:null==a.contextmenu||a.contextmenu,pointerLock:null!=a.pointerlock&&a.pointerlock,preventDefault:null!=a.preventdefault&&a.preventdefault,useCapture:null!=a.usecapture&&a.usecapture};e.InputController.ConfigureUserInput(i.getEngine(),i,C)}null!=a.freezeactivemeshes&&!0===a.freezeactivemeshes&&(this._activeMeshes=!0),null!=a.performancepriority&&(i.performancePriority=a.performancepriority)}},t.prototype.postProcessSceneProperties=function(t,i,n){return s(this,void 0,void 0,function(){var r,o,a,s,u,h,c,d,m,p,f,g,y,v,S,_,b,B,C;return l(this,function(l){if(!0===this._assetContainer)return[2];if(null!=i.extras&&null!=i.extras.metadata&&null!=i.extras.metadata.properties&&!0===i.extras.metadata.properties&&null!=(r=i.extras.metadata).skybox){null!=(o=r.skybox).skyurl&&o.skyurl,a=null!=o.skyres?o.skyres:512,s=null!=o.skyfog&&o.skyfog,u=null!=o.skytags?o.skytags:"Untagged",h=null!=o.skysize?o.skysize:1e3,c=null!=o.rotation?o.rotation:0,d=null!=o.basename&&""!==o.basename?t+o.basename:null,m=null!=o.skyfaces?o.skyfaces:null,p=null==o.sixsided||o.sixsided,f=null!=o.rendergroup?o.rendergroup:0,g=null!=o.extensions&&o.extensions.length>0?o.extensions:null,null==o.polynomial||o.polynomial;try{null!=m&&""!==m&&null!=d&&""!==d&&(y=null,"png"===m||"webp"===m?!0===p?(y=new BABYLON.CubeTexture(d,n,g),d.indexOf("_rgbd")>=0?(y.isRGBD=!0,y.gammaSpace=!0):(y.isRGBD=!1,y.gammaSpace=!0)):(v=d+"."+m,(y=new BABYLON.Texture(v,n,!0,!1)).isRGBD=d.indexOf("_rgbd")>=0,y.gammaSpace=!0):"hdr"===m?(S=d+"."+m,(y=new BABYLON.HDRCubeTexture(S,n,a,!0,!1,!0,!1)).isRGBD=!1,y.gammaSpace=!0):"exr"===m?(_=d+"."+m,(y=new BABYLON.EXRCubeTexture(_,n,a,!0,!1,!0,!1)).isRGBD=!1,y.gammaSpace=!0):((y=new BABYLON.CubeTexture(d,n,g)).isRGBD=!1,y.gammaSpace=!0),y.name=o.basename,y.coordinatesMode=BABYLON.Texture.SKYBOX_MODE,y.rotationY=BABYLON.Tools.ToRadians(c),b="Default Skybox",(B=BABYLON.MeshBuilder.CreateBox(b,{size:h},n)).renderingGroupId=e.Utilities.DefaultRenderGroup(),B.id=b,B.infiniteDistance=!0,B.applyFog=s,B.renderingGroupId=f,null!=u&&""!==u&&BABYLON.Tags.AddTagsTo(B,u),!0===n.useRightHandedSystem&&(B.scaling.x*=-1),(C=new BABYLON.StandardMaterial("Skybox-Material",n)).backFaceCulling=!1,C.disableLighting=!0,C.diffuseColor=new BABYLON.Color3(0,0,0),C.emissiveColor=new BABYLON.Color3(0,0,0),C.specularColor=new BABYLON.Color3(0,0,0),C.ambientColor=new BABYLON.Color3(0,0,0),C.reflectionTexture=y,B.material=C)}catch(e){console.warn(e)}}return[2]})})},t.prototype.updateSkyboxEnvironment=function(t,i){if(null!=t.environment){var n=t.environment,r=null!=n.info&&""!==n.info?n.info:null,o=null!=n.ibl?n.ibl:1,a=null!=n.level?n.level:1,s=null!=n.refl?n.refl:null,l=null!=n.scale?n.scale:1,u=null!=n.mode?n.mode:0;o=Math.max(0,o);var h=null!=s?s:o*a,c=BABYLON.Scalar.Clamp(o,0,10),d=BABYLON.Scalar.Clamp(h,0,1e3),m=Array.isArray(n.sh)&&27===n.sh.length,p="skybox"===n.sky&&!0===m;if(p&&this.generateSphericalHarmonics(i,n.sh,c),null!=r&&""!==r)try{var f=(null!=this._rootUrl?this._rootUrl:"/")+r.rooturl+r.name;if(null!=this._assetsManager){var g=this._assetsManager.addBinaryFileTask("Global.EnvironmentTextureTask",f);g.onSuccess=function(t){if(null!=t.data){var n=t.data instanceof ArrayBuffer?new Uint8Array(t.data):t.data,o=f.toLowerCase().endsWith(".env")?".env":".dds",a=new BABYLON.CubeTexture(f,i,{buffer:n,prefiltered:!0,forcedExtension:o,createPolynomials:1===u,onLoad:function(){},onError:function(e,t){return console.error(e,t)}});if(i.environmentTexture=a,i.environmentTexture.name="assets/"+r.name,i.environmentTexture.level=p?d*l:d,p)if(a.isReady()){var s=e.SceneManager.GetImageBasedLighting(i);null!=s&&(0===u&&(i.environmentTexture.sphericalPolynomial=s),i.markAllMaterialsAsDirty(BABYLON.Material.AllDirtyFlag))}else a.onLoadObservable.addOnce(function(){var t=e.SceneManager.GetImageBasedLighting(i);null!=t&&(0===u&&(i.environmentTexture.sphericalPolynomial=t),i.markAllMaterialsAsDirty(BABYLON.Material.AllDirtyFlag))})}else console.error("❌ Failed to load environment texture task: "+f)},g.onError=function(e,t,i){console.error("❌ Environment texture error:",t,i)}}}catch(e){console.warn("⚠️ Error setting up environment texture:",e)}}},t.prototype.generateSphericalHarmonics=function(e,t,i){try{var n=t.slice(0,9),r=t.slice(9,18),o=t.slice(18,27),a=new BABYLON.SphericalHarmonics;a.l00=new BABYLON.Vector3(n[0],r[0],o[0]),a.l1_1=new BABYLON.Vector3(n[1],r[1],o[1]),a.l10=new BABYLON.Vector3(n[2],r[2],o[2]),a.l11=new BABYLON.Vector3(n[3],r[3],o[3]),a.l2_2=new BABYLON.Vector3(n[4],r[4],o[4]),a.l2_1=new BABYLON.Vector3(n[5],r[5],o[5]),a.l20=new BABYLON.Vector3(n[6],r[6],o[6]),a.l21=new BABYLON.Vector3(n[7],r[7],o[7]),a.l22=new BABYLON.Vector3(n[8],r[8],o[8]),a.preScaled=!0,1!==i&&a.scaleInPlace(i);var s=BABYLON.SphericalPolynomial.FromHarmonics(a);e.globalSphericalPolynomial=s}catch(e){console.error("Failed to apply Unity SH to scene environment:",e)}},t.prototype.lateProcessSceneProperties=function(t,i,n){return s(this,void 0,void 0,function(){var t,r,o,a;return l(this,function(s){switch(s.label){case 0:return!0===this._assetContainer?[2]:null==i.extras||null==i.extras.metadata||null==i.extras.metadata.properties||!0!==i.extras.metadata.properties||null==(t=i.extras.metadata).navigation||null==t.navigation.prebaked||""===t.navigation.prebaked?[3,2]:(r=null!=t.navigation.prebaked&&""!==t.navigation.prebaked?t.navigation.prebaked:null,o=null!=t.navigation.showdebug&&!0===t.navigation.showdebug,a=null,null!=t.navigation.heightmesh&&""!==t.navigation.heightmesh&&null!=(a=n.getMeshByName(t.navigation.heightmesh))&&(a.material.transparencyMode=BABYLON.Material.MATERIAL_ALPHABLEND,a.checkCollisions=!1,a.visibility=o?.3:0,a.isVisible=!0,a.isPickable=!0),[4,e.SceneManager.LoadNavigationMeshDataAsync(n,r,a,o)]);case 1:s.sent(),s.label=2;case 2:return[2]}})})},t.prototype._preloadRawMaterialsAsync=function(e,t,i){var n=this._loader,r=new Array,o=BABYLON.Material.TriangleFillMode;return i.forEach(function(i){var a=BABYLON.GLTF2.ArrayItem.Get("".concat(e,"/material"),t,i);if(null!=a){var s=n.createMaterial(e,a,o);BABYLON.GLTF2.GLTFLoader.AddPointerMetadata(s,e),n._parent.onMaterialLoadedObservable.notifyObservers(s),r.push(n.loadMaterialPropertiesAsync(e,a,s))}}),Promise.all(r).then(function(){})},t.prototype._parseMultiMaterialAsync=function(e,t,i,n,r){var o=this;void 0===r&&(r=function(){});var a=this._loader,s=t;s._data=s._data||{};var l=s._data[n];if(!l){a.logOpen("".concat(e," ").concat(i.name||""));var u=[],h=new Array;t.forEach(function(t){var i=null;if(t.index){var r=t.index;r>=0&&(i=o._getCachedMaterialByIndex(r))}null==i&&(i=a.createMaterial(e,t,n),BABYLON.GLTF2.GLTFLoader.AddPointerMetadata(i,e),a._parent.onMaterialLoadedObservable.notifyObservers(i),h.push(a.loadMaterialPropertiesAsync(e,t,i))),u.push(i)}),l={babylonMaterials:u,babylonMeshes:[],promises:h},s._data[n]=l,a.logClose()}return l.babylonMeshes.push(i),i.onDisposeObservable.addOnce(function(){var e=l.babylonMeshes.indexOf(i);-1!==e&&l.babylonMeshes.splice(e,1)}),r(l.babylonMaterials),Promise.all(l.promises).then(function(){return l.babylonMaterials})},t.prototype._parseCommonConstantProperties=function(i,n,r,o){var a=this,s=null!=r.extras&&null!=r.extras.metadata?r.extras.metadata:null;if(null!=s){var l=o;e.Utilities.HasOwnProperty(l,"alphaMode")&&(l.alphaMode=null!=s&&s.alphaMode?s.alphaMode:BABYLON.Engine.ALPHA_COMBINE),e.Utilities.HasOwnProperty(l,"ambientColor")&&(l.ambientColor=null!=s&&s.ambientColorFactor?BABYLON.Color3.FromArray(s.ambientColorFactor):BABYLON.Color3.Black()),e.Utilities.HasOwnProperty(l,"backFaceCulling")&&(l.backFaceCulling=null==s||null==s.backFaceCulling||s.backFaceCulling);var u=!1,h=!1;if(o instanceof BABYLON.PBRMaterial){switch(u=!(!r.extensions||!r.extensions.KHR_materials_pbrSpecularGlossiness),!r.extensions||r.extensions.KHR_materials_specular,!0!==(h=u)&&(o.useMetallnessFromMetallicTextureBlue=!0,o.useRoughnessFromMetallicTextureGreen=!0,o.useRoughnessFromMetallicTextureAlpha=!1,o.useAmbientOcclusionFromMetallicTextureRed=!1),!0===h&&(o.useMicroSurfaceFromReflectivityMapAlpha=!0),o.directIntensity=null!=s.directIntensity?s.directIntensity:1,o.specularIntensity=null!=s.specularIntensity?s.specularIntensity:1,o.emissiveIntensity=null!=s.emissiveIntensity?s.emissiveIntensity:1,o.environmentIntensity=null!=s.environmentIntensity?s.environmentIntensity:1,o.indexOfRefraction=null!=s.indexOfRefraction?s.indexOfRefraction:1.5,e.Utilities.MarkGamma(o.albedoTexture),e.Utilities.MarkGamma(o.emissiveTexture),!0!==h&&e.Utilities.MarkLinear(o.metallicTexture),e.Utilities.MarkLinear(o.ambientTexture),e.Utilities.MarkLinear(o.opacityTexture),e.Utilities.MarkLinear(o.bumpTexture),!0===h&&e.Utilities.MarkGamma(o.reflectivityTexture),r.alphaMode||e.MaterialAlphaMode.OPAQUE){case e.MaterialAlphaMode.OPAQUE:o.alpha=1,o.transparencyMode=BABYLON.ShaderMaterial.MATERIAL_OPAQUE;break;case e.MaterialAlphaMode.MASK:o.transparencyMode=BABYLON.ShaderMaterial.MATERIAL_ALPHATEST;break;case e.MaterialAlphaMode.BLEND:o.transparencyMode=BABYLON.ShaderMaterial.MATERIAL_ALPHABLEND;break;default:o.alpha=1,o.transparencyMode=BABYLON.ShaderMaterial.MATERIAL_OPAQUE}var c=null!=s.clearCoatIntensity?s.clearCoatIntensity:0;c>0&&(o.clearCoat.isEnabled=!0,o.clearCoat.intensity=c),null!=s.useAlphaFromAlbedoTexture&&(o.useAlphaFromAlbedoTexture=s.useAlphaFromAlbedoTexture),null!=s.parallaxBias&&s.parallaxBias>0&&(o.useParallax=!0,o.parallaxScaleBias=s.parallaxBias)}if(e.Utilities.HasOwnProperty(l,"unlit")&&(l.unlit=null!=s.unlitMaterial&&s.unlitMaterial),e.Utilities.HasOwnProperty(l,"wireframe")&&(l.wireframe=null!=s.useWireframe&&s.useWireframe),e.Utilities.HasOwnProperty(l,"disableLighting")&&(l.disableLighting=null!=s.disableLighting&&s.disableLighting),e.Utilities.HasOwnProperty(l,"maxSimultaneousLights")&&(l.maxSimultaneousLights=null!=s.maxSimultaneousLights?s.maxSimultaneousLights:4),e.Utilities.HasOwnProperty(l,"needDepthPrePass")&&(l.needDepthPrePass=null!=s.depthPrepass&&s.depthPrepass),e.Utilities.HasOwnProperty(l,"lightmapTexture")&&s.lightmapTexture){s.lightmapTexture.nonColorData=!0;var d=!0;e.Utilities.HasOwnProperty(l,"useLightmapAsShadowmap")&&(d=null==s.useLightmapAsShadowmap||s.useLightmapAsShadowmap);var m=null,p=null!=s.lightmapTexture.index?s.lightmapTexture.index:-1;p>=0&&(m=this._getCachedLightmapByIndex(p)),null!=m?(l.lightmapTexture=m,l.useLightmapAsShadowmap=d,e.Utilities.HasOwnProperty(l,"ambientColor")&&(l.ambientColor=BABYLON.Color3.White())):i.push(this._loader.loadTextureInfoAsync(n+"/lightmapTexture",s.lightmapTexture,function(t){t.name="assets/LightmapTexture-".concat(p),t.level=s.lightmapLevel?s.lightmapLevel:1;var i=t;i.onLoadObservable.addOnce(function(){i.isReady()?(i.isRGBD=!0,i.gammaSpace=!1):BABYLON.Tools.Warn("[LM] Failed to register RGBD lightmap (not ready): "+i.name)}),l.lightmapTexture=t,l.useLightmapAsShadowmap=d,p>=0&&null!=a._lightmapMap&&(a._lightmapMap.has(p)||a._lightmapMap.set(p,i)),e.Utilities.HasOwnProperty(l,"ambientColor")&&(l.ambientColor=BABYLON.Color3.White())}))}o instanceof BABYLON.PBRMaterial&&s.detailMapTexture&&(s.detailMapTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(n+"/detailMapTexture",s.detailMapTexture,function(e){e.name="".concat(o.name," (Detail Map)"),e.level=1;var t=e;t.gammaSpace=!1,o.detailMap.texture=t,o.detailMap.bumpLevel=null!=s.detailBumpLevel?s.detailBumpLevel:1,o.detailMap.diffuseBlendLevel=null!=s.detailBlendLevel?s.detailBlendLevel:.75,o.detailMap.roughnessBlendLevel=null!=s.detailRoughLevel?s.detailRoughLevel:.5,null!=BABYLON.Material.MATERIAL_NORMALBLENDMETHOD_RNM&&(o.detailMap.normalBlendMethod=BABYLON.Material.MATERIAL_NORMALBLENDMETHOD_RNM),o.detailMap.isEnabled=!0})));var f=e.SceneManager.GetRenderQuality(),g=f===e.RenderQuality.High||f===e.RenderQuality.Medium;if(!0===g&&e.Utilities.HasOwnProperty(l,"reflectionColor")&&(l.reflectionColor=null!=s&&s.reflectionColorFactor?BABYLON.Color3.FromArray(s.reflectionColorFactor):BABYLON.Color3.White()),!0===g&&e.Utilities.HasOwnProperty(l,"reflectionTexture")&&s.reflectionCubemapInfo){var y=(this._loader._rootUrl+s.reflectionCubemapInfo.rooturl+s.reflectionCubemapInfo.name).toLowerCase(),v=y.lastIndexOf("."),S=v>-1?y.substring(v).toLowerCase():"",_=null!=s.reflectionCubemapInfo.size?s.reflectionCubemapInfo.size:128,b=null!=s.reflectionProbePower?s.reflectionProbePower:1,B=new e.CubeTextureLoader;B.name="assets/"+s.reflectionCubemapInfo.name,B.size=_,B.mapkey=y,B.material=l,B.extension=S,B.prefiltered=!0,B.reflectionProbePower=b,s.reflectionCubemapInfo.boundingBoxSize&&(B.boundingBoxSize=BABYLON.Vector3.FromArray(s.reflectionCubemapInfo.boundingBoxSize),B.name+=" ("+B.boundingBoxSize.x.toString()+" "+B.boundingBoxSize.y.toString()+" "+B.boundingBoxSize.z.toString()+")",B.mapkey+="_"+B.boundingBoxSize.x.toString()+"_"+B.boundingBoxSize.y.toString()+"_"+B.boundingBoxSize.z.toString()),s.reflectionCubemapInfo.boundingBoxPosition&&(B.boundingBoxPosition=BABYLON.Vector3.FromArray(s.reflectionCubemapInfo.boundingBoxPosition),B.name+=" ("+B.boundingBoxPosition.x.toString()+" "+B.boundingBoxPosition.y.toString()+" "+B.boundingBoxPosition.z.toString()+")",B.mapkey+="_"+B.boundingBoxPosition.x.toString()+"_"+B.boundingBoxPosition.y.toString()+"_"+B.boundingBoxPosition.z.toString());var C=this._reflectionMap[y];null==C?(C=[B],this._reflectionMap[y]=C):C.push(B)}if(e.Utilities.HasOwnProperty(l,"terrainInfo")&&(l.terrainInfo=null!=s.terrainInfo?s.terrainInfo:null),e.Utilities.HasOwnProperty(o,"universalMaterial")){var A=o;if(s.customTextures){var T=function(e){var t=s.customTextures[e];null!=t&&(A.checkSampler(e),i.push(M._loader.loadTextureInfoAsync(n+"/"+e,t,function(t){t.name="".concat(o.name,"detailsSampler"===e||"normalsSampler"===e?" (Atlas)":" (Custom)"),A.setTextureValue(e,t)})))},M=this;for(var L in s.customTextures)T(L)}if(s.customVectors)for(var P in s.customVectors)null!=(I=s.customVectors[P])&&A.addVector4Uniform(P,BABYLON.Vector4.FromArray(I),!0);if(s.customColors)for(var w in s.customColors)null!=(N=s.customColors[w])&&A.addVector4Uniform(w,BABYLON.Vector4.FromArray(N),!0);if(s.customFloats)for(var x in s.customFloats)null!=(k=s.customFloats[x])&&A.addFloatUniform(x,k,!0)}else{if(s.customTextures){var O=function(t){var r=s.customTextures[t];null!=r&&e.Utilities.HasOwnProperty(l,t)&&i.push(R._loader.loadTextureInfoAsync(n+"/"+t,r,function(e){e.name="".concat(o.name,"detailsSampler"===t||"normalsSampler"===t?" (Atlas)":" (Custom)"),l[t]=e}))},R=this;for(var L in s.customTextures)O(L)}if(s.customVectors)for(var P in s.customVectors){var I;null!=(I=s.customVectors[P])&&e.Utilities.HasOwnProperty(l,P)&&(l[P]=BABYLON.Vector4.FromArray(I))}if(s.customColors)for(var w in s.customColors){var N;null!=(N=s.customColors[w])&&e.Utilities.HasOwnProperty(l,w)&&(l[w]instanceof BABYLON.Vector4?l[w]=BABYLON.Vector4.FromArray(N):l[w]instanceof BABYLON.Color4?l[w]=BABYLON.Color4.FromArray(N):l[w]=BABYLON.Color3.FromArray(N))}if(s.customFloats)for(var x in s.customFloats){var k;null!=(k=s.customFloats[x])&&e.Utilities.HasOwnProperty(l,x)&&(l[x]instanceof Boolean?l[x]=k>0:l[x]=k)}}if(o instanceof e.CustomShaderMaterial){var F=null==s.enableGlossyReflections||s.enableGlossyReflections,D=null!=s.specularIntensityScale?s.specularIntensityScale:1,E=null!=s.lightmapTexture?t.IBL_TINY_VALUE:1,V=!0===F?t.IBL_SPEC_FACTOR*D:t.IBL_TINY_VALUE;o.splitLighting(E,V),o.initMaterial()}else o instanceof e.StandardShaderMaterial&&o.initMaterial();null!=s.freezeMaterial&&!0===s.freezeMaterial&&null!=this._shaderList&&this._shaderList.push(o)}},t.prototype._parseUniformAndSamplerProperties=function(t,i,n){var r=null!=i.extras&&null!=i.extras.metadata?i.extras.metadata:null;if(null!=r&&e.Utilities.HasOwnProperty(n,"universalMaterial")){var o=n;if(r.customTextures)for(var a in r.customTextures)null!=r.customTextures[a]&&o.checkSampler(a);if(r.customVectors)for(var s in r.customVectors){var l=r.customVectors[s];null!=l&&o.checkUniform(s,"vec4",BABYLON.Vector4.FromArray(l))}if(r.customColors)for(var u in r.customColors){var h=r.customColors[u];null!=h&&o.checkUniform(u,"vec4",BABYLON.Vector4.FromArray(h))}if(r.customFloats)for(var c in r.customFloats){var d=r.customFloats[c];null!=d&&o.checkUniform(c,"float",d)}}},t.IBL_TINY_VALUE=.001,t.IBL_SPEC_FACTOR=1,t.IBL_PROBE_FACTOR=1,t.ScriptBundleCache={},t}();e.CVTOOLS_unity_metadata=i;var n=function(){function t(t){this.name=e.SceneManager.CVTOOLS_MESH,this.enabled=!1,this._loader=t,this.enabled=this._loader.isExtensionUsed(e.SceneManager.CVTOOLS_MESH),this.order=101}return t.prototype.dispose=function(){delete this._loader},t}();e.CVTOOLS_babylon_mesh=n;var r=function(){function t(t){this.name=e.SceneManager.CVTOOLS_HAND,this.enabled=!1,this._loader=t,this.enabled=this._loader.isExtensionUsed(e.SceneManager.CVTOOLS_HAND),this.order=102}return t.prototype.dispose=function(){delete this._loader},t}();e.CVTOOLS_left_handed=r}(n||(n={})),function(e){var t=function(t){function i(i,n){var r=t.call(this,i,n)||this;return r.universalMaterial=!0,r._defines={},r._uniforms=[],r._samplers=[],r._attributes=[],r._textures={},r._vectors4={},r._vectors3={},r._vectors2={},r._floats={},r._bools={},r._ubos=null,r._wgslSamplers=null,r._noMatrixTextures=null,r.shader=null,r.plugin=null,r._unityLightingPlugin=null,r.shader="CustomShaderMaterial",r.addFloatUniform("tkIblDiffuseScale",1),r.addFloatUniform("tkIblSpecularScale",1),r._unityLightingPlugin=new e.UnityStyleLightingPlugin(r,r.shader),r}return o(i,t),i.prototype.getPlugin=function(){return this.plugin},i.prototype.getClassName=function(){return"PBRMaterial"},i.prototype.initMaterial=function(){this.awake&&this.awake()},i.prototype.addAttribute=function(e){-1===this._attributes.indexOf(e)&&this._attributes.push(e)},i.prototype.checkUniform=function(e,t,i){void 0===i&&(i=null),-1===this._uniforms.indexOf(e)&&(this._uniforms.push(e),this._defines[e.toUpperCase()]=!0,this.buildUniformProperty(e,t,i))},i.prototype.checkSampler=function(e,t){void 0===t&&(t=null),-1===this._samplers.indexOf(e)&&(this._samplers.push(e),this._defines[e.toUpperCase()]=!0,this.buildUniformProperty(e,"sampler2D",t),this.checkUniform(e+"Infos","vec2",BABYLON.Vector2.Zero()),this.checkUniform(e+"Matrix","mat4",BABYLON.Matrix.Identity()))},i.prototype.splitLighting=function(e,t){var i,n;this.setFloatValue("tkIblDiffuseScale",e),this.setFloatValue("tkIblSpecularScale",t),this.markAsDirty(BABYLON.Constants.MATERIAL_AllDirtyFlag),null===(i=this.plugin)||void 0===i||i.markAllDefinesAsDirty(),null===(n=this._unityLightingPlugin)||void 0===n||n.markAllDefinesAsDirty()},i.prototype.addTextureUniform=function(e,t){return this.checkSampler(e,t),this._textures[e]=t,this},i.prototype.setTextureValue=function(e,t){return this._textures[e]=t,this},i.prototype.markTextureAsRaw=function(e){this._noMatrixTextures||(this._noMatrixTextures=new Set),this._noMatrixTextures.add(e)},i.prototype.getTextureValue=function(e){return this._textures[e]},i.prototype.addVector4Uniform=function(e,t){return this.checkUniform(e,"vec4",t),this._vectors4[e]=t,this},i.prototype.setVector4Value=function(e,t){return this._vectors4[e]=t,this},i.prototype.getVector4Value=function(e){return this._vectors4[e]},i.prototype.addVector3Uniform=function(e,t){return this.checkUniform(e,"vec3",t),this._vectors3[e]=t,this},i.prototype.setVector3Value=function(e,t){return this._vectors3[e]=t,this},i.prototype.getVector3Value=function(e){return this._vectors3[e]},i.prototype.addVector2Uniform=function(e,t){return this.checkUniform(e,"vec2",t),this._vectors2[e]=t,this},i.prototype.setVector2Value=function(e,t){return this._vectors2[e]=t,this},i.prototype.getVector2Value=function(e){return this._vectors2[e]},i.prototype.addFloatUniform=function(e,t){return this.checkUniform(e,"float",t),this._floats[e]=t,this},i.prototype.setFloatValue=function(e,t){return this._floats[e]=t,this},i.prototype.getFloatValue=function(e){return this._floats[e]},i.prototype.addBoolUniform=function(e,t){return this.checkUniform(e,"bool",t),this._bools[e]=t,this},i.prototype.setBoolValue=function(e,t){return this._bools[e]=t,this},i.prototype.getBoolValue=function(e){return this._bools[e]},i.prototype.getAnimatables=function(){var e=t.prototype.getAnimatables.call(this);for(var i in this._textures){var n=this._textures[i];n&&n.animations&&n.animations.length>0&&e.push(n)}return e},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);for(var i in this._textures){var n=this._textures[i];n&&e.push(n)}return e},i.prototype.hasTexture=function(e){if(t.prototype.hasTexture.call(this,e))return!0;for(var i in this._textures)if(this._textures[i]===e)return!0;return!1},i.prototype.getCustomUniforms=function(e){var t={};return null!=this._ubos&&this._ubos.length>0&&(t.ubo=this._ubos.filter(function(e){return"sampler2D"!==e.type})),!1===e&&(t.fragment=this.getCustomFragmentCode(!1)),t},i.prototype.getCustomSamplers=function(){return this._samplers},i.prototype.getCustomAttributes=function(){return this._attributes},i.prototype.getCustomVertexCode=function(e){return null},i.prototype.getCustomFragmentCode=function(e){var t=this,i=null;return null!=this._ubos&&this._ubos.length>0&&(i="#ifdef "+this.shader.toUpperCase()+"\n",this._ubos.forEach(function(n){if(!0===e)"sampler2D"===n.type&&(null==t._wgslSamplers&&(t._wgslSamplers=new Set),t._wgslSamplers.has(n.name)||(i+="\tvar "+n.name+": texture_2d<f32>;\n",i+="\tvar "+n.name+"Sampler: sampler;\n",t._wgslSamplers.add(n.name)));else{var r=n.name.toUpperCase()+"_DEFINED";"float"===n.type||"bool"===n.type||"int"===n.type?(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform float "+n.name+";\n",i+="\t#endif\n"):"vec2"===n.type?(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform vec2 "+n.name+";\n",i+="\t#endif\n"):"vec3"===n.type?(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform vec3 "+n.name+";\n",i+="\t#endif\n"):"vec4"===n.type?(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform vec4 "+n.name+";\n",i+="\t#endif\n"):"mat4"===n.type?(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform mat4 "+n.name+";\n",i+="\t#endif\n"):"sampler2D"===n.type&&(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform sampler2D "+n.name+";\n",i+="\t#endif\n")}}),i+="#endif\n"),i},i.prototype.prepareCustomDefines=function(e){if(this._wgslSamplers&&this._wgslSamplers.clear(),e[this.shader.toUpperCase()]=!0,null!=this._defines){var t=Object.keys(this._defines);if(null!=t&&t.length>0)for(var i=0,n=t;i<n.length;i++){var r=n[i];e[r]=this._defines[r]}}e.isDirty&&e.rebuild()},i.prototype.updateCustomBindings=function(e){var t,i=this.getScene();this.update&&this.update();var n=null!=e&&"function"==typeof e.getUniformNames,r=n?e.getUniformNames():[],o=function(e){return n&&-1!==r.indexOf(e)};if(i.texturesEnabled)for(t in this._textures){var a=this._textures[t];null!=a&&a.isReady&&a.isReady()&&(null==a.isChecked&&(a.isChecked=!0,("detailsSampler"===t||"normalsSampler"===t||t.indexOf("(Atlas)")>=0)&&a.updateSamplingMode(8)),e.setTexture&&e.setTexture(t,a),this._noMatrixTextures&&this._noMatrixTextures.has(t)||(o(t+"Infos")&&e.updateFloat2?e.updateFloat2(t+"Infos",a.coordinatesIndex,a.level):e.setFloat2?e.setFloat2(t+"Infos",a.coordinatesIndex,a.level):e.setFloat&&e.setFloat(t+"Infos",a.coordinatesIndex),o(t+"Matrix")&&e.updateMatrix?e.updateMatrix(t+"Matrix",a.getTextureMatrix()):e.setMatrix&&e.setMatrix(t+"Matrix",a.getTextureMatrix())))}for(t in this._vectors4){var s=this._vectors4[t];o(t)&&e.updateVector4?e.updateVector4(t,s):e.setVector4?e.setVector4(t,s):e.setFloat4&&e.setFloat4(t,s.x,s.y,s.z,s.w)}for(t in this._vectors3)s=this._vectors3[t],o(t)&&e.updateVector3?e.updateVector3(t,s):e.setVector3?e.setVector3(t,s):e.setFloat3&&e.setFloat3(t,s.x,s.y,s.z);for(t in this._vectors2)s=this._vectors2[t],o(t)&&e.updateFloat2?e.updateFloat2(t,s.x,s.y):e.setFloat2?e.setFloat2(t,s.x,s.y):e.setFloat&&e.setFloat(t,s.x);for(t in this._floats){var l=this._floats[t];o(t)&&e.updateFloat?e.updateFloat(t,l):e.setFloat&&e.setFloat(t,l)}for(t in this._bools)l=this._bools[t]?1:0,o(t)&&e.updateFloat?e.updateFloat(t,l):e.setFloat&&e.setFloat(t,l)},i.prototype.legacyUpdateCustomBindings=function(e){var t,i=this.getScene();if(this.update&&this.update(),i.texturesEnabled)for(t in this._textures){var n=this._textures[t];null!=n&&n.isReady&&n.isReady()&&(null==n.isChecked&&(n.isChecked=!0,("detailsSampler"===t||"normalsSampler"===t||t.indexOf("(Atlas)")>=0)&&n.updateSamplingMode(8)),e.setTexture(t,n),e.updateFloat2(t+"Infos",n.coordinatesIndex,n.level),e.updateMatrix(t+"Matrix",n.getTextureMatrix()))}for(t in this._vectors4)e.updateVector4(t,this._vectors4[t]);for(t in this._vectors3)e.updateVector3(t,this._vectors3[t]);for(t in this._vectors2)e.updateFloat2(t,this._vectors2[t].x,this._vectors2[t].y);for(t in this._floats)e.updateFloat(t,this._floats[t]);for(t in this._bools)e.updateFloat(t,this._bools[t]?1:0);e.update()},i.prototype.buildUniformProperty=function(e,t,i){var n=1;switch(t){case"float":case"bool":case"int":n=1;break;case"vec2":n=2;break;case"vec3":n=3;break;case"vec4":n=4;break;case"mat4":n=16}null==this._ubos&&(this._ubos=[]),this._ubos.push({name:e,size:n,type:t})},i}(BABYLON.PBRMaterial);e.CustomShaderMaterial=t;var i=function(e){function t(t,i,n,r,o,a,s){void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===s&&(s=!1);var l=e.call(this,t,i,n,r,o,a,s)||this;return l._isEnabled=!1,l.vertexDefinitions=null,l.fragmentDefinitions=null,l.setIsEnabled(a),l}return o(t,e),t.prototype.getClassName=function(){return"MaterialPluginBase"},t.prototype.getIsEnabled=function(){return this._isEnabled},t.prototype.setIsEnabled=function(e){this._isEnabled=e,this._material.markAsDirty(BABYLON.Constants.MATERIAL_AllDirtyFlag),this.markAllDefinesAsDirty(),this._enable(this._isEnabled)},t.prototype.getCustomShaderMaterial=function(){return this._material},t}(BABYLON.MaterialPluginBase);e.CustomShaderMaterialPlugin=i;var n=function(e){function t(t,i){return e.call(this,t,i,10,{UNITYSTYLELIGHTINGPLUGIN:!1},!0,!0,!1)||this}return o(t,e),t.prototype.isCompatible=function(e){return e===BABYLON.ShaderLanguage.WGSL||e===BABYLON.ShaderLanguage.GLSL},t.prototype.getClassName=function(){return"UnityStyleLightingPlugin"},t.prototype.getCustomCode=function(e,t){var i=t===BABYLON.ShaderLanguage.WGSL;if("fragment"===e){var n=i?"\n // Unity-Style IBL split scaling (WGSL)\n #if defined(REFLECTION) && defined(UNITYSTYLELIGHTINGPLUGIN) && !defined(UNLIT)\n finalIrradiance = finalIrradiance * uniforms.tkIblDiffuseScale;\n finalRadiance = finalRadiance * uniforms.tkIblSpecularScale;\n finalRadianceScaled = finalRadianceScaled * uniforms.tkIblSpecularScale;\n #endif\n ":"\n // Unity-Style IBL split scaling (GLSL)\n #if defined(REFLECTION) && defined(UNITYSTYLELIGHTINGPLUGIN) && !defined(UNLIT)\n finalIrradiance = finalIrradiance * tkIblDiffuseScale;\n finalRadiance = finalRadiance * tkIblSpecularScale;\n finalRadianceScaled = finalRadianceScaled * tkIblSpecularScale;\n #endif\n ";return{CUSTOM_FRAGMENT_DEFINITIONS:this.fragmentDefinitions,CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION:n}}return null},t.prototype.getUniforms=function(e){var t=e===BABYLON.ShaderLanguage.WGSL;return this.vertexDefinitions=this.getCustomShaderMaterial().getCustomVertexCode(t),this.fragmentDefinitions=!0===t?this.getCustomShaderMaterial().getCustomFragmentCode(t):null,this.getCustomShaderMaterial().getCustomUniforms(t)},t.prototype.prepareDefines=function(e,t,i){this.getIsEnabled()&&(e.UNITYSTYLELIGHTINGPLUGIN=!0,this.getCustomShaderMaterial().prepareCustomDefines(e))},t.prototype.bindForSubMesh=function(e,t,i,n){this.getIsEnabled()&&this.getCustomShaderMaterial().updateCustomBindings(e)},t}(e.CustomShaderMaterialPlugin);e.UnityStyleLightingPlugin=n;var r=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.shader=n.getShaderName(),n}return o(t,e),t.prototype.getShaderName=function(){return"UniversalShaderMaterial"},t}(e.CustomShaderMaterial);e.UniversalShaderMaterial=r,e.SceneManager.RegisterClass("TOOLKIT.CustomShaderMaterial",t),e.SceneManager.RegisterClass("TOOLKIT.UniversalShaderMaterial",r),e.SceneManager.RegisterClass("TOOLKIT.UnityStyleLightingPlugin",n),e.SceneManager.RegisterClass("TOOLKIT.CustomShaderMaterialPlugin",i)}(n||(n={})),function(e){var t=function(){function t(e){this._babylonScene=e,this._physicList=[],this._shadowList=[],this._scriptList=[],this._freezeList=[]}return t.prototype.parseSceneComponents=function(t){e.MetadataParser.DoParseSceneComponents(this._babylonScene,t,this._physicList,this._shadowList,this._scriptList,this._freezeList)},t.prototype.postProcessSceneComponents=function(t,i){e.MetadataParser.DoProcessPendingPhysics(this._babylonScene,this._physicList),e.MetadataParser.DoProcessPendingShadows(this._babylonScene,this._shadowList),e.MetadataParser.DoProcessPendingScripts(this._babylonScene,this._scriptList,t,i),e.MetadataParser.DoProcessPendingFreezes(this._freezeList),this._babylonScene=null,this._physicList=null,this._shadowList=null,this._scriptList=null,this._freezeList=null},t.DoParseSceneComponents=function(t,i,n,r,o,a){if(null!=i&&null!=i.metadata&&null!=i.metadata.toolkit&&null!=i.metadata.toolkit.parsed&&!1===i.metadata.toolkit.parsed){i.onDisposeObservable.addOnce(function(){e.Utilities.DisposeEntity(i)}),i.metadata.toolkit.parsed=!0,i.metadata.toolkit.prefab=!1;var s=i.metadata.toolkit,l=null==i.metadata.toolkit.visible||i.metadata.toolkit.visible,u=null!=i.metadata.toolkit.visibility?i.metadata.toolkit.visibility:1,h=null!=i.metadata.toolkit.billboard?i.metadata.toolkit.billboard:0,c=i instanceof BABYLON.AbstractMesh,d=(null!=i.metadata.toolkit.lightmapped&&i.metadata.toolkit.lightmapped,s.tags);if(null!=d&&""!==d&&(BABYLON.Tags.AddTagsTo(i,d),d.indexOf("NavigationMesh")>=0&&(i.isVisible=!1,i.isPickable=!1,i.useVertexColors=!1)),null!=s.physics&&null!=n&&n.push(i),null!=s.renderer)if(!0===c)i.isPickable=!0,i.useVertexColors=!1,i.isVisible=l,i.visibility=u,i.billboardMode=h,i.cullingStrategy=BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD,null!=s.renderer.cullingstrategy&&s.renderer.cullingstrategy!==BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD&&(i.cullingStrategy=s.renderer.cullingstrategy),null!=s.renderer.castshadows&&!0===s.renderer.castshadows&&null!=r&&r.push(i),null!=s.renderer.receiveshadows&&!0===s.renderer.receiveshadows&&(i.receiveShadows=!0),null!=s.renderer.checkcollisions&&!0===s.renderer.checkcollisions&&(i.checkCollisions=!0),null!=s.renderer.istriggervolume&&!0===s.renderer.istriggervolume&&(i.collisionResponse=!1),null!=s.renderer.usevertexcolors&&(i.useVertexColors=s.renderer.usevertexcolors),null!=s.renderer.setmeshpickable&&(i.isPickable=s.renderer.setmeshpickable),null!=s.renderer.showboundingbox&&(i.showBoundingBox=s.renderer.showboundingbox),null!=s.renderer.defaultellipsoid&&(i.ellipsoid=e.Utilities.ParseVector3(s.renderer.defaultellipsoid)),null!=s.renderer.ellipsoidoffset&&(i.ellipsoidOffset=e.Utilities.ParseVector3(s.renderer.ellipsoidoffset)),null!=s.renderer.rendergroupid&&(i.renderingGroupId=s.renderer.rendergroupid),null!=s.renderer.freezeworldmatrix&&!0===s.renderer.freezeworldmatrix&&null!=a&&a.push(i),null!=s.renderer.snapshotrendering&&s.renderer.snapshotrendering>0&&(e.Utilities.PrepareSkeletonForRendering(i.skeleton),i.alwaysSelectAsActiveMesh=!0);else{var m=e.SceneManager.GetSkinnedMesh(i);if(null!=m)m.isPickable=!0,m.useVertexColors=!1,m.isVisible=l,m.visibility=u,m.billboardMode=h,m.cullingStrategy=BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD,m.alwaysSelectAsActiveMesh=!0,null!=s.renderer.cullingstrategy&&s.renderer.cullingstrategy!==BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD&&(m.cullingStrategy=s.renderer.cullingstrategy),null!=s.renderer.castshadows&&!0===s.renderer.castshadows&&null!=r&&r.push(m),null!=s.renderer.receiveshadows&&!0===s.renderer.receiveshadows&&(m.receiveShadows=!0),null!=s.renderer.checkcollisions&&!0===s.renderer.checkcollisions&&(m.checkCollisions=!0),null!=s.renderer.istriggervolume&&!0===s.renderer.istriggervolume&&(m.collisionResponse=!1),null!=s.renderer.usevertexcolors&&(m.useVertexColors=s.renderer.usevertexcolors),null!=s.renderer.setmeshpickable&&(m.isPickable=s.renderer.setmeshpickable),null!=s.renderer.showboundingbox&&(m.showBoundingBox=s.renderer.showboundingbox),null!=s.renderer.defaultellipsoid&&(m.ellipsoid=e.Utilities.ParseVector3(s.renderer.defaultellipsoid)),null!=s.renderer.ellipsoidoffset&&(m.ellipsoidOffset=e.Utilities.ParseVector3(s.renderer.ellipsoidoffset)),null!=s.renderer.rendergroupid&&(m.renderingGroupId=s.renderer.rendergroupid),null!=s.renderer.freezeworldmatrix&&!0===s.renderer.freezeworldmatrix&&null!=a&&a.push(m),null!=s.renderer.snapshotrendering&&s.renderer.snapshotrendering>0&&e.Utilities.PrepareSkeletonForRendering(m.skeleton);else{var p=e.SceneManager.GetPrimitiveMeshes(i);null!=p&&p.length>0&&p.forEach(function(t){var i=e.SceneManager.GetSkinnedMesh(t);null!=i?(i.isPickable=!0,i.useVertexColors=!1,i.isVisible=l,i.visibility=u,i.billboardMode=h,i.cullingStrategy=BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD,i.alwaysSelectAsActiveMesh=!0,null!=s.renderer.cullingstrategy&&s.renderer.cullingstrategy!==BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD&&(i.cullingStrategy=s.renderer.cullingstrategy),null!=s.renderer.castshadows&&!0===s.renderer.castshadows&&null!=r&&r.push(i),null!=s.renderer.receiveshadows&&!0===s.renderer.receiveshadows&&(i.receiveShadows=!0),null!=s.renderer.checkcollisions&&!0===s.renderer.checkcollisions&&(i.checkCollisions=!0),null!=s.renderer.istriggervolume&&!0===s.renderer.istriggervolume&&(i.collisionResponse=!1),null!=s.renderer.usevertexcolors&&(i.useVertexColors=s.renderer.usevertexcolors),null!=s.renderer.setmeshpickable&&(i.isPickable=s.renderer.setmeshpickable),null!=s.renderer.showboundingbox&&(i.showBoundingBox=s.renderer.showboundingbox),null!=s.renderer.defaultellipsoid&&(i.ellipsoid=e.Utilities.ParseVector3(s.renderer.defaultellipsoid)),null!=s.renderer.ellipsoidoffset&&(i.ellipsoidOffset=e.Utilities.ParseVector3(s.renderer.ellipsoidoffset)),null!=s.renderer.rendergroupid&&(i.renderingGroupId=s.renderer.rendergroupid),null!=s.renderer.freezeworldmatrix&&!0===s.renderer.freezeworldmatrix&&null!=a&&a.push(i),null!=s.renderer.snapshotrendering&&s.renderer.snapshotrendering>0&&e.Utilities.PrepareSkeletonForRendering(i.skeleton)):(t.isPickable=!0,t.useVertexColors=!1,t.isVisible=l,t.visibility=u,t.billboardMode=h,t.cullingStrategy=BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD,null!=s.renderer.cullingstrategy&&s.renderer.cullingstrategy!==BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD&&(t.cullingStrategy=s.renderer.cullingstrategy),null!=s.renderer.castshadows&&!0===s.renderer.castshadows&&null!=r&&r.push(t),null!=s.renderer.receiveshadows&&!0===s.renderer.receiveshadows&&(t.receiveShadows=!0),null!=s.renderer.checkcollisions&&!0===s.renderer.checkcollisions&&(t.checkCollisions=!0),null!=s.renderer.istriggervolume&&!0===s.renderer.istriggervolume&&(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&&!0===s.renderer.freezeworldmatrix&&null!=a&&a.push(t),null!=s.renderer.snapshotrendering&&s.renderer.snapshotrendering>0&&(e.Utilities.PrepareSkeletonForRendering(t.skeleton),t.alwaysSelectAsActiveMesh=!0))})}}if(null!=s.components){var f=s.components;null!=f&&f.length>0&&f.forEach(function(n){if(null!=n)switch(n.alias){case"camera":e.MetadataParser.SetupCameraComponent(t,i,n);break;case"light":e.MetadataParser.SetupLightComponent(t,i,n);break;case"script":null!=o&&o.push({mesh:i,comp:n})}})}}},t.DoProcessPendingScripts=function(t,i,n,r){null!=i&&i.length>0&&(i.sort(function(e,t){return e.comp.order<t.comp.order?-1:e.comp.order>t.comp.order?1:0}),i.forEach(function(i){if(null!=i.comp.klass&&""!==i.comp.klass){var o=i.comp.klass.substring(0);if(!0===e.SceneManager.AutoStripNamespacePrefix&&!1===e.SceneManager.UniversalModuleDefinition&&(0===o.indexOf("BABYLON.")||0===o.indexOf("TOOLKIT.")||0===o.indexOf("PROJECT."))){var a=o.lastIndexOf(".");-1!==a&&(i.comp.klass=o.substring(a+1))}if("TOOLKIT.ScriptComponent"!==o){var s=i.comp.klass.substring(0);null==i.comp.properties&&(i.comp.properties={}),i.comp.properties._scriptComponentAlias=o,i.comp.properties._registerComponentAlias=!1;var l=e.Utilities.InstantiateClass(s);if(null==l&&(l=e.Utilities.InstantiateClass(o)),null!=l){var u=new l(i.mesh,t,i.comp.properties);null!=u?(i.comp.instance=u,null!=r&&r.push(i.comp.instance),i.comp.instance.addPreloaderTasks&&null!=n&&n.push(i.comp.instance),e.SceneManager.AttachScriptComponent(i.comp.instance,o,!1)):BABYLON.Tools.Warn("Failed to instantiate script class: "+o)}else BABYLON.Tools.Warn("Failed to locate script class: "+o)}}}))},t.DoProcessPendingShadows=function(e,t){null!=t&&t.length>0&&null!=e.lights&&e.lights.length>0&&e.lights.forEach(function(e){var i=e.getShadowGenerator();null!=i&&null!=e.metadata&&null!=e.metadata.toolkit&&!0===e.metadata.toolkit.autorender&&t.forEach(function(t){!0==(!(null!=e.includedOnlyMeshes&&e.includedOnlyMeshes.length>0)||e.includedOnlyMeshes.indexOf(t)>=0)&&i.addShadowCaster(t,!1)})})},t.DoProcessPendingPhysics=function(t,i){if(null!=i&&i.length>0){var n=t.isPhysicsEnabled(),r=!0===n?t.getPhysicsEngine():null;!0==(!0===n&&null!=r)?i.forEach(function(i){e.RigidbodyPhysics.SetupPhysicsComponent(t,i)}):BABYLON.Tools.Warn("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,i,n){i.checkCollisions=!1;var r=0,o=i.name+".Rig",a=null!=n.culling?n.culling:-1,s=null!=n.camerabase?n.camerabase:0,l=(null!=n.clearflags&&n.clearflags,null!=n.renderlist?n.renderlist:null),u=null!=n.maincamera&&n.maincamera,h=4===s?new BABYLON.FreeCamera(o,BABYLON.Vector3.Zero(),t):new BABYLON.UniversalCamera(o,BABYLON.Vector3.Zero(),t);switch(h.layerMask=~e.SceneManager.HiddenLayerMask,h.checkCollisions=!1,h.rotationQuaternion=BABYLON.Quaternion.FromEulerAngles(0,0,0),h.parent=i,!0===u&&(t.activeCamera=h),null!=n.type?n.type:0){case 0:h.mode=BABYLON.Camera.PERSPECTIVE_CAMERA,null!=n.perspectiveyfov&&(h.fov=n.perspectiveyfov),null!=n.perspectiveznear&&(h.minZ=n.perspectiveznear),null!=n.perspectivezfar&&(h.maxZ=n.perspectivezfar);break;case 1:h.mode=BABYLON.Camera.ORTHOGRAPHIC_CAMERA,null!=n.orthoxmag&&(h.orthoLeft=-n.orthoxmag,h.orthoRight=n.orthoxmag),null!=n.orthoymag&&(h.orthoBottom=-n.orthoymag,h.orthoTop=n.orthoymag),null!=n.orthoznear&&(h.minZ=n.orthoznear),null!=n.orthozfar&&(h.maxZ=n.orthozfar)}if(-1===a);else if(0===a);else{var c=l;if(null!=c&&c.length>0){var d=function(){var i=c[r],n=e.SceneManager.GetMeshByID(t,i);if(null!=n){var o=n.name+".Detail",a=n.getChildren(function(e){return e.name===o},!0);null!=a&&a.length}};for(r=0;r<c.length;r++)d()}}i.cameraRig=h},t.SetupLightComponent=function(t,i,n){i.checkCollisions=!1;var r,o=i.name+".Rig",a=0,s=BABYLON.Light.INTENSITYMODE_AUTOMATIC,l=1,u=null!=n.culling?n.culling:-1,h=(null!=n.clearflags&&n.clearflags,null!=n.renderlist?n.renderlist:null),c=null!=n.type?n.type:0,d=e.SceneManager.GetRenderQuality(),m=null!=n.exponentdecayspeed?n.exponentdecayspeed:1,p=!1;switch(c){case 0:var f=BABYLON.Vector3.Forward(),g=null!=n.orthoscale?n.orthoscale:.1,y=null!=n.ortholeft?n.ortholeft:Number.MAX_VALUE,v=null!=n.orthoright?n.orthoright:Number.MAX_VALUE,S=null!=n.orthotop?n.orthotop:Number.MAX_VALUE,_=null!=n.orthobottom?n.orthobottom:Number.MAX_VALUE,b=null!=n.calczbounds&&n.calczbounds,B=null!=n.updateextends&&n.updateextends,C=null!=n.shadowfrustumsize?n.shadowfrustumsize:0,A=new BABYLON.DirectionalLight(o,f,t);A.shadowFrustumSize=C,A.shadowOrthoScale=g,A.autoCalcShadowZBounds=b,A.autoUpdateExtends=B,A.orthoLeft=y,A.orthoRight=v,A.orthoTop=S,A.orthoBottom=_,(r=A).falloffType=BABYLON.Light.FALLOFF_STANDARD,p=d===e.RenderQuality.High||d===e.RenderQuality.Medium,s=BABYLON.Light.INTENSITYMODE_ILLUMINANCE,l=e.SceneManager.DirectionalLightIntensity;break;case 1:var T=r=new BABYLON.PointLight(o,BABYLON.Vector3.Zero(),t);(r=T).falloffType=BABYLON.Light.FALLOFF_STANDARD,p=d===e.RenderQuality.High||d===e.RenderQuality.Medium,s=BABYLON.Light.INTENSITYMODE_LUMINOUSPOWER,l=e.SceneManager.PointLightIntensity;break;case 2:f=BABYLON.Vector3.Forward();var M=null!=n.spotangle?n.spotangle:Math.PI/4,L=new BABYLON.SpotLight(o,BABYLON.Vector3.Zero(),f,0,m,t);L.angle=.966*BABYLON.Tools.ToRadians(M),L.innerAngle=.8*L.angle,(r=L).falloffType=BABYLON.Light.FALLOFF_GLTF,p=d===e.RenderQuality.High||d===e.RenderQuality.Medium,s=BABYLON.Light.INTENSITYMODE_LUMINOUSPOWER,l=e.SceneManager.SpotLightIntensity}if(null!=r){var P=null!=n.range?n.range:Number.MAX_VALUE,w=null!=n.color?e.Utilities.ParseColor3(n.color,BABYLON.Color3.White()):BABYLON.Color3.White(),x=null!=n.specular?e.Utilities.ParseColor3(n.specular,BABYLON.Color3.White()):BABYLON.Color3.White(),O=null!=n.lightmapmode?n.lightmapmode:0;switch(null!=n.lightmaptype&&n.lightmaptype,r.parent=i,r.range=P,r.diffuse=w,r.specular=x,r.intensity=(null!=n.intensity?n.intensity:1)*l,O){case 2:r.lightmapMode=BABYLON.Light.LIGHTMAP_SHADOWSONLY;break;case 1:r.lightmapMode=BABYLON.Light.LIGHTMAP_SPECULAR;break;default:r.lightmapMode=BABYLON.Light.LIGHTMAP_DEFAULT}r.intensityMode=s,r.shadowEnabled=!1;var R=null==n.autorender||n.autorender,I=null!=n.softshadows&&n.softshadows,N=null!=n.numcascades?n.numcascades:0,k=null!=n.cascadelambda?n.cascadelambda:1,F=null!=n.setdepthclamp&&n.setdepthclamp,D=null!=n.blendpertecntage?n.blendpertecntage:1e-8,E=null!=n.boundsrefreshrate?n.boundsrefreshrate:1,V=null!=n.lightcontactratio?n.lightcontactratio:.1,Y=null!=n.stabilizecascades&&n.stabilizecascades,U=null!=n.penumbradarkness?n.penumbradarkness:1,W=null!=n.softshadowsfilter?n.softshadowsfilter:99,G=null!=n.freezeshadows&&n.freezeshadows,H=null!=n.calcdepths&&n.calcdepths,z=null!=n.depthscaling?n.depthscaling:50,K=null!=n.blurscaling?n.blurscaling:2,X=null==n.kernelblur||n.kernelblur,Q=null!=n.blurkernelsize?n.blurkernelsize:1,j=null!=n.blurboxoffset?n.blurboxoffset:1,Z=null!=n.shadowmapsize?n.shadowmapsize:1024,J=null!=n.generateshadows&&n.generateshadows,q=null!=n.shadowbiasfactor?n.shadowbiasfactor:.01,$=null!=n.normalbiasfactor?n.normalbiasfactor:.01,ee=null!=n.shadowmapbias?n.shadowmapbias:.05,te=null!=n.normalmapbias?n.normalmapbias:.4,ie=null!=n.shadowstrength?n.shadowstrength:1,ne=null!=n.shadowdistance?n.shadowdistance:150,re=null!=n.shadownearplane?n.shadownearplane:.2,oe=null!=n.shadowfilterquality?n.shadowfilterquality:"Medium",ae=null!=n.transparencyshadow&&n.transparencyshadow,se=null!=n.softtransparency&&n.softtransparency,le=null==n.forcebackfacesonly||n.forcebackfacesonly,ue=null!=n.frustumedgefalloff?n.frustumedgefalloff:0,he=null!=n.usefullfloatfirst&&n.usefullfloatfirst;if(!0===p&&!0===J){var ce=r,de=e.SceneManager.GetEngine(t),me=de instanceof BABYLON.Engine?de.webGLVersion:0,pe=de instanceof BABYLON.WebGPUEngine?1:0,fe=0===c&&N>=2&&(me>=2||pe>=1),ge=!0===fe?new BABYLON.CascadedShadowGenerator(Z,r,he):new BABYLON.ShadowGenerator(Z,ce,he);if(ge.bias=ee*q,ge.normalBias=te*$,ge.depthScale=z,ge.useKernelBlur=X,ge.blurKernel=Q,ge.blurScale=K,ge.blurBoxOffset=j,ge.frustumEdgeFalloff=ue,ge.forceBackFacesOnly=le,ge.transparencyShadow=ae,ge.enableSoftTransparentShadow=se,ge.contactHardeningLightSizeUVRatio=V,!0===I)if(me<=1&&pe<=0)ge.usePoissonSampling=!0;else if(!0===fe)ge.usePercentageCloserFiltering=!0;else switch(W){case 0:default:ge.usePoissonSampling=!0;break;case 1:ge.useExponentialShadowMap=!0;break;case 2:ge.useBlurExponentialShadowMap=!0;break;case 3:ge.useCloseExponentialShadowMap=!0;break;case 4:ge.useBlurCloseExponentialShadowMap=!0;break;case 5:ge.useContactHardeningShadow=!0;break;case 99:ge.usePercentageCloserFiltering=!0}switch(oe){case"High":ge.filteringQuality=BABYLON.ShadowGenerator.QUALITY_HIGH;break;case"Medium":ge.filteringQuality=BABYLON.ShadowGenerator.QUALITY_MEDIUM;break;case"Low":ge.filteringQuality=BABYLON.ShadowGenerator.QUALITY_LOW}if(!0===fe){var ye=ge;ye.lambda=k,ye.depthClamp=F,ye.shadowMaxZ=ne,ye.numCascades=N,ye.penumbraDarkness=U,ye.autoCalcDepthBounds=H,ye.stabilizeCascades=Y,ye.cascadeBlendPercentage=D,ye.autoCalcDepthBoundsRefreshRate=E,ye.freezeShadowCastersBoundingInfo=G,ye.setDarkness(1-BABYLON.Scalar.Clamp(ie)),ce.shadowEnabled=!0,ye.splitFrustum()}else ge.setDarkness(1-BABYLON.Scalar.Clamp(ie)),ce.shadowEnabled=!0,ce.shadowMinZ=re,ce.shadowMaxZ=ne;null==r.metadata&&(r.metadata={}),null==r.metadata.toolkit&&(r.metadata.toolkit={}),r.metadata.toolkit.autorender=R}var ve=i.name+".Holder";if(-1===u)r.includedOnlyMeshes=[];else if(0===u)r.includedOnlyMeshes=[new BABYLON.Mesh(ve,t)];else{r.includedOnlyMeshes=[new BABYLON.Mesh(ve,t)];var Se=h;if(null!=Se&&Se.length>0){var _e=function(){var i=Se[a],n=e.SceneManager.GetMeshByID(t,i);if(null!=n){var o=n.name+".Detail",s=n.getChildren(function(e){return e.name===o},!0);null!=s&&s.length>0?r.includedOnlyMeshes.push(s[0]):r.includedOnlyMeshes.push(n)}};for(a=0;a<Se.length;a++)_e()}}i.lightRig=r}},t}();e.MetadataParser=t}(n||(n={})),function(e){var t=function(){function e(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=i;var n=(0|e)>>>0,r=function(){return(n=16807*n%2147483647)/2147483647};for(i=255;i>0;i--){var o=Math.floor(r()*(i+1)),a=t[i];t[i]=t[o],t[o]=a}for(this.perm=new Array(512),i=0;i<512;i++)this.perm[i]=t[255&i]}return e.prototype.fade=function(e){return e*e*e*(e*(6*e-15)+10)},e.prototype.lerp=function(e,t,i){return e+i*(t-e)},e.prototype.grad=function(e,t,i){var n=7&e,r=n<4?t:i,o=n<4?i:t;return(1&n?-r:r)+(2&n?-o:o)},e.prototype.noise=function(e,t){var i=255&Math.floor(e),n=255&Math.floor(t),r=e-Math.floor(e),o=t-Math.floor(t),a=this.fade(r),s=this.fade(o),l=this.perm[i]+n,u=this.perm[i+1]+n;return this.lerp(this.lerp(this.grad(this.perm[l],r,o),this.grad(this.perm[u],r-1,o),a),this.lerp(this.grad(this.perm[l+1],r,o-1),this.grad(this.perm[u+1],r-1,o-1),a),s)},e}();e.Perlin2D=t;var i=function(){function e(){}return e.fastFloor=function(e){return 0|Math.floor(e)},e.createNoise2D=function(t){void 0===t&&(t=Math.random);var i=e.buildPermutationTable(t),n=new Float64Array(i).map(function(t){return e.grad2[t%12*2]}),r=new Float64Array(i).map(function(t){return e.grad2[t%12*2+1]});return function(t,o){var a,s,l=0,u=0,h=0,c=(t+o)*e.F2,d=e.fastFloor(t+c),m=e.fastFloor(o+c),p=(d+m)*e.G2,f=t-(d-p),g=o-(m-p);f>g?(a=1,s=0):(a=0,s=1);var y=f-a+e.G2,v=g-s+e.G2,S=f-1+2*e.G2,_=g-1+2*e.G2,b=255&d,B=255&m,C=.5-f*f-g*g;if(C>=0){var A=b+i[B];l=(C*=C)*C*(n[A]*f+r[A]*g)}var T=.5-y*y-v*v;if(T>=0){var M=b+a+i[B+s];u=(T*=T)*T*(n[M]*y+r[M]*v)}var L=.5-S*S-_*_;if(L>=0){var P=b+1+i[B+1];h=(L*=L)*L*(n[P]*S+r[P]*_)}return 70*(l+u+h)}},e.createNoise3D=function(t){void 0===t&&(t=Math.random);var i=e.buildPermutationTable(t),n=new Float64Array(i).map(function(t){return e.grad3[t%12*3]}),r=new Float64Array(i).map(function(t){return e.grad3[t%12*3+1]}),o=new Float64Array(i).map(function(t){return e.grad3[t%12*3+2]});return function(t,a,s){var l,u,h,c,d,m,p,f,g,y,v=(t+a+s)*e.F3,S=e.fastFloor(t+v),_=e.fastFloor(a+v),b=e.fastFloor(s+v),B=(S+_+b)*e.G3,C=t-(S-B),A=a-(_-B),T=s-(b-B);C>=A?A>=T?(d=1,m=0,p=0,f=1,g=1,y=0):C>=T?(d=1,m=0,p=0,f=1,g=0,y=1):(d=0,m=0,p=1,f=1,g=0,y=1):A<T?(d=0,m=0,p=1,f=0,g=1,y=1):C<T?(d=0,m=1,p=0,f=0,g=1,y=1):(d=0,m=1,p=0,f=1,g=1,y=0);var M=C-d+e.G3,L=A-m+e.G3,P=T-p+e.G3,w=C-f+2*e.G3,x=A-g+2*e.G3,O=T-y+2*e.G3,R=C-1+3*e.G3,I=A-1+3*e.G3,N=T-1+3*e.G3,k=255&S,F=255&_,D=255&b,E=.6-C*C-A*A-T*T;if(E<0)l=0;else{var V=k+i[F+i[D]];l=(E*=E)*E*(n[V]*C+r[V]*A+o[V]*T)}var Y=.6-M*M-L*L-P*P;if(Y<0)u=0;else{var U=k+d+i[F+m+i[D+p]];u=(Y*=Y)*Y*(n[U]*M+r[U]*L+o[U]*P)}var W=.6-w*w-x*x-O*O;if(W<0)h=0;else{var G=k+f+i[F+g+i[D+y]];h=(W*=W)*W*(n[G]*w+r[G]*x+o[G]*O)}var H=.6-R*R-I*I-N*N;if(H<0)c=0;else{var z=k+1+i[F+1+i[D+1]];c=(H*=H)*H*(n[z]*R+r[z]*I+o[z]*N)}return 32*(l+u+h+c)}},e.createNoise4D=function(t){void 0===t&&(t=Math.random);var i=e.buildPermutationTable(t),n=new Float64Array(i).map(function(t){return e.grad4[t%32*4]}),r=new Float64Array(i).map(function(t){return e.grad4[t%32*4+1]}),o=new Float64Array(i).map(function(t){return e.grad4[t%32*4+2]}),a=new Float64Array(i).map(function(t){return e.grad4[t%32*4+3]});return function(t,s,l,u){var h,c,d,m,p,f=(t+s+l+u)*e.F4,g=e.fastFloor(t+f),y=e.fastFloor(s+f),v=e.fastFloor(l+f),S=e.fastFloor(u+f),_=(g+y+v+S)*e.G4,b=t-(g-_),B=s-(y-_),C=l-(v-_),A=u-(S-_),T=0,M=0,L=0,P=0;b>B?T++:M++,b>C?T++:L++,b>A?T++:P++,B>C?M++:L++,B>A?M++:P++,C>A?L++:P++;var w=T>=3?1:0,x=M>=3?1:0,O=L>=3?1:0,R=P>=3?1:0,I=T>=2?1:0,N=M>=2?1:0,k=L>=2?1:0,F=P>=2?1:0,D=T>=1?1:0,E=M>=1?1:0,V=L>=1?1:0,Y=P>=1?1:0,U=b-w+e.G4,W=B-x+e.G4,G=C-O+e.G4,H=A-R+e.G4,z=b-I+2*e.G4,K=B-N+2*e.G4,X=C-k+2*e.G4,Q=A-F+2*e.G4,j=b-D+3*e.G4,Z=B-E+3*e.G4,J=C-V+3*e.G4,q=A-Y+3*e.G4,$=b-1+4*e.G4,ee=B-1+4*e.G4,te=C-1+4*e.G4,ie=A-1+4*e.G4,ne=255&g,re=255&y,oe=255&v,ae=255&S,se=.6-b*b-B*B-C*C-A*A;if(se<0)h=0;else{var le=ne+i[re+i[oe+i[ae]]];h=(se*=se)*se*(n[le]*b+r[le]*B+o[le]*C+a[le]*A)}var ue=.6-U*U-W*W-G*G-H*H;if(ue<0)c=0;else{var he=ne+w+i[re+x+i[oe+O+i[ae+R]]];c=(ue*=ue)*ue*(n[he]*U+r[he]*W+o[he]*G+a[he]*H)}var ce=.6-z*z-K*K-X*X-Q*Q;if(ce<0)d=0;else{var de=ne+I+i[re+N+i[oe+k+i[ae+F]]];d=(ce*=ce)*ce*(n[de]*z+r[de]*K+o[de]*X+a[de]*Q)}var me=.6-j*j-Z*Z-J*J-q*q;if(me<0)m=0;else{var pe=ne+D+i[re+E+i[oe+V+i[ae+Y]]];m=(me*=me)*me*(n[pe]*j+r[pe]*Z+o[pe]*J+a[pe]*q)}var fe=.6-$*$-ee*ee-te*te-ie*ie;if(fe<0)p=0;else{var ge=ne+1+i[re+1+i[oe+1+i[ae+1]]];p=(fe*=fe)*fe*(n[ge]*$+r[ge]*ee+o[ge]*te+a[ge]*ie)}return 27*(h+c+d+m+p)}},e.buildPermutationTable=function(e){for(var t=new Uint8Array(512),i=0;i<256;i++)t[i]=i;for(i=0;i<255;i++){var n=i+~~(e()*(256-i)),r=t[i];t[i]=t[n],t[n]=r}for(i=256;i<512;i++)t[i]=t[i-256];return t},e.F2=.5*(Math.sqrt(3)-1),e.G2=(3-Math.sqrt(3))/6,e.F3=1/3,e.G3=1/6,e.F4=(Math.sqrt(5)-1)/4,e.G4=(5-Math.sqrt(5))/20,e.grad2=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),e.grad3=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),e.grad4=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]),e}();e.SimplexNoise=i}(n||(n={})),function(e){var t=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.universalMaterial=!0,n._defines={},n._uniforms=[],n._samplers=[],n._attributes=[],n._textures={},n._vectors4={},n._vectors3={},n._vectors2={},n._floats={},n._bools={},n._ubos=null,n._wgslSamplers=null,n.shader=null,n.plugin=null,n.shader="StandardShaderMaterial",n.specularColor=new BABYLON.Color3(0,0,0),n}return o(t,e),t.prototype.getClassName=function(){return"StandardMaterial"},t.prototype.initMaterial=function(){this.awake&&this.awake()},t.prototype.addAttribute=function(e){-1===this._attributes.indexOf(e)&&this._attributes.push(e)},t.prototype.checkUniform=function(e,t,i){void 0===i&&(i=null),-1===this._uniforms.indexOf(e)&&(this._uniforms.push(e),this._defines[e.toUpperCase()]=!0,this.buildUniformProperty(e,t,i))},t.prototype.checkSampler=function(e,t){void 0===t&&(t=null),-1===this._samplers.indexOf(e)&&(this._samplers.push(e),this._defines[e.toUpperCase()]=!0,this.buildUniformProperty(e,"sampler2D",t),this.checkUniform(e+"Infos","vec2",BABYLON.Vector2.Zero()),this.checkUniform(e+"Matrix","mat4",BABYLON.Matrix.Identity()))},t.prototype.addTextureUniform=function(e,t){return this.checkSampler(e,t),this._textures[e]=t,this},t.prototype.setTextureValue=function(e,t){return this._textures[e]=t,this},t.prototype.getTextureValue=function(e){return this._textures[e]},t.prototype.addVector4Uniform=function(e,t){return this.checkUniform(e,"vec4",t),this._vectors4[e]=t,this},t.prototype.setVector4Value=function(e,t){return this._vectors4[e]=t,this},t.prototype.getVector4Value=function(e){return this._vectors4[e]},t.prototype.addVector3Uniform=function(e,t){return this.checkUniform(e,"vec3",t),this._vectors3[e]=t,this},t.prototype.setVector3Value=function(e,t){return this._vectors3[e]=t,this},t.prototype.getVector3Value=function(e){return this._vectors3[e]},t.prototype.addVector2Uniform=function(e,t){return this.checkUniform(e,"vec2",t),this._vectors2[e]=t,this},t.prototype.setVector2Value=function(e,t){return this._vectors2[e]=t,this},t.prototype.getVector2Value=function(e){return this._vectors2[e]},t.prototype.addFloatUniform=function(e,t){return this.checkUniform(e,"float",t),this._floats[e]=t,this},t.prototype.setFloatValue=function(e,t){return this._floats[e]=t,this},t.prototype.getFloatValue=function(e){return this._floats[e]},t.prototype.addBoolUniform=function(e,t){return this.checkUniform(e,"bool",t),this._bools[e]=t,this},t.prototype.setBoolValue=function(e,t){return this._bools[e]=t,this},t.prototype.getBoolValue=function(e){return this._bools[e]},t.prototype.getAnimatables=function(){var t=e.prototype.getAnimatables.call(this);for(var i in this._textures){var n=this._textures[i];n&&n.animations&&n.animations.length>0&&t.push(n)}return t},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);for(var i in this._textures){var n=this._textures[i];n&&t.push(n)}return t},t.prototype.hasTexture=function(t){if(e.prototype.hasTexture.call(this,t))return!0;for(var i in this._textures)if(this._textures[i]===t)return!0;return!1},t.prototype.getCustomUniforms=function(e){var t={};return null!=this._ubos&&this._ubos.length>0&&(t.ubo=this._ubos.filter(function(e){return"sampler2D"!==e.type})),!1===e&&(t.fragment=this.getCustomFragmentCode(!1)),t},t.prototype.getCustomSamplers=function(){return this._samplers},t.prototype.getCustomAttributes=function(){return this._attributes},t.prototype.getCustomVertexCode=function(e){return null},t.prototype.getCustomFragmentCode=function(e){var t=this,i=null;return null!=this._ubos&&this._ubos.length>0&&(i="#ifdef "+this.shader.toUpperCase()+"\n",this._ubos.forEach(function(n){if(!0===e)"sampler2D"===n.type&&(null==t._wgslSamplers&&(t._wgslSamplers=new Set),t._wgslSamplers.has(n.name)||(i+="\tvar "+n.name+": texture_2d<f32>;\n",i+="\tvar "+n.name+"Sampler: sampler;\n",t._wgslSamplers.add(n.name)));else{var r=n.name.toUpperCase()+"_DEFINED";"float"===n.type||"bool"===n.type||"int"===n.type?(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform float "+n.name+";\n",i+="\t#endif\n"):"vec2"===n.type?(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform vec2 "+n.name+";\n",i+="\t#endif\n"):"vec3"===n.type?(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform vec3 "+n.name+";\n",i+="\t#endif\n"):"vec4"===n.type?(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform vec4 "+n.name+";\n",i+="\t#endif\n"):"mat4"===n.type?(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform mat4 "+n.name+";\n",i+="\t#endif\n"):"sampler2D"===n.type&&(i+="\t#ifndef "+r+"\n",i+="\t#define "+r+"\n",i+="\tuniform sampler2D "+n.name+";\n",i+="\t#endif\n")}}),i+="#endif\n"),i},t.prototype.prepareCustomDefines=function(e){if(this._wgslSamplers&&this._wgslSamplers.clear(),e[this.shader.toUpperCase()]=!0,null!=this._defines){var t=Object.keys(this._defines);if(null!=t&&t.length>0)for(var i=0,n=t;i<n.length;i++){var r=n[i];e[r]=this._defines[r]}}e.isDirty&&e.rebuild()},t.prototype.updateCustomBindings=function(e){var t,i=this.getScene();this.update&&this.update();var n=null!=e&&"function"==typeof e.getUniformNames,r=n?e.getUniformNames():[],o=function(e){return n&&-1!==r.indexOf(e)};if(i.texturesEnabled)for(t in this._textures){var a=this._textures[t];null!=a&&a.isReady&&a.isReady()&&(null==a.isChecked&&(a.isChecked=!0,("detailsSampler"===t||"normalsSampler"===t||t.indexOf("(Atlas)")>=0)&&a.updateSamplingMode(8)),e.setTexture&&e.setTexture(t,a),o(t+"Infos")&&e.updateFloat2?e.updateFloat2(t+"Infos",a.coordinatesIndex,a.level):e.setFloat2?e.setFloat2(t+"Infos",a.coordinatesIndex,a.level):e.setFloat&&e.setFloat(t+"Infos",a.coordinatesIndex),o(t+"Matrix")&&e.updateMatrix?e.updateMatrix(t+"Matrix",a.getTextureMatrix()):e.setMatrix&&e.setMatrix(t+"Matrix",a.getTextureMatrix()))}for(t in this._vectors4){var s=this._vectors4[t];o(t)&&e.updateVector4?e.updateVector4(t,s):e.setVector4?e.setVector4(t,s):e.setFloat4&&e.setFloat4(t,s.x,s.y,s.z,s.w)}for(t in this._vectors3)s=this._vectors3[t],o(t)&&e.updateVector3?e.updateVector3(t,s):e.setVector3?e.setVector3(t,s):e.setFloat3&&e.setFloat3(t,s.x,s.y,s.z);for(t in this._vectors2)s=this._vectors2[t],o(t)&&e.updateFloat2?e.updateFloat2(t,s.x,s.y):e.setFloat2?e.setFloat2(t,s.x,s.y):e.setFloat&&e.setFloat(t,s.x);for(t in this._floats){var l=this._floats[t];o(t)&&e.updateFloat?e.updateFloat(t,l):e.setFloat&&e.setFloat(t,l)}for(t in this._bools)l=this._bools[t]?1:0,o(t)&&e.updateFloat?e.updateFloat(t,l):e.setFloat&&e.setFloat(t,l);n&&e.update&&e.update()},t.prototype.legacyUpdateCustomBindings=function(e){var t,i=this.getScene();if(this.update&&this.update(),i.texturesEnabled)for(t in this._textures){var n=this._textures[t];null!=n&&n.isReady&&n.isReady()&&(null==n.isChecked&&(n.isChecked=!0,("detailsSampler"===t||"normalsSampler"===t||t.indexOf("(Atlas)")>=0)&&n.updateSamplingMode(8)),e.setTexture(t,n),e.updateFloat2(t+"Infos",n.coordinatesIndex,n.level),e.updateMatrix(t+"Matrix",n.getTextureMatrix()))}for(t in this._vectors4)e.updateVector4(t,this._vectors4[t]);for(t in this._vectors3)e.updateVector3(t,this._vectors3[t]);for(t in this._vectors2)e.updateFloat2(t,this._vectors2[t].x,this._vectors2[t].y);for(t in this._floats)e.updateFloat(t,this._floats[t]);for(t in this._bools)e.updateFloat(t,this._bools[t]?1:0);e.update()},t.prototype.buildUniformProperty=function(e,t,i){var n=1;switch(t){case"float":case"bool":case"int":n=1;break;case"vec2":n=2;break;case"vec3":n=3;break;case"vec4":n=4;break;case"mat4":n=16}null==this._ubos&&(this._ubos=[]),this._ubos.push({name:e,size:n,type:t})},t}(BABYLON.StandardMaterial);e.StandardShaderMaterial=t;var i=function(e){function t(t,i,n,r,o,a,s){void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===s&&(s=!1);var l=e.call(this,t,i,n,r,o,a,s)||this;return l._isEnabled=!1,l.vertexDefinitions=null,l.fragmentDefinitions=null,l.setIsEnabled(a),l}return o(t,e),t.prototype.getClassName=function(){return"StandardMaterialPlugin"},t.prototype.getIsEnabled=function(){return this._isEnabled},t.prototype.setIsEnabled=function(e){this._isEnabled=e,this._material.markAsDirty(BABYLON.Constants.MATERIAL_AllDirtyFlag),this.markAllDefinesAsDirty(),this._enable(this._isEnabled)},t.prototype.getCustomShaderMaterial=function(){return this._material},t}(BABYLON.MaterialPluginBase);e.StandardShaderMaterialPlugin=i,e.SceneManager.RegisterClass("TOOLKIT.StandardShaderMaterial",t),e.SceneManager.RegisterClass("TOOLKIT.StandardShaderMaterialPlugin",i)}(n||(n={})),function(e){var t=function(){function t(){}return t.ZeroPad=function(e,t){var i=t-e.toString().length+1;return Array(+(i>0&&i)).join("0")+e},t.ShiftArray=function(e,t){return t?e.unshift(e.pop()):e.push(e.shift()),e},t.GetLayerMask=function(e){return 1<<e},t.IsLayerMasked=function(e,t){return!!(e&1<<t)},t.GetHavokPlugin=function(){return globalThis.HKP},t.GetLoadingState=function(){return e.Utilities.LoadingState},t.GetRandomRange=function(e,t,i,n){void 0===i&&(i=null),void 0===n&&(n=null);var r=BABYLON.Scalar.RandomRange(e,t);if(null!=i){var o=null!=n?n:100;if(r===i)for(var a=0;a<o&&(r=BABYLON.Scalar.RandomRange(e,t))===i;a++);}return r},t.GetRandomFloat=function(t,i,n,r){return void 0===n&&(n=null),void 0===r&&(r=null),parseFloat(e.Utilities.GetRandomRange(t,i,n,r).toFixed(2))},t.GetRandomInteger=function(t,i,n,r){return void 0===n&&(n=null),void 0===r&&(r=null),parseInt(e.Utilities.GetRandomRange(t,i,n,r).toFixed(0))},t.Approximately=function(t,i){return Math.abs(i-t)<Math.max(e.System.Epsilon*Math.max(Math.abs(t),Math.abs(i)),8*e.System.SingleEpsilon)},t.GetVertexDataFromMesh=function(e){var t=e.computeWorldMatrix(!0),i=BABYLON.VertexData.ExtractFromMesh(e,!0,!0);return i.transform(t),i},t.CalculateDestinationPoint=function(t,i,n){var r=new BABYLON.Vector3(0,0,0);return e.Utilities.CalculateDestinationPointToRef(t,i,n,r),r},t.CalculateDestinationPointToRef=function(t,i,n,r){null==e.Utilities.TempDirectionBuffer&&(e.Utilities.TempDirectionBuffer=new BABYLON.Vector3(0,0,0)),e.Utilities.TempDirectionBuffer.set(0,0,0),i.scaleToRef(n,e.Utilities.TempDirectionBuffer),t.addToRef(e.Utilities.TempDirectionBuffer,r)},t.UpdateAbstractMeshMaterial=function(e,t,i){if(null!=e)if(!1==e instanceof BABYLON.InstancedMesh){var n=e.material;if(n instanceof BABYLON.MultiMaterial){var r=n.clone(n.name+".Clone");r.subMaterials[i]=t,e.material=r}else e.material=t}else console.warn("Instanced mesh not supported as a node material on mesh: "+e.name);else console.warn("Null source mesh for mesh: "+e.name)},t.HermiteVector3=function(t,i,n,r,o){var a=new BABYLON.Vector3(0,0,0);return e.Utilities.HermiteVector3ToRef(t,i,n,r,o,a),a},t.HermiteVector3ToRef=function(e,t,i,n,r,o){var a=r*r,s=r*a,l=2*s-3*a+1,u=-2*s+3*a,h=s-2*a+r,c=s-a,d=e._x*l+i._x*u+t._x*h+n._x*c,m=e._y*l+i._y*u+t._y*h+n._y*c,p=e._z*l+i._z*u+t._z*h+n._z*c;o.set(d,m,p)},t.ExpSmoothing=function(e,t){return t<=0?1:1-Math.exp(-e/t)},t.LerpLog=function(e,t,i){var n=Math.min(Math.max(i,0),1);return e+(t-e)*Math.sin(n*Math.PI*.5)},t.LerpExp=function(e,t,i){var n=Math.min(Math.max(i,0),1);return e+(t-e)*(1-Math.cos(n*Math.PI*.5))},t.LerpUnclamped=function(e,t,i){return e+(t-e)*i},t.LerpUnclampedColor3=function(t,i,n){var r=new BABYLON.Color3(0,0,0);return e.Utilities.LerpUnclampedColor3ToRef(t,i,n,r),r},t.LerpUnclampedColor3ToRef=function(e,t,i,n){n.set(e.r+(t.r-e.r)*i,e.g+(t.g-e.g)*i,e.b+(t.b-e.b)*i)},t.LerpUnclampedColor4=function(t,i,n){var r=new BABYLON.Color4(0,0,0,1);return e.Utilities.LerpUnclampedColor4ToRef(t,i,n,r),r},t.LerpUnclampedColor4ToRef=function(e,t,i,n){n.set(e.r+(t.r-e.r)*i,e.g+(t.g-e.g)*i,e.b+(t.b-e.b)*i,e.a+(t.a-e.a)*i)},t.LerpUnclampedVector2=function(t,i,n){var r=new BABYLON.Vector2(0,0);return e.Utilities.LerpUnclampedVector2ToRef(t,i,n,r),r},t.LerpUnclampedVector2ToRef=function(e,t,i,n){n.set(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},t.LerpUnclampedVector3=function(t,i,n){var r=new BABYLON.Vector3(0,0,0);return e.Utilities.LerpUnclampedVector3ToRef(t,i,n,r),r},t.LerpUnclampedVector3ToRef=function(e,t,i,n){n.set(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i,e.z+(t.z-e.z)*i)},t.LerpUnclampedVector4=function(t,i,n){var r=new BABYLON.Vector4(0,0,0,0);return e.Utilities.LerpUnclampedVector4ToRef(t,i,n,r),r},t.LerpUnclampedVector4ToRef=function(e,t,i,n){n.set(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i,e.z+(t.z-e.z)*i,e.w+(t.w-e.w)*i)},t.IsEqualUsingDot=function(t){return t>1-e.System.Epsilon},t.QuaternionAngle=function(t,i){var n=Math.min(Math.abs(BABYLON.Quaternion.Dot(t,i)),1);return e.Utilities.IsEqualUsingDot(n)?0:2*Math.acos(n)*e.System.Rad2Deg},t.QuaternionLengthSquared=function(e){return e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w},t.QuaternionRotateTowards=function(t,i,n){var r=new BABYLON.Quaternion(0,0,0,1);return e.Utilities.QuaternionRotateTowardsToRef(t,i,n,r),r},t.QuaternionRotateTowardsToRef=function(t,i,n,r){var o=e.Utilities.QuaternionAngle(t,i);0==o?r.copyFrom(i):e.Utilities.QuaternionSlerpUnclampedToRef(t,i,Math.min(1,n/o),r)},t.QuaternionSlerpUnclamped=function(t,i,n){var r=new BABYLON.Quaternion(0,0,0,1);return e.Utilities.QuaternionSlerpUnclampedToRef(t,i,n,r),r},t.QuaternionSlerpUnclampedToRef=function(e,t,i,n){},t.MoveTowards=function(e,t,i){var n=t-e;return Math.abs(n)<=i?t:e+Math.sign(n)*i},t.MoveTowardsVector2=function(t,i,n){var r=new BABYLON.Vector2(0,0);return e.Utilities.MoveTowardsVector2ToRef(t,i,n,r),r},t.MoveTowardsVector2ToRef=function(e,t,i,n){var r=t.x-e.x,o=t.y-e.y,a=r*r+o*o;if(0==a||i>=0&&a<=i*i)n.set(t.x,t.y);else{var s=Math.sqrt(a);n.set(e.x+r/s*i,e.y+o/s*i)}},t.MoveTowardsVector3=function(t,i,n){var r=new BABYLON.Vector3(0,0,0);return e.Utilities.MoveTowardsVector3ToRef(t,i,n,r),r},t.MoveTowardsVector3ToRef=function(e,t,i,n){var r=t.x-e.x,o=t.y-e.y,a=t.z-e.z,s=r*r+o*o+a*a;if(0==s||i>=0&&s<=i*i)n.set(t.x,t.y,t.z);else{var l=Math.sqrt(s);n.set(e.x+r/l*i,e.y+o/l*i,e.z+a/l*i)}},t.MoveTowardsVector4=function(t,i,n){var r=new BABYLON.Vector4(0,0,0,0);return e.Utilities.MoveTowardsVector4ToRef(t,i,n,r),r},t.MoveTowardsVector4ToRef=function(e,t,i,n){var r=t.x-e.x,o=t.y-e.y,a=t.z-e.z,s=t.w-e.w,l=r*r+o*o+a*a+s*s;if(0==l||i>=0&&l<=i*i)n.set(t.x,t.y,t.z,t.w);else{var u=Math.sqrt(l);n.set(e.x+r/u*i,e.y+o/u*i,e.z+a/u*i,e.w+s/u*i)}},t.ClampMagnitudeVector2=function(t,i){var n=new BABYLON.Vector2(0,0);return e.Utilities.ClampMagnitudeVector2ToRef(t,i,n),n},t.ClampMagnitudeVector2ToRef=function(e,t,i){var n=e.lengthSquared();if(n>t*t){var r=Math.sqrt(n),o=e.x/r,a=e.y/r;i.set(o*t,a*t)}},t.ClampMagnitudeVector3=function(t,i){var n=new BABYLON.Vector3(0,0,0);return e.Utilities.ClampMagnitudeVector3ToRef(t,i,n),n},t.ClampMagnitudeVector3ToRef=function(e,t,i){var n=e.lengthSquared();if(n>t*t){var r=Math.sqrt(n),o=e.x/r,a=e.y/r,s=e.z/r;i.set(o*t,a*t,s*t)}},t.GetAngle=function(t,i){return e.Utilities.GetAngleRadians(t,i)*e.System.Rad2Deg},t.GetAngleRadians=function(e,t){return Math.acos(BABYLON.Vector3.Dot(e,t))},t.ClampAngle=function(e,t,i){var n=e;do{n<-360&&(n+=360),n>360&&(n-=360)}while(n<-360||n>360);return BABYLON.Scalar.Clamp(n,t,i)},t.ClampAngle180=function(e,t,i){return e>180&&(e-=360),(e=BABYLON.Scalar.Clamp(e,t,i))<0&&(e+=360),e},t.ClampAngle360=function(e,t,i){return(e<90||e>270)&&(e>180&&(e-=360),i>180&&(i-=360),t>180&&(t-=360)),(e=BABYLON.Scalar.Clamp(e,t,i))<0&&(e+=360),e},t.SmoothDamp=function(e,t,i,n,r,o){if(!o)return 0;var a=e-t,s=Math.max(1e-4,i),l=2/s,u=l*r,h=1/(1+u+.48*u*u+.235*u*u*u),c=t,d=n*s,m=e-(a=BABYLON.Scalar.Clamp(a,-d,d)),p=(o.x+l*a)*r;o.x=(o.x-l*p)*h;var f=m+(a+p)*h;return c-e>0==f>c&&(f=c,o.x=(f-c)/r),f},t.SmoothDampAngle=function(t,i,n,r,o,a){var s=t+BABYLON.Scalar.DeltaAngle(t,i);return e.Utilities.SmoothDamp(t,s,n,r,o,a)},t.SmoothDampVector2=function(t,i,n,r,o,a){var s=new BABYLON.Vector2(0,0);return e.Utilities.SmoothDampVector2ToRef(t,i,n,r,o,a,s),s},t.SmoothDampVector2ToRef=function(e,t,i,n,r,o,a){var s=2/(i=Math.max(1e-4,i)),l=s*r,u=1/(1+l+.48*l*l+.235*l*l*l),h=e.x-t.x,c=e.y-t.y,d=t.clone(),m=n*i,p=h*h+c*c;if(p>m*m){var f=Math.sqrt(p);h=h/f*m,c=c/f*m}t.x=e.x-h,t.y=e.y-c;var g=(o.x+s*h)*r,y=(o.y+s*c)*r;o.x=(o.x-s*g)*u,o.y=(o.y-s*y)*u;var v=t.x+(h+g)*u,S=t.y+(c+y)*u,_=d.x-e.x,b=d.y-e.y;_*(v-d.x)+b*(S-d.y)>0&&(v=d.x,S=d.y,o.x=(v-d.x)/r,o.y=(S-d.y)/r),a.set(v,S)},t.SmoothDampVector3=function(t,i,n,r,o,a){var s=new BABYLON.Vector3(0,0,0);return e.Utilities.SmoothDampVector3ToRef(t,i,n,r,o,a,s),s},t.SmoothDampVector3ToRef=function(e,t,i,n,r,o,a){var s=0,l=0,u=0,h=2/(i=Math.max(1e-4,i)),c=h*r,d=1/(1+c+.48*c*c+.235*c*c*c),m=e.x-t.x,p=e.y-t.y,f=e.z-t.z,g=t.clone(),y=n*i,v=m*m+p*p+f*f;if(v>y*y){var S=Math.sqrt(v);m=m/S*y,p=p/S*y,f=f/S*y}t.x=e.x-m,t.y=e.y-p,t.z=e.z-f;var _=(o.x+h*m)*r,b=(o.y+h*p)*r,B=(o.z+h*f)*r;o.x=(o.x-h*_)*d,o.y=(o.y-h*b)*d,o.z=(o.z-h*B)*d,s=t.x+(m+_)*d,l=t.y+(p+b)*d,u=t.z+(f+B)*d;var C=g.x-e.x,A=g.y-e.y,T=g.z-e.z;C*(s-g.x)+A*(l-g.y)+T*(u-g.z)>0&&(s=g.x,l=g.y,u=g.z,o.x=(s-g.x)/r,o.y=(l-g.y)/r,o.z=(u-g.z)/r),a.set(s,l,u)},t.ToMatrix=function(e,t,i){return BABYLON.Matrix.RotationYawPitchRoll(BABYLON.Tools.ToRadians(t),BABYLON.Tools.ToRadians(e),BABYLON.Tools.ToRadians(i))},t.ToMatrixToRef=function(e,t,i,n){BABYLON.Matrix.RotationYawPitchRollToRef(BABYLON.Tools.ToRadians(t),BABYLON.Tools.ToRadians(e),BABYLON.Tools.ToRadians(i),n)},t.FastMatrixLerp=function(e,t,i,n){BABYLON.Matrix.LerpToRef(e,t,i,n)},t.FastMatrixSlerp=function(e,t,i,n){BABYLON.Matrix.DecomposeLerpToRef(e,t,i,n)},t.ToEuler=function(e){var t=e.toEulerAngles();return t.x=BABYLON.Tools.ToDegrees(t.x),t.y=BABYLON.Tools.ToDegrees(t.y),t.z=BABYLON.Tools.ToDegrees(t.z),t},t.ToEulerToRef=function(e,t){e.toEulerAnglesToRef(t),t.x=BABYLON.Tools.ToDegrees(t.x),t.y=BABYLON.Tools.ToDegrees(t.y),t.z=BABYLON.Tools.ToDegrees(t.z)},t.FromEuler=function(e,t,i){return BABYLON.Quaternion.FromEulerAngles(BABYLON.Tools.ToRadians(e),BABYLON.Tools.ToRadians(t),BABYLON.Tools.ToRadians(i))},t.FromEulerToRef=function(e,t,i,n){BABYLON.Quaternion.FromEulerAnglesToRef(BABYLON.Tools.ToRadians(e),BABYLON.Tools.ToRadians(t),BABYLON.Tools.ToRadians(i),n)},t.QuaternionDiff=function(t,i){var n=new BABYLON.Quaternion(0,0,0,1);return e.Utilities.QuaternionDiffToRef(t,i,n),n},t.QuaternionDiffToRef=function(t,i,n){BABYLON.Quaternion.InverseToRef(i,e.Utilities.TempQuaternion),e.Utilities.TempQuaternion.multiplyToRef(t,n)},t.QuaternionSubtractToRef=function(e,t,i){i.set(e._x-t._x,e._y-t._y,e._z-t._z,e._w-t._w)},t.RotateVector=function(e,t){var i=2*(t.y*e.z-t.z*e.y),n=2*(t.z*e.x-t.x*e.z),r=2*(t.x*e.y-t.y*e.x);return new BABYLON.Vector3(e.x+t.w*i+(t.y*r-t.z*n),e.y+t.w*n+(t.z*i-t.x*r),e.z+t.w*r+(t.x*n-t.y*i))},t.RotateVectorToRef=function(e,t,i){var n=2*(t.y*e.z-t.z*e.y),r=2*(t.z*e.x-t.x*e.z),o=2*(t.x*e.y-t.y*e.x);i.x=e.x+t.w*n+(t.y*o-t.z*r),i.y=e.y+t.w*r+(t.z*n-t.x*o),i.z=e.z+t.w*o+(t.x*r-t.y*n)},t.LookRotation=function(t){var i=BABYLON.Quaternion.Zero();return e.Utilities.LookRotationToRef(t,i),i},t.LookRotationToRef=function(e,t){BABYLON.Quaternion.FromLookDirectionRHToRef(e,BABYLON.Vector3.Up(),t)},t.Vector3Rad2Deg=function(t){var i=BABYLON.Vector3.Zero();return e.Utilities.Vector3Rad2DegToRef(t,i),i},t.Vector3Rad2DegToRef=function(e,t){t.x=BABYLON.Tools.ToDegrees(e.x),t.y=BABYLON.Tools.ToDegrees(e.y),t.z=BABYLON.Tools.ToDegrees(e.z)},t.MultiplyQuaternionByVector=function(t,i){var n=new BABYLON.Vector3(0,0,0);return e.Utilities.MultiplyQuaternionByVectorToRef(t,i,n),n},t.MultiplyQuaternionByVectorToRef=function(e,t,i){var n=2*e.x,r=2*e.y,o=2*e.z,a=e.x*n,s=e.y*r,l=e.z*o,u=e.x*r,h=e.x*o,c=e.y*o,d=e.w*n,m=e.w*r,p=e.w*o;i.x=(1-(s+l))*t.x+(u-p)*t.y+(h+m)*t.z,i.y=(u+p)*t.x+(1-(a+l))*t.y+(c-d)*t.z,i.z=(h-m)*t.x+(c+d)*t.y+(1-(a+s))*t.z},t.ValidateTransformRotation=function(e){null!=e.rotationQuaternion&&(e.rotation=e.rotationQuaternion.toEulerAngles(),e.rotationQuaternion=null)},t.ValidateTransformQuaternion=function(e){null==e.rotationQuaternion&&null!=e.rotation&&(e.rotationQuaternion=BABYLON.Quaternion.FromEulerAngles(e.rotation.x,e.rotation.y,e.rotation.z),e.rotation.set(0,0,0))},t.GetKeyboardInputValue=function(t,i,n){var r=n;return!0===e.UserInputOptions.KeyboardSmoothing&&(r=BABYLON.Scalar.MoveTowards(i,n,e.UserInputOptions.KeyboardMoveSensibility*e.SceneManager.GetDeltaSeconds(t)),Math.abs(r)<e.UserInputOptions.KeyboardMoveDeadZone&&(r=0)),r},t.GenerateRandonNumber=function(e,t,i){void 0===i&&(i=2);var n=(Math.random()*(t-e)+e).toFixed(i);return parseFloat(n)},t.ProjectVector=function(t,i){var n=new BABYLON.Vector3(0,0,0);return e.Utilities.ProjectVectorToRef(t,i,n),n},t.ProjectVectorToRef=function(t,i,n){var r=BABYLON.Vector3.Dot(i,i);if(r<e.System.Epsilon)n.set(0,0,0);else{var o=BABYLON.Vector3.Dot(t,i);n.set(i.x*o/r,i.y*o/r,i.z*o/r)}},t.ProjectVectorOnPlane=function(t,i){var n=new BABYLON.Vector3(0,0,0);return e.Utilities.ProjectVectorOnPlaneToRef(t,i,n),n},t.ProjectVectorOnPlaneToRef=function(t,i,n){var r=BABYLON.Vector3.Dot(i,i);if(r<e.System.Epsilon)n.copyFrom(t);else{var o=BABYLON.Vector3.Dot(t,i);n.set(t.x-i.x*o/r,t.y-i.y*o/r,t.z-i.z*o/r)}},t.AreVectorsEqual=function(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i&&Math.abs(e.z-t.z)<i},t.GetVerticalSlopeAngle=function(t,i){void 0===i&&(i=0);var n=Math.atan(Math.abs(t.y/Math.sqrt(t.x*t.x+t.z*t.z)))*e.System.Rad2Deg;return n=null!=n&&!1===Number.isNaN(n)?n:0,i>0&&n>=i&&(n=0),n},t.DownloadEnvironment=function(e,t,i){void 0===t&&(t=null),void 0===i&&(i=null),BABYLON.EnvironmentTextureTools.CreateEnvTextureAsync(e).then(function(i){var n=e.name||"Environment",r=new Blob([i],{type:"octet/stream"});BABYLON.Tools.Download(r,n+".env"),null!=t&&t()}).catch(function(e){console.error(e),null!=i&&i()})},t.HasOwnProperty=function(e,t){return null!=e&&null!=t&&""!==t&&t in e},t.FindMeshCollider=function(e,t){var i=null;if(t instanceof BABYLON.TransformNode&&!0==(null!=t.metadata&&null!=t.metadata.toolkit&&null!=t.metadata.toolkit.renderer&&null!=t.metadata.toolkit.renderer.hasmeshcollider&&!0===t.metadata.toolkit.renderer.hasmeshcollider)){var n=t.id+"-collider";i=e.getMeshById(n)}return i},t.ColliderInstances=function(){return null==e.SceneManager.GlobalOptions.colliderInstances||e.SceneManager.GlobalOptions.colliderInstances},t.ReparentColliders=function(){return null==e.SceneManager.GlobalOptions.reparentColliders||e.SceneManager.GlobalOptions.reparentColliders},t.UseTriangleNormals=function(){return null!=e.SceneManager.GlobalOptions.useTriangleNormals&&e.SceneManager.GlobalOptions.useTriangleNormals},t.UseConvexTriangles=function(){return null!=e.SceneManager.GlobalOptions.useConvexTriangles&&e.SceneManager.GlobalOptions.useConvexTriangles},t.DefaultRenderGroup=function(){return null!=e.SceneManager.GlobalOptions.defaultRenderGroup?e.SceneManager.GlobalOptions.defaultRenderGroup:0},t.ShowDebugColliders=function(){return!0===e.SceneManager.EnableDebugMode||null!=e.SceneManager.GlobalOptions.showDebugColliders&&e.SceneManager.GlobalOptions.showDebugColliders},t.ColliderVisibility=function(){return null!=e.SceneManager.GlobalOptions.colliderVisibility?e.SceneManager.GlobalOptions.colliderVisibility:0},t.ColliderRenderGroup=function(){return null!=e.SceneManager.GlobalOptions.colliderRenderGroup?e.SceneManager.GlobalOptions.colliderRenderGroup:0},t.CollisionWireframe=function(){return null!=e.SceneManager.GlobalOptions.collisionWireframe&&e.SceneManager.GlobalOptions.collisionWireframe},t.GetColliderMaterial=function(t){var i="Collider-Material",n=t.getMaterialByName(i);if(null==n){var r=new BABYLON.PBRMaterial(i,t);r.albedoColor=new BABYLON.Color3(0,.75,0),r.wireframe=e.Utilities.CollisionWireframe(),r.unlit=!0,n=r}return n},t.CalculateCombinedFriction=function(e,t){var i=e*t;return i<-10&&(i=-10),i>10&&(i=10),i},t.CalculateCombinedRestitution=function(e,t){return e*t},t.AddLoaderItemMarkedForDisposal=function(t){null==e.Utilities.LoaderItemsMarkedForDisposal&&(e.Utilities.LoaderItemsMarkedForDisposal=[]),e.Utilities.LoaderItemsMarkedForDisposal.push(t)},t.ResetLoaderItemsMarkedForDisposal=function(){e.Utilities.LoaderItemsMarkedForDisposal=[]},t.RemoveLoaderItemsMarkedForDisposal=function(){null!=e.Utilities.LoaderItemsMarkedForDisposal&&e.Utilities.LoaderItemsMarkedForDisposal.length>0&&e.Utilities.LoaderItemsMarkedForDisposal.forEach(function(e){try{e.dispose()}catch(e){console.warn(e)}}),e.Utilities.ResetLoaderItemsMarkedForDisposal()},t.GetDirectTargetAngle=function(t,i){return e.Utilities.TempVector3.set(0,0,0),e.Utilities.InverseTransformPointToRef(t,i,e.Utilities.TempVector3),Math.atan2(e.Utilities.TempVector3.x,e.Utilities.TempVector3.z)},t.GetSmoothTargetAngle=function(t,i){return e.Utilities.TempVector3.set(0,0,0),e.Utilities.InverseTransformPointToRef(t,i,e.Utilities.TempVector3),e.Utilities.TempVector3.x/e.Utilities.TempVector3.length()},t.CalculatCatmullRom=function(t,i,n,r,o){var a=new BABYLON.Vector3(0,0,0);return e.Utilities.CalculatCatmullRomToRef(t,i,n,r,o,a),a},t.CalculatCatmullRomToRef=function(e,t,i,n,r,o){},t.MakeProper=function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()},t.StartsWith=function(e,t){return 0===e.lastIndexOf(t,0)},t.EndsWith=function(e,t){return-1!==e.indexOf(t,e.length-t.length)},t.ReplaceAll=function(e,t,i){return e.replace(new RegExp(t,"g"),i)},t.IsNullOrEmpty=function(e){return null==e||""===e},t.SafeStringPush=function(e,t){-1===e.indexOf(t)&&e.push(t)},t.ParseColor3=function(e,t,i){return void 0===t&&(t=null),void 0===i&&(i=!1),null!=e&&null!=e.r&&null!=e.g&&null!=e.b?!0===i?new BABYLON.Color3(e.r,e.g,e.b).toLinearSpace():new BABYLON.Color3(e.r,e.g,e.b):t},t.ParseColor4=function(e,t,i){void 0===t&&(t=null),void 0===i&&(i=!1);var n=null;if(null!=e&&null!=e.r&&null!=e.g&&null!=e.b){var r=null!=e.a?e.a:1;n=!0===i?new BABYLON.Color4(e.r,e.g,e.b,r).toLinearSpace():new BABYLON.Color4(e.r,e.g,e.b,r)}else n=t;return n},t.ParseVector2=function(e,t){return void 0===t&&(t=null),null!=e&&null!=e.x&&null!=e.y?new BABYLON.Vector2(e.x,e.y):t},t.ParseVector3=function(e,t){return void 0===t&&(t=null),null!=e&&null!=e.x&&null!=e.y&&null!=e.z?new BABYLON.Vector3(e.x,e.y,e.z):t},t.ParseVector4=function(e,t){return void 0===t&&(t=null),null!=e&&null!=e.x&&null!=e.y&&null!=e.z&&null!=e.w?new BABYLON.Vector4(e.x,e.y,e.z,e.w):t},t.ParseSound=function(t,i,n,r,o){return s(this,void 0,void 0,function(){var a,s,u;return l(this,function(l){switch(l.label){case 0:return a=null,null==t||null==t.filename||""===t.filename?[3,2]:(s=e.SceneManager.GetRootUrl(i),u=t.filename,[4,e.AudioSource.CreateStaticSound(n,s+u,o)]);case 1:a=l.sent(),null!=r&&r(),l.label=2;case 2:return[2,a]}})})},t.ParseTexture=function(t,i,n,r,o,a,s,l,u,h){var c=null;if(null!=t&&null!=t.filename&&""!==t.filename){var d=e.SceneManager.GetRootUrl(i),m=t.filename;c=new BABYLON.Texture(d+m,i,n,r,o,a,s,l,u,h)}return c},t.ParseCubemap=function(t,i){var n=null;if(null!=t&&null!=t.info){var r=e.SceneManager.GetRootUrl(i),o=(t.info.rooturl,r+t.info.rooturl);null!=(n=BABYLON.CubeTexture.Parse(t.info,i,o))&&(n.gammaSpace=!1)}return n},t.ParseTextAsset=function(t,i){return void 0===i&&(i=null),null!=t&&null!=t.base64&&""!==t.base64?e.WindowManager.Atob(t.base64):i},t.ParseJsonAsset=function(t,i,n){void 0===i&&(i=null),void 0===n&&(n=null);var r=e.Utilities.ParseTextAsset(t,i);return null!=r&&""!==r?JSON.parse(r,n):null},t.ParseTransformByID=function(t,i,n){return void 0===n&&(n=null),null!=t&&null!=t.id?e.SceneManager.GetTransformNodeByID(i,t.id):n},t.ParseTransformByName=function(t,i,n){return void 0===n&&(n=null),null!=t&&null!=t.id?e.SceneManager.GetTransformNode(i,t.id):n},t.ParseChildTransform=function(t,i,n){return void 0===n&&(n=null),null!=i&&null!=i.name?e.SceneManager.FindChildTransformNode(t,i.name,e.SearchType.IndexOf,!1):n},t.SetAbsolutePosition=function(e,t){e.setAbsolutePosition(t)},t.GetAbsolutePosition=function(t,i,n){void 0===i&&(i=null),void 0===n&&(n=!0);var r=new BABYLON.Vector3(0,0,0);return e.Utilities.GetAbsolutePositionToRef(t,r,i,n),r},t.GetAbsolutePositionToRef=function(e,t,i,n){void 0===i&&(i=null),void 0===n&&(n=!0),!0===n&&e.computeWorldMatrix(!0),t.copyFrom(e.getAbsolutePosition()),null!=i&&t.addInPlace(i)},t.SetAbsoluteRotation=function(t,i){null==t.rotationQuaternion&&(t.rotationQuaternion=t.rotation.toQuaternion()),null!=t.parent&&t.parent instanceof BABYLON.TransformNode?(e.Utilities.TempQuaternion2.set(0,0,0,1),e.Utilities.GetAbsoluteRotationToRef(t.parent,e.Utilities.TempQuaternion2),BABYLON.Quaternion.InverseToRef(e.Utilities.TempQuaternion2,e.Utilities.TempQuaternion2),e.Utilities.TempQuaternion2.multiplyInPlace(i),t.rotationQuaternion.copyFrom(e.Utilities.TempQuaternion2)):t.rotationQuaternion.copyFrom(i)},t.GetAbsoluteRotation=function(t){var i=new BABYLON.Quaternion(0,0,0,1);return e.Utilities.GetAbsoluteRotationToRef(t,i),i},t.GetAbsoluteRotationToRef=function(e,t){null!=e.absoluteRotationQuaternion&&t.copyFrom(e.absoluteRotationQuaternion)},t.TransformPoint=function(e,t,i){return void 0===i&&(i=!0),!0===i&&e.computeWorldMatrix(),BABYLON.Vector3.TransformCoordinates(t,e.getWorldMatrix())},t.InverseTransformPoint=function(t,i,n){return void 0===n&&(n=!0),!0===n&&t.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),t.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),BABYLON.Vector3.TransformCoordinates(i,e.Utilities.TempMatrix)},t.TransformPointToRef=function(e,t,i,n){void 0===n&&(n=!0),!0===n&&e.computeWorldMatrix(),BABYLON.Vector3.TransformCoordinatesToRef(t,e.getWorldMatrix(),i)},t.InverseTransformPointToRef=function(t,i,n,r){void 0===r&&(r=!0),!0===r&&t.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),t.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),BABYLON.Vector3.TransformCoordinatesToRef(i,e.Utilities.TempMatrix,n)},t.TransformDirection=function(e,t,i){return void 0===i&&(i=!0),!0===i&&e.computeWorldMatrix(),BABYLON.Vector3.TransformNormal(t,e.getWorldMatrix())},t.InverseTransformDirection=function(t,i,n){return void 0===n&&(n=!0),!0===n&&t.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),t.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),BABYLON.Vector3.TransformNormal(i,e.Utilities.TempMatrix)},t.TransformDirectionToRef=function(e,t,i,n){void 0===n&&(n=!0),!0===n&&e.computeWorldMatrix(),BABYLON.Vector3.TransformNormalToRef(t,e.getWorldMatrix(),i)},t.InverseTransformDirectionToRef=function(t,i,n,r){void 0===r&&(r=!0),!0===r&&t.computeWorldMatrix(),e.Utilities.TempMatrix.reset(),t.getWorldMatrix().invertToRef(e.Utilities.TempMatrix),BABYLON.Vector3.TransformNormalToRef(i,e.Utilities.TempMatrix,n)},t.RecomputeCenterPivotPoint=function(e){var t=e.getBoundingInfo().boundingSphere.center;e.setPivotMatrix(BABYLON.Matrix.Translation(-t.x,-t.y,-t.z))},t.GetDirectionVector=function(e,t){return e.getDirection(t)},t.GetDirectionVectorToRef=function(e,t,i){e.getDirectionToRef(t,i)},t.GetForwardVector=function(e){return e.getDirection(BABYLON.Vector3.Forward())},t.GetForwardVectorToRef=function(e,t){e.getDirectionToRef(BABYLON.Vector3.Forward(),t)},t.GetRightVector=function(e){return e.getDirection(BABYLON.Vector3.Right())},t.GetRightVectorToRef=function(e,t){e.getDirectionToRef(BABYLON.Vector3.Right(),t)},t.GetUpVector=function(e){return e.getDirection(BABYLON.Vector3.Up())},t.GetUpVectorToRef=function(e,t){e.getDirectionToRef(BABYLON.Vector3.Up(),t)},t.BlendFloatValue=function(e,t,i){var n=BABYLON.Scalar.Clamp(i,0,1);return n>0?BABYLON.Scalar.Lerp(e,t,n):e},t.BlendVector2Value=function(e,t,i){var n=BABYLON.Scalar.Clamp(i,0,1);if(n>0){var r=BABYLON.Vector2.Lerp(e,t,n);e.copyFrom(r)}},t.BlendVector3Value=function(e,t,i){var n=BABYLON.Scalar.Clamp(i,0,1);n>0&&BABYLON.Vector3.LerpToRef(e,t,n,e)},t.BlendQuaternionValue=function(e,t,i){var n=BABYLON.Scalar.Clamp(i,0,1);n>0&&BABYLON.Quaternion.SlerpToRef(e,t,n,e)},t.SetAnimationTargetProperty=function(e,t){null!=e&&(e.targetProperty=t,e.targetPropertyPath=e.targetProperty.split("."))},t.SampleAnimationFloat=function(t,i,n,r){void 0===n&&(n=BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE),void 0===r&&(r=!1);var o=0;return null!=t&&t.dataType===BABYLON.Animation.ANIMATIONTYPE_FLOAT&&(null==t._state&&(t._state={key:0,repeatCount:0,loopMode:n,workValue:BABYLON.Matrix.Zero()}),o=e.Utilities.InterpolateAnimation(t,i,t._state,r)),o},t.SampleAnimationVector2=function(t,i,n,r){void 0===n&&(n=BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE),void 0===r&&(r=!1);var o=null;return null!=t&&t.dataType===BABYLON.Animation.ANIMATIONTYPE_VECTOR2&&(null==t._state&&(t._state={key:0,repeatCount:0,loopMode:n,workValue:BABYLON.Matrix.Zero()}),o=e.Utilities.InterpolateAnimation(t,i,t._state,r)),o},t.SampleAnimationVector3=function(t,i,n,r){void 0===n&&(n=BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE),void 0===r&&(r=!1);var o=null;return null!=t&&t.dataType===BABYLON.Animation.ANIMATIONTYPE_VECTOR3&&(null==t._state&&(t._state={key:0,repeatCount:0,loopMode:n,workValue:BABYLON.Matrix.Zero()}),o=e.Utilities.InterpolateAnimation(t,i,t._state,r)),o},t.SampleAnimationQuaternion=function(t,i,n,r){void 0===n&&(n=BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE),void 0===r&&(r=!1);var o=null;return null!=t&&t.dataType===BABYLON.Animation.ANIMATIONTYPE_QUATERNION&&(null==t._state&&(t._state={key:0,repeatCount:0,loopMode:n,workValue:BABYLON.Matrix.Zero()}),o=e.Utilities.InterpolateAnimation(t,i,t._state,r)),o},t.SampleAnimationMatrix=function(t,i,n,r){void 0===n&&(n=BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE),void 0===r&&(r=!1);var o=null;return null!=t&&t.dataType===BABYLON.Animation.ANIMATIONTYPE_MATRIX&&(null==t._state&&(t._state={key:0,repeatCount:0,loopMode:n,workValue:BABYLON.Matrix.Zero()}),o=e.Utilities.InterpolateAnimation(t,i,t._state,r)),o},t.GetLastKeyFrameIndex=function(e){var t=0;if(null!=e){var i=e.getKeys();if(null!=i&&i.length>0){var n=i[i.length-1];null!=n&&(t=n.frame)}}return t},t.InterpolateAnimation=function(t,i,n,r){void 0===r&&(r=!1);var o=!0===r?i*e.SceneManager.AnimationTargetFps:i;return t._interpolate(o,n)},t.UpdateLoopBlendPositionSettings=function(e,t,i){var n=e;null!=n.metadata&&null!=n.metadata.toolkit&&null!=n.metadata.toolkit.settings&&(n.metadata.toolkit.settings.loopblendpositiony=t,n.metadata.toolkit.settings.loopblendpositionxz=i)},t.TakeScreenSnapshot=function(e,t,i,n,r){if(e&&t){var o=e.activeCamera;if(o){var a=t.getRenderWidth(),s=t.getRenderHeight(),l=a,u=s;if(i)if(i.width&&i.height)l=Math.max(1,i.width),u=Math.max(1,i.height);else if(i.width){l=Math.max(1,i.width);var h=s/Math.max(1,a);u=Math.round(l*h)}else if(i.height)u=Math.max(1,i.height),h=a/Math.max(1,s),l=Math.round(u*h);else if(i.precision){var c=Math.max(.05,i.precision);l=Math.round(a*c),u=Math.round(s*c)}BABYLON.CreateScreenshotUsingRenderTarget(t,o,{width:l,height:u},void 0,void 0,void 0,!1,void 0,!1,!1,!0,void 0,void 0,function(e,t,i,o,a,s,l){try{var u=i,h=new Uint8ClampedArray(u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength));if(l)for(var c=4*e,d=Math.floor(t/2),m=new Uint8ClampedArray(c),p=0;p<d;p++){var f=p*c,g=(t-1-p)*c;m.set(h.subarray(f,f+c)),h.copyWithin(f,g,g+c),h.set(m,g)}var y=void 0;if("OffscreenCanvas"in window)y=new OffscreenCanvas(e,t);else{var v=document.createElement("canvas");v.width=e,v.height=t,y=v}var S=y.getContext("2d");if(!S)return void(r&&r(null));var _=S.createImageData(e,t);if(_.data.set(h),S.putImageData(_,0,0),!r)return;y instanceof OffscreenCanvas&&"function"==typeof y.transferToImageBitmap?r(y.transferToImageBitmap()):"function"==typeof createImageBitmap?createImageBitmap(y,n).then(function(e){return r(e)}).catch(function(){return r(null)}):r(null)}catch(e){r&&r(null)}})}else r&&r(null)}else r&&r(null)},t.DownloadImageBitmap=function(e,t,i,n){if(void 0===t&&(t="image.png"),void 0===i&&(i="image/png"),!e)return null;var r=e.width,o=e.height,a="OffscreenCanvas"in window?new OffscreenCanvas(r,o):Object.assign(document.createElement("canvas"),{width:r,height:o});a.getContext("2d").drawImage(e,0,0);var s=function(e){if(e){var i=URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download=t,n.click(),setTimeout(function(){return URL.revokeObjectURL(i)},2e3)}};return"convertToBlob"in a?a.convertToBlob({type:i,quality:n}).then(s):a.toBlob(s,i,n),a},t.MarkLinear=function(e){e&&(e.gammaSpace=!1)},t.MarkGamma=function(e){e&&(e.gammaSpace=!0)},t.WorldToScreenPoint=function(e,t,i){void 0===i&&(i=null);var n=null,r=null!=i?i.viewport:null!=e.activeCamera?e.activeCamera.viewport:null;return null!=r&&(n=BABYLON.Vector3.Project(t,BABYLON.Matrix.Identity(),e.getTransformMatrix(),r.toGlobal(e.getEngine().getRenderWidth(),e.getEngine().getRenderHeight()))),n},t.ScreenToWorldPoint=function(e,t){return BABYLON.Vector3.Unproject(t,e.getEngine().getRenderWidth(),e.getEngine().getRenderHeight(),BABYLON.Matrix.Identity(),e.getViewMatrix(),e.getProjectionMatrix())},t.LoadTextFile=function(e,t,i,n){return BABYLON.Tools.LoadFile(e,t,i,null,!1,n)},t.LoadTextFileAsync=function(e){return BABYLON.Tools.LoadFileAsync(e,!1)},t.GetHttpRequest=function(e,t,i,n,r,o,a){void 0===t&&(t=null),void 0===i&&(i=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=!1),void 0===a&&(a=null);var s=new XMLHttpRequest;return s.open("GET",e,!0),!0===o&&(s.responseType="arraybuffer"),null!=a&&s.overrideMimeType(a),null!=t&&t.forEach(function(e){null!=e&&null!=e.name&&""!==e.name&&s.setRequestHeader(e.name,e.value)}),s.onreadystatechange=function(){s.readyState===XMLHttpRequest.DONE&&null!=i&&i(s)},s.onprogress=function(e){null!=r&&r(e)},s.onerror=function(){null!=n&&n("Failed to get data from server.")},s.onabort=function(){null!=n&&n("Aborted get data from server.")},s.send(null),s},t.GetHttpRequestAsync=function(t,i,n,r,o){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===r&&(r=!1),void 0===o&&(o=null),new Promise(function(a,s){e.Utilities.GetHttpRequest(t,i,function(e){a(e)},function(e){s(e)},n,r,o)})},t.PostHttpRequest=function(e,t,i,n,r,o,a,s,l){void 0===i&&(i=null),void 0===n&&(n="application/x-www-form-urlencoded"),void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=!1),void 0===l&&(l=null);var u=new XMLHttpRequest;return u.open("POST",e,!0),!0===s&&(u.responseType="arraybuffer"),null!=l&&u.overrideMimeType(l),null!=i&&i.forEach(function(e){null!=e&&null!=e.name&&""!==e.name&&u.setRequestHeader(e.name,e.value)}),u.setRequestHeader("Content-Type",n),u.onreadystatechange=function(){u.readyState===XMLHttpRequest.DONE&&null!=r&&r(u)},u.onprogress=function(e){null!=a&&a(e)},u.onerror=function(){null!=o&&o("Failed to post data to server.")},u.onabort=function(){null!=o&&o("Aborted post data to server.")},u.send(t),u},t.PostHttpRequestAsync=function(t,i,n,r,o,a,s){return void 0===n&&(n=null),void 0===r&&(r="application/x-www-form-urlencoded"),void 0===o&&(o=null),void 0===a&&(a=!1),void 0===s&&(s=null),new Promise(function(l,u){e.Utilities.PostHttpRequest(t,i,n,r,function(e){l(e)},function(e){u(e)},o,a,s)})},t.RemapValueToRange=function(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)},t.CloneSkeletonPrefab=function(e,t,i,n,r){void 0===r&&(r=null);var o=new BABYLON.Skeleton(i,n||i,e);o.needInitialSkinMatrix=t.needInitialSkinMatrix;for(var a=0;a<t.bones.length;a++){var s=t.bones[a],l=null,u=s.getParent();if(u){var h=t.bones.indexOf(u);l=o.bones[h]}var c=new BABYLON.Bone(s.name,o,l,s.getBaseMatrix().clone(),s.getRestPose().clone());c._index=s._index,c.metadata=s.metadata,s._linkedTransformNode&&c.linkTransformNode(s._linkedTransformNode),BABYLON.DeepCopier.DeepCopy(s.animations,c.animations)}var d=o,m=t;if(m._ranges)for(var p in d._ranges={},m._ranges){var f=m._ranges[p];f&&(d._ranges[p]=f.clone())}return m._isDirty=!0,o},t.GetSceneTransforms=function(e){var t=null;return null!=e.transformNodes&&e.transformNodes.length>0&&e.transformNodes.forEach(function(e){null!=e.metadata&&null!=e.metadata.toolkit&&null!=e.metadata.toolkit.prefab&&!1===e.metadata.toolkit.prefab&&(null==t&&(t=[]),t.push(e))}),null!=e.meshes&&e.meshes.length>0&&e.meshes.forEach(function(e){null!=e.metadata&&null!=e.metadata.toolkit&&null!=e.metadata.toolkit.prefab&&!1===e.metadata.toolkit.prefab&&(null==t&&(t=[]),t.push(e))}),t},t.PostParseSceneComponents=function(t,i,n,r){var o=new e.MetadataParser(t);return null!=i&&i.length>0&&(i.forEach(function(e){o.parseSceneComponents(e)}),o.postProcessSceneComponents(n,r)),o},t.GetDefaultReflectionTexture=function(e){if(!e._DefaultCube){var t=document.createElement("canvas");t.width=t.height=1;var i=t.getContext("2d");i.fillStyle="rgba(128,128,128,1)",i.fillRect(0,0,1,1);var n=t.toDataURL("image/png"),r=[n,n,n,n,n,n],o=BABYLON.CubeTexture.CreateFromImages(r,e,!0);o.name="DefaultReflection",o.gammaSpace=!1,o.coordinatesMode=BABYLON.Texture.CUBIC_MODE,o.level=.1,e._DefaultCube=o}return e._DefaultCube},t.GetNeutralReflectionTexture=function(e,t,i){void 0===t&&(t=128),void 0===i&&(i=.4);var n="_NeutralCube_".concat(t,"_").concat(i);if(!e[n]){var r=document.createElement("canvas");r.width=r.height=1;var o=r.getContext("2d");o.fillStyle="rgba(".concat(t,",").concat(t,",").concat(t,",1)"),o.fillRect(0,0,1,1);var a=r.toDataURL("image/png"),s=[a,a,a,a,a,a],l=BABYLON.CubeTexture.CreateFromImages(s,e,!0);l.name="NeutralReflection",l.gammaSpace=!1,l.coordinatesMode=BABYLON.Texture.CUBIC_MODE,l.level=i,e[n]=l}return e[n]},t.GetAssetContainerMesh=function(e,t){var i=null,n=t.toLowerCase();if(null==i&&null!=e.meshes&&e.meshes.length>0)for(var r=0;r<e.meshes.length;r++){var o=e.meshes[r];if(o instanceof BABYLON.Mesh&&o.name.toLowerCase()===n){i=o;break}}return i},t.GetAssetContainerNode=function(e,t){var i=null,n=t.toLowerCase();if(null==i&&null!=e.transformNodes&&e.transformNodes.length>0)for(var r=0;r<e.transformNodes.length;r++){var o=e.transformNodes[r];if(o.name.toLowerCase()===n){i=o;break}}return i},t.CloneAssetContainerItem=function(t,i,n,r,o,a){void 0===r&&(r=null),void 0===o&&(o=!1),void 0===a&&(a=!0);var s=null,l={},u={},h={},c=null,d=null,m=[],p=[],f=i.toLowerCase(),g=null,y=function(t,i){null==g&&(g=i),l[t.uniqueId]=i.uniqueId,u[i.uniqueId]=i,n&&(i.name=n(t.name)),null!=t.metadata&&null!=t.metadata.toolkit&&null!=t.metadata.toolkit.entity&&(i.metadata=e.Utilities.CloneEntityMetadata(t.metadata));var r=null!=i.metadata&&null!=i.metadata.toolkit&&null!=i.metadata.toolkit.animator?i.metadata.toolkit.animator:null;if(null!=r&&""!==r&&(null==c&&(c=[]),c.indexOf(r)<0&&c.push(r),i.metadata.toolkit.animator=e.Utilities.CreateGuid(),h[r]=i.metadata.toolkit.animator),t instanceof BABYLON.AbstractMesh&&null!=t.skeleton&&(null==d&&(d=[]),d.indexOf(t.skeleton)<0&&d.push(t.skeleton)),i instanceof BABYLON.Mesh){var o=i;if(o.morphTargetManager){var a=t.morphTargetManager;o.morphTargetManager=a.clone();for(var s=0;s<a.numTargets;s++){var m=a.getTarget(s),p=o.morphTargetManager.getTarget(s);l[m.uniqueId]=p.uniqueId,u[p.uniqueId]=p}}}};if(null==s&&null!=t.transformNodes&&t.transformNodes.length>0)for(var v=0;v<t.transformNodes.length;v++){var S=t.transformNodes[v];if(S.name.toLowerCase()===f){var _=e.Utilities.InstantiateHierarchy(S,r,function(e,t){y(e,t)});if(_){s=_;break}}}if(null==s&&null!=t.meshes&&t.meshes.length>0){var b=function(i){var a=t.meshes[i];if(a.name.toLowerCase()===f){var h=e.Utilities.InstantiateHierarchy(a,r,function(e,i){y(e,i);var r=i;if(!0===a.isWorldMatrixFrozen&&r.freezeWorldMatrix&&r.freezeWorldMatrix(),i.material&&r.material)if(!0===o){var s=e.material;if(-1===p.indexOf(s)){var h=s.clone(n?n(s.name):"Clone of "+s.name);if(!0===s.isFrozen&&h.freeze&&h.freeze(),p.push(s),l[s.uniqueId]=h.uniqueId,u[h.uniqueId]=h,"MultiMaterial"===s.getClassName())for(var c=0,d=s.subMaterials;c<d.length;c++){var m=d[c];m&&(h=m.clone(n?n(m.name):"Clone of "+m.name),!0===m.isFrozen&&h.freeze&&h.freeze(),p.push(m),l[m.uniqueId]=h.uniqueId,u[h.uniqueId]=h)}}r.material=u[l[s.uniqueId]]}else"MultiMaterial"===r.material.getClassName()?-1===t.scene.multiMaterials.indexOf(r.material)&&t.scene.addMultiMaterial(r.material):-1===t.scene.materials.indexOf(r.material)&&t.scene.addMaterial(r.material)});if(h)return s=h,"break"}};for(v=0;v<t.meshes.length&&"break"!==b(v);v++);}if(null!=d&&d.length>0&&d.forEach(function(i){for(var r=n?n(i.name):"Clone of "+i.name,o=e.Utilities.CloneSkeletonPrefab(t.scene,i,r,r,g),a=0,s=t.meshes;a<s.length;a++){var h=s[a];if(h.skeleton===i&&!h.isAnInstance){if(u[l[h.uniqueId]].skeleton=o,-1!==m.indexOf(o))continue;m.push(o);for(var c=0,d=o.bones;c<d.length;c++){var p=d[c];p._linkedTransformNode&&(p._linkedTransformNode=u[l[p._linkedTransformNode.uniqueId]])}}}}),!0===a){var B=null;t.animationGroups.forEach(function(e){var t=e,i=null!=t.metadata&&null!=t.metadata.toolkit&&null!=t.metadata.toolkit.source&&""!==t.metadata.toolkit.source?t.metadata.toolkit.source:null;if(null!=i&&""!==i&&null!=c&&c.indexOf(i)>=0){var n=e.clone(e.name,function(e){return u[l[e.uniqueId]]||e}),r=h[i]||i;null!=t.metadata&&(n.metadata={},n.metadata.toolkit={},n.metadata.toolkit.id=t.metadata.toolkit.id,n.metadata.toolkit.clip=t.metadata.toolkit.clip,n.metadata.toolkit.source=r,n.metadata.toolkit.legacy=t.metadata.toolkit.legacy,n.metadata.toolkit.length=t.metadata.toolkit.length,n.metadata.toolkit.looping=t.metadata.toolkit.looping,n.metadata.toolkit.settings=t.metadata.toolkit.settings,n.metadata.toolkit.behavior=t.metadata.toolkit.behavior,n.metadata.toolkit.wrapmode=t.metadata.toolkit.wrapmode,n.metadata.toolkit.framerate=t.metadata.toolkit.framerate,n.metadata.toolkit.humanmotion=t.metadata.toolkit.humanmotion,n.metadata.toolkit.averagespeed=t.metadata.toolkit.averagespeed,n.metadata.toolkit.averageduration=t.metadata.toolkit.averageduration,n.metadata.toolkit.averageangularspeed=t.metadata.toolkit.averageangularspeed),null==B&&(B=[]),B.push(n)}}),null!=s&&null!=B&&e.Utilities.AssignAnimationGroupsToInstance(s,B)}return s},t.AssignAnimationGroupsToInstance=function(t,i){e.Utilities.AssignAnimationGroupsToNode(t,i);var n=t.getChildren(null,!1);null!=n&&n.length>0&&n.forEach(function(t){e.Utilities.AssignAnimationGroupsToNode(t,i)})},t.AssignAnimationGroupsToNode=function(t,i){if(null!=t&&null!=t.metadata&&t.metadata.toolkit){var n=t.metadata.toolkit;if(null!=n.components&&n.components.length>0)for(var r=0;r<n.components.length;r++){var o=n.components[r].klass;if(null!=o&&""!==o){if(!0===e.SceneManager.AutoStripNamespacePrefix&&!1===e.SceneManager.UniversalModuleDefinition&&(0===o.indexOf("BABYLON.")||0===o.indexOf("TOOLKIT.")||0===o.indexOf("PROJECT."))){var a=o.lastIndexOf(".");-1!==a&&(o=o.substring(a+1))}"TOOLKIT.AnimationState"!==o&&"AnimationState"!==o||(t.metadata.toolkit.sourceAnimationGroups=i)}}}},t.UnitySlopeAngleToCosine=function(e){return Math.cos(e*Math.PI/180)},t.InstantiateHierarchy=function(t,i,n){if(void 0===i&&(i=null),t instanceof BABYLON.Mesh){var r=null!=t.metadata&&null!=t.metadata.toolkit&&null!=t.metadata.toolkit.instance&&!0===t.metadata.toolkit.instance;return e.Utilities.InstantiateMeshHierarchy(t,i,r,n)}return e.Utilities.InstantiateNodeHierarchy(t,i,n)},t.InstantiateNodeHierarchy=function(t,i,n){void 0===i&&(i=null);var r=t.clone("Clone of "+(t.name||t.id),i,!0);r&&n&&n(t,r);for(var o=0,a=t.getChildTransformNodes(!0);o<a.length;o++){var s=a[o];e.Utilities.InstantiateHierarchy(s,r,n)}return r},t.InstantiateMeshHierarchy=function(t,i,n,r){void 0===i&&(i=null);var o=t.getTotalVertices()>0&&!0===n?t.createInstance("Instance of "+(t.name||t.id)):t.clone("Clone of "+(t.name||t.id),i||t.parent,!0);o&&(o.parent=i,o.position=t.position.clone(),o.scaling=t.scaling.clone(),t.rotationQuaternion?o.rotationQuaternion=t.rotationQuaternion.clone():o.rotation=t.rotation.clone(),r&&r(t,o));for(var a=0,s=t.getChildTransformNodes(!0);a<s.length;a++){var l=s[a];e.Utilities.InstantiateHierarchy(l,o,r)}return o},t.PrepareSkeletonForRendering=function(e,t){void 0===t&&(t=!1),null!=e&&e.prepare(t)},t.RetargetAnimationGroupSkeleton=function(e,t,i){void 0===i&&(i=null),null!=e&&null!=t&&e.targetedAnimations.forEach(function(e,n){if(null!=e.target&&null!=e.target.name){var r=t.bones.filter(function(t){return t.name.toLowerCase()===e.target.name.toLowerCase()})[0];null!=r?null!=r.getTransformNode()&&(e.target=r.getTransformNode()):"Armature"===e.target.name&&null!=i?e.target=i:console.warn("Failed to locate matching animation cloning target: "+e.target.name)}})},t.RetargetAnimationGroupBlendShapes=function(e,t){null!=e&&null!=t&&e.targetedAnimations.forEach(function(e,t){null!=e.target&&e.target.name})},t.LinkSkeletonMeshes=function(t,i){if(null!=t&&null!=t.bones&&t.bones.length>0&&null!=i&&null!=i.bones&&i.bones.length>0)for(var n=i.bones.length,r=0;r<n;r++){var o=i.bones[r];if(null!=o){var a=e.Utilities.FindBoneByName(t,o.name);null!=a?o._linkedTransformNode=a._linkedTransformNode:console.warn("Failed to locate bone on mater rig: "+o.name)}}},t.FindBoneByName=function(e,t){var i=null;if(null!=e&&null!=e.bones)for(var n=0;n<e.bones.length;n++){var r=e.bones[n];if(r.name.toLowerCase().replace("mixamo:","").replace("left_","left").replace("right_","right")===t.toLowerCase().replace("mixamo:","").replace("left_","left").replace("right_","right")){i=r;break}}return i},t.SwitchHandednessVector3=function(e){return new BABYLON.Vector3(e.x,e.y,-e.z)},t.SwitchHandednessVector4=function(e){return new BABYLON.Vector4(e.x,e.y,-e.z,-e.w)},t.SwitchHandednessQuaternion=function(e){return new BABYLON.Quaternion(e.x,e.y,-e.z,-e.w)},t.ComputeBlendingSpeed=function(e,t,i){void 0===i&&(i=!1);var n=1/(e*t);return!0===i&&(n*=.5),n},t.CalculateCameraDistance=function(e,t,i){return void 0===i&&(i=1),Math.round(e*i*t*1)},t.EvalSphericalPolynomialRGB=function(e,t){var i=t.x,n=t.y,r=t.z,o=e.x.x*i+e.y.x*n+e.z.x*r+e.xx.x*i*i+e.yy.x*n*n+e.zz.x*r*r+e.xy.x*i*n+e.yz.x*n*r+e.zx.x*r*i,a=e.x.y*i+e.y.y*n+e.z.y*r+e.xx.y*i*i+e.yy.y*n*n+e.zz.y*r*r+e.xy.y*i*n+e.yz.y*n*r+e.zx.y*r*i,s=e.x.z*i+e.y.z*n+e.z.z*r+e.xx.z*i*i+e.yy.z*n*n+e.zz.z*r*r+e.xy.z*i*n+e.yz.z*n*r+e.zx.z*r*i;return new BABYLON.Color3(o,a,s)},t.BestFitScale=function(e,t){for(var i=0,n=0,r=0;r<e.length;r++){var o=e[r],a=t[r];i+=a*o,n+=a*a}return n>1e-12?i/n:1},t.ComputeSHEval6Fit=function(e,t){if(!Array.isArray(t)||18!==t.length)throw new Error("unityEval6 must be an array of 18 floats (6 dirs * RGB)");for(var i=[new BABYLON.Vector3(1,0,0),new BABYLON.Vector3(-1,0,0),new BABYLON.Vector3(0,1,0),new BABYLON.Vector3(0,-1,0),new BABYLON.Vector3(0,0,1),new BABYLON.Vector3(0,0,-1)],n=[],r=0;r<i.length;r++){var o=this.EvalSphericalPolynomialRGB(e,i[r]);n.push(o.r,o.g,o.b)}for(var a=t.slice(0),s=this.BestFitScale(a,n),l=0,u=[0,0,0],h=a.length,c=0;c<h;c++){var d=a[c]-s*n[c];l+=d*d,u[c%3]+=d*d}var m=Math.sqrt(l/h),p=u.map(function(e){return Math.sqrt(e/(h/3))}),f=[];for(r=0;r<i.length;r++)f.push({dir:i[r],unity:new BABYLON.Color3(a[3*r+0],a[3*r+1],a[3*r+2]),bab:new BABYLON.Color3(n[3*r+0],n[3*r+1],n[3*r+2]),scaledBab:new BABYLON.Color3(s*n[3*r+0],s*n[3*r+1],s*n[3*r+2]),diff:new BABYLON.Color3(a[3*r+0]-s*n[3*r+0],a[3*r+1]-s*n[3*r+1],a[3*r+2]-s*n[3*r+2])});return{scale:s,rmse:m,perChannelRMSE:p,perDir:f}},t.InstantiateClass=function(t,i){void 0===i&&(i=!0);try{var n=e.SceneManager.GetClass(t);if(n)return n;var r=t.split("."),o=void 0;if("undefined"!=typeof window)o=window;else if("undefined"!=typeof globalThis)o=globalThis;else{if(void 0===globalThis.global)throw new Error("No global object available");o=globalThis.global}for(var a=0;a<r.length;a++)if(!(o=o[r[a]]))throw new Error("Class not found: ".concat(t));return"function"==typeof o?o:null}catch(e){return!1===i&&console.error("Failed to instantiate class: ".concat(t),e),null}},t.GetSimpleClassName=function(e){if(e&&e.constructor&&e.constructor.toString){var t=e.constructor.toString().match(/function\s*(\w+)/);if(t&&2==t.length)return t[1]}},t.DisposeEntity=function(t){if(null!=t){if(null!=t.metadata&&t.metadata.toolkit){var i=t.metadata.toolkit;null!=i.components&&i.components.length>0&&i.components.forEach(function(t){if(null!=t.instance){try{e.SceneManager.DestroyScriptComponent(t.instance)}catch(e){}t.instance=null}}),delete t.metadata.toolkit}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 n=t.physicsImpostor;null!=n.onCollideEvent&&(n.onCollideEvent=null),null!=n.tmpCollisionObjects&&delete n.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),null!=t._debugCollider&&(t._debugCollider.dispose&&t._debugCollider.dispose(),delete t._debugCollider),null!=t._meshCollider&&(t._meshCollider=null),null!=t._colliderType&&delete t._colliderType,null!=t._skinnedMesh&&delete t._skinnedMesh}},t.SearchTransformNodes=function(t,i,n){void 0===n&&(n=e.SearchType.ExactMatch);var r=null,o=null!=n?n:e.SearchType.ExactMatch;if(null!=i&&i.length>0)for(var a=0;a<i.length;a++){var s=i[a];if(o===e.SearchType.ExactMatch){if(s.name===t){r=s;break}}else if(o===e.SearchType.StartsWith){if(e.Utilities.StartsWith(s.name,t)){r=s;break}}else if(o===e.SearchType.EndsWith){if(e.Utilities.EndsWith(s.name,t)){r=s;break}}else if(o===e.SearchType.IndexOf){if(s.name.indexOf(t)>=0){r=s;break}}else if(s.name===t){r=s;break}}return r},t.SearchTransformNodeForTags=function(e,t){var i=null;if(null!=t&&t.length>0)for(var n=0;n<t.length;n++){var r=t[n];if(r instanceof BABYLON.TransformNode&&BABYLON.Tags.MatchesQuery(r,e)){i=r;break}}return i},t.SearchAllTransformNodesForTags=function(e,t){var i=null;if(null!=t&&t.length>0)for(var n=0;n<t.length;n++){var r=t[n];r instanceof BABYLON.TransformNode&&BABYLON.Tags.MatchesQuery(r,e)&&(null==i&&(i=[]),i.push(r))}return i},t.SearchTransformNodeForScript=function(t,i){var n=t.substring(0);if(!0===e.SceneManager.AutoStripNamespacePrefix&&!1===e.SceneManager.UniversalModuleDefinition&&(0===n.indexOf("BABYLON.")||0===n.indexOf("TOOLKIT.")||0===n.indexOf("PROJECT."))){var r=n.lastIndexOf(".");-1!==r&&(n=n.substring(r+1))}var o=null;if(null!=i&&i.length>0)for(var a=0;a<i.length;a++){var s=i[a];if(s instanceof BABYLON.TransformNode){if(null!=s.metadata&&s.metadata.toolkit){var l=s.metadata.toolkit;if(null!=l.components&&l.components.length>0)for(var u=0;u<l.components.length;u++){var h=l.components[u];if(null!=h.instance&&(h.klass===t||h.klass===n)){o=s;break}}}if(null!=o)break}}return o},t.SearchAllTransformNodesForScript=function(t,i){var n=t.substring(0);if(!0===e.SceneManager.AutoStripNamespacePrefix&&!1===e.SceneManager.UniversalModuleDefinition&&(0===n.indexOf("BABYLON.")||0===n.indexOf("TOOLKIT.")||0===n.indexOf("PROJECT."))){var r=n.lastIndexOf(".");-1!==r&&(n=n.substring(r+1))}var o=null;if(null!=i&&i.length>0)for(var a=0;a<i.length;a++){var s=i[a];if(s instanceof BABYLON.TransformNode&&null!=s.metadata&&s.metadata.toolkit){var l=s.metadata.toolkit;if(null!=l.components&&l.components.length>0)for(var u=0;u<l.components.length;u++){var h=l.components[u];if(null!=h.instance&&(h.klass===t||h.klass===n)){null==o&&(o=[]),o.push(s);break}}}}return o},t.CreateGuid=function(t){void 0===t&&(t=null);var i=BABYLON.Tools.RandomId();return e.Utilities.IsNullOrEmpty(t)||(i+="-"+t),i},t.ValidateTransformGuid=function(e){if(null!=e&&null!=e.metadata&&null!=e.metadata.toolkit&&null!=e.metadata.toolkit.guid&&""!==e.metadata.toolkit.guid){var t=e.metadata.toolkit.guid;e.id!==t&&(e.id=t),delete e.metadata.toolkit.guid}},t.RegisterInstancedMeshBuffers=function(e){var t=null!=e.metadata&&null!=e.metadata.toolkit&&null!=e.metadata.toolkit.buffers?e.metadata.toolkit.buffers:null;null!=t&&(null!=t.floats&&t.floats.length>0&&t.floats.forEach(function(t){null!=t.kind&&""!==t.kind&&null!=t.value&&(e.registerInstancedBuffer(t.kind,1),e.instancedBuffers[t.kind]=t.value)}),null!=t.colors&&t.colors.length>0&&t.colors.forEach(function(t){null!=t.kind&&""!==t.kind&&null!=t.value&&(e.registerInstancedBuffer(t.kind,4),e.instancedBuffers[t.kind]=new BABYLON.Color4(t.value.r||0,t.value.g||0,t.value.b||0,t.value.a||1).toLinearSpace())}),null!=t.vector2&&t.vector2.length>0&&t.vector2.forEach(function(t){null!=t.kind&&""!==t.kind&&null!=t.value&&(e.registerInstancedBuffer(t.kind,2),e.instancedBuffers[t.kind]=new BABYLON.Vector2(t.value.x||0,t.value.y||0))}),null!=t.vector3&&t.vector3.length>0&&t.vector3.forEach(function(t){null!=t.kind&&""!==t.kind&&null!=t.value&&(e.registerInstancedBuffer(t.kind,3),e.instancedBuffers[t.kind]=new BABYLON.Vector3(t.value.x||0,t.value.y||0,t.value.z||0))}),null!=t.vector4&&t.vector4.length>0&&t.vector4.forEach(function(t){null!=t.kind&&""!==t.kind&&null!=t.value&&(e.registerInstancedBuffer(t.kind,4),e.instancedBuffers[t.kind]=new BABYLON.Vector4(t.value.x||0,t.value.y||0,t.value.z||0,t.value.w||0))}))},t.CloneValue=function(e,t){return e?e instanceof BABYLON.Mesh?null:e instanceof BABYLON.SubMesh?e.clone(t):e.clone?e.clone():e:null},t.CloneEntityMetadata=function(t){var i=null;if(null!=t){var n=null;if(null!=t.toolkit){var r=null!=t.toolkit.instance&&t.toolkit.instance,o=null==t.toolkit.visible||t.toolkit.visible,a=null!=t.toolkit.visibility?t.toolkit.visibility:1,s=null!=t.toolkit.billboard?t.toolkit.billboard:0,l=null!=t.toolkit.tags?t.toolkit.tags:"Untagged Layer0",u=null!=t.toolkit.skin&&t.toolkit.skin,h=null!=t.toolkit.bone?t.toolkit.bone:null,c=null!=t.toolkit.rootbone&&t.toolkit.rootbone,d=null!=t.toolkit.rootpos?t.toolkit.rootpos:null,m=null!=t.toolkit.rootrot?t.toolkit.rootrot:null,p=null!=t.toolkit.group?t.toolkit.group:"Untagged",f=null!=t.toolkit.layer?t.toolkit.layer:0,g=null!=t.toolkit.layername?t.toolkit.layername:"Default",y=null!=t.toolkit.navigation?t.toolkit.navigation:null,v=null!=t.toolkit.lightmapped&&t.toolkit.lightmapped,S=null!=t.toolkit.lightmapuvs?t.toolkit.lightmapuvs:null,_=null!=t.toolkit.animator?t.toolkit.animator:null,b=null,B=null,C=null,A=null;t.toolkit.physics&&(b={},e.Utilities.DeepCopyProperties(t.toolkit.physics,b)),t.toolkit.renderer&&(B={},e.Utilities.DeepCopyProperties(t.toolkit.renderer,B)),t.toolkit.collision&&(C={},e.Utilities.DeepCopyProperties(t.toolkit.collision,C)),t.toolkit.properties&&(A={},e.Utilities.DeepCopyProperties(t.toolkit.properties,A));var T=null;null!=t.toolkit.wheels&&t.toolkit.wheels.length>0&&(T=[],t.toolkit.wheels.forEach(function(t){if(null!=t){var i={};e.Utilities.DeepCopyProperties(t,i),T.push(i)}}));var M=null;null!=t.toolkit.components&&t.toolkit.components.length>0&&(M=[],t.toolkit.components.forEach(function(t){if(null!=t){var i=e.Utilities.FastJsonCopy(t);i.instance=null,M.push(i)}})),(n={}).parsed=!1,n.prefab=!1,n.buffers=null,n.lods=null,n.coverages=null,n.distances=null,n.handlers=null,n.instance=r,n.visible=o,n.visibility=a,n.billboard=s,n.tags=l,n.skin=u,n.bone=h,n.rootbone=c,n.rootpos=d,n.rootrot=m,n.group=p,n.layer=f,n.layername=g,n.navigation=y,n.lightmapped=v,n.lightmapuvs=S,n.animator=_,n.renderer=B,n.physics=b,n.wheels=T,n.collision=C,n.properties=A,n.components=M}null!=n&&(i={toolkit:n})}return i},t.FastJsonCopy=function(t){if(!t)return t;if(Array.isArray(t)){for(var i=[],n=t.length,r=0;r<n;r++)i.push(e.Utilities.FastJsonCopy(t[r]));return i}if("object"==typeof t){var o=Object.keys(t),a={};for(r=o.length-1;r>-1;r--){var s=o[r];a[s]=e.Utilities.FastJsonCopy(t[s])}return a}return t},t.DeepCopyProperties=function(t,i,n,r){for(var o in t)if(("_"!==o[0]||r&&-1!==r.indexOf(o))&&(!n||-1===n.indexOf(o))){var a=t[o],s=typeof a;if("function"!==s)if("object"===s)if(a instanceof Array){if(i[o]=[],a.length>0)if("object"==typeof a[0])for(var l=0;l<a.length;l++){var u=e.Utilities.CloneValue(a[l],i);-1===i[o].indexOf(u)&&i[o].push(u)}else i[o]=a.slice(0)}else i[o]=e.Utilities.CloneValue(a,i);else i[o]=a}},t.ValidateTransformMetadata=function(t){null==t.metadata&&(t.metadata={}),null==t.metadata.toolkit&&(t.metadata.toolkit={});var i=t.metadata.toolkit;e.Utilities.HasOwnProperty(i,"entity")||(t.metadata.toolkit.entity=!0),e.Utilities.HasOwnProperty(i,"parsed")||(t.metadata.toolkit.parsed=!1),e.Utilities.HasOwnProperty(i,"prefab")||(t.metadata.toolkit.prefab=!1),e.Utilities.HasOwnProperty(i,"instance")||(t.metadata.toolkit.instance=!1),e.Utilities.HasOwnProperty(i,"buffers")||(t.metadata.toolkit.buffers=null),e.Utilities.HasOwnProperty(i,"visible")||(t.metadata.toolkit.visible=!0),e.Utilities.HasOwnProperty(i,"visibility")||(t.metadata.toolkit.visibility=1),e.Utilities.HasOwnProperty(i,"billboard")||(t.metadata.toolkit.billboard=0),e.Utilities.HasOwnProperty(i,"tags")||(t.metadata.toolkit.tags="Untagged Layer0"),e.Utilities.HasOwnProperty(i,"skin")||(t.metadata.toolkit.skin=!1),e.Utilities.HasOwnProperty(i,"bone")||(t.metadata.toolkit.bone=null),e.Utilities.HasOwnProperty(i,"rootbone")||(t.metadata.toolkit.rootbone=!1),e.Utilities.HasOwnProperty(i,"rootpos")||(t.metadata.toolkit.rootpos=null),e.Utilities.HasOwnProperty(i,"rootrot")||(t.metadata.toolkit.rootrot=null),e.Utilities.HasOwnProperty(i,"group")||(t.metadata.toolkit.group="Untagged"),e.Utilities.HasOwnProperty(i,"layer")||(t.metadata.toolkit.layer=0),e.Utilities.HasOwnProperty(i,"layername")||(t.metadata.toolkit.layername="Default"),e.Utilities.HasOwnProperty(i,"navigation")||(t.metadata.toolkit.navigation=null),e.Utilities.HasOwnProperty(i,"lightmapped")||(t.metadata.toolkit.lightmapped=!1),e.Utilities.HasOwnProperty(i,"lightmapuvs")||(t.metadata.toolkit.lightmapuvs=!1),e.Utilities.HasOwnProperty(i,"animator")||(t.metadata.toolkit.animator=null),e.Utilities.HasOwnProperty(i,"lods")||(t.metadata.toolkit.lods=null),e.Utilities.HasOwnProperty(i,"coverages")||(t.metadata.toolkit.coverages=null),e.Utilities.HasOwnProperty(i,"distances")||(t.metadata.toolkit.distances=null),e.Utilities.HasOwnProperty(i,"handlers")||(t.metadata.toolkit.handlers=null),e.Utilities.HasOwnProperty(i,"physics")||(t.metadata.toolkit.physics=null),e.Utilities.HasOwnProperty(i,"wheels")||(t.metadata.toolkit.wheels=null),e.Utilities.HasOwnProperty(i,"renderer")||(t.metadata.toolkit.renderer=null),e.Utilities.HasOwnProperty(i,"collision")||(t.metadata.toolkit.collision=null),e.Utilities.HasOwnProperty(i,"properties")||(t.metadata.toolkit.properties=null),e.Utilities.HasOwnProperty(i,"components")||(t.metadata.toolkit.components=null)},t.UpVector=BABYLON.Vector3.Up(),t.AuxVector=BABYLON.Vector3.Zero(),t.ZeroVector=BABYLON.Vector3.Zero(),t.TempMatrix=BABYLON.Matrix.Zero(),t.TempMatrix2=BABYLON.Matrix.Zero(),t.TempVector2=BABYLON.Vector2.Zero(),t.TempVector3=BABYLON.Vector3.Zero(),t.TempQuaternion=BABYLON.Quaternion.Zero(),t.TempQuaternion2=BABYLON.Quaternion.Zero(),t.TempQuaternion3=BABYLON.Quaternion.Zero(),t.TempDirectionBuffer=BABYLON.Vector3.Zero(),t.LoadingState=-1,t.OnPreloaderProgress=null,t.OnPreloaderComplete=null,t.LoaderItemsMarkedForDisposal=[],t}();e.Utilities=t}(n||(n={})),function(e){var t=function(t){function i(i,n){var r=t.call(this,i,n)||this;return r.terrainInfo=null,r.shader=r.getShaderName(),r.plugin=new e.UniversalTerrainMaterialPlugin(r,r.shader),r}return o(i,t),i.prototype.awake=function(){},i.prototype.update=function(){},i.prototype.getShaderName=function(){return"UniversalTerrainMaterial"},i.prototype.getTerrainInfo=function(){return this.terrainInfo},i}(e.CustomShaderMaterial);e.UniversalTerrainMaterial=t;var i=function(t){function i(e,i){var n=t.call(this,e,i,100,{UNIVERSALTERRAINMATERIAL:!1},!0,!0,!1)||this;return n.colorName="surfaceAlbedo",n.splatmapSampler="splatmapSampler",n.detailsSampler="detailsSampler",n.normalsSampler="normalsSampler",n.GLSL_CustomFragment=null,n.GLSL_CustomVertex=null,n.GLSL_VertexMainEnd=null,n.GLSL_FragmentUpdateColor=null,n.WGSL_CustomFragment=null,n.WGSL_CustomVertex=null,n.WGSL_VertexMainEnd=null,n.WGSL_FragmentUpdateColor=null,n}return o(i,t),i.prototype.isCompatible=function(e){return e===BABYLON.ShaderLanguage.WGSL||e===BABYLON.ShaderLanguage.GLSL},i.prototype.getClassName=function(){return"UniversalTerrainMaterialPlugin"},i.prototype.getCustomCode=function(t,i){var n=this.getCustomShaderMaterial().getTerrainInfo();if("vertex"===t){if(i===BABYLON.ShaderLanguage.WGSL)return null==this.WGSL_CustomVertex&&(this.WGSL_CustomVertex=this.WGSL_FormatTerrainVertexDefintions(n)),null==this.WGSL_VertexMainEnd&&(this.WGSL_VertexMainEnd=this.WGSL_FormatTerrainVertexMainEnd(n)),{CUSTOM_VERTEX_DEFINITIONS:this.WGSL_CustomVertex,CUSTOM_VERTEX_MAIN_END:this.WGSL_VertexMainEnd};if(i===BABYLON.ShaderLanguage.GLSL)return null==this.GLSL_CustomVertex&&(this.GLSL_CustomVertex=this.GLSL_FormatTerrainVertexDefintions(n)),null==this.GLSL_VertexMainEnd&&(this.GLSL_VertexMainEnd=this.GLSL_FormatTerrainVertexMainEnd(n)),{CUSTOM_VERTEX_DEFINITIONS:this.GLSL_CustomVertex,CUSTOM_VERTEX_MAIN_END:this.GLSL_VertexMainEnd}}else if("fragment"===t){if(i===BABYLON.ShaderLanguage.WGSL)return null==this.WGSL_CustomFragment&&(this.WGSL_CustomFragment=this.WGSL_FormatTerrainFragmentDefintions(n,this.splatmapSampler,this.detailsSampler,this.normalsSampler)),null==this.WGSL_FragmentUpdateColor&&(this.WGSL_FragmentUpdateColor=this.WGSL_FormatTerrainFragmentUpdateColor(n,this.colorName,this.splatmapSampler,this.detailsSampler,this.normalsSampler,e.SceneManager.TerrainColorCorrection)),{CUSTOM_FRAGMENT_DEFINITIONS:this.WGSL_CustomFragment,CUSTOM_FRAGMENT_BEFORE_LIGHTS:this.WGSL_FragmentUpdateColor};if(i===BABYLON.ShaderLanguage.GLSL)return null==this.GLSL_CustomFragment&&(this.GLSL_CustomFragment=this.GLSL_FormatTerrainFragmentDefintions(n,this.splatmapSampler,this.detailsSampler,this.normalsSampler)),null==this.GLSL_FragmentUpdateColor&&(this.GLSL_FragmentUpdateColor=this.GLSL_FormatTerrainFragmentUpdateColor(n,this.colorName,this.splatmapSampler,this.detailsSampler,this.normalsSampler,e.SceneManager.TerrainColorCorrection)),{CUSTOM_FRAGMENT_DEFINITIONS:this.GLSL_CustomFragment,CUSTOM_FRAGMENT_BEFORE_LIGHTS:this.GLSL_FragmentUpdateColor}}return null},i.prototype.getUniforms=function(e){var t=e===BABYLON.ShaderLanguage.WGSL;return this.vertexDefinitions=this.getCustomShaderMaterial().getCustomVertexCode(t),this.fragmentDefinitions=!0===t?this.getCustomShaderMaterial().getCustomFragmentCode(t):null,this.getCustomShaderMaterial().getCustomUniforms(t)},i.prototype.getSamplers=function(e){var t=this.getCustomShaderMaterial().getCustomSamplers();null!=t&&t.length>0&&e.push.apply(e,t)},i.prototype.getAttributes=function(e,t,i){var n=this.getCustomShaderMaterial().getCustomAttributes();null!=n&&n.length>0&&e.push.apply(e,n)},i.prototype.prepareDefines=function(e,t,i){this.getIsEnabled()&&this.getCustomShaderMaterial().prepareCustomDefines(e)},i.prototype.bindForSubMesh=function(e,t,i,n){this.getIsEnabled()&&this.getCustomShaderMaterial().updateCustomBindings(e)},i.prototype.WGSL_FormatTerrainVertexDefintions=function(e){var t="";return null!=e&&null!=e.textureAtlas&&null!=e.splatmapAtlas&&e.splatmapCount>0&&(t="\r\n#ifndef TERRAIN_VERTEX_DEFINITIONS\r\n\r\n#define TERRAIN_VERTEX_DEFINITIONS\r\n\r\nvarying vSplatmapUV: vec2<f32>;\r\n\r\n#endif\r\n\r\n"),t},i.prototype.WGSL_FormatTerrainVertexMainEnd=function(e){var t="";return null!=e&&null!=e.textureAtlas&&null!=e.splatmapAtlas&&e.splatmapCount>0&&(t="\r\n#ifndef TERRAIN_VERTEX_MAIN_END\r\n\r\n#define TERRAIN_VERTEX_MAIN_END\r\n\r\n#ifdef UV1\r\nvertexOutputs.vSplatmapUV = uvUpdated;\r\n#endif\r\n\r\n#endif\r\n\r\n"),t},i.prototype.WGSL_FormatTerrainFragmentDefintions=function(e,t,i,n){var r="";return null!=e&&null!=e.textureAtlas&&null!=e.splatmapAtlas&&e.splatmapCount>0&&(r="\r\n#ifndef TERRAIN_FRAGMENT_DEFNITIONS\r\n\r\n#define TERRAIN_FRAGMENT_DEFNITIONS\r\n\r\nvarying vSplatmapUV: vec2<f32>;\r\n\r\nfn srgb_to_linear(c: vec3<f32>) -> vec3<f32>\r\n{\r\n return pow(c, vec3<f32>(2.2));\r\n}\r\n\r\nfn linear_to_srgb(c: vec3<f32>) -> vec3<f32>\r\n{\r\n return pow(c, vec3<f32>(1.0 / 2.2));\r\n}\r\n\r\nfn calculateMipmapLevel(uvs: vec2<f32>, size: vec2<f32>) -> f32\r\n{\r\n let dx: vec2<f32> = dpdx(uvs * size.x);\r\n let dy: vec2<f32> = dpdy(uvs * size.y);\r\n let d: f32 = max(dot(dx, dx), dot(dy, dy));\r\n return (0.4 * log2(d));\r\n}\r\n\r\nfn sampleTextureAtlas2D(atlas: texture_2d<f32>, sampler: sampler, gamma: f32, tile: vec2<f32>, rect: vec4<f32>, uvs: vec2<f32>, lod: f32) -> vec4<f32>\r\n{\r\n var level: f32 = lod;\r\n if (level < 0.0) {\r\n level = clamp(calculateMipmapLevel(uvs, vec2(tile.x, tile.x)), 0.0, tile.y);\r\n }\r\n let size: f32 = pow(2.0, tile.y - level);\r\n let sizex: f32 = size / rect.z;\r\n let sizey: f32 = size / rect.w;\r\n var uv: vec2<f32> = fract(uvs);\r\n uv.x = uv.x * ((sizex * rect.z - 1.0) / sizex) + 0.5 / sizex + rect.z * rect.x;\r\n uv.y = uv.y * ((sizey * rect.w - 1.0) / sizey) + 0.5 / sizey + rect.w * rect.y;\r\n var color: vec4<f32> = textureSampleLevel(atlas, sampler, uv, level);\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\nfn sampleSplatmapAtlas2D(atlas: texture_2d<f32>, sampler: sampler, tile: vec2<f32>, rect: vec4<f32>, uvs: vec2<f32>) -> vec4<f32>\r\n{\r\n let size: f32 = pow(2.0, tile.y);\r\n\t let sizex: f32 = size / rect.z;\r\n\t let sizey: f32 = size / rect.w;\r\n\t var uv: vec2<f32> = uvs;\r\n\t uv.x = uv.x * ((sizex * rect.z - 1.0) / sizex) + 0.5 / sizex + rect.z * rect.x;\r\n\t uv.y = uv.y * ((sizey * rect.w - 1.0) / sizey) + 0.5 / sizey + rect.w * rect.y;\r\n return textureSample(atlas, sampler, uv);\r\n}\r\n\r\nfn blendSplatmapAtlasColors(splatmap: vec4<f32>, color1: vec4<f32>, color2: vec4<f32>, color3: vec4<f32>, color4: vec4<f32>, mixbuffer: vec3<f32>) -> vec3<f32>\r\n{\r\n let buffer1: vec3<f32> = mix(mixbuffer, color1.rgb, splatmap.r);\r\n let buffer2: vec3<f32> = mix(buffer1, color2.rgb, splatmap.g);\r\n let buffer3: vec3<f32> = mix(buffer2, color3.rgb, splatmap.b);\r\n return mix(buffer3, color4.rgb, splatmap.a);\r\n}\r\n\r\nfn perturbNormalSamplerColor(cotangentFrame: mat3x3<f32>, samplerColor: vec3<f32>, scale: f32) -> vec3<f32>\r\n{\r\n var map: vec3<f32> = samplerColor.xyz;\r\n map = map * 2.00787402 - 1.00787402;\r\n #ifdef NORMALXYSCALE\r\n map = normalize(map * vec3<f32>(scale, scale, 1.0));\r\n #endif\r\n return normalize(cotangentFrame * map);\r\n}\r\n#endif\r\n\r\n"),r},i.prototype.WGSL_FormatTerrainFragmentUpdateColor=function(e,t,i,n,r,o){void 0===o&&(o=1);var a="";if(null!=e&&null!=e.textureAtlas&&null!=e.splatmapAtlas&&e.splatmapCount>0){if(a="\r\n#ifndef TERRAIN_FRAGMENT_UPDATE_COLOR\r\n\r\n#define TERRAIN_FRAGMENT_UPDATE_COLOR\r\n\r\nvar normalsColor: vec3<f32> = vec3<f32>(0.5, 0.5, 1.0);\r\nvar normalsBuffer: vec3<f32> = normalW.rgb;\r\nvar splatmapBuffer: vec3<f32> = "+t+".rgb;\r\nvar autoMipMapLevel: f32 = -1.0;\r\nvar normalCorrection: f32 = 1.0;\r\nvar detailCorrection: f32 = "+o.toFixed(4)+";\r\n\r\n#if defined(ALBEDO) && defined("+i.toUpperCase()+") && defined("+n.toUpperCase()+")\r\n\r\n// Reset Normal Values\r\n#if defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC)\r\n uvOffset = vec2<f32>(0.0, 0.0);\r\n #ifdef NORMAL\r\n normalW = normalize(input.vNormalW);\r\n #else\r\n normalW = normalize(cross(dpdx(input.vPositionW), dpdy(input.vPositionW))) * scene.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(CLEARCOAT_BUMP) && defined(TANGENT) && defined(NORMAL)\r\n TBN = vTBN;\r\n #else\r\n TBN = cotangent_frame(normalW, input.vPositionW, fragmentInputs.vSplatmapUV, vec2<f32>(1.0, 1.0));\r\n #endif\r\n #elif defined(ANISOTROPIC)\r\n #if defined(CLEARCOAT_BUMP) && defined(TANGENT) && defined(NORMAL)\r\n TBN = vTBN;\r\n #else\r\n TBN = cotangent_frame(normalW, input.vPositionW, fragmentInputs.vSplatmapUV, vec2<f32>(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\nlet splatTileSize: f32 = "+e.splatmapAtlas[2].toFixed(4)+";\r\nlet splatTileBits: f32 = "+e.splatmapAtlas[3].toFixed(4)+";\r\nlet detailTileSize: f32 = "+e.textureAtlas[2].toFixed(4)+";\r\nlet detailTileBits: f32 = "+e.textureAtlas[3].toFixed(4)+";\r\n\r\n// Sample splatmap textures\r\n",e.splatmapCount>0){var s=0;a+="normalsBuffer = vec3<f32>(0.0,0.0,0.0);\r\n";for(var l=0;l<e.splatmapCount;l++){s=4*l;var u=e["splatmapRect"+l];if(a+="var splatmapRect"+l+": vec4<f32> = vec4<f32>("+u[0].toFixed(4)+", "+u[1].toFixed(4)+", "+u[2].toFixed(4)+", "+u[3].toFixed(4)+");\r\n",a+="var splatmapAlbedo"+l+": vec4<f32> = sampleSplatmapAtlas2D("+i+", "+i+"Sampler, vec2<f32>(splatTileSize, splatTileBits), splatmapRect"+l+", (fragmentInputs.vSplatmapUV + uvOffset));\r\n",a+="var textureAlbedo"+(s+0)+": vec4<f32> = vec4<f32>(0.0, 0.0, 0.0, 1.0);\r\n",a+="var textureAlbedo"+(s+1)+": vec4<f32> = vec4<f32>(0.0, 0.0, 0.0, 1.0);\r\n",a+="var textureAlbedo"+(s+2)+": vec4<f32> = vec4<f32>(0.0, 0.0, 0.0, 1.0);\r\n",a+="var textureAlbedo"+(s+3)+": vec4<f32> = vec4<f32>(0.0, 0.0, 0.0, 1.0);\r\n",e["textureRect"+(s+0)]){var h=e["textureRect"+(s+0)],c=e["textureInfo"+(s+0)];a+="var textureRect"+(s+0)+": vec4<f32> = vec4<f32>("+h[0].toFixed(4)+", "+h[1].toFixed(4)+", "+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",a+="var textureScale"+(s+0)+": vec2<f32> = vec2<f32>("+c[0].toFixed(4)+", "+c[1].toFixed(4)+");\r\n",a+="var textureOffset"+(s+0)+": vec2<f32> = vec2<f32>("+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",a+="var textureTileUV"+(s+0)+": vec2<f32> = ((fragmentInputs.vSplatmapUV + textureOffset"+(s+0)+") * textureScale"+(s+0)+");\r\n",a+="textureAlbedo"+(s+0)+" = sampleTextureAtlas2D("+n+", "+n+"Sampler, detailCorrection, vec2<f32>(detailTileSize, detailTileBits), textureRect"+(s+0)+", textureTileUV"+(s+0)+", autoMipMapLevel);\r\n"}e["textureRect"+(s+1)]&&(h=e["textureRect"+(s+1)],c=e["textureInfo"+(s+1)],a+="var textureRect"+(s+1)+": vec4<f32> = vec4<f32>("+h[0].toFixed(4)+", "+h[1].toFixed(4)+", "+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",a+="var textureScale"+(s+1)+": vec2<f32> = vec2<f32>("+c[0].toFixed(4)+", "+c[1].toFixed(4)+");\r\n",a+="var textureOffset"+(s+1)+": vec2<f32> = vec2<f32>("+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",a+="var textureTileUV"+(s+1)+": vec2<f32> = ((fragmentInputs.vSplatmapUV + textureOffset"+(s+1)+") * textureScale"+(s+1)+");\r\n",a+="textureAlbedo"+(s+1)+" = sampleTextureAtlas2D("+n+", "+n+"Sampler, detailCorrection, vec2<f32>(detailTileSize, detailTileBits), textureRect"+(s+1)+", textureTileUV"+(s+1)+", autoMipMapLevel);\r\n"),e["textureRect"+(s+2)]&&(h=e["textureRect"+(s+2)],c=e["textureInfo"+(s+2)],a+="var textureRect"+(s+2)+": vec4<f32> = vec4<f32>("+h[0].toFixed(4)+", "+h[1].toFixed(4)+", "+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",a+="var textureScale"+(s+2)+": vec2<f32> = vec2<f32>("+c[0].toFixed(4)+", "+c[1].toFixed(4)+");\r\n",a+="var textureOffset"+(s+2)+": vec2<f32> = vec2<f32>("+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",a+="var textureTileUV"+(s+2)+": vec2<f32> = ((fragmentInputs.vSplatmapUV + textureOffset"+(s+2)+") * textureScale"+(s+2)+");\r\n",a+="textureAlbedo"+(s+2)+" = sampleTextureAtlas2D("+n+", "+n+"Sampler, detailCorrection, vec2<f32>(detailTileSize, detailTileBits), textureRect"+(s+2)+", textureTileUV"+(s+2)+", autoMipMapLevel);\r\n"),e["textureRect"+(s+3)]&&(h=e["textureRect"+(s+3)],c=e["textureInfo"+(s+3)],a+="var textureRect"+(s+3)+": vec4<f32> = vec4<f32>("+h[0].toFixed(4)+", "+h[1].toFixed(4)+", "+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",a+="var textureScale"+(s+3)+": vec2<f32> = vec2<f32>("+c[0].toFixed(4)+", "+c[1].toFixed(4)+");\r\n",a+="var textureOffset"+(s+3)+": vec2<f32> = vec2<f32>("+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",a+="var textureTileUV"+(s+3)+": vec2<f32> = ((fragmentInputs.vSplatmapUV + textureOffset"+(s+3)+") * textureScale"+(s+3)+");\r\n",a+="textureAlbedo"+(s+3)+" = sampleTextureAtlas2D("+n+", "+n+"Sampler, detailCorrection, vec2<f32>(detailTileSize, detailTileBits), textureRect"+(s+3)+", textureTileUV"+(s+3)+", autoMipMapLevel);\r\n"),a+="splatmapBuffer = blendSplatmapAtlasColors(splatmapAlbedo"+l+", textureAlbedo"+(s+0)+", textureAlbedo"+(s+1)+", textureAlbedo"+(s+2)+", textureAlbedo"+(s+3)+", splatmapBuffer);\r\n",a+="#if defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC)\r\n",a+=" #if defined("+r.toUpperCase()+")\r\n",a+=" var normalColor"+(s+0)+": vec4<f32> = vec4<f32>(0.0, 0.0, 0.0, 1.0);\r\n",a+=" var normalColor"+(s+1)+": vec4<f32> = vec4<f32>(0.0, 0.0, 0.0, 1.0);\r\n",a+=" var normalColor"+(s+2)+": vec4<f32> = vec4<f32>(0.0, 0.0, 0.0, 1.0);\r\n",a+=" var normalColor"+(s+3)+": vec4<f32> = vec4<f32>(0.0, 0.0, 0.0, 1.0);\r\n",e["textureRect"+(s+0)]&&(a+=" var normalScale"+(s+0)+": f32 = "+e["normalsScale"+(s+0)].toFixed(4)+";\r\n",a+=" normalColor"+(s+0)+" = sampleTextureAtlas2D("+r+", "+r+"Sampler, normalCorrection, vec2<f32>(detailTileSize, detailTileBits), textureRect"+(s+0)+", textureTileUV"+(s+0)+", autoMipMapLevel);\r\n",a+=" normalColor"+(s+0)+" = vec4<f32>(perturbNormalSamplerColor(TBN, normalColor"+(s+0)+".rgb, normalScale"+(s+0)+"), 1.0);\r\n"),e["textureRect"+(s+1)]&&(a+=" var normalScale"+(s+1)+": f32 = "+e["normalsScale"+(s+1)].toFixed(4)+";\r\n",a+=" normalColor"+(s+1)+" = sampleTextureAtlas2D("+r+", "+r+"Sampler, normalCorrection, vec2<f32>(detailTileSize, detailTileBits), textureRect"+(s+1)+", textureTileUV"+(s+1)+", autoMipMapLevel);\r\n",a+=" normalColor"+(s+1)+" = vec4<f32>(perturbNormalSamplerColor(TBN, normalColor"+(s+1)+".rgb, normalScale"+(s+1)+"), 1.0);\r\n"),e["textureRect"+(s+2)]&&(a+=" var normalScale"+(s+2)+": f32 = "+e["normalsScale"+(s+2)].toFixed(4)+";\r\n",a+=" normalColor"+(s+2)+" = sampleTextureAtlas2D("+r+", "+r+"Sampler, normalCorrection, vec2<f32>(detailTileSize, detailTileBits), textureRect"+(s+2)+", textureTileUV"+(s+2)+", autoMipMapLevel);\r\n",a+=" normalColor"+(s+2)+" = vec4<f32>(perturbNormalSamplerColor(TBN, normalColor"+(s+2)+".rgb, normalScale"+(s+2)+"), 1.0);\r\n"),e["textureRect"+(s+3)]&&(a+=" var normalScale"+(s+3)+": f32 = "+e["normalsScale"+(s+3)].toFixed(4)+";\r\n",a+=" normalColor"+(s+3)+" = sampleTextureAtlas2D("+r+", "+r+"Sampler, normalCorrection, vec2<f32>(detailTileSize, detailTileBits), textureRect"+(s+3)+", textureTileUV"+(s+3)+", autoMipMapLevel);\r\n",a+=" normalColor"+(s+3)+" = vec4<f32>(perturbNormalSamplerColor(TBN, normalColor"+(s+3)+".rgb, normalScale"+(s+3)+"), 1.0);\r\n"),a+=" normalsBuffer = blendSplatmapAtlasColors(splatmapAlbedo"+l+", normalColor"+(s+0)+", normalColor"+(s+1)+", normalColor"+(s+2)+", normalColor"+(s+3)+", normalsBuffer);\r\n",a+=" #endif\r\n",a+="#endif\r\n",a+="\r\n"}}a+="// Update Color Values\r\n"+t+" = splatmapBuffer.rgb;\r\n#if defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC)\r\n #if defined("+r.toUpperCase()+")\r\n normalW = normalsBuffer.rgb;\r\n #endif\r\n #if defined(FORCENORMALFORWARD) && defined(NORMAL)\r\n var faceNormal: vec3<f32> = normalize(cross(dpdx(input.vPositionW), dpdy(input.vPositionW))) * scene.vEyePosition.w;\r\n #if defined(TWOSIDEDLIGHTING)\r\n faceNormal = select(-faceNormal, faceNormal, fragmentInputs.frontFacing)\r\n #endif\r\n normalW *= sign(dot(normalW, faceNormal));\r\n #endif\r\n #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\r\n normalW = select(-normalW, normalW, fragmentInputs.frontFacing);\r\n #endif\r\n#endif\r\n\r\n#endif\r\n\r\n#endif\r\n\r\n"}return a},i.prototype.GLSL_FormatTerrainVertexDefintions=function(e){var t="";return null!=e&&null!=e.textureAtlas&&null!=e.splatmapAtlas&&e.splatmapCount>0&&(t="\r\n#ifndef TERRAIN_VERTEX_DEFINITIONS\r\n\r\n#define TERRAIN_VERTEX_DEFINITIONS\r\n\r\nvarying vec2 vSplatmapUV;\r\n\r\n#endif\r\n\r\n"),t},i.prototype.GLSL_FormatTerrainVertexMainEnd=function(e){var t="";return null!=e&&null!=e.textureAtlas&&null!=e.splatmapAtlas&&e.splatmapCount>0&&(t="\r\n#ifndef TERRAIN_VERTEX_MAIN_END\r\n\r\n#define TERRAIN_VERTEX_MAIN_END\r\n\r\n#ifdef UV1\r\nvSplatmapUV = uv;\r\n#endif\r\n\r\n#endif\r\n\r\n"),t},i.prototype.GLSL_FormatTerrainFragmentDefintions=function(e,t,i,n){var r="";return null!=e&&null!=e.textureAtlas&&null!=e.splatmapAtlas&&e.splatmapCount>0&&(r="\r\n#ifndef TERRAIN_FRAGMENT_DEFNITIONS\r\n\r\n#define TERRAIN_FRAGMENT_DEFNITIONS\r\n\r\nvarying vec2 vSplatmapUV;\r\n\r\nvec3 srgb_to_linear(const in vec3 c)\r\n{\r\n return pow(c, vec3(2.2));\r\n}\r\n\r\nvec3 linear_to_srgb(const in vec3 c)\r\n{\r\n return pow(c, vec3(1.0 / 2.2));\r\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#endif\r\n\r\n"),r},i.prototype.GLSL_FormatTerrainFragmentUpdateColor=function(e,t,i,n,r,o){void 0===o&&(o=1);var a="";if(null!=e&&null!=e.textureAtlas&&null!=e.splatmapAtlas&&e.splatmapCount>0){if(a="\r\n#ifndef TERRAIN_FRAGMENT_UPDATE_COLOR\r\n\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 = "+o.toFixed(4)+";\r\n\r\n#if defined(ALBEDO) && defined("+i.toUpperCase()+") && defined("+n.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",e.splatmapCount>0){var s=0;a+="normalsBuffer = vec3(0.0,0.0,0.0);\r\n";for(var l=0;l<e.splatmapCount;l++){s=4*l;var u=e["splatmapRect"+l];if(a+="vec4 splatmapRect"+l+" = vec4("+u[0].toFixed(4)+", "+u[1].toFixed(4)+", "+u[2].toFixed(4)+", "+u[3].toFixed(4)+");\r\n",a+="vec4 splatmapAlbedo"+l+" = sampleSplatmapAtlas2D("+i+", vec2(splatTileSize, splatTileBits), splatmapRect"+l+", (vSplatmapUV + uvOffset));\r\n",a+="vec4 textureAlbedo"+(s+0)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",a+="vec4 textureAlbedo"+(s+1)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",a+="vec4 textureAlbedo"+(s+2)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",a+="vec4 textureAlbedo"+(s+3)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",e["textureRect"+(s+0)]){var h=e["textureRect"+(s+0)],c=e["textureInfo"+(s+0)];a+="vec4 textureRect"+(s+0)+" = vec4("+h[0].toFixed(4)+", "+h[1].toFixed(4)+", "+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",a+="vec2 textureScale"+(s+0)+" = vec2("+c[0].toFixed(4)+", "+c[1].toFixed(4)+");\r\n",a+="vec2 textureOffset"+(s+0)+" = vec2("+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",a+="vec2 textureTileUV"+(s+0)+" = ((vSplatmapUV + textureOffset"+(s+0)+") * textureScale"+(s+0)+");\r\n",a+="textureAlbedo"+(s+0)+" = sampleTextureAtlas2D("+n+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+0)+", textureTileUV"+(s+0)+", autoMipMapLevel);\r\n"}e["textureRect"+(s+1)]&&(h=e["textureRect"+(s+1)],c=e["textureInfo"+(s+1)],a+="vec4 textureRect"+(s+1)+" = vec4("+h[0].toFixed(4)+", "+h[1].toFixed(4)+", "+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",a+="vec2 textureScale"+(s+1)+" = vec2("+c[0].toFixed(4)+", "+c[1].toFixed(4)+");\r\n",a+="vec2 textureOffset"+(s+1)+" = vec2("+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",a+="vec2 textureTileUV"+(s+1)+" = ((vSplatmapUV + textureOffset"+(s+1)+") * textureScale"+(s+1)+");\r\n",a+="textureAlbedo"+(s+1)+" = sampleTextureAtlas2D("+n+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+1)+", textureTileUV"+(s+1)+", autoMipMapLevel);\r\n"),e["textureRect"+(s+2)]&&(h=e["textureRect"+(s+2)],c=e["textureInfo"+(s+2)],a+="vec4 textureRect"+(s+2)+" = vec4("+h[0].toFixed(4)+", "+h[1].toFixed(4)+", "+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",a+="vec2 textureScale"+(s+2)+" = vec2("+c[0].toFixed(4)+", "+c[1].toFixed(4)+");\r\n",a+="vec2 textureOffset"+(s+2)+" = vec2("+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",a+="vec2 textureTileUV"+(s+2)+" = ((vSplatmapUV + textureOffset"+(s+2)+") * textureScale"+(s+2)+");\r\n",a+="textureAlbedo"+(s+2)+" = sampleTextureAtlas2D("+n+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+2)+", textureTileUV"+(s+2)+", autoMipMapLevel);\r\n"),e["textureRect"+(s+3)]&&(h=e["textureRect"+(s+3)],c=e["textureInfo"+(s+3)],a+="vec4 textureRect"+(s+3)+" = vec4("+h[0].toFixed(4)+", "+h[1].toFixed(4)+", "+h[2].toFixed(4)+", "+h[3].toFixed(4)+");\r\n",a+="vec2 textureScale"+(s+3)+" = vec2("+c[0].toFixed(4)+", "+c[1].toFixed(4)+");\r\n",a+="vec2 textureOffset"+(s+3)+" = vec2("+c[2].toFixed(4)+", "+c[3].toFixed(4)+");\r\n",a+="vec2 textureTileUV"+(s+3)+" = ((vSplatmapUV + textureOffset"+(s+3)+") * textureScale"+(s+3)+");\r\n",a+="textureAlbedo"+(s+3)+" = sampleTextureAtlas2D("+n+", detailCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+3)+", textureTileUV"+(s+3)+", autoMipMapLevel);\r\n"),a+="splatmapBuffer = blendSplatmapAtlasColors(splatmapAlbedo"+l+", textureAlbedo"+(s+0)+", textureAlbedo"+(s+1)+", textureAlbedo"+(s+2)+", textureAlbedo"+(s+3)+", splatmapBuffer);\r\n",a+="#if defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC)\r\n",a+=" #if defined("+r.toUpperCase()+")\r\n",a+=" vec4 normalColor"+(s+0)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",a+=" vec4 normalColor"+(s+1)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",a+=" vec4 normalColor"+(s+2)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",a+=" vec4 normalColor"+(s+3)+" = vec4(0.0, 0.0, 0.0, 1.0);\r\n",e["textureRect"+(s+0)]&&(a+=" float normalScale"+(s+0)+" = "+e["normalsScale"+(s+0)].toFixed(4)+";\r\n",a+=" normalColor"+(s+0)+" = sampleTextureAtlas2D("+r+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+0)+", textureTileUV"+(s+0)+", autoMipMapLevel);\r\n",a+=" normalColor"+(s+0)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(s+0)+".rgb, normalScale"+(s+0)+");\r\n"),e["textureRect"+(s+1)]&&(a+=" float normalScale"+(s+1)+" = "+e["normalsScale"+(s+1)].toFixed(4)+";\r\n",a+=" normalColor"+(s+1)+" = sampleTextureAtlas2D("+r+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+1)+", textureTileUV"+(s+1)+", autoMipMapLevel);\r\n",a+=" normalColor"+(s+1)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(s+1)+".rgb, normalScale"+(s+1)+");\r\n"),e["textureRect"+(s+2)]&&(a+=" float normalScale"+(s+2)+" = "+e["normalsScale"+(s+2)].toFixed(4)+";\r\n",a+=" normalColor"+(s+2)+" = sampleTextureAtlas2D("+r+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+2)+", textureTileUV"+(s+2)+", autoMipMapLevel);\r\n",a+=" normalColor"+(s+2)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(s+2)+".rgb, normalScale"+(s+2)+");\r\n"),e["textureRect"+(s+3)]&&(a+=" float normalScale"+(s+3)+" = "+e["normalsScale"+(s+3)].toFixed(4)+";\r\n",a+=" normalColor"+(s+3)+" = sampleTextureAtlas2D("+r+", normalCorrection, vec2(detailTileSize, detailTileBits), textureRect"+(s+3)+", textureTileUV"+(s+3)+", autoMipMapLevel);\r\n",a+=" normalColor"+(s+3)+".rgb = perturbNormalSamplerColor(TBN, normalColor"+(s+3)+".rgb, normalScale"+(s+3)+");\r\n"),a+=" normalsBuffer = blendSplatmapAtlasColors(splatmapAlbedo"+l+", normalColor"+(s+0)+", normalColor"+(s+1)+", normalColor"+(s+2)+", normalColor"+(s+3)+", normalsBuffer);\r\n",a+=" #endif\r\n",a+="#endif\r\n",a+="\r\n"}}a+="// Update Color Values\r\n"+t+" = splatmapBuffer.rgb;\r\n#if defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC)\r\n #if defined("+r.toUpperCase()+")\r\n normalW = normalsBuffer.rgb;\r\n #endif\r\n #if defined(FORCENORMALFORWARD) && defined(NORMAL)\r\n vec3 faceNormal = normalize(cross(dFdx(vPositionW), dFdy(vPositionW))) * vEyePosition.w;\r\n #if defined(TWOSIDEDLIGHTING)\r\n faceNormal = gl_FrontFacing ? faceNormal : -faceNormal;\r\n #endif\r\n normalW *= sign(dot(normalW, faceNormal));\r\n #endif\r\n #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\r\n normalW = gl_FrontFacing ? normalW : -normalW;\r\n #endif\r\n#endif\r\n\r\n#endif\r\n\r\n#endif\r\n\r\n"}return a},i}(e.CustomShaderMaterialPlugin);e.UniversalTerrainMaterialPlugin=i,e.SceneManager.RegisterClass("TOOLKIT.UniversalTerrainMaterial",t),e.SceneManager.RegisterClass("TOOLKIT.UniversalTerrainMaterialPlugin",i)}(n||(n={})),function(e){var t=function(t){function i(i,n){var r=t.call(this,i,n)||this;return r._windTimeAccum=0,r._lastUpdateFrame=-1,r.shader=r.getShaderName(),r.plugin=new e.GrassStandardMaterialPlugin(r,r.shader),r.addFloatUniform("g_maxDistance",0),r.addFloatUniform("g_fadeStart",0),r.addFloatUniform("g_alphaCutoff",.3),r.addFloatUniform("g_windTime",0),r.addFloatUniform("g_waveSpeed",.5),r.addFloatUniform("g_waveSize",.5),r.addFloatUniform("g_windAmount",.5),r.addVector4Uniform("g_windTint",new BABYLON.Vector4(.7,.6,.5,0)),r.addFloatUniform("g_shadowIntensity",.7),r.emissiveColor=new BABYLON.Color3(.7,.7,.7),r._windTimeAccum=0,r}return o(i,t),i.prototype.awake=function(){},i.prototype.update=function(){var t;try{var i=this.getScene(),n=i.getFrameId();if(this._lastUpdateFrame===n)return;this._lastUpdateFrame=n;var r=e.SceneManager.GetDeltaSeconds(i),o=Math.min(r,1/30);(null!==(t=this.getFloatValue("g_waveSpeed"))&&void 0!==t?t:0)>0&&(this._windTimeAccum=this._windTimeAccum+o,this.setFloatValue("g_windTime",this._windTimeAccum))}catch(e){}},i.prototype.getShaderName=function(){return"GrassStandardMaterial"},i.prototype.getMaxDistance=function(){return this.getFloatValue("g_maxDistance")},i.prototype.setMaxDistance=function(e){this.setFloatValue("g_maxDistance",e)},i.prototype.getFadeStart=function(){return this.getFloatValue("g_fadeStart")},i.prototype.setFadeStart=function(e){this.setFloatValue("g_fadeStart",e)},i.prototype.getWaveSpeed=function(){return this.getFloatValue("g_waveSpeed")},i.prototype.setWaveSpeed=function(e){this.setFloatValue("g_waveSpeed",e)},i.prototype.getWaveSize=function(){return this.getFloatValue("g_waveSize")},i.prototype.setWaveSize=function(e){this.setFloatValue("g_waveSize",e)},i.prototype.getWindAmount=function(){return this.getFloatValue("g_windAmount")},i.prototype.setWindAmount=function(e){this.setFloatValue("g_windAmount",e)},i.prototype.getWindTint=function(){return this.getVector4Value("g_windTint")},i.prototype.setWindTint=function(e){this.setVector4Value("g_windTint",e)},i.prototype.getShadowIntensity=function(){return this.getFloatValue("g_shadowIntensity")},i.prototype.setShadowIntensity=function(e){var t=Math.max(0,Math.min(1,e));this.setFloatValue("g_shadowIntensity",t),this.emissiveColor=new BABYLON.Color3(t,t,t)},i}(e.StandardShaderMaterial);e.GrassStandardMaterial=t;var i=function(e){function t(t,i){return e.call(this,t,i,110,{GRASSSTANDARDMATERIAL:!1})||this}return o(t,e),t.prototype.isCompatible=function(e){return e===BABYLON.ShaderLanguage.WGSL||e===BABYLON.ShaderLanguage.GLSL},t.prototype.getCustomCode=function(e,t){if("vertex"===e){if(t===BABYLON.ShaderLanguage.WGSL)return{CUSTOM_VERTEX_DEFINITIONS:this.getWGSLVaryingDefinitions(),CUSTOM_VERTEX_MAIN_END:this.getWGSLVertexMainEnd(),CUSTOM_VERTEX_UPDATE_WORLDPOS:this.getWGSLVertexWorldPos()};if(t===BABYLON.ShaderLanguage.GLSL)return{CUSTOM_VERTEX_DEFINITIONS:this.getGLSLVertexDefinitions(),CUSTOM_VERTEX_MAIN_END:this.getGLSLVertexMainEnd(),CUSTOM_VERTEX_UPDATE_WORLDPOS:this.getGLSLVertexWorldPos()}}return"fragment"===e?t===BABYLON.ShaderLanguage.WGSL?{CUSTOM_FRAGMENT_DEFINITIONS:this.getWGSLVaryingDefinitions(),CUSTOM_FRAGMENT_BEFORE_FOG:this.getWGSLFragmentCode()}:{CUSTOM_FRAGMENT_DEFINITIONS:this.getGLSLFragmentDefinitions(),CUSTOM_FRAGMENT_BEFORE_FOG:this.getGLSLFragmentCode()}:null},t.prototype.getWGSLVertexMainEnd=function(){return""},t.prototype.getWGSLVaryingDefinitions=function(){return"\n #ifndef TOOLKIT_GRASS_VARYINGS\n #define TOOLKIT_GRASS_VARYINGS\n varying vGrassFade: f32;\n #endif\n "},t.prototype.getWGSLVertexWorldPos=function(){return"\n // Get instance world position (center of grass blade)\n let centerW = (finalWorld * vec4f(0.0, 0.0, 0.0, 1.0)).xyz;\n let up = vec3f(0.0, 1.0, 0.0);\n \n // Extract instance basis vectors and scale\n let right = normalize(finalWorld[0].xyz);\n let forward = normalize(finalWorld[2].xyz);\n let sx = length(finalWorld[0].xyz);\n let sy = length(finalWorld[1].xyz);\n let sz = length(finalWorld[2].xyz);\n \n // Compute world position of this vertex BEFORE waving\n // This is critical - Unity uses the actual vertex world position for wave phase\n let localPos = positionUpdated;\n var worldVertexPos = centerW + right * (localPos.x * sx) + up * (localPos.y * sy) + forward * (localPos.z * sz);\n \n // ============================================================\n // UNITY TerrainWaveGrass EXACT IMPLEMENTATION\n // From TerrainEngine.cginc lines 80-125\n // ============================================================\n \n // Wave amount is based on vertex height (top vertices wave more)\n // In Unity: v.color.a for mesh grass, tangent.y for billboard\n // Here we use the local Y position as the wave factor\n let waveAmount = max(localPos.y, 0.0) * uniforms.g_windAmount;\n \n // Wave constants tuned for LARGE, GENTLE rolling waves like Unity\n // Key insight: Unity's grass shows broad bands spanning large terrain sections\n // NOT tight ripples - spatial frequency must be very LOW\n let waveSize = uniforms.g_waveSize;\n \n // Spatial frequencies reduced by 10x from Unity's original values\n // This creates wavelengths of ~50-100 units instead of ~5-10 units\n // Result: 1-2 visible wave crests across terrain instead of 10-20\n let waveXSize = vec4f(0.0012, 0.002, 0.006, 0.0024) * waveSize;\n let waveZSize = vec4f(0.0006, 0.002, 0.002, 0.005) * waveSize;\n \n // Temporal speed reduced for smooth, gentle motion\n // Original Unity values divided by 10 for slower wave travel\n let waveSpeed = vec4f(0.03, 0.05, 0.04, 0.12);\n \n // Movement amplitudes - these control how far grass sways\n // Increased 5x from previous values to get visible bending like Unity\n // Unity grass shows significant physical displacement (20-30 degree lean)\n let waveXmove = vec4f(0.12, 0.2, -0.6, 0.48);\n let waveZmove = vec4f(0.06, 0.2, -0.2, 1.0);\n \n // Compute wave phases from BLADE CENTER position - this creates spatial bands\n // Using centerW ensures all vertices of the same blade have identical phase\n // The height-based waveAmount controls per-vertex displacement amount\n // Unity: waves = vertex.x * _waveXSize + vertex.z * _waveZSize + time * waveSpeed\n var waves = vec4f(\n centerW.x * waveXSize.x + centerW.z * waveZSize.x,\n centerW.x * waveXSize.y + centerW.z * waveZSize.y,\n centerW.x * waveXSize.z + centerW.z * waveZSize.z,\n centerW.x * waveXSize.w + centerW.z * waveZSize.w\n );\n \n // Add time component - this makes waves travel\n let windTime = uniforms.g_windTime * uniforms.g_waveSpeed;\n waves = waves + vec4f(\n windTime * waveSpeed.x,\n windTime * waveSpeed.y,\n windTime * waveSpeed.z,\n windTime * waveSpeed.w\n );\n \n // Keep in 0-1 range for FastSinCos\n waves = fract(waves);\n \n // ============================================================\n // FastSinCos - Unity's Taylor series approximation\n // From TerrainEngine.cginc lines 56-78\n // ============================================================\n // Convert from 0-1 to -PI to PI range\n let wavesRad = waves * 6.408849 - 3.1415927;\n \n // Powers for Taylor series\n let r5 = wavesRad * wavesRad; // x^2\n let r6 = r5 * r5; // x^4\n let r7 = r6 * r5; // x^6\n let r8 = r6 * r5; // x^8 (same as r7 in Unity code)\n let r1 = r5 * wavesRad; // x^3\n let r2 = r1 * r5; // x^5\n let r3 = r2 * r5; // x^7\n \n // Taylor series coefficients\n let sin7 = vec4f(1.0, -0.16161616, 0.0083333, -0.00019841);\n let cos8 = vec4f(-0.5, 0.041666666, -0.0013888889, 0.000024801587);\n \n // Compute sine using Taylor series: x - x^3/3! + x^5/5! - x^7/7!\n var s = wavesRad + r1 * sin7.y + r2 * sin7.z + r3 * sin7.w;\n \n // Compute cosine (not used for displacement but kept for completeness)\n // var c = vec4f(1.0) + r5 * cos8.x + r6 * cos8.y + r7 * cos8.z + r8 * cos8.w;\n \n // ============================================================\n // Unity's characteristic wave shaping: s = s * s; s = s * s;\n // This creates sharper peaks and flatter troughs (gust appearance)\n // ============================================================\n s = s * s; // s^2\n s = s * s; // s^4\n \n // Lighting variation based on wave state (for color tinting)\n let lightingWeights = normalize(vec4f(1.0, 1.0, 0.4, 0.2));\n let lighting = dot(s, lightingWeights) * 0.7;\n \n // Scale by wave amount (height-based)\n s = s * waveAmount;\n \n // Compute final displacement using dot product with movement vectors\n // Unity: waveMove.x = dot(s, _waveXmove); waveMove.z = dot(s, _waveZmove);\n var waveMove = vec3f(0.0, 0.0, 0.0);\n waveMove.x = dot(s, waveXmove);\n waveMove.z = dot(s, waveZmove);\n \n // Apply displacement scaled by wind amount\n // Unity: vertex.xz -= waveMove.xz * _WaveAndDistance.z;\n // Note: Unity subtracts, we add in the opposite direction for same effect\n let displacement = waveMove * uniforms.g_windAmount;\n \n // Apply wave color tinting (Unity's waveColor calculation)\n // This creates visual bands of lighter/darker grass\n // let waveColor = mix(vec3f(0.5), uniforms.g_windTint.xyz, vec3f(lighting));\n \n // Final world position with waving applied\n let billboardWorld = worldVertexPos - vec3f(displacement.x, 0.0, displacement.z);\n\n // Distance-based culling (Unity-style fade)\n var detailAlpha: f32 = 1.0;\n if (uniforms.g_maxDistance > 0.0) {\n let dist = length(centerW - scene.vEyePosition.xyz);\n let maxD = uniforms.g_maxDistance;\n let fadeStart = uniforms.g_fadeStart;\n if (dist > maxD) { detailAlpha = 0.0; }\n else if (dist > fadeStart) { detailAlpha = 1.0 - ((dist - fadeStart) / max((maxD - fadeStart), 0.0001)); }\n }\n vertexOutputs.vGrassFade = detailAlpha;\n \n // UPDATE worldPos to the animated position BEFORE shadow calculations\n // This is critical for correct shadow receiving - shadows should be stationary\n // while grass moves through them, not move with the grass\n worldPos = vec4f(billboardWorld, 1.0);\n \n // Output\n #if defined(POSITION) || defined(BUMP)\n vertexOutputs.vPositionW = billboardWorld;\n #endif\n #ifdef NORMAL\n vertexOutputs.vNormalW = up;\n #endif\n \n vertexOutputs.position = scene.viewProjection * vec4f(billboardWorld, 1.0);\n "},t.prototype.getGLSLVertexDefinitions=function(){return"\n #ifndef TOOLKIT_GRASS_V_UNIFORMS\n #define TOOLKIT_GRASS_V_UNIFORMS\n uniform vec4 vEyePosition;\n uniform float g_windTime;\n uniform float g_maxDistance;\n uniform float g_fadeStart;\n uniform float g_alphaCutoff;\n uniform float g_waveSpeed;\n uniform float g_waveSize;\n uniform float g_windAmount;\n uniform vec4 g_windTint;\n uniform float g_shadowIntensity;\n #endif\n\n #ifndef TOOLKIT_GRASS_VARYINGS\n #define TOOLKIT_GRASS_VARYINGS\n varying float vGrassFade;\n #endif\n "},t.prototype.getGLSLVertexMainEnd=function(){return""},t.prototype.getGLSLVertexWorldPos=function(){return"\n // Get instance world position (center of grass blade)\n vec3 centerW = (finalWorld * vec4(0.0, 0.0, 0.0, 1.0)).xyz;\n vec3 up = vec3(0.0, 1.0, 0.0);\n \n // Extract instance basis vectors and scale\n vec3 right = normalize(finalWorld[0].xyz);\n vec3 forward = normalize(finalWorld[2].xyz);\n float sx = length(finalWorld[0].xyz);\n float sy = length(finalWorld[1].xyz);\n float sz = length(finalWorld[2].xyz);\n \n // Compute world position of this vertex BEFORE waving\n vec3 localPos = positionUpdated;\n vec3 worldVertexPos = centerW + right * (localPos.x * sx) + up * (localPos.y * sy) + forward * (localPos.z * sz);\n \n // ============================================================\n // UNITY TerrainWaveGrass EXACT IMPLEMENTATION\n // ============================================================\n \n // Wave amount based on vertex height\n float waveAmount = max(localPos.y, 0.0) * g_windAmount;\n \n // Wave constants tuned for LARGE, GENTLE rolling waves like Unity\n // Key insight: Unity's grass shows broad bands spanning large terrain sections\n // NOT tight ripples - spatial frequency must be very LOW\n float waveSize = g_waveSize;\n \n // Spatial frequencies reduced by 10x from Unity's original values\n // This creates wavelengths of ~50-100 units instead of ~5-10 units\n vec4 waveXSize = vec4(0.0012, 0.002, 0.006, 0.0024) * waveSize;\n vec4 waveZSize = vec4(0.0006, 0.002, 0.002, 0.005) * waveSize;\n \n // Temporal speed reduced for smooth, gentle motion\n vec4 waveSpeedVec = vec4(0.03, 0.05, 0.04, 0.12);\n \n // Movement amplitudes - increased 5x for visible bending like Unity\n vec4 waveXmove = vec4(0.12, 0.2, -0.6, 0.48);\n vec4 waveZmove = vec4(0.06, 0.2, -0.2, 1.0);\n \n // Compute wave phases from BLADE CENTER position\n // Using centerW ensures all vertices of the same blade have identical phase\n vec4 waves = vec4(\n centerW.x * waveXSize.x + centerW.z * waveZSize.x,\n centerW.x * waveXSize.y + centerW.z * waveZSize.y,\n centerW.x * waveXSize.z + centerW.z * waveZSize.z,\n centerW.x * waveXSize.w + centerW.z * waveZSize.w\n );\n \n // Add time component\n float windTime = g_windTime * g_waveSpeed;\n waves += vec4(\n windTime * waveSpeedVec.x,\n windTime * waveSpeedVec.y,\n windTime * waveSpeedVec.z,\n windTime * waveSpeedVec.w\n );\n \n // Keep in 0-1 range\n waves = fract(waves);\n \n // ============================================================\n // FastSinCos - Unity's Taylor series approximation\n // ============================================================\n vec4 wavesRad = waves * 6.408849 - 3.1415927;\n \n // Powers for Taylor series\n vec4 r5 = wavesRad * wavesRad;\n vec4 r6 = r5 * r5;\n vec4 r7 = r6 * r5;\n vec4 r1 = r5 * wavesRad;\n vec4 r2 = r1 * r5;\n vec4 r3 = r2 * r5;\n \n // Taylor series coefficients\n vec4 sin7 = vec4(1.0, -0.16161616, 0.0083333, -0.00019841);\n \n // Compute sine\n vec4 s = wavesRad + r1 * sin7.y + r2 * sin7.z + r3 * sin7.w;\n \n // ============================================================\n // Unity's wave shaping: s = s * s; s = s * s; (s^4)\n // ============================================================\n s = s * s;\n s = s * s;\n \n // Lighting for color tinting\n float lighting = dot(s, normalize(vec4(1.0, 1.0, 0.4, 0.2))) * 0.7;\n \n // Scale by wave amount\n s = s * waveAmount;\n \n // Compute displacement\n vec3 waveMove = vec3(0.0);\n waveMove.x = dot(s, waveXmove);\n waveMove.z = dot(s, waveZmove);\n \n // Apply displacement\n vec3 displacement = waveMove * g_windAmount;\n \n // Final world position\n vec3 billboardWorld = worldVertexPos - vec3(displacement.x, 0.0, displacement.z);\n \n // Distance-based culling\n float detailAlpha = 1.0;\n if (g_maxDistance > 0.0) {\n float dist = distance(vEyePosition.xyz, centerW);\n float maxD = g_maxDistance;\n float fadeStart = g_fadeStart;\n if (dist > maxD) { detailAlpha = 0.0; }\n else if (dist > fadeStart) { detailAlpha = 1.0 - ((dist - fadeStart) / max((maxD - fadeStart), 0.0001)); }\n }\n vGrassFade = detailAlpha;\n \n // UPDATE worldPos to the animated position BEFORE shadow calculations\n // This is critical for correct shadow receiving - shadows should be stationary\n // while grass moves through them, not move with the grass\n worldPos = vec4(billboardWorld, 1.0);\n \n #if defined(POSITION) || defined(BUMP)\n vPositionW = billboardWorld;\n #endif\n #ifdef NORMAL\n vNormalW = up;\n #endif\n \n gl_Position = viewProjection * vec4(billboardWorld, 1.0);\n "},t.prototype.getWGSLFragmentCode=function(){return"\n let detailAlpha = fragmentInputs.vGrassFade;\n let combinedAlpha = alpha * detailAlpha;\n if (combinedAlpha <= uniforms.g_alphaCutoff) { discard; }\n alpha = combinedAlpha;\n \n // Apply shadow intensity - adds ambient light to dark/shadowed areas\n // shadowIntensity controls how much ambient light to add: 0.0 = no ambient, 1.0 = full texture color\n // Simple approach: check if pixel is very dark (likely in shadow) and add ambient\n let shadowIntensity = uniforms.g_shadowIntensity;\n let brightness = max(color.r, max(color.g, color.b));\n // If brightness is below threshold, we're likely in shadow - add ambient light\n // The darker the pixel, the more ambient we add (inverse relationship)\n let shadowThreshold = 0.2;\n let shadowAmount = clamp((shadowThreshold - brightness) / shadowThreshold, 0.0, 1.0);\n // Add ambient light using the grass texture color\n color = vec4f(color.rgb + baseColor.rgb * shadowIntensity * shadowAmount, color.a);\n "},t.prototype.getGLSLFragmentCode=function(){return"\n float detailAlpha = vGrassFade;\n float combinedAlpha = alpha * detailAlpha;\n if (combinedAlpha <= g_alphaCutoff) discard;\n alpha = combinedAlpha;\n \n // Apply shadow intensity - adds ambient light to dark/shadowed areas\n // shadowIntensity controls how much ambient light to add: 0.0 = no ambient, 1.0 = full texture color\n // Simple approach: check if pixel is very dark (likely in shadow) and add ambient\n float shadowIntensity = g_shadowIntensity;\n float brightness = max(color.r, max(color.g, color.b));\n // If brightness is below threshold, we're likely in shadow - add ambient light\n // The darker the pixel, the more ambient we add (inverse relationship)\n float shadowThreshold = 0.2;\n float shadowAmount = clamp((shadowThreshold - brightness) / shadowThreshold, 0.0, 1.0);\n // Add ambient light using the grass texture color\n color.rgb += baseColor.rgb * shadowIntensity * shadowAmount;\n "},t.prototype.getGLSLFragmentDefinitions=function(){return"\n #ifndef TOOLKIT_GRASS_VARYINGS\n #define TOOLKIT_GRASS_VARYINGS\n varying float vGrassFade;\n #endif\n "},t.prototype.getUniforms=function(e){var t=e===BABYLON.ShaderLanguage.WGSL;return this.vertexDefinitions=this.getCustomShaderMaterial().getCustomVertexCode(t),this.fragmentDefinitions=!0===t?this.getCustomShaderMaterial().getCustomFragmentCode(t):null,this.getCustomShaderMaterial().getCustomUniforms(t)},t.prototype.getSamplers=function(e){var t=this.getCustomShaderMaterial().getCustomSamplers();null!=t&&t.length>0&&e.push.apply(e,t)},t.prototype.getAttributes=function(e,t,i){var n=this.getCustomShaderMaterial().getCustomAttributes();null!=n&&n.length>0&&e.push.apply(e,n)},t.prototype.prepareDefines=function(e,t,i){this.getIsEnabled()&&this.getCustomShaderMaterial().prepareCustomDefines(e)},t.prototype.bindForSubMesh=function(e,t,i,n){this.getIsEnabled()&&this.getCustomShaderMaterial().updateCustomBindings(e)},t}(e.StandardShaderMaterialPlugin);e.GrassStandardMaterialPlugin=i,e.SceneManager.RegisterClass("TOOLKIT.GrassStandardMaterial",t),e.SceneManager.RegisterClass("TOOLKIT.GrassStandardMaterialPlugin",i)}(n||(n={})),function(e){var t=function(t){function i(i,n){var r=t.call(this,i,n)||this;return r._windTimeAccum=0,r._lastUpdateFrame=-1,r.shader=r.getShaderName(),r.plugin=new e.GrassBillboardMaterialPlugin(r,r.shader),r.addFloatUniform("g_maxDistance",0),r.addFloatUniform("g_fadeStart",0),r.addFloatUniform("g_alphaCutoff",.3),r.addFloatUniform("g_windTime",0),r.addFloatUniform("g_waveSpeed",.5),r.addFloatUniform("g_waveSize",.5),r.addFloatUniform("g_windAmount",.5),r.addVector4Uniform("g_windTint",new BABYLON.Vector4(.7,.6,.5,0)),r.addFloatUniform("g_shadowIntensity",.7),r.addFloatUniform("g_sphericalBillboardEnabled",1),r.emissiveColor=new BABYLON.Color3(.7,.7,.7),r._windTimeAccum=0,r}return o(i,t),i.prototype.awake=function(){},i.prototype.update=function(){var t;try{var i=this.getScene(),n=i.getFrameId();if(this._lastUpdateFrame===n)return;this._lastUpdateFrame=n;var r=e.SceneManager.GetDeltaSeconds(i),o=Math.min(r,1/30);(null!==(t=this.getFloatValue("g_waveSpeed"))&&void 0!==t?t:0)>0&&(this._windTimeAccum=this._windTimeAccum+o,this.setFloatValue("g_windTime",this._windTimeAccum))}catch(e){}},i.prototype.getShaderName=function(){return"GrassBillboardMaterial"},i.prototype.getMaxDistance=function(){return this.getFloatValue("g_maxDistance")},i.prototype.setMaxDistance=function(e){this.setFloatValue("g_maxDistance",e)},i.prototype.getFadeStart=function(){return this.getFloatValue("g_fadeStart")},i.prototype.setFadeStart=function(e){this.setFloatValue("g_fadeStart",e)},i.prototype.getWaveSpeed=function(){return this.getFloatValue("g_waveSpeed")},i.prototype.setWaveSpeed=function(e){this.setFloatValue("g_waveSpeed",e)},i.prototype.getWaveSize=function(){return this.getFloatValue("g_waveSize")},i.prototype.setWaveSize=function(e){this.setFloatValue("g_waveSize",e)},i.prototype.getWindAmount=function(){return this.getFloatValue("g_windAmount")},i.prototype.setWindAmount=function(e){this.setFloatValue("g_windAmount",e)},i.prototype.getWindTint=function(){return this.getVector4Value("g_windTint")},i.prototype.setWindTint=function(e){this.setVector4Value("g_windTint",e)},i.prototype.getShadowIntensity=function(){return this.getFloatValue("g_shadowIntensity")},i.prototype.setShadowIntensity=function(e){var t=Math.max(0,Math.min(1,e));this.setFloatValue("g_shadowIntensity",t),this.emissiveColor=new BABYLON.Color3(t,t,t)},i.prototype.getSphericalBillboardEnabled=function(){var e;return(null!==(e=this.getFloatValue("g_sphericalBillboardEnabled"))&&void 0!==e?e:0)>.5},i.prototype.setSphericalBillboardEnabled=function(e){this.setFloatValue("g_sphericalBillboardEnabled",e?1:0)},i}(e.StandardShaderMaterial);e.GrassBillboardMaterial=t;var i=function(e){function t(t,i){return e.call(this,t,i,110,{GRASSBILLBOARDMATERIAL:!1})||this}return o(t,e),t.prototype.isCompatible=function(e){return e===BABYLON.ShaderLanguage.WGSL||e===BABYLON.ShaderLanguage.GLSL},t.prototype.getCustomCode=function(e,t){if("vertex"===e){if(t===BABYLON.ShaderLanguage.WGSL)return{CUSTOM_VERTEX_DEFINITIONS:this.getWGSLVaryingDefinitions(),CUSTOM_VERTEX_MAIN_END:this.getWGSLVertexMainEnd(),CUSTOM_VERTEX_UPDATE_WORLDPOS:this.getWGSLVertexWorldPos()};if(t===BABYLON.ShaderLanguage.GLSL)return{CUSTOM_VERTEX_DEFINITIONS:this.getGLSLVertexDefinitions(),CUSTOM_VERTEX_MAIN_END:this.getGLSLVertexMainEnd(),CUSTOM_VERTEX_UPDATE_WORLDPOS:this.getGLSLVertexWorldPos()}}return"fragment"===e?t===BABYLON.ShaderLanguage.WGSL?{CUSTOM_FRAGMENT_DEFINITIONS:this.getWGSLVaryingDefinitions(),CUSTOM_FRAGMENT_BEFORE_FOG:this.getWGSLFragmentCode()}:{CUSTOM_FRAGMENT_DEFINITIONS:this.getGLSLFragmentDefinitions(),CUSTOM_FRAGMENT_BEFORE_FOG:this.getGLSLFragmentCode()}:null},t.prototype.getWGSLVertexMainEnd=function(){return""},t.prototype.getWGSLVaryingDefinitions=function(){return"\n #ifndef TOOLKIT_GRASS_VARYINGS\n #define TOOLKIT_GRASS_VARYINGS\n varying vGrassFade: f32;\n #endif\n "},t.prototype.getWGSLVertexWorldPos=function(){return"\n // Get instance world position (center of grass blade)\n let centerW = (finalWorld * vec4f(0.0, 0.0, 0.0, 1.0)).xyz;\n let up = vec3f(0.0, 1.0, 0.0);\n \n // Extract instance scale (keep scale, but override rotation with Y-locked billboard basis)\n let sx = length(finalWorld[0].xyz);\n let sy = length(finalWorld[1].xyz);\n let sz = length(finalWorld[2].xyz);\n\n // Compute billboard basis (Y-locked or spherical)\n // Face the camera on XZ plane without tilting unless spherical is enabled\n let eyeW = scene.vEyePosition.xyz;\n var faceDir = centerW - eyeW;\n if (uniforms.g_sphericalBillboardEnabled < 0.5) {\n faceDir.y = 0.0;\n }\n let faceLen = length(faceDir);\n if (faceLen < 0.0001) {\n faceDir = vec3f(0.0, 0.0, 1.0);\n } else {\n faceDir = faceDir / faceLen;\n }\n\n // Safe up reference to avoid degeneracy when looking straight down\n var upRef = up;\n if (abs(faceDir.y) > 0.99) {\n upRef = vec3f(0.0, 0.0, 1.0);\n }\n\n let right = normalize(cross(upRef, faceDir));\n let forward = normalize(cross(faceDir, right));\n\n // Compute world position of this vertex BEFORE waving\n // This is critical - Unity uses the actual vertex world position for wave phase\n let localPos = positionUpdated;\n var worldVertexPos = centerW + right * (localPos.x * sx) + up * (localPos.y * sy) + forward * (localPos.z * sz);\n \n // ============================================================\n // UNITY TerrainWaveGrass EXACT IMPLEMENTATION\n // From TerrainEngine.cginc lines 80-125\n // ============================================================\n \n // Wave amount is based on vertex height (top vertices wave more)\n // In Unity: v.color.a for mesh grass, tangent.y for billboard\n // Here we use the local Y position as the wave factor\n let waveAmount = max(localPos.y, 0.0) * uniforms.g_windAmount;\n \n // Wave constants tuned for LARGE, GENTLE rolling waves like Unity\n // Key insight: Unity's grass shows broad bands spanning large terrain sections\n // NOT tight ripples - spatial frequency must be very LOW\n let waveSize = uniforms.g_waveSize;\n \n // Spatial frequencies reduced by 10x from Unity's original values\n // This creates wavelengths of ~50-100 units instead of ~5-10 units\n // Result: 1-2 visible wave crests across terrain instead of 10-20\n let waveXSize = vec4f(0.0012, 0.002, 0.006, 0.0024) * waveSize;\n let waveZSize = vec4f(0.0006, 0.002, 0.002, 0.005) * waveSize;\n \n // Temporal speed reduced for smooth, gentle motion\n // Original Unity values divided by 10 for slower wave travel\n let waveSpeed = vec4f(0.03, 0.05, 0.04, 0.12);\n \n // Movement amplitudes - these control how far grass sways\n // Increased 5x from previous values to get visible bending like Unity\n // Unity grass shows significant physical displacement (20-30 degree lean)\n let waveXmove = vec4f(0.12, 0.2, -0.6, 0.48);\n let waveZmove = vec4f(0.06, 0.2, -0.2, 1.0);\n \n // Compute wave phases from BLADE CENTER position - this creates spatial bands\n // Using centerW ensures all vertices of the same blade have identical phase\n // The height-based waveAmount controls per-vertex displacement amount\n // Unity: waves = vertex.x * _waveXSize + vertex.z * _waveZSize + time * waveSpeed\n var waves = vec4f(\n centerW.x * waveXSize.x + centerW.z * waveZSize.x,\n centerW.x * waveXSize.y + centerW.z * waveZSize.y,\n centerW.x * waveXSize.z + centerW.z * waveZSize.z,\n centerW.x * waveXSize.w + centerW.z * waveZSize.w\n );\n \n // Add time component - this makes waves travel\n let windTime = uniforms.g_windTime * uniforms.g_waveSpeed;\n waves = waves + vec4f(\n windTime * waveSpeed.x,\n windTime * waveSpeed.y,\n windTime * waveSpeed.z,\n windTime * waveSpeed.w\n );\n \n // Keep in 0-1 range for FastSinCos\n waves = fract(waves);\n \n // ============================================================\n // FastSinCos - Unity's Taylor series approximation\n // From TerrainEngine.cginc lines 56-78\n // ============================================================\n // Convert from 0-1 to -PI to PI range\n let wavesRad = waves * 6.408849 - 3.1415927;\n \n // Powers for Taylor series\n let r5 = wavesRad * wavesRad; // x^2\n let r6 = r5 * r5; // x^4\n let r7 = r6 * r5; // x^6\n let r8 = r6 * r5; // x^8 (same as r7 in Unity code)\n let r1 = r5 * wavesRad; // x^3\n let r2 = r1 * r5; // x^5\n let r3 = r2 * r5; // x^7\n \n // Taylor series coefficients\n let sin7 = vec4f(1.0, -0.16161616, 0.0083333, -0.00019841);\n let cos8 = vec4f(-0.5, 0.041666666, -0.0013888889, 0.000024801587);\n \n // Compute sine using Taylor series: x - x^3/3! + x^5/5! - x^7/7!\n var s = wavesRad + r1 * sin7.y + r2 * sin7.z + r3 * sin7.w;\n \n // Compute cosine (not used for displacement but kept for completeness)\n // var c = vec4f(1.0) + r5 * cos8.x + r6 * cos8.y + r7 * cos8.z + r8 * cos8.w;\n \n // ============================================================\n // Unity's characteristic wave shaping: s = s * s; s = s * s;\n // This creates sharper peaks and flatter troughs (gust appearance)\n // ============================================================\n s = s * s; // s^2\n s = s * s; // s^4\n \n // Lighting variation based on wave state (for color tinting)\n let lightingWeights = normalize(vec4f(1.0, 1.0, 0.4, 0.2));\n let lighting = dot(s, lightingWeights) * 0.7;\n \n // Scale by wave amount (height-based)\n s = s * waveAmount;\n \n // Compute final displacement using dot product with movement vectors\n // Unity: waveMove.x = dot(s, _waveXmove); waveMove.z = dot(s, _waveZmove);\n var waveMove = vec3f(0.0, 0.0, 0.0);\n waveMove.x = dot(s, waveXmove);\n waveMove.z = dot(s, waveZmove);\n \n // Apply displacement scaled by wind amount\n // Unity: vertex.xz -= waveMove.xz * _WaveAndDistance.z;\n // Note: Unity subtracts, we add in the opposite direction for same effect\n let displacement = waveMove * uniforms.g_windAmount;\n \n // Apply wave color tinting (Unity's waveColor calculation)\n // This creates visual bands of lighter/darker grass\n // let waveColor = mix(vec3f(0.5), uniforms.g_windTint.xyz, vec3f(lighting));\n \n // Final world position with waving applied\n let billboardWorld = worldVertexPos - vec3f(displacement.x, 0.0, displacement.z);\n\n // Distance-based culling (Unity-style fade)\n var detailAlpha: f32 = 1.0;\n if (uniforms.g_maxDistance > 0.0) {\n let dist = length(centerW - scene.vEyePosition.xyz);\n let maxD = uniforms.g_maxDistance;\n let fadeStart = uniforms.g_fadeStart;\n if (dist > maxD) { detailAlpha = 0.0; }\n else if (dist > fadeStart) { detailAlpha = 1.0 - ((dist - fadeStart) / max((maxD - fadeStart), 0.0001)); }\n }\n vertexOutputs.vGrassFade = detailAlpha;\n \n // UPDATE worldPos to the animated position BEFORE shadow calculations\n // This is critical for correct shadow receiving - shadows should be stationary\n // while grass moves through them, not move with the grass\n worldPos = vec4f(billboardWorld, 1.0);\n \n // Output\n #if defined(POSITION) || defined(BUMP)\n vertexOutputs.vPositionW = billboardWorld;\n #endif\n #ifdef NORMAL\n vertexOutputs.vNormalW = up;\n #endif\n \n vertexOutputs.position = scene.viewProjection * vec4f(billboardWorld, 1.0);\n "},t.prototype.getGLSLVertexDefinitions=function(){return"\n #ifndef TOOLKIT_GRASS_V_UNIFORMS\n #define TOOLKIT_GRASS_V_UNIFORMS\n uniform vec4 vEyePosition;\n uniform float g_windTime;\n uniform float g_maxDistance;\n uniform float g_fadeStart;\n uniform float g_alphaCutoff;\n uniform float g_waveSpeed;\n uniform float g_waveSize;\n uniform float g_windAmount;\n uniform vec4 g_windTint;\n uniform float g_shadowIntensity;\n uniform float g_sphericalBillboardEnabled;\n #endif\n\n #ifndef TOOLKIT_GRASS_VARYINGS\n #define TOOLKIT_GRASS_VARYINGS\n varying float vGrassFade;\n #endif\n "},t.prototype.getGLSLVertexMainEnd=function(){return""},t.prototype.getGLSLVertexWorldPos=function(){return"\n // Get instance world position (center of grass blade)\n vec3 centerW = (finalWorld * vec4(0.0, 0.0, 0.0, 1.0)).xyz;\n vec3 up = vec3(0.0, 1.0, 0.0);\n \n // Extract instance scale (keep scale, but override rotation with Y-locked billboard basis)\n float sx = length(finalWorld[0].xyz);\n float sy = length(finalWorld[1].xyz);\n float sz = length(finalWorld[2].xyz);\n\n // Compute billboard basis (Y-locked or spherical)\n // Face the camera on XZ plane without tilting unless spherical is enabled\n vec3 eyeW = vEyePosition.xyz;\n vec3 faceDir = centerW - eyeW;\n if (g_sphericalBillboardEnabled < 0.5) {\n faceDir.y = 0.0;\n }\n float faceLen = length(faceDir);\n if (faceLen < 0.0001) {\n faceDir = vec3(0.0, 0.0, 1.0);\n } else {\n faceDir = faceDir / faceLen;\n }\n\n // Safe up reference to avoid degeneracy when looking straight down\n vec3 upRef = up;\n if (abs(faceDir.y) > 0.99) {\n upRef = vec3(0.0, 0.0, 1.0);\n }\n\n vec3 right = normalize(cross(upRef, faceDir));\n vec3 forward = normalize(cross(faceDir, right));\n\n // Compute world position of this vertex BEFORE waving\n vec3 localPos = positionUpdated;\n vec3 worldVertexPos = centerW + right * (localPos.x * sx) + up * (localPos.y * sy) + forward * (localPos.z * sz);\n \n // ============================================================\n // UNITY TerrainWaveGrass EXACT IMPLEMENTATION\n // ============================================================\n \n // Wave amount based on vertex height\n float waveAmount = max(localPos.y, 0.0) * g_windAmount;\n \n // Wave constants tuned for LARGE, GENTLE rolling waves like Unity\n // Key insight: Unity's grass shows broad bands spanning large terrain sections\n // NOT tight ripples - spatial frequency must be very LOW\n float waveSize = g_waveSize;\n \n // Spatial frequencies reduced by 10x from Unity's original values\n // This creates wavelengths of ~50-100 units instead of ~5-10 units\n vec4 waveXSize = vec4(0.0012, 0.002, 0.006, 0.0024) * waveSize;\n vec4 waveZSize = vec4(0.0006, 0.002, 0.002, 0.005) * waveSize;\n \n // Temporal speed reduced for smooth, gentle motion\n vec4 waveSpeedVec = vec4(0.03, 0.05, 0.04, 0.12);\n \n // Movement amplitudes - increased 5x for visible bending like Unity\n vec4 waveXmove = vec4(0.12, 0.2, -0.6, 0.48);\n vec4 waveZmove = vec4(0.06, 0.2, -0.2, 1.0);\n \n // Compute wave phases from BLADE CENTER position\n // Using centerW ensures all vertices of the same blade have identical phase\n vec4 waves = vec4(\n centerW.x * waveXSize.x + centerW.z * waveZSize.x,\n centerW.x * waveXSize.y + centerW.z * waveZSize.y,\n centerW.x * waveXSize.z + centerW.z * waveZSize.z,\n centerW.x * waveXSize.w + centerW.z * waveZSize.w\n );\n \n // Add time component\n float windTime = g_windTime * g_waveSpeed;\n waves += vec4(\n windTime * waveSpeedVec.x,\n windTime * waveSpeedVec.y,\n windTime * waveSpeedVec.z,\n windTime * waveSpeedVec.w\n );\n \n // Keep in 0-1 range\n waves = fract(waves);\n \n // ============================================================\n // FastSinCos - Unity's Taylor series approximation\n // ============================================================\n vec4 wavesRad = waves * 6.408849 - 3.1415927;\n \n // Powers for Taylor series\n vec4 r5 = wavesRad * wavesRad;\n vec4 r6 = r5 * r5;\n vec4 r7 = r6 * r5;\n vec4 r1 = r5 * wavesRad;\n vec4 r2 = r1 * r5;\n vec4 r3 = r2 * r5;\n \n // Taylor series coefficients\n vec4 sin7 = vec4(1.0, -0.16161616, 0.0083333, -0.00019841);\n \n // Compute sine\n vec4 s = wavesRad + r1 * sin7.y + r2 * sin7.z + r3 * sin7.w;\n \n // ============================================================\n // Unity's wave shaping: s = s * s; s = s * s; (s^4)\n // ============================================================\n s = s * s;\n s = s * s;\n \n // Lighting for color tinting\n float lighting = dot(s, normalize(vec4(1.0, 1.0, 0.4, 0.2))) * 0.7;\n \n // Scale by wave amount\n s = s * waveAmount;\n \n // Compute displacement\n vec3 waveMove = vec3(0.0);\n waveMove.x = dot(s, waveXmove);\n waveMove.z = dot(s, waveZmove);\n \n // Apply displacement\n vec3 displacement = waveMove * g_windAmount;\n \n // Final world position\n vec3 billboardWorld = worldVertexPos - vec3(displacement.x, 0.0, displacement.z);\n \n // Distance-based culling\n float detailAlpha = 1.0;\n if (g_maxDistance > 0.0) {\n float dist = distance(vEyePosition.xyz, centerW);\n float maxD = g_maxDistance;\n float fadeStart = g_fadeStart;\n if (dist > maxD) { detailAlpha = 0.0; }\n else if (dist > fadeStart) { detailAlpha = 1.0 - ((dist - fadeStart) / max((maxD - fadeStart), 0.0001)); }\n }\n vGrassFade = detailAlpha;\n \n // UPDATE worldPos to the animated position BEFORE shadow calculations\n // This is critical for correct shadow receiving - shadows should be stationary\n // while grass moves through them, not move with the grass\n worldPos = vec4(billboardWorld, 1.0);\n \n #if defined(POSITION) || defined(BUMP)\n vPositionW = billboardWorld;\n #endif\n #ifdef NORMAL\n vNormalW = up;\n #endif\n \n gl_Position = viewProjection * vec4(billboardWorld, 1.0);\n "},t.prototype.getWGSLFragmentCode=function(){return"\n let detailAlpha = fragmentInputs.vGrassFade;\n let combinedAlpha = alpha * detailAlpha;\n if (combinedAlpha <= uniforms.g_alphaCutoff) { discard; }\n alpha = combinedAlpha;\n \n // Apply shadow intensity - adds ambient light to dark/shadowed areas\n // shadowIntensity controls how much ambient light to add: 0.0 = no ambient, 1.0 = full texture color\n // Simple approach: check if pixel is very dark (likely in shadow) and add ambient\n let shadowIntensity = uniforms.g_shadowIntensity;\n let brightness = max(color.r, max(color.g, color.b));\n // If brightness is below threshold, we're likely in shadow - add ambient light\n // The darker the pixel, the more ambient we add (inverse relationship)\n let shadowThreshold = 0.2;\n let shadowAmount = clamp((shadowThreshold - brightness) / shadowThreshold, 0.0, 1.0);\n // Add ambient light using the grass texture color\n color = vec4f(color.rgb + baseColor.rgb * shadowIntensity * shadowAmount, color.a);\n "},t.prototype.getGLSLFragmentCode=function(){return"\n float detailAlpha = vGrassFade;\n float combinedAlpha = alpha * detailAlpha;\n if (combinedAlpha <= g_alphaCutoff) discard;\n alpha = combinedAlpha;\n \n // Apply shadow intensity - adds ambient light to dark/shadowed areas\n // shadowIntensity controls how much ambient light to add: 0.0 = no ambient, 1.0 = full texture color\n // Simple approach: check if pixel is very dark (likely in shadow) and add ambient\n float shadowIntensity = g_shadowIntensity;\n float brightness = max(color.r, max(color.g, color.b));\n // If brightness is below threshold, we're likely in shadow - add ambient light\n // The darker the pixel, the more ambient we add (inverse relationship)\n float shadowThreshold = 0.2;\n float shadowAmount = clamp((shadowThreshold - brightness) / shadowThreshold, 0.0, 1.0);\n // Add ambient light using the grass texture color\n color.rgb += baseColor.rgb * shadowIntensity * shadowAmount;\n "},t.prototype.getGLSLFragmentDefinitions=function(){return"\n #ifndef TOOLKIT_GRASS_VARYINGS\n #define TOOLKIT_GRASS_VARYINGS\n varying float vGrassFade;\n #endif\n "},t.prototype.getUniforms=function(e){var t=e===BABYLON.ShaderLanguage.WGSL;return this.vertexDefinitions=this.getCustomShaderMaterial().getCustomVertexCode(t),this.fragmentDefinitions=!0===t?this.getCustomShaderMaterial().getCustomFragmentCode(t):null,this.getCustomShaderMaterial().getCustomUniforms(t)},t.prototype.getSamplers=function(e){var t=this.getCustomShaderMaterial().getCustomSamplers();null!=t&&t.length>0&&e.push.apply(e,t)},t.prototype.getAttributes=function(e,t,i){var n=this.getCustomShaderMaterial().getCustomAttributes();null!=n&&n.length>0&&e.push.apply(e,n)},t.prototype.prepareDefines=function(e,t,i){this.getIsEnabled()&&this.getCustomShaderMaterial().prepareCustomDefines(e)},t.prototype.bindForSubMesh=function(e,t,i,n){this.getIsEnabled()&&this.getCustomShaderMaterial().updateCustomBindings(e)},t}(e.StandardShaderMaterialPlugin);e.GrassBillboardMaterialPlugin=i,e.SceneManager.RegisterClass("TOOLKIT.GrassStandardMaterial",e.GrassStandardMaterial),e.SceneManager.RegisterClass("TOOLKIT.GrassStandardMaterialPlugin",e.GrassStandardMaterialPlugin)}(n||(n={})),function(e){var t=function(t){function i(i,n){var r=t.call(this,i,n)||this;return r._windTimeAccum=0,r.shader=r.getShaderName(),r.plugin=new e.TreeBranchMaterialPlugin(r,r.shader),r.addFloatUniform("g_windTime",0),r.addFloatUniform("g_windAmount",.5),r.addFloatUniform("g_windSpeed",1),r.addFloatUniform("g_windStrength",.5),r.addVector4Uniform("g_windDirection",new BABYLON.Vector4(1,0,0,0)),r.addFloatUniform("g_branchRootY",0),r.addFloatUniform("g_branchMaxAngle",.35),r.addFloatUniform("g_branchMaxHeight",2),r.addFloatUniform("g_useVertexColorMask",1),r.addFloatUniform("g_spatialFrequency",.15),r._windTimeAccum=0,r}return o(i,t),i.prototype.awake=function(){},i.prototype.update=function(){var t;try{var i=e.SceneManager.GetDeltaSeconds(this.getScene()),n=Math.min(i,1/30);(null!==(t=this.getFloatValue("g_windSpeed"))&&void 0!==t?t:0)>0&&(this._windTimeAccum+=n,this.setFloatValue("g_windTime",this._windTimeAccum))}catch(e){}},i.prototype.getShaderName=function(){return"TreeBranchMaterial"},i.prototype.setWindDirection=function(e,t,i){var n=new BABYLON.Vector3(e,t,i);n.lengthSquared()<1e-8?this.setVector4Value("g_windDirection",new BABYLON.Vector4(1,0,0,0)):(n.normalize(),this.setVector4Value("g_windDirection",new BABYLON.Vector4(n.x,n.y,n.z,0)))},i.prototype.getWindDirection=function(){return this.getVector4Value("g_windDirection")},i}(e.CustomShaderMaterial);e.TreeBranchMaterial=t;var i=function(e){function t(t,i){return e.call(this,t,i,110,{TREEBRANCHMATERIAL:!1})||this}return o(t,e),t.prototype.isCompatible=function(e){return e===BABYLON.ShaderLanguage.WGSL||e===BABYLON.ShaderLanguage.GLSL},t.prototype.getCustomCode=function(e,t){return"vertex"===e?t===BABYLON.ShaderLanguage.WGSL?{CUSTOM_VERTEX_MAIN_END:"\n // -------------------------\n // TreeBranch wind bending (local-space)\n // Authoring (recommended):\n // vertexColor.r = bend weight (0 trunk .. 1 tips)\n // vertexColor.g = phase offset noise (0..1)\n // Falls back to height-based weight if vertex color missing/disabled.\n // -------------------------\n\n fn safeNormalize(v: vec3f) -> vec3f {\n let lsq = dot(v, v);\n if (lsq < 1e-8) { return vec3f(1.0, 0.0, 0.0); }\n return v * inverseSqrt(lsq);\n }\n\n fn rotateRodrigues(p: vec3f, axis: vec3f, angle: f32) -> vec3f {\n let a = safeNormalize(axis);\n let c = cos(angle);\n let s = sin(angle);\n return p * c + cross(a, p) * s + a * dot(a, p) * (1.0 - c);\n }\n\n // Local position & normal (preferred: use normalUpdated if present in shader)\n var pL: vec3f = positionUpdated;\n\n // If COLOR attribute exists, Babylon usually provides vertexInputs.color.\n // If not available, these will be 1,1,1,1 (depending on pipeline) — we guard with g_useVertexColorMask.\n var bendMask: f32 = 1.0;\n var phaseNoise: f32 = 0.0;\n if (uniforms.g_useVertexColorMask > 0.5) {\n bendMask = clamp(vertexInputs.color.r, 0.0, 1.0);\n phaseNoise = vertexInputs.color.g; // 0..1\n }\n\n // Height-based fallback weight (normalized between rootY..maxHeight)\n let denom = max(uniforms.g_branchMaxHeight - uniforms.g_branchRootY, 1e-3);\n let h01 = clamp((pL.y - uniforms.g_branchRootY) / denom, 0.0, 1.0);\n\n // Final per-vertex weight:\n // - If using vertex colors: bendMask * smooth tip emphasis\n // - Else: height-based\n var w: f32 = h01;\n if (uniforms.g_useVertexColorMask > 0.5) {\n w = bendMask * (h01 * h01 * (3.0 - 2.0 * h01)); // smoothstep(h01)\n } else {\n w = h01 * h01; // a bit stiffer near base\n }\n\n // Wind direction in LOCAL space:\n // We transform windDirWorld by inverse world matrix rotation (approx using finalWorld columns).\n // finalWorld transforms local->world. For direction, inverse rotation is transpose of 3x3 if no shear.\n let windW = safeNormalize(uniforms.g_windDirection.xyz);\n let rightW = safeNormalize(finalWorld[0].xyz);\n let upW = safeNormalize(finalWorld[1].xyz);\n let fwdW = safeNormalize(finalWorld[2].xyz);\n\n // Convert world dir to local by dot with basis\n let windL = safeNormalize(vec3f(dot(windW, rightW), dot(windW, upW), dot(windW, fwdW)));\n\n // Bend axis: perpendicular to up and wind, in LOCAL space\n var axisL = safeNormalize(cross(vec3f(0.0, 1.0, 0.0), windL));\n if (dot(axisL, axisL) < 1e-6) { axisL = vec3f(1.0, 0.0, 0.0); }\n\n // Spatially varying phase so whole tree doesn't move as a rigid sheet\n // Use local xz for coherence; optionally mod by vertexColor.g\n let spatial = (pL.x + pL.z) * uniforms.g_spatialFrequency;\n let phase = uniforms.g_windTime * uniforms.g_windSpeed\n + spatial * uniforms.g_windStrength\n + phaseNoise * 6.28318;\n\n // Two-wave composite like Unity-ish wind\n let base = sin(phase);\n let gust = 0.5 * sin(phase * 1.7 + 1.2);\n let sway = (base + gust) * uniforms.g_windAmount;\n\n // Convert sway to angle (clamped)\n var angle = sway * w * uniforms.g_branchMaxAngle;\n angle = clamp(angle, -uniforms.g_branchMaxAngle, uniforms.g_branchMaxAngle);\n\n // Pivot in local space\n let pivotL = vec3f(0.0, uniforms.g_branchRootY, 0.0);\n let relL = pL - pivotL;\n let bentRelL = rotateRodrigues(relL, axisL, angle);\n let bentPL = pivotL + bentRelL;\n\n // Transform to world using finalWorld (keeps proper anchoring)\n let branchWorld = (finalWorld * vec4f(bentPL, 1.0)).xyz;\n\n // Rotate normal similarly (only if NORMAL is active)\n #ifdef NORMAL\n // Babylon WGSL PBR usually provides normalUpdated in local/object space\n var nL: vec3f = normalize(normalUpdated);\n let bentNL = rotateRodrigues(nL, axisL, angle);\n // Convert to world by world 3x3\n let nW = normalize(vec3f(\n dot(bentNL, vec3f(finalWorld[0].x, finalWorld[0].y, finalWorld[0].z)),\n dot(bentNL, vec3f(finalWorld[1].x, finalWorld[1].y, finalWorld[1].z)),\n dot(bentNL, vec3f(finalWorld[2].x, finalWorld[2].y, finalWorld[2].z))\n ));\n vertexOutputs.vNormalW = nW;\n #endif\n\n #if defined(POSITION) || defined(BUMP)\n vertexOutputs.vPositionW = branchWorld;\n #endif\n\n vertexOutputs.position = scene.viewProjection * vec4f(branchWorld, 1.0);\n "}:{CUSTOM_VERTEX_DEFINITIONS:"\n uniform float g_windTime;\n uniform float g_windAmount;\n uniform float g_windSpeed;\n uniform float g_windStrength;\n uniform vec4 g_windDirection;\n\n uniform float g_branchRootY;\n uniform float g_branchMaxAngle;\n uniform float g_branchMaxHeight;\n uniform float g_useVertexColorMask;\n uniform float g_spatialFrequency;\n\n vec3 safeNormalize(vec3 v) {\n float lsq = dot(v, v);\n if (lsq < 1e-8) return vec3(1.0, 0.0, 0.0);\n return v * inversesqrt(lsq);\n }\n\n vec3 rotateRodrigues(vec3 p, vec3 axis, float angle) {\n vec3 a = safeNormalize(axis);\n float c = cos(angle);\n float s = sin(angle);\n return p * c + cross(a, p) * s + a * dot(a, p) * (1.0 - c);\n }\n ",CUSTOM_VERTEX_MAIN_END:"\n // Local/object position\n vec3 pL = positionUpdated;\n\n // Vertex color mask (recommended authoring)\n float bendMask = 1.0;\n float phaseNoise = 0.0;\n #ifdef VERTEXCOLOR\n if (g_useVertexColorMask > 0.5) {\n bendMask = clamp(color.r, 0.0, 1.0);\n phaseNoise = color.g;\n }\n #endif\n\n float denom = max(g_branchMaxHeight - g_branchRootY, 1e-3);\n float h01 = clamp((pL.y - g_branchRootY) / denom, 0.0, 1.0);\n\n float w = h01;\n if (g_useVertexColorMask > 0.5) {\n // smoothstep(h01)\n w = bendMask * (h01 * h01 * (3.0 - 2.0 * h01));\n } else {\n w = h01 * h01;\n }\n\n // Convert wind world dir to local using world basis (transpose approx)\n vec3 windW = safeNormalize(g_windDirection.xyz);\n vec3 rightW = safeNormalize(finalWorld[0].xyz);\n vec3 upW = safeNormalize(finalWorld[1].xyz);\n vec3 fwdW = safeNormalize(finalWorld[2].xyz);\n vec3 windL = safeNormalize(vec3(dot(windW, rightW), dot(windW, upW), dot(windW, fwdW)));\n\n vec3 axisL = safeNormalize(cross(vec3(0.0, 1.0, 0.0), windL));\n if (dot(axisL, axisL) < 1e-6) axisL = vec3(1.0, 0.0, 0.0);\n\n float spatial = (pL.x + pL.z) * g_spatialFrequency;\n float phase = g_windTime * g_windSpeed\n + spatial * g_windStrength\n + phaseNoise * 6.2831853;\n\n float base = sin(phase);\n float gust = 0.5 * sin(phase * 1.7 + 1.2);\n float sway = (base + gust) * g_windAmount;\n\n float angle = clamp(sway * w * g_branchMaxAngle, -g_branchMaxAngle, g_branchMaxAngle);\n\n vec3 pivotL = vec3(0.0, g_branchRootY, 0.0);\n vec3 relL = pL - pivotL;\n vec3 bentPL = pivotL + rotateRodrigues(relL, axisL, angle);\n\n vec3 branchWorld = (finalWorld * vec4(bentPL, 1.0)).xyz;\n\n #if defined(POSITION) || defined(BUMP)\n vPositionW = branchWorld;\n #endif\n\n #ifdef NORMAL\n // normalUpdated is local/object normal\n vec3 nL = normalize(normalUpdated);\n vec3 bentNL = rotateRodrigues(nL, axisL, angle);\n\n // world normal from world basis (approx; assumes no non-uniform scale/shear)\n vec3 nW = normalize(bentNL.x * rightW + bentNL.y * upW + bentNL.z * fwdW);\n vNormalW = nW;\n #endif\n\n gl_Position = viewProjection * vec4(branchWorld, 1.0);\n "}:"fragment"===e?(BABYLON.ShaderLanguage.WGSL,{CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION:"\n // no-op\n "}):null},t.prototype.getUniforms=function(e){var t=e===BABYLON.ShaderLanguage.WGSL;return this.vertexDefinitions=this.getCustomShaderMaterial().getCustomVertexCode(t),this.fragmentDefinitions=!0===t?this.getCustomShaderMaterial().getCustomFragmentCode(t):null,this.getCustomShaderMaterial().getCustomUniforms(t)},t.prototype.getSamplers=function(e){var t=this.getCustomShaderMaterial().getCustomSamplers();t&&t.length>0&&e.push.apply(e,t)},t.prototype.getAttributes=function(e,t,i){var n=this.getCustomShaderMaterial().getCustomAttributes();n&&n.length>0&&e.push.apply(e,n),-1===e.indexOf("color")&&e.push("color")},t.prototype.prepareDefines=function(e,t,i){this.getIsEnabled()&&this.getCustomShaderMaterial().prepareCustomDefines(e)},t.prototype.bindForSubMesh=function(e,t,i,n){this.getIsEnabled()&&this.getCustomShaderMaterial().updateCustomBindings(e)},t.ExtractWindZoneOverride=function(e,t,i){var n,r=[];e&&r.push(e),e&&e.properties&&r.push(e.properties);var o=null==t?void 0:t.metadata;o&&r.push(o),o&&o.toolkit&&r.push(o.toolkit),o&&o.properties&&r.push(o.properties);var a=null==i?void 0:i.metadata;a&&r.push(a),a&&a.toolkit&&r.push(a.toolkit);var s=null===(n=null==i?void 0:i.transform)||void 0===n?void 0:n.metadata;s&&r.push(s),s&&s.toolkit&&r.push(s.toolkit);for(var l=null,u=0,h=r;u<h.length;u++){var c=h[u];if(c&&Array.isArray(c.windzones)){l=c.windzones;break}}if(!l||0===l.length)return null;for(var d=null,m=-1e9,p=0,f=l;p<f.length;p++){var g=f[p];if(g){var y=((null!=g.type?g.type:null!=g.mode?g.mode:"").toString().toLowerCase().indexOf("direction")>=0?1e3:0)+(null!=g.windMain?g.windMain:0);y>m&&(m=y,d=g)}}return d},t}(e.CustomShaderMaterialPlugin);e.TreeBranchMaterialPlugin=i,e.SceneManager.RegisterClass("TOOLKIT.TreeBranchMaterial",t),e.SceneManager.RegisterClass("TOOLKIT.TreeBranchMaterialPlugin",i)}(n||(n={})),function(e){var t=function(t){function i(i,n){var r=t.call(this,i,n)||this;return r.controller=null,r.runtimeAlbedoSkins=null,r.runtimeNormalSkins=null,r.shader=r.getShaderName(),r.addAttribute("g_vatAnim0"),r.addAttribute("g_vatAnim1"),r.addFloatUniform("g_vatTexWidth",1),r.addFloatUniform("g_vatTexHeight",1),r.addFloatUniform("g_vatRowsPerFrame",1),r.addFloatUniform("g_vatVertexCount",1),r.addVector3Uniform("g_vatPosMin",BABYLON.Vector3.Zero()),r.addVector3Uniform("g_vatPosMax",BABYLON.Vector3.One()),r.addFloatUniform("g_vatPrevTexWidth",1),r.addFloatUniform("g_vatPrevTexHeight",1),r.addFloatUniform("g_vatPrevRowsPerFrame",1),r.addVector3Uniform("g_vatPrevPosMin",BABYLON.Vector3.Zero()),r.addVector3Uniform("g_vatPrevPosMax",BABYLON.Vector3.One()),r.addTextureUniform("vatPosition",null),r.addTextureUniform("vatNormal",null),r.addTextureUniform("vatPrevPosition",null),r.addTextureUniform("vatPrevNormal",null),r.markTextureAsRaw("vatPosition"),r.markTextureAsRaw("vatNormal"),r.markTextureAsRaw("vatPrevPosition"),r.markTextureAsRaw("vatPrevNormal"),r.plugin=new e.VertexAnimationMaterialPlugin(r,r.shader),r}return o(i,t),i.prototype.awake=function(){console.warn("VertexAnimationMaterial - Awake(): "+this.name)},i.prototype.update=function(){},i.prototype.getShaderName=function(){return"VertexAnimationMaterial"},i.prototype.getController=function(){return this.controller},i.prototype.cloneForInstance=function(t){var i=this.getScene(),n=new e.VertexAnimationMaterial(t,i);return n.albedoColor=this.albedoColor?this.albedoColor.clone():n.albedoColor,n.albedoTexture=this.albedoTexture,n.reflectivityColor=this.reflectivityColor?this.reflectivityColor.clone():n.reflectivityColor,n.reflectivityTexture=this.reflectivityTexture,n.metallicTexture=this.metallicTexture,n.metallic=this.metallic,n.roughness=this.roughness,n.metallicF0Factor=this.metallicF0Factor,n.bumpTexture=this.bumpTexture,n.emissiveColor=this.emissiveColor?this.emissiveColor.clone():n.emissiveColor,n.emissiveTexture=this.emissiveTexture,n.ambientColor=this.ambientColor?this.ambientColor.clone():n.ambientColor,n.ambientTexture=this.ambientTexture,n.opacityTexture=this.opacityTexture,n.useAlphaFromAlbedoTexture=this.useAlphaFromAlbedoTexture,n.twoSidedLighting=this.twoSidedLighting,n.backFaceCulling=this.backFaceCulling,n.sideOrientation=this.sideOrientation,n.alpha=this.alpha,n.alphaMode=this.alphaMode,n.transparencyMode=this.transparencyMode,n.runtimeAlbedoSkins=this.runtimeAlbedoSkins,n.runtimeNormalSkins=this.runtimeNormalSkins,n._notifyPluginOfRuntimeSkinChange(),n},i.prototype.setRuntimeSkinArrays=function(e,t,i){void 0===i&&(i=!0),this.runtimeAlbedoSkins=e||null,this.runtimeNormalSkins=t||null,i&&(this.albedoTexture=null,this.bumpTexture=null),this._notifyPluginOfRuntimeSkinChange()},i.prototype.clearRuntimeSkinArrays=function(){this.runtimeAlbedoSkins=null,this.runtimeNormalSkins=null,this._notifyPluginOfRuntimeSkinChange()},i.prototype.installSkinsFromUrlsAsync=function(e,t,i,n){return s(this,void 0,void 0,function(){var r,o,a,s,u,h,c,d,m,p,f,g,y,v,S,_;return l(this,function(l){switch(l.label){case 0:if(!e||0===e.length)throw new Error("VertexAnimationMaterial.installSkinsFromUrlsAsync: layers list is empty.");for(o=!1!==(r=n||{}).nullOutDefaults,a=r.rootUrl||"",s=!1!==r.generateMipMaps,u=null!=r.samplingMode?r.samplingMode:BABYLON.Texture.TRILINEAR_SAMPLINGMODE,h=this.getScene(),c=e.length,d=t*i*4,m=new Uint8Array(d*c),p=new Uint8Array(d*c),f=function(e){if(!e)return"";if(e.indexOf("://")>=0||0===e.indexOf("blob:")||0===e.indexOf("data:")||0===e.indexOf("/"))return e;if(a){var t="/"===a.charAt(a.length-1)?"":"/";return a+t+e}return e},g=function(e,n,r,o){return new Promise(function(a,s){var l=f(e),c=new BABYLON.Texture(l,h,!0,!0,u,function(){var e=c.getSize();if(e.width!==t||e.height!==i)return c.dispose(),void s(new Error("".concat(o," '").concat(l,"' is ").concat(e.width,"x").concat(e.height,", expected ").concat(t,"x").concat(i,".")));var u=c.readPixels(),h=function(e){if(!e)return c.dispose(),void s(new Error("".concat(o," '").concat(l,"': readPixels returned null.")));n.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r*d),c.dispose(),a()};u&&"function"==typeof u.then?u.then(h).catch(function(e){c.dispose(),s(e)}):h(u)},function(e){return s(new Error("".concat(o," '").concat(l,"' load failed: ").concat(e)))})})},y=[],v=0;v<c;v++)y.push(g(e[v].albedo,m,v,"Skin albedo")),y.push(g(e[v].normal,p,v,"Skin normal"));return[4,Promise.all(y)];case 1:return l.sent(),S=BABYLON.RawTexture2DArray.CreateRGBATexture(m,t,i,c,h,s,!1,u),(_=BABYLON.RawTexture2DArray.CreateRGBATexture(p,t,i,c,h,s,!1,u)).gammaSpace=!1,this.setRuntimeSkinArrays(S,_,o),[2]}})})},i.prototype._notifyPluginOfRuntimeSkinChange=function(){var e=this.plugin;e&&"function"==typeof e.onRuntimeSkinArraysChanged&&e.onRuntimeSkinArraysChanged(),this.markAsDirty(BABYLON.Constants.MATERIAL_AllDirtyFlag)},i}(e.CustomShaderMaterial);e.VertexAnimationMaterial=t;var i=function(){function t(e,t,i,n){var r=this;this._plugins=[],this._clips={},this._currentClip=null,this._previousClip=null,this._time=0,this._previousTime=0,this._speed=1,this._loop=!1,this._loopBlend=!1,this._manualLoopOverride=null,this._playing=!1,this._blendDuration=0,this._blendElapsed=0,this._blendWeight=1,this._mode="auto",this._normalMode="none",this._lazyLoad=!1,this._tickObserver=null,this._disposeObserver=null,this._lastFrameId=-1,this._textureCache={},this._textureCacheKeys={},this._instanceMeshes={},this.guid=e,this.scene=t,this.rootUrl=i||"",this._lazyLoad=!0===n,this._tickObserver=t.onBeforeRenderObservable.add(function(){return r._tick()}),this._disposeObserver=t.onDisposeObservable.addOnce(function(){return r.dispose()})}return t.Find=function(t){return t&&e.VertexAnimationController._registry[t]||null},t.GetOrCreate=function(t,i,n,r){if(void 0===n&&(n=""),void 0===r&&(r=!1),!t)throw new Error("VertexAnimationController: vertexcontroller is required.");var o=e.VertexAnimationController._registry[t];return o||(o=new e.VertexAnimationController(t,i,n,r),e.VertexAnimationController._registry[t]=o),o},t.CollectRendererTargets=function(e){var t=[],i={};if(!e)return t;for(var n=0,r=e;n<r.length;n++){var o=r[n];if(o){var a=o.vertexguid||o.vertexpath||o.vertextransform||o.name;a&&!i[a]&&(i[a]=!0,t.push(o))}}return t},t.SetSkinIndex=function(e,t){e&&(e.runtimeSkinIndex=Math.max(0,Math.floor(t||0)))},t.GetSkinIndex=function(e){if(!e)return 0;var t=e.runtimeSkinIndex;return"number"==typeof t&&isFinite(t)&&t>=0?Math.floor(t):0},t.DisposeAll=function(t){for(var i=0,n=Object.keys(e.VertexAnimationController._registry);i<n.length;i++){var r=n[i],o=e.VertexAnimationController._registry[r];t&&o.scene!==t||o.dispose()}},t.prototype.setInstanceMesh=function(e,t){e&&t&&(this._instanceMeshes[e]=t)},t.prototype.dispose=function(){this._tickObserver&&(this.scene.onBeforeRenderObservable.remove(this._tickObserver),this._tickObserver=null),this._disposeObserver&&(this.scene.onDisposeObservable.remove(this._disposeObserver),this._disposeObserver=null);for(var i=0,n=Object.keys(this._textureCacheKeys);i<n.length;i++){var r=n[i];e.VertexAnimationController._releaseVATTexture(this.scene,r)}this._textureCache={},this._textureCacheKeys={},this._clips={},this._plugins.length=0,this._currentClip=null,this._previousClip=null,delete t._registry[this.guid]},Object.defineProperty(t.prototype,"currentClip",{get:function(){return this._currentClip},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"previousClip",{get:function(){return this._previousClip},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentTime",{get:function(){return this._time},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"previousTime",{get:function(){return this._previousTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendWeight",{get:function(){return this._blendWeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPlaying",{get:function(){return this._playing},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalMode",{get:function(){return this._normalMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loopBlend",{get:function(){return this._loopBlend},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mode",{get:function(){return this._mode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"speed",{get:function(){return this._speed},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loopOverride",{get:function(){return this._manualLoopOverride},enumerable:!1,configurable:!0}),t.prototype.getClip=function(e){return e&&this._clips[e]||null},t.prototype.setSpeed=function(e){this._speed=e},t.prototype.setLoop=function(e){this._manualLoopOverride=e,this._loop=e},t.prototype.setRuntimeSkinArrays=function(e,t,i){void 0===i&&(i=!0);for(var n=0;n<this._plugins.length;n++){var r=this._plugins[n].getCustomShaderMaterial();r&&r.setRuntimeSkinArrays(e,t,i)}},t.prototype.clearRuntimeSkinArrays=function(){for(var e=0;e<this._plugins.length;e++){var t=this._plugins[e].getCustomShaderMaterial();t&&t.clearRuntimeSkinArrays()}},t.prototype.installSkinsFromUrlsAsync=function(e,t,i,n){return s(this,void 0,void 0,function(){var r,o,s,u,h,c,d,m;return l(this,function(l){switch(l.label){case 0:if(0===this._plugins.length)throw new Error("VertexAnimationController.installSkinsFromUrlsAsync: no registered VAT materials.");return o=a(a({},r=n||{}),{rootUrl:r.rootUrl||this.rootUrl}),s=!1!==r.nullOutDefaults,[4,(u=this._plugins[0].getCustomShaderMaterial()).installSkinsFromUrlsAsync(e,t,i,o)];case 1:for(l.sent(),h=u.runtimeAlbedoSkins,c=u.runtimeNormalSkins,d=1;d<this._plugins.length;d++)(m=this._plugins[d].getCustomShaderMaterial())&&m.setRuntimeSkinArrays(h,c,s);return[2]}})})},t.prototype.setCurrentTime=function(e){if(this._currentClip){var t=this._currentClip.duration;this._time=e,t>0?this._loop?this._time=this._wrapTime(this._time,t):this._time=Math.max(0,Math.min(this._time,t)):this._time=Math.max(0,this._time)}},t.prototype.getCurrentTime=function(){return this._time},t.prototype.addPlugin=function(e){-1===this._plugins.indexOf(e)&&this._plugins.push(e)},t.prototype.removePlugin=function(e){var t=this._plugins.indexOf(e);-1!==t&&this._plugins.splice(t,1)},t.prototype.loadAnimations=function(e){var t;if(e&&0!==e.length){"none"===this._normalMode&&e[0]&&e[0].vertexpacking&&(this._normalMode=e[0].vertexpacking);for(var i=0,n=e;i<n.length;i++){var r=n[i];if(r&&r.name){var o=r.vertexguid||r.vertextransform;if(o){var a=this._clips[r.name];if(a||(a={name:r.name,renderers:{},firstRendererGuid:o,duration:0,loop:!1,loopBlend:!1},this._clips[r.name]=a),a.firstRendererGuid||(a.firstRendererGuid=o),!a.renderers[o]){a.renderers&&0===Object.keys(a.renderers).length&&(a.loop=!0===r.vertexlooptime,a.loopBlend=!0===r.vertexloopblend);var s=null,l=null;this._lazyLoad||(s=this._getOrAcquireTexture(r.vertex),l="separate"===r.vertexpacking&&r.vertexnormal?this._getOrAcquireTexture(r.vertexnormal):null),a.renderers[o]={guid:o,settings:r,positionTexture:s,normalTexture:l,posMinV3:BABYLON.Vector3.FromArray(r.vertexposmin),posMaxV3:BABYLON.Vector3.FromArray(r.vertexposmax),fromRow:r.vertexcombined&&null!==(t=r.vertexfromrow)&&void 0!==t?t:0};var u=r.vertexframes>0&&r.vertexfps>0?r.vertexframes/r.vertexfps:0;u>a.duration&&(a.duration=u)}}}}}},t.prototype.play=function(e,t){void 0===t&&(t=.1);var i=this._clips[e];return i?(this._mode="auto",this._ensureClipTexturesLoaded(i),t>0&&this._currentClip&&this._currentClip!==i?(this._ensureClipTexturesLoaded(this._currentClip),this._previousClip=this._currentClip,this._previousTime=this._time,this._blendDuration=t,this._blendElapsed=0,this._blendWeight=0):(this._previousClip=null,this._blendDuration=0,this._blendElapsed=0,this._blendWeight=1),this._currentClip=i,this._time=0,this._playing=!0,this._loop=null!==this._manualLoopOverride?this._manualLoopOverride:!!i.loop,this._loopBlend=!!i.loopBlend,!0):(console.error("VertexAnimationController '".concat(this.guid,"': No clip found with name '").concat(e,"'.")),!1)},t.prototype.pause=function(){this._playing=!1},t.prototype.resume=function(){this._currentClip&&(this._playing=!0)},t.prototype.stop=function(){this._mode="auto",this._playing=!1,this._time=0,this._previousClip=null,this._previousTime=0,this._blendDuration=0,this._blendElapsed=0,this._blendWeight=1},t.prototype.driveBlend=function(e,t,i,n,r){var o=e?this._clips[e]:null;if(!o)return!1;this._ensureClipTexturesLoaded(o);var a=i?this._clips[i]:null;return a&&this._ensureClipTexturesLoaded(a),this._mode="drive",this._playing=!0,this._currentClip=o,this._time=t,this._previousClip=a||null,this._previousTime=a?n:0,this._blendDuration=0,this._blendElapsed=0,this._blendWeight=r<0?0:r>1?1:r,this._loop=null!==this._manualLoopOverride?this._manualLoopOverride:!!o.loop,this._loopBlend=!!o.loopBlend,!0},t.prototype.getCurrentRendererClip=function(e){return this._getRendererClip(this._currentClip,e)},t.prototype.getPreviousRendererClip=function(e){return this._getRendererClip(this._previousClip,e)},t.prototype._tick=function(){var e=this.scene.getFrameId();if(this._lastFrameId!==e){if(this._lastFrameId=e,"auto"===this._mode&&this._playing&&this._currentClip){var t=this.scene.getEngine().getDeltaTime()/1e3,i=Math.min(t,1/30);this._time+=i*this._speed;var n=this._currentClip.duration;if(n>0&&(this._loop?this._time=this._wrapTime(this._time,n):this._time>=n?(this._time=n,this._playing=!1):this._time<0&&(this._time=0,this._playing=!1)),this._previousClip){this._previousTime+=i*this._speed;var r=this._previousClip.duration;r>0&&this._previousTime>r&&(this._previousTime=r),r>0&&this._previousTime<0&&(this._previousTime=0)}this._blendDuration>0&&(this._areBlendTargetsReady()?(this._blendElapsed+=i,this._blendWeight=Math.min(1,this._blendElapsed/this._blendDuration),this._blendWeight>=1&&(this._previousClip=null,this._blendDuration=0,this._blendElapsed=0)):(this._blendElapsed=0,this._blendWeight=0))}for(var o=0,a=Object.keys(this._instanceMeshes);o<a.length;o++){var s=a[o],l=this._instanceMeshes[s];if(l&&l.instancedBuffers){var u=l.instancedBuffers,h=this._getOrCreateVATBuffer(u,"g_vatAnim0"),c=this._getOrCreateVATBuffer(u,"g_vatAnim1"),d=this.getCurrentRendererClip(s);if(d&&this._currentClip&&this._isRendererPositionReady(d)){var m=d.settings;h.set(this._time*m.vertexfps,m.vertexframes,d.fromRow,this._blendWeight);var p=this._loopBlend?1:0,f=l.runtimeSkinIndex,g="number"==typeof f&&f>=0?f:0;c.w=2*g+p;var y=this.getPreviousRendererClip(s);if(y&&this._previousClip&&this._blendWeight<.999&&this._isRendererPositionReady(y)){var v=y.settings;c.x=this._previousTime*v.vertexfps,c.y=v.vertexframes,c.z=y.fromRow}else c.x=0,c.y=0,c.z=0}else h.set(0,0,0,1),c.set(0,0,0,0)}}for(var S=0;S<this._plugins.length;S++){var _=this._plugins[S],b=_.getCustomShaderMaterial();_.syncFromController(b,this)}}},t.prototype._getOrCreateVATBuffer=function(e,t){var i=e[t];return i&&"function"==typeof i.set||(i=new BABYLON.Vector4(0,0,0,0),e[t]=i),i},t.prototype._isRendererPositionReady=function(e){var t=e?e.positionTexture:null;return!(!t||"function"!=typeof t.isReady||!t.isReady())},t.prototype._areBlendTargetsReady=function(){if(!this._previousClip)return!0;for(var e=0,t=Object.keys(this._instanceMeshes);e<t.length;e++){var i=t[e],n=this.getCurrentRendererClip(i),r=this.getPreviousRendererClip(i);if(!this._isRendererPositionReady(n)||!this._isRendererPositionReady(r))return!1}return!0},t.prototype._wrapTime=function(e,t){if(t<=0)return 0;var i=e%t;return i<0&&(i+=t),i},t.prototype._ensureClipTexturesLoaded=function(e){if(e&&e.renderers)for(var t=0,i=Object.keys(e.renderers);t<i.length;t++){var n=i[t],r=e.renderers[n];r&&(!r.positionTexture&&r.settings.vertex&&(r.positionTexture=this._getOrAcquireTexture(r.settings.vertex)),!r.normalTexture&&"separate"===r.settings.vertexpacking&&r.settings.vertexnormal&&(r.normalTexture=this._getOrAcquireTexture(r.settings.vertexnormal)))}},t.prototype._getOrAcquireTexture=function(t){if(!t)return null;var i=this._resolveUrl(t),n=this._textureCache[i];return n||(n=e.VertexAnimationController._acquireVATTexture(this.scene,i),this._textureCache[i]=n,this._textureCacheKeys[i]=!0,n)},t._acquireVATTexture=function(t,i){var n=e.VertexAnimationController._makeVATTextureCacheKey(t,i),r=e.VertexAnimationController._globalTextureCache[n];if(r&&r.texture)return r.refs++,r.texture;var o=e.VertexAnimationController._createVATTexture(t,i);return e.VertexAnimationController._globalTextureCache[n]={texture:o,refs:1},o},t._releaseVATTexture=function(t,i){var n=e.VertexAnimationController._makeVATTextureCacheKey(t,i),r=e.VertexAnimationController._globalTextureCache[n];r&&(r.refs--,r.refs<=0&&(r.texture&&r.texture.dispose(),delete e.VertexAnimationController._globalTextureCache[n]))},t._makeVATTextureCacheKey=function(e,t){var i=e?e.getEngine():null;return[i&&null!=i.uid?i.uid:i&&null!=i._uid?i._uid:i&&i.getClassName?i.getClassName():"engine",e&&null!=e.uid?e.uid:e&&null!=e._uid?e._uid:e&&e.metadata&&e.metadata.guid?e.metadata.guid:"scene",t,"VAT","noMipmap=true","invertY=true","sampling=NEAREST_NEAREST","wrap=CLAMP","gammaSpace=false"].join("|")},t._createVATTexture=function(e,t){var i=new BABYLON.Texture(t,e,!0,!0,BABYLON.Texture.NEAREST_NEAREST);return i.wrapU=BABYLON.Texture.CLAMP_ADDRESSMODE,i.wrapV=BABYLON.Texture.CLAMP_ADDRESSMODE,i.anisotropicFilteringLevel=1,i.gammaSpace=!1,i},t.prototype._resolveUrl=function(e){if(!e)return"";if(e.indexOf("://")>=0||0===e.indexOf("blob:")||0===e.indexOf("data:")||0===e.indexOf("/"))return e;if(this.rootUrl){var t="/"===this.rootUrl.charAt(this.rootUrl.length-1)?"":"/";return this.rootUrl+t+e}return e},t.prototype._getRendererClip=function(e,t){if(!e||!e.renderers)return null;if(t&&e.renderers[t])return e.renderers[t];if(e.firstRendererGuid&&e.renderers[e.firstRendererGuid])return e.renderers[e.firstRendererGuid];var i=Object.keys(e.renderers);return i.length>0?e.renderers[i[0]]:null},t._registry={},t._globalTextureCache={},t}();e.VertexAnimationController=i;var n=function(t){function i(e,i){var n=t.call(this,e,i,100,{VERTEXANIMATIONMATERIAL:!1,VAT_NORMAL_SEPARATE:!1,RUNTIME_SKINS_ALBEDO:!1,RUNTIME_SKINS_NORMAL:!1,RUNTIME_SKINS_NORMAL_DERIVE_TBN:!1})||this;n.vertexAnimations=null,n.controller=null,n._rendererTargets=[],n._targetRendererGuid="",n._placeholderTexture=null,n._placeholderAlbedoArray=null,n._placeholderNormalArray=null,n._cc_posTex=null,n._cc_normTex=null,n._cc_prevPosTex=null,n._cc_prevNormTex=null,n._cc_texW=1,n._cc_texH=1,n._cc_rowsPF=1,n._cc_vCount=1,n._cc_posMin=null,n._cc_posMax=null,n._cc_prevTexW=1,n._cc_prevTexH=1,n._cc_prevRowsPF=1,n._cc_prevPosMin=null,n._cc_prevPosMax=null;var r=e.getScene();n._placeholderTexture=BABYLON.RawTexture.CreateRGBATexture(new Uint8Array([128,128,128,255]),1,1,r,!1,!1,BABYLON.Texture.NEAREST_SAMPLINGMODE),e.setTextureValue("vatPosition",n._placeholderTexture),e.setTextureValue("vatNormal",n._placeholderTexture),e.setTextureValue("vatPrevPosition",n._placeholderTexture),e.setTextureValue("vatPrevNormal",n._placeholderTexture);var o=new Uint8Array([128,128,128,255]),a=new Uint8Array([128,128,255,255]);return n._placeholderAlbedoArray=BABYLON.RawTexture2DArray.CreateRGBATexture(o,1,1,1,r,!1,!1,BABYLON.Texture.NEAREST_SAMPLINGMODE),n._placeholderNormalArray=BABYLON.RawTexture2DArray.CreateRGBATexture(a,1,1,1,r,!1,!1,BABYLON.Texture.NEAREST_SAMPLINGMODE),n}return o(i,t),i.prototype.dispose=function(){this._placeholderTexture&&(this._placeholderTexture.dispose(),this._placeholderTexture=null),this._placeholderAlbedoArray&&(this._placeholderAlbedoArray.dispose(),this._placeholderAlbedoArray=null),this._placeholderNormalArray&&(this._placeholderNormalArray.dispose(),this._placeholderNormalArray=null),t.prototype.dispose.call(this)},i.prototype.isCompatible=function(e){return e===BABYLON.ShaderLanguage.WGSL||e===BABYLON.ShaderLanguage.GLSL},i.prototype.getCustomCode=function(e,t){var i=t===BABYLON.ShaderLanguage.WGSL;return"vertex"===e?i?{CUSTOM_VERTEX_DEFINITIONS:this.getWGSLVertexDefinitions(),CUSTOM_VERTEX_UPDATE_POSITION:this.getWGSLVertexPositionCode(),CUSTOM_VERTEX_UPDATE_NORMAL:this.getWGSLVertexNormalCode(),CUSTOM_VERTEX_MAIN_END:this.getWGSLVertexMainEnd()}:{CUSTOM_VERTEX_DEFINITIONS:this.getGLSLVertexDefinitions(),CUSTOM_VERTEX_UPDATE_POSITION:this.getGLSLVertexPositionCode(),CUSTOM_VERTEX_UPDATE_NORMAL:this.getGLSLVertexNormalCode(),CUSTOM_VERTEX_MAIN_END:this.getGLSLVertexMainEnd()}:"fragment"===e?i?{CUSTOM_FRAGMENT_DEFINITIONS:this.getWGSLFragmentDefinitions(),CUSTOM_FRAGMENT_UPDATE_ALBEDO:this.getWGSLFragmentAlbedoCode(),CUSTOM_FRAGMENT_BEFORE_LIGHTS:this.getWGSLFragmentNormalCode()}:{CUSTOM_FRAGMENT_DEFINITIONS:this.getGLSLFragmentDefinitions(),CUSTOM_FRAGMENT_UPDATE_ALBEDO:this.getGLSLFragmentAlbedoCode(),CUSTOM_FRAGMENT_BEFORE_LIGHTS:this.getGLSLFragmentNormalCode()}:null},i.prototype.getUniforms=function(e){var t=e===BABYLON.ShaderLanguage.WGSL;return this.vertexDefinitions=this.getCustomShaderMaterial().getCustomVertexCode(t),this.fragmentDefinitions=!0===t?this.getCustomShaderMaterial().getCustomFragmentCode(t):null,this.getCustomShaderMaterial().getCustomUniforms(t)},i.prototype.getSamplers=function(e){var t=this.getCustomShaderMaterial().getCustomSamplers();null!=t&&t.length>0&&e.push.apply(e,t),this.getCustomShaderMaterial()&&(-1===e.indexOf("runtimeAlbedoSkins")&&e.push("runtimeAlbedoSkins"),-1===e.indexOf("runtimeNormalSkins")&&e.push("runtimeNormalSkins"))},i.prototype.getAttributes=function(e,t,i){var n=this.getCustomShaderMaterial().getCustomAttributes();null!=n&&n.length>0&&e.push.apply(e,n)},i.prototype.prepareDefines=function(e,t,i){if(this.getIsEnabled()){this._captureRendererTarget(i),this.getCustomShaderMaterial().prepareCustomDefines(e);var n=this.controller?this.controller.normalMode:"none";e.VAT_NORMAL_SEPARATE="separate"===n;var r=t?t.getEngine():null;e.UV3=!(r&&r.isWebGPU);var o=this.getCustomShaderMaterial(),a=!(!o||!o.runtimeAlbedoSkins),s=!(!o||!o.runtimeNormalSkins);e.RUNTIME_SKINS_ALBEDO=a,e.RUNTIME_SKINS_NORMAL=s,e.RUNTIME_SKINS_NORMAL_DERIVE_TBN=s&&!(o&&o.bumpTexture)}},i.prototype.onRuntimeSkinArraysChanged=function(){this.markAllDefinesAsDirty()},i.prototype.bindForSubMesh=function(e,t,i,n){if(this.getIsEnabled()){var r=n&&n.getRenderingMesh?n.getRenderingMesh():null;this._captureRendererTarget(r||(n?n.getMesh():null)),this._pushVATUniforms(e,!1),this._pushRuntimeSkinSamplers(e)}},i.prototype._pushRuntimeSkinSamplers=function(e){var t=this.getCustomShaderMaterial(),i=t&&t.runtimeAlbedoSkins&&t.runtimeAlbedoSkins.isReady&&t.runtimeAlbedoSkins.isReady()?t.runtimeAlbedoSkins:this._placeholderAlbedoArray,n=t&&t.runtimeNormalSkins&&t.runtimeNormalSkins.isReady&&t.runtimeNormalSkins.isReady()?t.runtimeNormalSkins:this._placeholderNormalArray;e.setTexture("runtimeAlbedoSkins",i),e.setTexture("runtimeNormalSkins",n)},i.prototype.setupAnimations=function(t,i,n,r){var o,a;if(void 0===n&&(n=""),void 0===r&&(r=!1),this.vertexAnimations=t,t&&0!==t.length){if(i){this._rendererTargets=e.VertexAnimationController.CollectRendererTargets(t),this._targetRendererGuid="";var s=this.getCustomShaderMaterial(),l=s.getScene(),u=e.VertexAnimationController.GetOrCreate(i,l,n,r);u.loadAnimations(t),u.addPlugin(this),this.controller=u,s.controller=u;var h=function(e){var t,i;if(e){if(!e._vatMaterials){e._vatMaterials=[];var n=null;e.onBeforeShadowMapRenderMeshObservable.add(function(e){n=e}),e.onBeforeShadowMapRenderObservable.add(function(t){if(n&&t)for(var i=n.material,r=e._vatMaterials,o=0;o<r.length;o++)if(r[o]===i){var a=r[o].getPlugin();a&&a.bindVATToEffect(t);break}n=null}),e.forceBackFacesOnly=!0,d?(e.normalBias=0,0===(null!==(i=e.bias)&&void 0!==i?i:0)&&(e.bias=.005)):0===(null!==(t=e.normalBias)&&void 0!==t?t:0)&&(e.normalBias=.02)}var r=e._vatMaterials;-1===r.indexOf(s)&&r.push(s)}},c=function(){for(var e,t,i=0,n=l.lights;i<n.length;i++){var r=n[i];h(null===(t=(e=r).getShadowGenerator)||void 0===t?void 0:t.call(e))}},d=!0===l.getEngine().isWebGPU||"WebGPUEngine"===(null===(a=(o=l.getEngine()).getClassName)||void 0===a?void 0:a.call(o));return s.shadowDepthWrapper||(s.shadowDepthWrapper=new BABYLON.ShadowDepthWrapper(s,l)),c(),l.onAfterRenderObservable.addOnce(function(){return c()}),s.markAsDirty(BABYLON.Constants.MATERIAL_AllDirtyFlag),this.markAllDefinesAsDirty(),u}BABYLON.Tools.Warn("VertexAnimationMaterialPlugin: vertexcontroller is empty — cannot share controller.")}},i.prototype._captureRendererTarget=function(e){if(""===this._targetRendererGuid){var t=this._resolveRendererTarget(e);t&&t.vertexguid&&(this._targetRendererGuid=t.vertexguid)}},i.prototype._resolveRendererTarget=function(e){if(!e||!this._rendererTargets||0===this._rendererTargets.length)return null;if(1===this._rendererTargets.length)return this._rendererTargets[0];for(var t=[],i=e;i;)t.push(i),i=i.parent;for(var n=0,r=t;n<r.length;n++){var o=r[n],a=this._readMetadataString(o,"guid");if(a&&(d=this._matchRendererByGuid(a)))return d}for(var s=0,l=t;s<l.length;s++){o=l[s];var u=this._buildNodePath(o);if(u&&(d=this._matchRendererByPath(u)))return d}for(var h=0,c=t;h<c.length;h++){var d,m=(o=c[h])&&o.name?o.name:"";if(m&&(d=this._matchRendererByName(m)))return d}return null},i.prototype._matchRendererByGuid=function(e){for(var t=0,i=this._rendererTargets;t<i.length;t++){var n=i[t];if(n&&n.vertexguid===e)return n}return null},i.prototype._matchRendererByPath=function(e){for(var t=0,i=this._rendererTargets;t<i.length;t++){var n=i[t];if(n&&n.vertexpath&&this._pathEndsWith(e,n.vertexpath))return n}return null},i.prototype._matchRendererByName=function(e){for(var t=0,i=this._rendererTargets;t<i.length;t++){var n=i[t];if(n){if(n.vertextransform===e)return n;if(n.vertexrenderer===e)return n;if(n.vertexmesh===e)return n}}return null},i.prototype._readMetadataString=function(e,t){if(!e||!e.metadata)return"";var i=e.metadata,n=i?i[t]:null;if("string"==typeof n&&""!==n)return n;var r=i?i.toolkit:null,o=r?r[t]:null;return"string"==typeof o&&""!==o?o:"guid"===t&&"string"==typeof e.id&&""!==e.id?e.id:""},i.prototype._buildNodePath=function(e){for(var t=[],i=e;i;)i.name&&t.unshift(i.name),i=i.parent;return t.join("/")},i.prototype._pathEndsWith=function(e,t){if(!e||!t)return!1;if(e===t)return!0;if(e.length<=t.length)return!1;var i=e.length-t.length;return e.substring(i)===t&&"/"===e.charAt(i-1)},i.prototype.syncFromController=function(e,t){void 0===t&&(t=null);var i=t||this.controller;if(i){var n=this._placeholderTexture,r=function(e){return null!=e&&"function"==typeof e.isReady&&e.isReady()},o=(i.normalMode,i.getCurrentRendererClip(this._targetRendererGuid));if(o){var a=r(o.positionTexture)?o.positionTexture:n,s=r(o.normalTexture)?o.normalTexture:n;e.setTextureValue("vatPosition",a),e.setTextureValue("vatNormal",s);var l=o.settings;this._cc_posTex=a,this._cc_normTex=s,this._cc_texW=l.vertexwidth,this._cc_texH=l.vertexheight,this._cc_rowsPF=l.vertexrowsperframe,this._cc_vCount=l.vertexcount,this._cc_posMin=o.posMinV3,this._cc_posMax=o.posMaxV3}else e.setTextureValue("vatPosition",n),e.setTextureValue("vatNormal",n),this._cc_posTex=n,this._cc_normTex=n,this._cc_posMin=null,this._cc_posMax=null;var u=i.getPreviousRendererClip(this._targetRendererGuid);if(u){var h=r(u.positionTexture)?u.positionTexture:n,c=r(u.normalTexture)?u.normalTexture:n;e.setTextureValue("vatPrevPosition",h),e.setTextureValue("vatPrevNormal",c),l=u.settings,this._cc_prevPosTex=h,this._cc_prevNormTex=c,this._cc_prevTexW=l.vertexwidth,this._cc_prevTexH=l.vertexheight,this._cc_prevRowsPF=l.vertexrowsperframe,this._cc_prevPosMin=u.posMinV3,this._cc_prevPosMax=u.posMaxV3}else e.setTextureValue("vatPrevPosition",n),e.setTextureValue("vatPrevNormal",n),this._cc_prevPosTex=n,this._cc_prevNormTex=n,this._cc_prevPosMin=null,this._cc_prevPosMax=null}},i.prototype.bindVATToEffect=function(e){this._pushVATUniforms(e,!0),this._pushRuntimeSkinSamplers(e)},i.prototype._pushVATUniforms=function(e,t){var n,r,o,a,s,l,u,h,c,d,m=this._placeholderTexture,p=i._zeroV3,f=i._oneV3,g=null==this._cc_prevPosTex||this._cc_prevPosTex===m||null==this._cc_prevPosMin||null==this._cc_prevPosMax,y=g?null!==(n=this._cc_posTex)&&void 0!==n?n:m:this._cc_prevPosTex,v=g?null!==(r=this._cc_normTex)&&void 0!==r?r:m:this._cc_prevNormTex,S=g?null!==(o=this._cc_posMin)&&void 0!==o?o:p:this._cc_prevPosMin,_=g?null!==(a=this._cc_posMax)&&void 0!==a?a:f:this._cc_prevPosMax,b=g?this._cc_texW:this._cc_prevTexW,B=g?this._cc_texH:this._cc_prevTexH,C=g?this._cc_rowsPF:this._cc_prevRowsPF;if(e.setTexture("vatPosition",null!==(s=this._cc_posTex)&&void 0!==s?s:m),e.setTexture("vatNormal",null!==(l=this._cc_normTex)&&void 0!==l?l:m),e.setTexture("vatPrevPosition",null!=y?y:m),e.setTexture("vatPrevNormal",null!=v?v:m),t){var A=e;A.setFloat("g_vatTexWidth",this._cc_texW),A.setFloat("g_vatTexHeight",this._cc_texH),A.setFloat("g_vatRowsPerFrame",this._cc_rowsPF),A.setFloat("g_vatVertexCount",this._cc_vCount),A.setVector3("g_vatPosMin",null!==(u=this._cc_posMin)&&void 0!==u?u:p),A.setVector3("g_vatPosMax",null!==(h=this._cc_posMax)&&void 0!==h?h:f),A.setFloat("g_vatPrevTexWidth",b),A.setFloat("g_vatPrevTexHeight",B),A.setFloat("g_vatPrevRowsPerFrame",C),A.setVector3("g_vatPrevPosMin",S),A.setVector3("g_vatPrevPosMax",_)}else{var T=e;T.updateFloat("g_vatTexWidth",this._cc_texW),T.updateFloat("g_vatTexHeight",this._cc_texH),T.updateFloat("g_vatRowsPerFrame",this._cc_rowsPF),T.updateFloat("g_vatVertexCount",this._cc_vCount),T.updateVector3("g_vatPosMin",null!==(c=this._cc_posMin)&&void 0!==c?c:p),T.updateVector3("g_vatPosMax",null!==(d=this._cc_posMax)&&void 0!==d?d:f),T.updateFloat("g_vatPrevTexWidth",b),T.updateFloat("g_vatPrevTexHeight",B),T.updateFloat("g_vatPrevRowsPerFrame",C),T.updateVector3("g_vatPrevPosMin",S),T.updateVector3("g_vatPrevPosMax",_)}},i.prototype.getGLSLVertexDefinitions=function(){return"\n #ifndef TOOLKIT_VAT_V_UNIFORMS\n #define TOOLKIT_VAT_V_UNIFORMS\n // Per-instance animation values come from InstancedMesh.instancedBuffers\n // (vertex attributes with divisor=1) — NOT uniforms. Every instance in a\n // hardware-instanced draw call gets its own independent values.\n attribute vec4 g_vatAnim0; // frame, frameCount, fromRow, blendWeight\n attribute vec4 g_vatAnim1; // prevFrame, prevFrameCount, prevFromRow, loopBlend\n uniform float g_vatTexWidth;\n uniform float g_vatTexHeight;\n uniform float g_vatRowsPerFrame;\n uniform float g_vatVertexCount;\n uniform vec3 g_vatPosMin;\n uniform vec3 g_vatPosMax;\n uniform float g_vatPrevTexWidth;\n uniform float g_vatPrevTexHeight;\n uniform float g_vatPrevRowsPerFrame;\n uniform vec3 g_vatPrevPosMin;\n uniform vec3 g_vatPrevPosMax;\n uniform sampler2D vatPosition;\n uniform sampler2D vatNormal;\n uniform sampler2D vatPrevPosition;\n uniform sampler2D vatPrevNormal;\n #endif\n // Runtime-skin varyings — pass packed skin index + UV0 to the fragment stage so\n // fragment can sample runtimeAlbedoSkins[layer]/runtimeNormalSkins[layer]. Always\n // emitted (cheap) so the shader compiles regardless of the runtime-skin defines.\n #ifndef TOOLKIT_VAT_RUNTIMESKIN_VARYINGS\n #define TOOLKIT_VAT_RUNTIMESKIN_VARYINGS\n varying float vRuntimeSkinIndex;\n varying vec2 vRuntimeSkinUV;\n #endif\n "},i.prototype.getGLSLVertexPositionCode=function(){return"\n #ifdef VERTEXANIMATIONMATERIAL\n float vatFrame = g_vatAnim0.x;\n float vatFrameCount = g_vatAnim0.y;\n float vatFromRow = g_vatAnim0.z;\n float vatBlendWeight = g_vatAnim0.w;\n float vatPrevFrame = g_vatAnim1.x;\n float vatPrevFrameCount = g_vatAnim1.y;\n float vatPrevFromRow = g_vatAnim1.z;\n float vatPackedSkinLoop = g_vatAnim1.w;\n float vatLoopBlend = mod(vatPackedSkinLoop, 2.0);\n if (vatFrameCount > 0.5) {\n // GLSL path uses the third UV channel:\n // Unity uv3 -> glTF TEXCOORD_2 -> Babylon shader uv3\n // uv3.x = texel-centre U inside one VAT frame\n // uv3.y = row index inside the frame tile (+0.5 for stable floor)\n float baseU = clamp(uv3.x, 0.0, 1.0);\n float rowInTile = max(0.0, floor(uv3.y));\n\n float rowsPF = g_vatRowsPerFrame;\n float frameA = clamp(floor(vatFrame), 0.0, vatFrameCount - 1.0);\n float fracA = fract(vatFrame);\n float frameB = frameA + 1.0;\n if (frameB >= vatFrameCount) {\n if (vatLoopBlend > 0.5) {\n frameB = 0.0;\n } else {\n frameB = frameA;\n fracA = 0.0;\n }\n }\n\n vec2 uvA = vec2(baseU, (vatFromRow + frameA * rowsPF + rowInTile + 0.5) / g_vatTexHeight);\n vec2 uvB = vec2(baseU, (vatFromRow + frameB * rowsPF + rowInTile + 0.5) / g_vatTexHeight);\n vec4 encA = textureLod(vatPosition, uvA, 0.0);\n vec4 encB = textureLod(vatPosition, uvB, 0.0);\n vec3 posA = mix(g_vatPosMin, g_vatPosMax, encA.xyz);\n vec3 posB = mix(g_vatPosMin, g_vatPosMax, encB.xyz);\n vec3 curPos = mix(posA, posB, fracA);\n\n // Crossfade with previous clip if a blend is active\n if (vatBlendWeight < 0.999 && vatPrevFrameCount > 0.5) {\n float rowsPFp = g_vatPrevRowsPerFrame;\n float rowInTileP = rowInTile;\n float frameAp = clamp(floor(vatPrevFrame), 0.0, vatPrevFrameCount - 1.0);\n float fracAp = fract(vatPrevFrame);\n float frameBp = frameAp + 1.0;\n if (frameBp >= vatPrevFrameCount) {\n if (vatLoopBlend > 0.5) {\n frameBp = 0.0;\n } else {\n frameBp = frameAp;\n fracAp = 0.0;\n }\n }\n float tileRowAp = frameAp * rowsPFp + rowInTileP;\n float tileRowBp = frameBp * rowsPFp + rowInTileP;\n vec2 uvAp = vec2(baseU, (vatPrevFromRow + tileRowAp + 0.5) / g_vatPrevTexHeight);\n vec2 uvBp = vec2(baseU, (vatPrevFromRow + tileRowBp + 0.5) / g_vatPrevTexHeight);\n vec4 encAp = textureLod(vatPrevPosition, uvAp, 0.0);\n vec4 encBp = textureLod(vatPrevPosition, uvBp, 0.0);\n vec3 prevPosA = mix(g_vatPrevPosMin, g_vatPrevPosMax, encAp.xyz);\n vec3 prevPosB = mix(g_vatPrevPosMin, g_vatPrevPosMax, encBp.xyz);\n vec3 prevPos = mix(prevPosA, prevPosB, fracAp);\n curPos = mix(prevPos, curPos, vatBlendWeight);\n }\n\n positionUpdated = curPos;\n }\n #endif\n "},i.prototype.getGLSLVertexNormalCode=function(){return"\n #ifdef VERTEXANIMATIONMATERIAL\n float vatNormFrame = g_vatAnim0.x;\n float vatNormFrameCount = g_vatAnim0.y;\n float vatNormFromRow = g_vatAnim0.z;\n \n float vatNormPackedSkinLoop = g_vatAnim1.w;\n float vatNormLoopBlend = mod(vatNormPackedSkinLoop, 2.0);\n\n if (vatNormFrameCount > 0.5) {\n // GLSL path uses the third UV channel:\n // Unity uv3 -> glTF TEXCOORD_2 -> Babylon shader uv3\n float baseU = clamp(uv3.x, 0.0, 1.0);\n float rowInTile = max(0.0, floor(uv3.y));\n float rowsPF = g_vatRowsPerFrame;\n float frameA = clamp(floor(vatNormFrame), 0.0, vatNormFrameCount - 1.0);\n float fractA = fract(vatNormFrame);\n float frameB = frameA + 1.0;\n if (frameB >= vatNormFrameCount) {\n if (vatNormLoopBlend > 0.5) {\n frameB = 0.0;\n } else {\n frameB = frameA;\n fractA = 0.0;\n }\n }\n\n vec2 uvA = vec2(baseU, (vatNormFromRow + frameA * rowsPF + rowInTile + 0.5) / g_vatTexHeight);\n vec2 uvB = vec2(baseU, (vatNormFromRow + frameB * rowsPF + rowInTile + 0.5) / g_vatTexHeight);\n vec4 nA = textureLod(vatNormal, uvA, 0.0);\n vec4 nB = textureLod(vatNormal, uvB, 0.0);\n vec3 normalA = normalize(nA.xyz * 2.0 - 1.0);\n vec3 normalB = normalize(nB.xyz * 2.0 - 1.0);\n vec3 normalResult = normalize(mix(normalA, normalB, fractA));\n\n normalUpdated = normalResult;\n }\n #endif\n "},i.prototype.getWGSLVertexDefinitions=function(){return"\n #ifdef VERTEXANIMATIONMATERIAL\n attribute g_vatAnim0 : vec4<f32>;\n attribute g_vatAnim1 : vec4<f32>;\n var vatPosition: texture_2d<f32>;\n var vatPositionSampler: sampler;\n var vatNormal: texture_2d<f32>;\n var vatNormalSampler: sampler;\n var vatPrevPosition: texture_2d<f32>;\n var vatPrevPositionSampler: sampler;\n var vatPrevNormal: texture_2d<f32>;\n var vatPrevNormalSampler: sampler;\n // Runtime-skin varyings — packed skin index and UV0, passed to fragment.\n varying vRuntimeSkinIndex: f32;\n varying vRuntimeSkinUV: vec2<f32>;\n #endif\n "},i.prototype.getWGSLVertexPositionCode=function(){return"\n #ifdef VERTEXANIMATIONMATERIAL\n let vatFrame = vertexInputs.g_vatAnim0.x;\n let vatFrameCount = vertexInputs.g_vatAnim0.y;\n let vatFromRow = vertexInputs.g_vatAnim0.z;\n let vatBlendWeight = vertexInputs.g_vatAnim0.w;\n let vatPrevFrame = vertexInputs.g_vatAnim1.x;\n let vatPrevFrameCount = vertexInputs.g_vatAnim1.y;\n let vatPrevFromRow = vertexInputs.g_vatAnim1.z;\n let packedSkinLoop = vertexInputs.g_vatAnim1.w;\n let vatLoopBlend = packedSkinLoop % 2.0;\n if (vatFrameCount > 0.5) {\n // WGSL path derives the VAT texel coordinate from the vertex index instead\n // of consuming a dedicated uv3 vertex-buffer slot.\n let vatTexWidth = max(uniforms.g_vatTexWidth, 1.0);\n let vatVertexIndex = f32(vertexInputs.vertexIndex);\n let rowInTile = max(0.0, floor(vatVertexIndex / vatTexWidth));\n let colInTile = vatVertexIndex - rowInTile * vatTexWidth;\n let baseU = (colInTile + 0.5) / vatTexWidth;\n\n let rowsPF = uniforms.g_vatRowsPerFrame;\n let frameA = clamp(floor(vatFrame), 0.0, vatFrameCount - 1.0);\n var fracA = fract(vatFrame);\n var frameB = frameA + 1.0;\n if (frameB >= vatFrameCount) {\n if (vatLoopBlend > 0.5) {\n frameB = 0.0;\n } else {\n frameB = frameA;\n fracA = 0.0;\n }\n }\n let tileRowA = frameA * rowsPF + rowInTile;\n let tileRowB = frameB * rowsPF + rowInTile;\n let uvA = vec2f(baseU, (vatFromRow + tileRowA + 0.5) / uniforms.g_vatTexHeight);\n let uvB = vec2f(baseU, (vatFromRow + tileRowB + 0.5) / uniforms.g_vatTexHeight);\n let encA = textureSampleLevel(vatPosition, vatPositionSampler, uvA, 0.0);\n let encB = textureSampleLevel(vatPosition, vatPositionSampler, uvB, 0.0);\n let posA = mix(uniforms.g_vatPosMin, uniforms.g_vatPosMax, encA.xyz);\n let posB = mix(uniforms.g_vatPosMin, uniforms.g_vatPosMax, encB.xyz);\n var curPos = mix(posA, posB, fracA);\n\n if (vatBlendWeight < 0.999 && vatPrevFrameCount > 0.5) {\n let rowsPFp = uniforms.g_vatPrevRowsPerFrame;\n let rowInTileP = rowInTile;\n let frameAp = clamp(floor(vatPrevFrame), 0.0, vatPrevFrameCount - 1.0);\n var fracAp = fract(vatPrevFrame);\n var frameBp = frameAp + 1.0;\n if (frameBp >= vatPrevFrameCount) {\n if (vatLoopBlend > 0.5) {\n frameBp = 0.0;\n } else {\n frameBp = frameAp;\n fracAp = 0.0;\n }\n }\n let tileRowAp = frameAp * rowsPFp + rowInTileP;\n let tileRowBp = frameBp * rowsPFp + rowInTileP;\n let uvAp = vec2f(baseU, (vatPrevFromRow + tileRowAp + 0.5) / uniforms.g_vatPrevTexHeight);\n let uvBp = vec2f(baseU, (vatPrevFromRow + tileRowBp + 0.5) / uniforms.g_vatPrevTexHeight);\n let encAp = textureSampleLevel(vatPrevPosition, vatPrevPositionSampler, uvAp, 0.0);\n let encBp = textureSampleLevel(vatPrevPosition, vatPrevPositionSampler, uvBp, 0.0);\n let prevPosA = mix(uniforms.g_vatPrevPosMin, uniforms.g_vatPrevPosMax, encAp.xyz);\n let prevPosB = mix(uniforms.g_vatPrevPosMin, uniforms.g_vatPrevPosMax, encBp.xyz);\n let prevPos = mix(prevPosA, prevPosB, fracAp);\n curPos = mix(prevPos, curPos, vatBlendWeight);\n }\n\n positionUpdated = curPos;\n }\n #endif\n "},i.prototype.getWGSLVertexNormalCode=function(){return"\n #ifdef VERTEXANIMATIONMATERIAL\n let vatNormFrame = vertexInputs.g_vatAnim0.x;\n let vatNormFrameCount = vertexInputs.g_vatAnim0.y;\n let vatNormFromRow = vertexInputs.g_vatAnim0.z;\n let vatNormPackedSkinLoop = vertexInputs.g_vatAnim1.w;\n let vatNormLoopBlend = vatNormPackedSkinLoop % 2.0;\n if (vatNormFrameCount > 0.5) {\n // WGSL path derives the VAT texel coordinate from the vertex index instead\n // of consuming a dedicated uv3 vertex-buffer slot.\n let vatTexWidth = max(uniforms.g_vatTexWidth, 1.0);\n let vatVertexIndex = f32(vertexInputs.vertexIndex);\n let rowInTile = max(0.0, floor(vatVertexIndex / vatTexWidth));\n let colInTile = vatVertexIndex - rowInTile * vatTexWidth;\n let baseU = (colInTile + 0.5) / vatTexWidth;\n let rowsPF = uniforms.g_vatRowsPerFrame;\n\n #ifdef VAT_NORMAL_SEPARATE\n let frameA = clamp(floor(vatNormFrame), 0.0, vatNormFrameCount - 1.0);\n var fracA = fract(vatNormFrame);\n var frameB = frameA + 1.0;\n if (frameB >= vatNormFrameCount) {\n if (vatNormLoopBlend > 0.5) {\n frameB = 0.0;\n } else {\n frameB = frameA;\n fracA = 0.0;\n }\n }\n let tileRowA = frameA * rowsPF + rowInTile;\n let tileRowB = frameB * rowsPF + rowInTile;\n let uvA = vec2f(baseU, (vatNormFromRow + tileRowA + 0.5) / uniforms.g_vatTexHeight);\n let uvB = vec2f(baseU, (vatNormFromRow + tileRowB + 0.5) / uniforms.g_vatTexHeight);\n let nA = textureSampleLevel(vatNormal, vatNormalSampler, uvA, 0.0);\n let nB = textureSampleLevel(vatNormal, vatNormalSampler, uvB, 0.0);\n let normalA = normalize(nA.xyz * 2.0 - vec3f(1.0));\n let normalB = normalize(nB.xyz * 2.0 - vec3f(1.0));\n normalUpdated = normalize(mix(normalA, normalB, fracA));\n #endif\n }\n #endif\n "},i.prototype.getGLSLVertexMainEnd=function(){return"\n #ifdef VERTEXANIMATIONMATERIAL\n {\n float _rsPackedSkinLoop = g_vatAnim1.w;\n vRuntimeSkinIndex = floor(_rsPackedSkinLoop * 0.5 + 0.0001);\n #ifdef UV1\n vRuntimeSkinUV = uv;\n #else\n vRuntimeSkinUV = vec2(0.0, 0.0);\n #endif\n }\n #endif\n "},i.prototype.getWGSLVertexMainEnd=function(){return"\n #ifdef VERTEXANIMATIONMATERIAL\n {\n let _rsPackedSkinLoop = vertexInputs.g_vatAnim1.w;\n vertexOutputs.vRuntimeSkinIndex = floor(_rsPackedSkinLoop * 0.5 + 0.0001);\n #ifdef UV1\n vertexOutputs.vRuntimeSkinUV = vertexInputs.uv;\n #else\n vertexOutputs.vRuntimeSkinUV = vec2f(0.0, 0.0);\n #endif\n }\n #endif\n "},i.prototype.getGLSLFragmentDefinitions=function(){return"\n #ifndef TOOLKIT_VAT_RUNTIMESKIN_F_UNIFORMS\n #define TOOLKIT_VAT_RUNTIMESKIN_F_UNIFORMS\n varying float vRuntimeSkinIndex;\n varying vec2 vRuntimeSkinUV;\n uniform highp sampler2DArray runtimeAlbedoSkins;\n uniform highp sampler2DArray runtimeNormalSkins;\n #endif\n "},i.prototype.getGLSLFragmentAlbedoCode=function(){return"\n #ifdef RUNTIME_SKINS_ALBEDO\n {\n float _rsLayer = max(0.0, floor(vRuntimeSkinIndex + 0.5));\n vec4 _rsAlbedo = texture(runtimeAlbedoSkins, vec3(vRuntimeSkinUV, _rsLayer));\n surfaceAlbedo = _rsAlbedo.rgb * vAlbedoColor.rgb;\n #ifdef ALPHATEST\n if (_rsAlbedo.a < alphaCutOff) discard;\n #endif\n }\n #endif\n "},i.prototype.getGLSLFragmentNormalCode=function(){return"\n #ifdef RUNTIME_SKINS_NORMAL\n {\n float _rsLayer = max(0.0, floor(vRuntimeSkinIndex + 0.5));\n vec3 _rsNormalSample = texture(runtimeNormalSkins, vec3(vRuntimeSkinUV, _rsLayer)).xyz;\n vec3 _rsNormalTS = _rsNormalSample * 2.0 - 1.0;\n vec3 _rsP = vPositionW;\n vec3 _rsN = normalize(vNormalW);\n vec3 _rsDp1 = dFdx(_rsP);\n vec3 _rsDp2 = dFdy(_rsP);\n vec2 _rsDuv1 = dFdx(vRuntimeSkinUV);\n vec2 _rsDuv2 = dFdy(vRuntimeSkinUV);\n vec3 _rsDp2perp = cross(_rsDp2, _rsN);\n vec3 _rsDp1perp = cross(_rsN, _rsDp1);\n vec3 _rsT = _rsDp2perp * _rsDuv1.x + _rsDp1perp * _rsDuv2.x;\n vec3 _rsB = _rsDp2perp * _rsDuv1.y + _rsDp1perp * _rsDuv2.y;\n float _rsInvMax = inversesqrt(max(dot(_rsT, _rsT), dot(_rsB, _rsB)));\n mat3 _rsTBN = mat3(_rsT * _rsInvMax, _rsB * _rsInvMax, _rsN);\n normalW = normalize(_rsTBN * _rsNormalTS);\n }\n #endif\n "},i.prototype.getWGSLFragmentDefinitions=function(){return"\n varying vRuntimeSkinIndex: f32;\n varying vRuntimeSkinUV: vec2<f32>;\n var runtimeAlbedoSkins: texture_2d_array<f32>;\n var runtimeAlbedoSkinsSampler: sampler;\n var runtimeNormalSkins: texture_2d_array<f32>;\n var runtimeNormalSkinsSampler: sampler;\n "},i.prototype.getWGSLFragmentAlbedoCode=function(){return"\n #ifdef RUNTIME_SKINS_ALBEDO\n {\n let _rsLayer = i32(max(0.0, floor(fragmentInputs.vRuntimeSkinIndex + 0.5)));\n let _rsAlbedo = textureSample(runtimeAlbedoSkins, runtimeAlbedoSkinsSampler, fragmentInputs.vRuntimeSkinUV, _rsLayer);\n surfaceAlbedo = _rsAlbedo.rgb * vAlbedoColor.rgb;\n #ifdef ALPHATEST\n if (_rsAlbedo.a < alphaCutOff) { discard; }\n #endif\n }\n #endif\n "},i.prototype.getWGSLFragmentNormalCode=function(){return"\n #ifdef RUNTIME_SKINS_NORMAL\n {\n let _rsLayer = i32(max(0.0, floor(fragmentInputs.vRuntimeSkinIndex + 0.5)));\n let _rsNormalSample = textureSample(runtimeNormalSkins, runtimeNormalSkinsSampler, fragmentInputs.vRuntimeSkinUV, _rsLayer).xyz;\n let _rsNormalTS = _rsNormalSample * 2.0 - vec3f(1.0);\n let _rsP = fragmentInputs.vPositionW;\n let _rsN = normalize(fragmentInputs.vNormalW);\n let _rsDp1 = dpdx(_rsP);\n let _rsDp2 = dpdy(_rsP);\n let _rsDuv1 = dpdx(fragmentInputs.vRuntimeSkinUV);\n let _rsDuv2 = dpdy(fragmentInputs.vRuntimeSkinUV);\n let _rsDp2perp = cross(_rsDp2, _rsN);\n let _rsDp1perp = cross(_rsN, _rsDp1);\n let _rsT = _rsDp2perp * _rsDuv1.x + _rsDp1perp * _rsDuv2.x;\n let _rsB = _rsDp2perp * _rsDuv1.y + _rsDp1perp * _rsDuv2.y;\n let _rsInvMax = inverseSqrt(max(dot(_rsT, _rsT), dot(_rsB, _rsB)));\n let _rsTcol = _rsT * _rsInvMax;\n let _rsBcol = _rsB * _rsInvMax;\n normalW = normalize(_rsTcol * _rsNormalTS.x + _rsBcol * _rsNormalTS.y + _rsN * _rsNormalTS.z);\n }\n #endif\n "},i._zeroV3=BABYLON.Vector3.Zero(),i._oneV3=BABYLON.Vector3.One(),i}(e.CustomShaderMaterialPlugin);e.VertexAnimationMaterialPlugin=n,e.SceneManager.RegisterClass("TOOLKIT.VertexAnimationController",i),e.SceneManager.RegisterClass("TOOLKIT.VertexAnimationMaterial",t),e.SceneManager.RegisterClass("TOOLKIT.VertexAnimationMaterialPlugin",n)}(n||(n={})),function(e){var t=function(t){function i(e,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.CheckpointManager");var o=t.call(this,e,i,n,r)||this;return o.checkPointList=null,o.checkPointCount=0,o.checkPointIndex=0,o.nextCheckPoint=0,o.startRaceTime=0,o.totalRaceTime=0,o.lapNumber=0,o.lapTimer=0,o.lapTimes=null,o.playerID=0,o.playerName="Player",o.raceOver=!1,o.nextCheckPointName="",o}return o(i,t),i.prototype.register=function(t,i){this.playerID=t,this.playerName=i,e.RaceTrackManager.RegisterPlayer(this.playerID,this.playerName)},i.prototype.getLapTimes=function(){return this.lapTimes},i.prototype.getLapNumber=function(){return this.lapNumber},i.prototype.getCheckPoint=function(){return this.checkPointIndex},i.prototype.getPlayerName=function(){return this.playerName},i.prototype.getPlayerID=function(){return this.playerID},i.prototype.getRaceTime=function(){return this.totalRaceTime},i.prototype.getRaceOver=function(){return this.raceOver},i.prototype.start=function(){this.lapTimes=[],this.lapNumber=0,this.nextCheckPoint=0,this.checkPointList=e.RaceTrackManager.GetCheckpointList(),this.checkPointCount=e.RaceTrackManager.GetCheckpointCount()},i.prototype.update=function(){if(!1===this.raceOver&&null!=this.checkPointList&&this.checkPointList.length>0){var t=this.checkPointList[this.nextCheckPoint];if(null!=t&&(this.nextCheckPointName=t.name,t.intersectsPoint(this.transform.absolutePosition))){if(this.checkPointIndex=this.nextCheckPoint,0===this.checkPointIndex){if(this.lapNumber>0&&this.lapTimer>0){var i=n.SceneManager.GetGameTime()-this.lapTimer;null==this.lapTimes&&(this.lapTimes=[]),this.lapTimes.push(i)}this.lapNumber++,this.lapTimer=n.SceneManager.GetGameTime(),this.lapNumber>e.RaceTrackManager.TotalLapCount&&(this.startRaceTime=0,this.lapNumber=e.RaceTrackManager.TotalLapCount,this.raceOver=!0,e.RaceTrackManager.EventBus.PostMessage("GameOver"),null==e.RaceTrackManager.WinnerTransform&&(e.RaceTrackManager.WinnerTransform=this.transform,console.warn("RACE WINNER: "+this.transform.name)))}this.nextCheckPoint++,this.nextCheckPoint>=this.checkPointCount&&(this.nextCheckPoint=0)}}},i.prototype.late=function(){!1===this.raceOver&&(this.startRaceTime>0&&(this.totalRaceTime=n.SceneManager.GetGameTime()-this.startRaceTime),this.playerID>0&&e.RaceTrackManager.UpdateLeaderboard(this.playerID,this.lapNumber,this.checkPointIndex,this.transform.absolutePosition))},i.prototype.startRaceTimer=function(){0===this.startRaceTime&&(this.lapTimes=[],this.raceOver=!1,this.startRaceTime=n.SceneManager.GetGameTime())},i}(n.ScriptComponent);e.CheckpointManager=t,n.SceneManager.RegisterClass("PROJECT.CheckpointManager",t)}(r||(r={})),function(e){var t=function(){};e.RoutePoint=t;e.PlayerRaceStats=function(){};var i=function(i){function r(e,t,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.RaceTrackManager");var o=i.call(this,e,t,n,r)||this;return o.trackNodes=null,o.raceLineData_1=null,o.raceLineData_2=null,o.raceLineData_3=null,o.raceLineData_4=null,o.raceLineData_5=null,o.raceLineColor_1=null,o.raceLineColor_2=null,o.raceLineColor_3=null,o.raceLineColor_4=null,o.raceLineColor_5=null,o.debugMeshLines_1=null,o.debugMeshLines_2=null,o.debugMeshLines_3=null,o.debugMeshLines_4=null,o.debugMeshLines_5=null,o.p0n=0,o.p1n=0,o.p2n=0,o.p3n=0,o.i=0,o.drawDebugLines=!1,o}return o(r,i),Object.defineProperty(r,"EventBus",{get:function(){return null==e.RaceTrackManager._EventBus&&(e.RaceTrackManager._EventBus=new n.LocalMessageBus),e.RaceTrackManager._EventBus},enumerable:!1,configurable:!0}),r.prototype.getTrackNodes=function(){return this.trackNodes},r.prototype.getControlPoints=function(e){var t=null;switch(e){case 0:t=this.raceLineData_1;break;case 1:t=this.raceLineData_2;break;case 2:t=this.raceLineData_3;break;case 3:t=this.raceLineData_4;break;case 4:t=this.raceLineData_5}return t},r.prototype.awake=function(){this.trackNodes=this.getProperty("TrackNodes",this.trackNodes),this.raceLineData_1=this.getProperty("RaceLineData_1",this.raceLineData_1),this.raceLineData_2=this.getProperty("RaceLineData_2",this.raceLineData_2),this.raceLineData_3=this.getProperty("RaceLineData_3",this.raceLineData_3),this.raceLineData_4=this.getProperty("RaceLineData_4",this.raceLineData_4),this.raceLineData_5=this.getProperty("RaceLineData_5",this.raceLineData_5),this.raceLineColor_1=this.getProperty("RaceLineColor_1",this.raceLineColor_1),this.raceLineColor_2=this.getProperty("RaceLineColor_2",this.raceLineColor_2),this.raceLineColor_3=this.getProperty("RaceLineColor_3",this.raceLineColor_3),this.raceLineColor_4=this.getProperty("RaceLineColor_4",this.raceLineColor_4),this.raceLineColor_5=this.getProperty("RaceLineColor_5",this.raceLineColor_5),this.drawDebugLines=this.getProperty("DrawDebugLines",this.drawDebugLines);var t=0;if(null!=this.trackNodes)for(e.RaceTrackManager.TrackLength=0,t=0;t<this.trackNodes.length;t++){var i=this.trackNodes[t],r=this.trackNodes[t%this.trackNodes.length],o=this.trackNodes[(t+1)%this.trackNodes.length];if(null!=r&&null!=o){var a=n.Utilities.ParseVector4(i.rotation);i.localRotation=new BABYLON.Quaternion(a.x,a.y,a.z,a.w),i.localPosition=n.Utilities.ParseVector3(i.position);var s=n.Utilities.ParseVector3(r.position),l=n.Utilities.ParseVector3(o.position);i.localDistance=e.RaceTrackManager.TrackLength,e.RaceTrackManager.TrackLength+=s.subtract(l).length()}}if(console.warn(">>> Race Track Nodes"),console.log(this.trackNodes),null==e.RaceTrackManager.LeaderBoardList&&(e.RaceTrackManager.LeaderBoardList=[]),null==e.RaceTrackManager.CheckPointList&&(e.RaceTrackManager.CheckPointList=this.scene.getMeshesByTags(e.RaceTrackManager.CheckPointTag),null!=e.RaceTrackManager.CheckPointList&&e.RaceTrackManager.CheckPointList.length>0))for(t=0;t<e.RaceTrackManager.CheckPointList.length;t++)e.RaceTrackManager.CheckPointList[t].refreshBoundingInfo({})},r.prototype.start=function(){var e=this;if(!0===this.drawDebugLines){var t=0,i=new BABYLON.TransformNode(this.transform.name+".DebugLines",this.scene);if(i.position.set(0,0,0),i.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1),null!=this.trackNodes&&this.trackNodes.length>0){var r=[],o=BABYLON.Color3.White(),a=new BABYLON.StandardMaterial(this.transform.name+".NodeMaterial",this.scene);a.diffuseColor=o,t=0,this.trackNodes.forEach(function(o){var s=new BABYLON.Vector3(o.position.x,o.position.y,o.position.z),l=new BABYLON.Quaternion(o.rotation.x,o.rotation.y,o.rotation.z,o.rotation.w);r.push(s);var u=BABYLON.MeshBuilder.CreateCylinder(e.transform.name+".TrackNode_"+t,{diameterTop:0,diameterBottom:1,height:2},e.scene);u.parent=i,u.position.copyFrom(s),u.position.y+=.5,u.rotationQuaternion=l.multiply(n.Utilities.FromEuler(90,0,0)),u.material=a,t++})}if(null!=this.raceLineData_5&&this.raceLineData_5.length>0){var s=[],l=null!=this.raceLineColor_5?new BABYLON.Color3(this.raceLineColor_5.r,this.raceLineColor_5.g,this.raceLineColor_5.b):BABYLON.Color3.White(),u=new BABYLON.StandardMaterial(this.transform.name+".PointMaterial_5",this.scene);u.diffuseColor=l,t=0,this.raceLineData_5.forEach(function(n){var r=new BABYLON.Vector3(n.position.x,n.position.y,n.position.z);s.push(r);var o=BABYLON.MeshBuilder.CreateSphere(e.transform.name+".ControlPoint_5_"+t,{segments:24,diameter:1},e.scene);o.parent=i,o.position.copyFrom(r),o.position.y+=.5,o.material=u,t++}),this.debugMeshLines_5=BABYLON.MeshBuilder.CreateLines(this.transform.name+".RaceLine_5",{points:s},this.scene),this.debugMeshLines_5.parent=i,this.debugMeshLines_5.position.y+=.5,this.debugMeshLines_5.color=l}if(null!=this.raceLineData_4&&this.raceLineData_4.length>0){var h=[],c=null!=this.raceLineColor_4?new BABYLON.Color3(this.raceLineColor_4.r,this.raceLineColor_4.g,this.raceLineColor_4.b):BABYLON.Color3.White(),d=new BABYLON.StandardMaterial(this.transform.name+".PointMaterial_4",this.scene);d.diffuseColor=c,t=0,this.raceLineData_4.forEach(function(n){var r=new BABYLON.Vector3(n.position.x,n.position.y,n.position.z);h.push(r);var o=BABYLON.MeshBuilder.CreateSphere(e.transform.name+".ControlPoint_4_"+t,{segments:24,diameter:1},e.scene);o.parent=i,o.position.copyFrom(r),o.position.y+=.5,o.material=d,t++}),this.debugMeshLines_4=BABYLON.MeshBuilder.CreateLines(this.transform.name+".RaceLine_4",{points:h},this.scene),this.debugMeshLines_4.parent=i,this.debugMeshLines_4.position.y+=.5,this.debugMeshLines_4.color=c}if(null!=this.raceLineData_3&&this.raceLineData_3.length>0){var m=[],p=null!=this.raceLineColor_3?new BABYLON.Color3(this.raceLineColor_3.r,this.raceLineColor_3.g,this.raceLineColor_3.b):BABYLON.Color3.White(),f=new BABYLON.StandardMaterial(this.transform.name+".PointMaterial_3",this.scene);f.diffuseColor=p,t=0,this.raceLineData_3.forEach(function(n){var r=new BABYLON.Vector3(n.position.x,n.position.y,n.position.z);m.push(r);var o=BABYLON.MeshBuilder.CreateSphere(e.transform.name+".ControlPoint_3_"+t,{segments:24,diameter:1},e.scene);o.parent=i,o.position.copyFrom(r),o.position.y+=.5,o.material=f,t++}),this.debugMeshLines_3=BABYLON.MeshBuilder.CreateLines(this.transform.name+".RaceLine_3",{points:m},this.scene),this.debugMeshLines_3.parent=i,this.debugMeshLines_3.position.y+=.5,this.debugMeshLines_3.color=p}if(null!=this.raceLineData_2&&this.raceLineData_2.length>0){var g=[],y=null!=this.raceLineColor_2?new BABYLON.Color3(this.raceLineColor_2.r,this.raceLineColor_2.g,this.raceLineColor_2.b):BABYLON.Color3.White(),v=new BABYLON.StandardMaterial(this.transform.name+".PointMaterial_2",this.scene);v.diffuseColor=y,t=0,this.raceLineData_2.forEach(function(n){var r=new BABYLON.Vector3(n.position.x,n.position.y,n.position.z);g.push(r);var o=BABYLON.MeshBuilder.CreateSphere(e.transform.name+".ControlPoint_2_"+t,{segments:24,diameter:1},e.scene);o.parent=i,o.position.copyFrom(r),o.position.y+=.5,o.material=v,t++}),this.debugMeshLines_2=BABYLON.MeshBuilder.CreateLines(this.transform.name+".RaceLine_2",{points:g},this.scene),this.debugMeshLines_2.parent=i,this.debugMeshLines_2.position.y+=.5,this.debugMeshLines_2.color=y}if(null!=this.raceLineData_1&&this.raceLineData_1.length>0){var S=[],_=null!=this.raceLineColor_1?new BABYLON.Color3(this.raceLineColor_1.r,this.raceLineColor_1.g,this.raceLineColor_1.b):BABYLON.Color3.White(),b=new BABYLON.StandardMaterial(this.transform.name+".PointMaterial_1",this.scene);b.diffuseColor=_,t=0,this.raceLineData_1.forEach(function(n){var r=new BABYLON.Vector3(n.position.x,n.position.y,n.position.z);S.push(r);var o=BABYLON.MeshBuilder.CreateSphere(e.transform.name+".ControlPoint_1_"+t,{segments:24,diameter:1},e.scene);o.parent=i,o.position.copyFrom(r),o.position.y+=.5,o.material=b,t++}),this.debugMeshLines_1=BABYLON.MeshBuilder.CreateLines(this.transform.name+".RaceLine_1",{points:S},this.scene),this.debugMeshLines_1.parent=i,this.debugMeshLines_1.position.y+=.5,this.debugMeshLines_1.color=_}}},r.prototype.after=function(){this.isReady()&&e.RaceTrackManager.SortLeaderboardPositionList()},r.prototype.destroy=function(){},r.prototype.getRoutePoint=function(e){var i=new t;return this.getRoutePointToRef(e,i),i},r.prototype.getRoutePointToRef=function(e,t){var i=this.getRoutePosition(e),n=this.getRoutePosition(e+.1).subtract(i);t.position=i.clone(),t.direction=n.normalizeToNew()},r.prototype.getRoutePosition=function(e){var t=new BABYLON.Vector3(0,0,0);return this.getRoutePositionToRef(e,t),t},r.prototype.getRoutePositionToRef=function(t,i){for(var n=0,r=BABYLON.Scalar.Repeat(t,e.RaceTrackManager.TrackLength),o=this.trackNodes.length;this.trackNodes[n].localDistance<r;)++n;this.p1n=(n-1+o)%o,this.p2n=n,this.i=BABYLON.Scalar.InverseLerp(this.trackNodes[this.p1n].localDistance,this.trackNodes[this.p2n].localDistance,r),BABYLON.Vector3.LerpToRef(this.trackNodes[this.p1n].localPosition,this.trackNodes[this.p2n].localPosition,this.i,i)},r.GetCheckpointTag=function(){return e.RaceTrackManager.CheckPointTag},r.GetCheckpointList=function(){return e.RaceTrackManager.CheckPointList},r.GetCheckpointCount=function(){return null!=e.RaceTrackManager.CheckPointList?e.RaceTrackManager.CheckPointList.length:0},r.GetCheckpointDistance=function(e,t,i){var n=e.subtract(t),r=i.subtract(t),o=BABYLON.Vector3.Dot(n,r)/r.lengthSquared();return BABYLON.Scalar.Clamp(o)},r.RegisterVehicle=function(t){null==e.RaceTrackManager.PlayerVehicleList&&(e.RaceTrackManager.PlayerVehicleList=[]),e.RaceTrackManager.PlayerVehicleList.push(t)},r.GetPlayerVehicles=function(){return e.RaceTrackManager.PlayerVehicleList},r.RegisterPlayer=function(t,i){var n=new e.PlayerRaceStats;n.id=t,n.name=i,n.position=0,null==e.RaceTrackManager.LeaderBoardList&&(e.RaceTrackManager.LeaderBoardList=[]),e.RaceTrackManager.LeaderBoardList.push(n)},r.UpdateLeaderboard=function(t,i,n,r){if(null!=e.RaceTrackManager.LeaderBoardList&&e.RaceTrackManager.LeaderBoardList.length>0)for(var o=e.RaceTrackManager.LeaderBoardList,a=0;a<o.length;a++){var s=o[a];if(s.id===t){if(null!=e.RaceTrackManager.CheckPointList&&e.RaceTrackManager.CheckPointList.length>0){var l=n+1;l>=e.RaceTrackManager.CheckPointList.length&&(l=0);var u=e.RaceTrackManager.CheckPointList[n],h=e.RaceTrackManager.CheckPointList[l],c=e.RaceTrackManager.GetCheckpointDistance(r,u.absolutePosition,h.absolutePosition);s.position=1e3*i+n+c}break}}},r.GetLeaderboardPosition=function(t){var i=-1;if(null!=e.RaceTrackManager.LeaderBoardList&&e.RaceTrackManager.LeaderBoardList.length>0)for(var n=e.RaceTrackManager.LeaderBoardList,r=0;r<n.length;r++)if(n[r].id===t){i=r+1;break}return i},r.GetLeaderboardPositionList=function(){return e.RaceTrackManager.LeaderBoardList},r.SortLeaderboardPositionList=function(){null!=e.RaceTrackManager.LeaderBoardList&&e.RaceTrackManager.LeaderBoardList.length>0&&e.RaceTrackManager.LeaderBoardList.sort(function(e,t){return e.position<t.position?1:e.position>t.position?-1:0})},r.TrackLength=0,r.TotalLapCount=3,r.WinnerTransform=null,r.CheckPointTag="Checkpoint",r.CheckPointList=null,r.LeaderBoardList=null,r.PlayerVehicleList=null,r._EventBus=null,r}(n.ScriptComponent);e.RaceTrackManager=i,n.SceneManager.RegisterClass("PROJECT.RaceTrackManager",i)}(r||(r={})),function(e){var t=function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e.centerOfMass=.4,e.burnoutWheelPitch=.85,e.linkTrackManager=!0,e.playVehicleSounds=!0,e.smokeTexture=null,e.skidThreashold=.65,e.smokeIntensity=150,e.wheelDrawVelocity=.02,e.smokeOpacity=.1,e.smokeDonuts=2,e.steeringWheelHub=null,e.steeringWheelAxis=2,e.maxSteeringAngle=35,e.maxSteeringSpeed=10,e._animator=null,e._engineAudioSource=null,e._skidAudioSource=null,e.brakeLightsMesh=null,e.brakeLightsTrans=null,e.reverseLightsMesh=null,e.reverseLightsTrans=null,e.frontLeftWheelTrans=null,e.frontRightWheelTrans=null,e.backLeftWheelTrans=null,e.backRightWheelTrans=null,e.frontLeftWheelMesh=null,e.frontRightWheelMesh=null,e.backLeftWheelMesh=null,e.backRightWheelMesh=null,e.frontLeftWheelEmitter=null,e.frontRightWheelEmitter=null,e.backLeftWheelEmitter=null,e.backRightWheelEmitter=null,e.frontLeftWheelParticle=null,e.frontRightWheelParticle=null,e.backLeftWheelParticle=null,e.backRightWheelParticle=null,e.frontLeftContact=!1,e.frontRightContact=!1,e.rearLeftContact=!1,e.rearRightContact=!1,e.frontLeftContactTag="",e.frontRightContactTag="",e.rearLeftContactTag="",e.rearRightContactTag="",e.frontLeftContactPoint=new BABYLON.Vector3(0,0,0),e.frontRightContactPoint=new BABYLON.Vector3(0,0,0),e.rearLeftContactPoint=new BABYLON.Vector3(0,0,0),e.rearRightContactPoint=new BABYLON.Vector3(0,0,0),e.frontLeftContactNormal=new BABYLON.Vector3(0,0,0),e.frontRightContactNormal=new BABYLON.Vector3(0,0,0),e.rearLeftContactNormal=new BABYLON.Vector3(0,0,0),e.rearRightContactNormal=new BABYLON.Vector3(0,0,0),e.startRaycastPosition=new BABYLON.Vector3(0,0,0),e.endRaycastPosition=new BABYLON.Vector3(0,0,0),e.smokeIntensityFactor=0,e.downDirection=new BABYLON.Vector3(0,-1,0),e.downDistance=2,e.lastPitch=0,e.lastBrake=0,e.lastReverse=0,e.lastBurnout=0,e.lastSteering=0,e.lastSKID_FL=0,e.lastSKID_FR=0,e.lastSKID_RL=0,e.lastSKID_RR=0,e.lastSPIN_FL=0,e.lastSPIN_FR=0,e.lastSPIN_RL=0,e.lastSPIN_RR=0,e.PITCH_FL=0,e.PITCH_FR=0,e.PITCH_RL=0,e.PITCH_RR=0,e.WHEEL_SKID_PITCH=0,e.m_frontLeftWheelSkid=-1,e.m_frontRightWheelSkid=-1,e.m_backLeftWheelSkid=-1,e.m_backRightWheelSkid=-1,e.m_velocityOffset=new BABYLON.Vector3(0,0,0),e.m_linearVelocity=new BABYLON.Vector3(0,0,0),e.m_lastPosition=new BABYLON.Vector3(0,0,0),e.m_positionCenter=new BABYLON.Vector3(0,0,0),e.m_scaledVelocity=0,e}return o(i,t),i.prototype.getFrontLeftWheelContact=function(){return this.frontLeftContact},i.prototype.getFrontRightWheelContact=function(){return this.frontRightContact},i.prototype.getRearLeftWheelContact=function(){return this.rearLeftContact},i.prototype.getRearRightWheelContact=function(){return this.rearRightContact},i.prototype.getFrontLeftWheelContactTag=function(){return this.frontLeftContactTag},i.prototype.getFrontRightWheelContactTag=function(){return this.frontRightContactTag},i.prototype.getRearLeftWheelContactTag=function(){return this.rearLeftContactTag},i.prototype.getRearRightWheelContactTag=function(){return this.rearRightContactTag},i.prototype.getFrontLeftWheelContactPoint=function(){return this.frontLeftContactPoint},i.prototype.getFrontRightWheelContactPoint=function(){return this.frontRightContactPoint},i.prototype.getRearLeftWheelContactPoint=function(){return this.rearLeftContactPoint},i.prototype.getRearRightWheelContactPoint=function(){return this.rearRightContactPoint},i.prototype.getFrontLeftWheelContactNormal=function(){return this.frontLeftContactNormal},i.prototype.getFrontRightWheelContactNormal=function(){return this.frontRightContactNormal},i.prototype.getRearLeftWheelContactNormal=function(){return this.rearLeftContactNormal},i.prototype.getRearRightWheelContactNormal=function(){return this.rearRightContactNormal},i.prototype.awake=function(){this.centerOfMass=this.getProperty("centerOfMass",this.centerOfMass),this.burnoutWheelPitch=this.getProperty("burnoutWheelPitch",this.burnoutWheelPitch),this.linkTrackManager=this.getProperty("linkTrackManager",this.linkTrackManager),this.playVehicleSounds=this.getProperty("playVehicleSounds",this.playVehicleSounds),this.wheelDrawVelocity=this.getProperty("wheelDrawVelocity",this.wheelDrawVelocity),this.skidThreashold=this.getProperty("skidThreashold",this.skidThreashold),this.smokeIntensity=this.getProperty("smokeIntensity",this.smokeIntensity),this.smokeOpacity=this.getProperty("smokeOpacity",this.smokeOpacity),this.smokeDonuts=this.getProperty("smokeDonuts",this.smokeDonuts),this.steeringWheelAxis=this.getProperty("steeringWheelAxis",this.steeringWheelAxis),this.maxSteeringAngle=this.getProperty("maxSteeringAngle",this.maxSteeringAngle),this.maxSteeringSpeed=this.getProperty("maxSteeringSpeed",this.maxSteeringSpeed),this.frontLeftWheelTrans=this.getProperty("frontLeftWheelMesh",this.frontLeftWheelTrans),this.frontRightWheelTrans=this.getProperty("frontRightWheelMesh",this.frontRightWheelTrans),this.backLeftWheelTrans=this.getProperty("rearLeftWheelMesh",this.backLeftWheelTrans),this.backRightWheelTrans=this.getProperty("rearRightWheelMesh",this.backRightWheelTrans),this.brakeLightsTrans=this.getProperty("brakeLightsMesh",this.brakeLightsTrans),this.reverseLightsTrans=this.getProperty("reverseLightsMesh",this.reverseLightsTrans);var t=this.getProperty("smokeTexture");if(null!=t&&(this.smokeTexture=n.Utilities.ParseTexture(t,this.scene)),!0===this.linkTrackManager&&e.RaceTrackManager.RegisterVehicle(this.transform),this._animator=this.getComponent("TOOLKIT.AnimationState"),null==this._animator){var i=this.getChildWithScript("TOOLKIT.AnimationState");null!=i&&(this._animator=n.SceneManager.FindScriptComponent(i,"TOOLKIT.AnimationState"))}this._engineAudioSource=this.getComponent("TOOLKIT.AudioSource"),null==this._engineAudioSource&&n.SceneManager.LogWarning("No engine audio source manager found for: "+this.transform.name);var r=this.getProperty("steeringWheelHub");null!=r&&null!=r.name&&""!==r.name&&(this.steeringWheelHub=this.getChildNode(r.name,n.SearchType.IndexOf,!1));var o=null!=this.brakeLightsTrans&&null!=this.brakeLightsTrans.name&&""!==this.brakeLightsTrans.name?this.brakeLightsTrans.name:null,a=null!=this.reverseLightsTrans&&null!=this.reverseLightsTrans.name&&""!==this.reverseLightsTrans.name?this.reverseLightsTrans.name:null,s=null!=this.frontLeftWheelTrans&&null!=this.frontLeftWheelTrans.name&&""!==this.frontLeftWheelTrans.name?this.frontLeftWheelTrans.name:null,l=null!=this.frontRightWheelTrans&&null!=this.frontRightWheelTrans.name&&""!==this.frontRightWheelTrans.name?this.frontRightWheelTrans.name:null,u=null!=this.backLeftWheelTrans&&null!=this.backLeftWheelTrans.name&&""!==this.backLeftWheelTrans.name?this.backLeftWheelTrans.name:null,h=null!=this.backRightWheelTrans&&null!=this.backRightWheelTrans.name&&""!==this.backRightWheelTrans.name?this.backRightWheelTrans.name:null;null!=o&&(this.brakeLightsMesh=this.getChildNode(o,n.SearchType.IndexOf,!1),null!=this.brakeLightsMesh&&(this.brakeLightsMesh.isVisible=!1)),null!=a&&(this.reverseLightsMesh=this.getChildNode(a,n.SearchType.IndexOf,!1),null!=this.reverseLightsMesh&&(this.reverseLightsMesh.isVisible=!1)),this.frontLeftWheelMesh=this.getChildNode(s,n.SearchType.IndexOf,!1),null!=this.frontLeftWheelMesh&&(this.frontLeftWheelMesh.spinner=n.SceneManager.FindChildTransformNode(this.frontLeftWheelMesh,"Wheel",n.SearchType.IndexOf,!0),this.frontLeftWheelEmitter=new BABYLON.Mesh("Emitter_FL"),this.frontLeftWheelEmitter.parent=this.frontLeftWheelMesh.spinner||this.frontLeftWheelMesh,this.frontLeftWheelEmitter.position=new BABYLON.Vector3(0,0,0),this.frontLeftWheelParticle=this.createSmokeParticleSystem(this.transform.name+"Smoke_FL",this.frontLeftWheelEmitter)),this.frontRightWheelMesh=this.getChildNode(l,n.SearchType.IndexOf,!1),null!=this.frontRightWheelMesh&&(this.frontRightWheelMesh.spinner=n.SceneManager.FindChildTransformNode(this.frontRightWheelMesh,"Wheel",n.SearchType.IndexOf,!0),this.frontRightWheelEmitter=new BABYLON.Mesh("Emitter_FR"),this.frontRightWheelEmitter.parent=this.frontRightWheelMesh.spinner||this.frontRightWheelMesh,this.frontRightWheelEmitter.position=new BABYLON.Vector3(0,0,0),this.frontRightWheelParticle=this.createSmokeParticleSystem(this.transform.name+"Smoke_FR",this.frontRightWheelEmitter)),this.backLeftWheelMesh=this.getChildNode(u,n.SearchType.IndexOf,!1),null!=this.backLeftWheelMesh&&(this.backLeftWheelMesh.spinner=n.SceneManager.FindChildTransformNode(this.backLeftWheelMesh,"Wheel",n.SearchType.IndexOf,!0),this.backLeftWheelEmitter=new BABYLON.Mesh("Emitter_RL"),this.backLeftWheelEmitter.parent=this.backLeftWheelMesh.spinner||this.backLeftWheelMesh,this.backLeftWheelEmitter.position=new BABYLON.Vector3(0,0,0),this.backLeftWheelParticle=this.createSmokeParticleSystem(this.transform.name+"Smoke_RL",this.backLeftWheelEmitter)),this.backRightWheelMesh=this.getChildNode(h,n.SearchType.IndexOf,!1),null!=this.backRightWheelMesh&&(this.backRightWheelMesh.spinner=n.SceneManager.FindChildTransformNode(this.backRightWheelMesh,"Wheel",n.SearchType.IndexOf,!0),this.backRightWheelEmitter=new BABYLON.Mesh("Emitter_RR"),this.backRightWheelEmitter.parent=this.backRightWheelMesh.spinner||this.backRightWheelMesh,this.backRightWheelEmitter.position=new BABYLON.Vector3(0,0,0),this.backRightWheelParticle=this.createSmokeParticleSystem(this.transform.name+"Smoke_RR",this.backRightWheelEmitter)),null==this._skidAudioSource&&null!=this.backRightWheelMesh&&(this._skidAudioSource=n.SceneManager.FindScriptComponent(this.backRightWheelMesh,"TOOLKIT.AudioSource")),null==this._skidAudioSource&&null!=this.backLeftWheelMesh&&(this._skidAudioSource=n.SceneManager.FindScriptComponent(this.backLeftWheelMesh,"TOOLKIT.AudioSource")),null==this._skidAudioSource&&null!=this.frontRightWheelMesh&&(this._skidAudioSource=n.SceneManager.FindScriptComponent(this.frontRightWheelMesh,"TOOLKIT.AudioSource")),null==this._skidAudioSource&&null!=this.frontLeftWheelMesh&&(this._skidAudioSource=n.SceneManager.FindScriptComponent(this.frontLeftWheelMesh,"TOOLKIT.AudioSource")),null==this._skidAudioSource&&n.SceneManager.LogWarning("No skid audio source manager found for: "+this.transform.name)},i.prototype.start=function(){this.m_positionCenter.set(0,0,-this.centerOfMass)},i.prototype.update=function(){n.EntityController.HasNetworkEntity(this.transform)&&(this.lastPitch=n.EntityController.QueryBufferedAttribute(this.transform,0),this.lastBrake=n.EntityController.QueryBufferedAttribute(this.transform,1),this.lastReverse=n.EntityController.QueryBufferedAttribute(this.transform,2),this.lastBurnout=n.EntityController.QueryBufferedAttribute(this.transform,3),this.lastSKID_FL=n.EntityController.QueryBufferedAttribute(this.transform,4),this.lastSKID_FR=n.EntityController.QueryBufferedAttribute(this.transform,5),this.lastSKID_RL=n.EntityController.QueryBufferedAttribute(this.transform,6),this.lastSKID_RR=n.EntityController.QueryBufferedAttribute(this.transform,7),this.lastSPIN_FL=n.EntityController.QueryBufferedAttribute(this.transform,8),this.lastSPIN_FR=n.EntityController.QueryBufferedAttribute(this.transform,9),this.lastSPIN_RL=n.EntityController.QueryBufferedAttribute(this.transform,10),this.lastSPIN_RR=n.EntityController.QueryBufferedAttribute(this.transform,11),this.lastSteering=n.EntityController.QueryBufferedAttribute(this.transform,12)),this.updateVehicleProperties()},i.prototype.destroy=function(){},i.prototype.updateVehicleProperties=function(){this.m_linearVelocity=this.transform.absolutePosition.subtract(this.m_lastPosition),this.m_scaledVelocity=this.m_linearVelocity.length()/this.getDeltaSeconds(),this.m_linearVelocity.normalize(),this.m_linearVelocity.scaleInPlace(this.m_scaledVelocity),this.wheelDrawVelocity>0?(this.m_velocityOffset.copyFrom(this.m_linearVelocity),this.m_velocityOffset.scaleInPlace(this.wheelDrawVelocity)):this.m_velocityOffset.set(0,0,0),this.m_lastPosition.copyFrom(this.transform.absolutePosition),!0===this.playVehicleSounds&&null!=this._engineAudioSource&&this._engineAudioSource.setPitch(this.lastPitch);var t=this.frontLeftWheelMesh.spinner,i=this.frontRightWheelMesh.spinner,n=this.backLeftWheelMesh.spinner,r=this.backRightWheelMesh.spinner;if(null!=t&&null!=t.rotationQuaternion){var o=BABYLON.Quaternion.FromEulerAngles(this.lastSPIN_FL,0,0);BABYLON.Quaternion.SlerpToRef(t.rotationQuaternion,o,.5,t.rotationQuaternion)}if(null!=i&&null!=i.rotationQuaternion){var a=BABYLON.Quaternion.FromEulerAngles(this.lastSPIN_FR,0,0);BABYLON.Quaternion.SlerpToRef(i.rotationQuaternion,a,.5,i.rotationQuaternion)}if(null!=n&&null!=n.rotationQuaternion){var s=BABYLON.Quaternion.FromEulerAngles(this.lastSPIN_RL,0,0);BABYLON.Quaternion.SlerpToRef(n.rotationQuaternion,s,.5,n.rotationQuaternion)}if(null!=r&&null!=r.rotationQuaternion){var l=BABYLON.Quaternion.FromEulerAngles(this.lastSPIN_RR,0,0);BABYLON.Quaternion.SlerpToRef(r.rotationQuaternion,l,.5,r.rotationQuaternion)}if(this.smokeDonuts=BABYLON.Scalar.Clamp(this.smokeDonuts,1,10),this.smokeIntensityFactor=this.smokeIntensity,this.lastBurnout>0&&(this.smokeIntensityFactor*=this.smokeDonuts),this.lastSKID_FL>0&&!0===this.frontLeftContact){var u=BABYLON.Scalar.Normalize(this.lastSKID_FL,this.skidThreashold,1);if(this.m_frontLeftWheelSkid=e.SkidMarkManager.AddSkidMarkSegment(this.frontLeftContactPoint,this.frontLeftContactNormal,u,this.m_frontLeftWheelSkid),null!=this.frontLeftWheelParticle){!1===this.frontLeftWheelParticle.isStarted()&&this.frontLeftWheelParticle.start();var h=this.lastSKID_FL*this.lastSKID_FL;this.frontLeftWheelParticle.emitRate=this.smokeIntensityFactor*h,this.frontLeftWheelParticle.minSize=.2*h+.2,this.frontLeftWheelParticle.maxSize=1.5*h+1.2}}else null!=this.frontLeftWheelParticle&&(this.frontLeftWheelParticle.emitRate=0),this.m_frontLeftWheelSkid=-1;if(this.lastSKID_FR>0&&!0===this.frontRightContact){var c=BABYLON.Scalar.Normalize(this.lastSKID_FR,this.skidThreashold,1);if(this.m_frontRightWheelSkid=e.SkidMarkManager.AddSkidMarkSegment(this.frontRightContactPoint,this.frontRightContactNormal,c,this.m_frontRightWheelSkid),null!=this.frontRightWheelParticle){!1===this.frontRightWheelParticle.isStarted()&&this.frontRightWheelParticle.start();var d=this.lastSKID_FR*this.lastSKID_FR;this.frontRightWheelParticle.emitRate=this.smokeIntensityFactor*d,this.frontRightWheelParticle.minSize=.2*d+.2,this.frontRightWheelParticle.maxSize=1.5*d+1.2}}else null!=this.frontRightWheelParticle&&(this.frontRightWheelParticle.emitRate=0),this.m_frontRightWheelSkid=-1;if(this.PITCH_FL=this.lastSKID_FL,this.PITCH_FR=this.lastSKID_FR,this.lastBurnout>0&&(this.PITCH_FL*=this.burnoutWheelPitch,this.PITCH_FR*=this.burnoutWheelPitch),this.PITCH_FL*=.75,this.PITCH_FR*=.75,this.lastSKID_RL>0&&!0===this.rearLeftContact){var m=BABYLON.Scalar.Normalize(this.lastSKID_RL,this.skidThreashold,1);if(this.m_backLeftWheelSkid=e.SkidMarkManager.AddSkidMarkSegment(this.rearLeftContactPoint,this.rearLeftContactNormal,m,this.m_backLeftWheelSkid),null!=this.backLeftWheelParticle){!1===this.backLeftWheelParticle.isStarted()&&this.backLeftWheelParticle.start();var p=this.lastSKID_RL*this.lastSKID_RL;this.backLeftWheelParticle.emitRate=this.smokeIntensityFactor*p,this.backLeftWheelParticle.minSize=.2*p+.2,this.backLeftWheelParticle.maxSize=1.5*p+1.2}}else null!=this.backLeftWheelParticle&&(this.backLeftWheelParticle.emitRate=0),this.m_backLeftWheelSkid=-1;if(this.lastSKID_RR>0&&!0===this.rearRightContact){var f=BABYLON.Scalar.Normalize(this.lastSKID_RR,this.skidThreashold,1);if(this.m_backRightWheelSkid=e.SkidMarkManager.AddSkidMarkSegment(this.rearRightContactPoint,this.rearRightContactNormal,f,this.m_backRightWheelSkid),null!=this.backRightWheelParticle){!1===this.backRightWheelParticle.isStarted()&&this.backRightWheelParticle.start();var g=this.lastSKID_RR*this.lastSKID_RR;this.backRightWheelParticle.emitRate=this.smokeIntensityFactor*g,this.backRightWheelParticle.minSize=.2*g+.2,this.backRightWheelParticle.maxSize=1.5*g+1.2}}else null!=this.backRightWheelParticle&&(this.backRightWheelParticle.emitRate=0),this.m_backRightWheelSkid=-1;if(this.PITCH_RL=this.lastSKID_RL,this.PITCH_RR=this.lastSKID_RR,this.lastBurnout>0&&(this.PITCH_RL*=this.burnoutWheelPitch,this.PITCH_RR*=this.burnoutWheelPitch),this.WHEEL_SKID_PITCH=0,this.PITCH_FL>this.WHEEL_SKID_PITCH&&(this.WHEEL_SKID_PITCH=this.PITCH_FL),this.PITCH_FR>this.WHEEL_SKID_PITCH&&(this.WHEEL_SKID_PITCH=this.PITCH_FR),this.PITCH_RL>this.WHEEL_SKID_PITCH&&(this.WHEEL_SKID_PITCH=this.PITCH_RL),this.PITCH_RR>this.WHEEL_SKID_PITCH&&(this.WHEEL_SKID_PITCH=this.PITCH_RR),!0===this.playVehicleSounds&&null!=this._skidAudioSource&&this._skidAudioSource.setPitch(this.WHEEL_SKID_PITCH),null!=this.steeringWheelHub){null==this.steeringWheelHub.rotationQuaternion&&(this.steeringWheelHub.rotationQuaternion=BABYLON.Quaternion.FromEulerVector(this.steeringWheelHub.rotation));var y=this.lastSteering*this.maxSteeringAngle,v=BABYLON.Tools.ToRadians(y),S=0===this.steeringWheelAxis?v:0,_=1===this.steeringWheelAxis?v:0,b=2===this.steeringWheelAxis?v:0;BABYLON.Quaternion.FromEulerAnglesToRef(S,_,b,this.steeringWheelHub.rotationQuaternion)}null!=this._animator&&this._animator.setFloat("TurnAngle",this.lastSteering),null!=this.brakeLightsMesh&&(this.brakeLightsMesh.isVisible=this.lastBrake>0),null!=this.reverseLightsMesh&&(this.reverseLightsMesh.isVisible=this.lastReverse>0),0===this.lastSKID_FL&&0===this.lastSKID_FL&&0===this.lastSKID_FL&&0===this.lastSKID_FL&&(this.smokeIntensityFactor=0)},i.prototype.createSmokeParticleSystem=function(e,t){var i=new BABYLON.ParticleSystem(e,1e4,this.scene);return i.blendMode=BABYLON.ParticleSystem.BLENDMODE_STANDARD,i.particleTexture=this.smokeTexture,i.emitter=t,i.emitRate=0,i.updateSpeed=.01,i.minSize=.2,i.maxSize=1.3,i.minAngularSpeed=-1.5,i.maxAngularSpeed=1.5,i.minLifeTime=3,i.maxLifeTime=5,i.addVelocityGradient(0,1),i.addVelocityGradient(.1,.7),i.addVelocityGradient(.7,.2),i.addVelocityGradient(1,.05),i.gravity=new BABYLON.Vector3(0,-.1,0),i.minEmitBox=new BABYLON.Vector3(0,-.25,0),i.maxEmitBox=new BABYLON.Vector3(0,-.25,0),i.direction1=new BABYLON.Vector3(-1,-1,-1),i.direction2=new BABYLON.Vector3(1,1,1),i.color1=new BABYLON.Color4(.95,.95,.95,this.smokeOpacity),i.color2=new BABYLON.Color4(.85,.85,.85,this.smokeOpacity),i.colorDead=new BABYLON.Color4(.9,.9,.9,.5*this.smokeOpacity),i},i.ShowSensorLines=!1,i}(n.ScriptComponent);e.RemoteCarController=t}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){return void 0===n&&(n={}),void 0===r&&(r="PROJECT.SideCameraController"),e.call(this,t,i,n,r)||this}return o(t,e),t.prototype.awake=function(){this._camera=this.getCameraRig(),this._adt=n.UserInterface.GetForegroundTexture(this.scene),console.log("SideCameraController Awake(): "+this.transform.name,this),this._camera&&this.enableWindowView(this._camera)},t.prototype.start=function(){},t.prototype.ready=function(){},t.prototype.update=function(){},t.prototype.late=function(){},t.prototype.step=function(){},t.prototype.fixed=function(){},t.prototype.after=function(){},t.prototype.reset=function(){},t.prototype.destroy=function(){if(this._camera){var e=this.scene.activeCameras?this.scene.activeCameras.indexOf(this._camera):-1;e>=0&&this.scene.activeCameras.splice(e,1)}},t.prototype.enableWindowView=function(e){if(e.viewport=new BABYLON.Viewport(.75,.75,.25,.25),e.layerMask=e.layerMask,e.inputs&&e.inputs.attached)for(var t in e.inputs.attached){var i=e.inputs.attached[t];i&&"function"==typeof i.detachControl&&i.detachControl()}if(!this.scene.activeCameras||0===this.scene.activeCameras.length){var n=this.scene.activeCamera||null;n&&n!==e||(n=this.scene.cameras.find(function(t){return t!==e})||null),n?(n.viewport=new BABYLON.Viewport(0,0,1,1),this.scene.activeCameras=[n],this.scene.activeCamera=null):this.scene.activeCameras=[]}-1===this.scene.activeCameras.indexOf(e)&&this.scene.activeCameras.push(e)},t}(n.ScriptComponent);e.SideCameraController=t,n.SceneManager.RegisterClass("PROJECT.SideCameraController",t)}(r||(r={})),function(e){var t=function(){this.Pos=BABYLON.Vector3.Zero(),this.Normal=BABYLON.Vector3.Zero(),this.Tangent=BABYLON.Vector4.Zero(),this.Posl=BABYLON.Vector3.Zero(),this.Posr=BABYLON.Vector3.Zero(),this.Intensity=0,this.LastIndex=-1};e.SkidMarkSection=t;var i=function(e){function i(t,r,o,a){void 0===o&&(o={}),void 0===a&&(a="PROJECT.SkidMarkManager");var s=e.call(this,t,r,o,a)||this;return i.MAX_MARKS=s.getProperty("maxSections",i.MAX_MARKS),i.MARK_COLOR=n.Utilities.ParseColor3(s.getProperty("textureColor"),i.MARK_COLOR),i.MARK_WIDTH=s.getProperty("textureWidth",i.MARK_WIDTH),i.GROUND_OFFSET=s.getProperty("groundOffset",i.GROUND_OFFSET),i.GPU_TRIANGLES=s.getProperty("gpuQuadIndices",i.GPU_TRIANGLES),i.TEXTURE_MARKS=s.getProperty("textureMarks",i.TEXTURE_MARKS),i.TEX_INTENSITY=s.getProperty("textureIntensity",i.TEX_INTENSITY),i.MIN_DISTANCE=s.getProperty("textureDistance",i.MIN_DISTANCE),i.MIN_SQR_DISTANCE=i.MIN_DISTANCE*i.MIN_DISTANCE,s}return o(i,e),i.prototype.start=function(){i.CreateSkidMarkManager(this.scene)},i.prototype.update=function(){i.UpdateSkidMarkManager()},i.AddSkidMarkSegment=function(e,t,n,r){if(null==i.SkidMarkMesh)return null;if(i.TempVector3_POS.set(0,0,0),i.TempVector3_DIR.set(0,0,0),i.TempVector3_XDIR.set(0,0,0),i.TempVector3_SDIR.set(0,0,0),n>1)n=1;else if(n<0)return-1;if(r>0&&(e.subtractToRef(i.SkidMarkSections[r].Pos,i.TempVector3_POS),i.TempVector3_POS.lengthSquared()<i.MIN_SQR_DISTANCE))return r;var o=i.SkidMarkSections[i.SkidMarkIndex];if(t.scaleToRef(i.GROUND_OFFSET,i.TempVector3_POS),e.addToRef(i.TempVector3_POS,o.Pos),o.Normal.copyFrom(t),o.Intensity=n*i.TEX_INTENSITY,o.LastIndex=r,-1!=r){var a=i.SkidMarkSections[r];o.Pos.subtractToRef(a.Pos,i.TempVector3_DIR),BABYLON.Vector3.CrossToRef(i.TempVector3_DIR,t,i.TempVector3_XDIR),i.TempVector3_XDIR.normalizeToRef(i.TempVector3_XDIR),i.TempVector3_XDIR.scaleToRef(.5*i.MARK_WIDTH,i.TempVector3_SDIR),o.Pos.addToRef(i.TempVector3_SDIR,o.Posl),o.Pos.subtractToRef(i.TempVector3_SDIR,o.Posr),o.Tangent.set(i.TempVector3_XDIR.x,i.TempVector3_XDIR.y,i.TempVector3_XDIR.z,1),-1===a.LastIndex&&(o.Pos.addToRef(i.TempVector3_SDIR,a.Posl),o.Pos.subtractToRef(i.TempVector3_SDIR,a.Posr),a.Tangent.copyFrom(o.Tangent))}i.AddSkidMarkVertexData();var s=i.SkidMarkIndex;return i.SkidMarkIndex=++i.SkidMarkIndex%i.MAX_MARKS,s},i.CreateSkidMarkManager=function(e){if(null==i.SkidMarkMesh){var r=new BABYLON.StandardMaterial("SkidMarkMaterial",e);r.backFaceCulling=!1,r.disableLighting=!0,r.emissiveColor=i.MARK_COLOR,r.diffuseColor=i.MARK_COLOR,r.diffuseTexture=n.Utilities.ParseTexture(i.TEXTURE_MARKS,e),null!=r.diffuseTexture&&(r.diffuseTexture.hasAlpha=!0,r.useAlphaFromDiffuseTexture=!0),r.freeze(),i.SkidMarkMesh=new BABYLON.Mesh("SkidMarkMesh",e),i.SkidMarkMesh.material=r,i.SkidMarkMesh.renderingGroupId=n.Utilities.DefaultRenderGroup(),i.SkidMarkMesh.alwaysSelectAsActiveMesh=!0,i.SkidMarkMesh.doNotSyncBoundingInfo=!0,i.SkidMarkMesh.receiveShadows=!1,i.SkidMarkMesh.checkCollisions=!1,i.SkidMarkMesh.useVertexColors=!0,i.SkidMarkMesh.hasVertexAlpha=!0,i.SkidMarkMesh.isPickable=!1,i.SkidMarkSections=new Array(i.MAX_MARKS);for(var o=0;o<i.SkidMarkSections.length;o++)i.SkidMarkSections[o]=new t;i.SkidBufferPositions=new Float32Array(4*i.MAX_MARKS*3),i.SkidBufferNormals=new Float32Array(4*i.MAX_MARKS*3),i.SkidBufferTangents=new Float32Array(4*i.MAX_MARKS*4),i.SkidBufferColors=new Float32Array(4*i.MAX_MARKS*4),i.SkidBufferUvs=new Float32Array(4*i.MAX_MARKS*2),i.SkidBufferIndices=new Int32Array(6*i.MAX_MARKS);var a=new BABYLON.VertexData;a.positions=i.SkidBufferPositions,a.normals=i.SkidBufferNormals,a.tangents=i.SkidBufferTangents,a.colors=i.SkidBufferColors,a.uvs=i.SkidBufferUvs,a.indices=i.SkidBufferIndices,a.applyToMesh(i.SkidMarkMesh,!0),i.SkidMarkMesh.freezeWorldMatrix()}},i.AddSkidMarkVertexData=function(){var e=i.SkidMarkSections[i.SkidMarkIndex];if(-1!==e.LastIndex){var t=i.SkidMarkSections[e.LastIndex];i.SkidMarkUpdated=!0;var n=4*i.SkidMarkIndex+0;i.SkidBufferPositions[3*n]=t.Posl.x,i.SkidBufferPositions[3*n+1]=t.Posl.y,i.SkidBufferPositions[3*n+2]=t.Posl.z,n=4*i.SkidMarkIndex+1,i.SkidBufferPositions[3*n]=t.Posr.x,i.SkidBufferPositions[3*n+1]=t.Posr.y,i.SkidBufferPositions[3*n+2]=t.Posr.z,n=4*i.SkidMarkIndex+2,i.SkidBufferPositions[3*n]=e.Posl.x,i.SkidBufferPositions[3*n+1]=e.Posl.y,i.SkidBufferPositions[3*n+2]=e.Posl.z,n=4*i.SkidMarkIndex+3,i.SkidBufferPositions[3*n]=e.Posr.x,i.SkidBufferPositions[3*n+1]=e.Posr.y,i.SkidBufferPositions[3*n+2]=e.Posr.z,n=4*i.SkidMarkIndex+0,i.SkidBufferNormals[3*n]=t.Normal.x,i.SkidBufferNormals[3*n+1]=t.Normal.y,i.SkidBufferNormals[3*n+2]=t.Normal.z,n=4*i.SkidMarkIndex+1,i.SkidBufferNormals[3*n]=t.Normal.x,i.SkidBufferNormals[3*n+1]=t.Normal.y,i.SkidBufferNormals[3*n+2]=t.Normal.z,n=4*i.SkidMarkIndex+2,i.SkidBufferNormals[3*n]=e.Normal.x,i.SkidBufferNormals[3*n+1]=e.Normal.y,i.SkidBufferNormals[3*n+2]=e.Normal.z,n=4*i.SkidMarkIndex+3,i.SkidBufferNormals[3*n]=e.Normal.x,i.SkidBufferNormals[3*n+1]=e.Normal.y,i.SkidBufferNormals[3*n+2]=e.Normal.z,n=4*i.SkidMarkIndex+0,i.SkidBufferTangents[4*n]=t.Tangent.x,i.SkidBufferTangents[4*n+1]=t.Tangent.y,i.SkidBufferTangents[4*n+2]=t.Tangent.z,i.SkidBufferTangents[4*n+3]=t.Tangent.w,n=4*i.SkidMarkIndex+1,i.SkidBufferTangents[4*n]=t.Tangent.x,i.SkidBufferTangents[4*n+1]=t.Tangent.y,i.SkidBufferTangents[4*n+2]=t.Tangent.z,i.SkidBufferTangents[4*n+3]=t.Tangent.w,n=4*i.SkidMarkIndex+2,i.SkidBufferTangents[4*n]=e.Tangent.x,i.SkidBufferTangents[4*n+1]=e.Tangent.y,i.SkidBufferTangents[4*n+2]=e.Tangent.z,i.SkidBufferTangents[4*n+3]=e.Tangent.w,n=4*i.SkidMarkIndex+3,i.SkidBufferTangents[4*n]=e.Tangent.x,i.SkidBufferTangents[4*n+1]=e.Tangent.y,i.SkidBufferTangents[4*n+2]=e.Tangent.z,i.SkidBufferTangents[4*n+3]=e.Tangent.w,n=4*i.SkidMarkIndex+0,i.SkidBufferColors[4*n]=1,i.SkidBufferColors[4*n+1]=1,i.SkidBufferColors[4*n+2]=1,i.SkidBufferColors[4*n+3]=t.Intensity,n=4*i.SkidMarkIndex+1,i.SkidBufferColors[4*n]=1,i.SkidBufferColors[4*n+1]=1,i.SkidBufferColors[4*n+2]=1,i.SkidBufferColors[4*n+3]=t.Intensity,n=4*i.SkidMarkIndex+2,i.SkidBufferColors[4*n]=1,i.SkidBufferColors[4*n+1]=1,i.SkidBufferColors[4*n+2]=1,i.SkidBufferColors[4*n+3]=e.Intensity,n=4*i.SkidMarkIndex+3,i.SkidBufferColors[4*n]=1,i.SkidBufferColors[4*n+1]=1,i.SkidBufferColors[4*n+2]=1,i.SkidBufferColors[4*n+3]=e.Intensity,n=4*i.SkidMarkIndex+0,i.SkidBufferUvs[2*n]=0,i.SkidBufferUvs[2*n+1]=0,n=4*i.SkidMarkIndex+1,i.SkidBufferUvs[2*n]=1,i.SkidBufferUvs[2*n+1]=0,n=4*i.SkidMarkIndex+2,i.SkidBufferUvs[2*n]=0,i.SkidBufferUvs[2*n+1]=1,n=4*i.SkidMarkIndex+3,i.SkidBufferUvs[2*n]=1,i.SkidBufferUvs[2*n+1]=1,i.SkidBufferIndices[6*i.SkidMarkIndex+0]=4*i.SkidMarkIndex+0,i.SkidBufferIndices[6*i.SkidMarkIndex+2]=4*i.SkidMarkIndex+1,i.SkidBufferIndices[6*i.SkidMarkIndex+1]=4*i.SkidMarkIndex+2,i.SkidBufferIndices[6*i.SkidMarkIndex+3]=4*i.SkidMarkIndex+2,i.SkidBufferIndices[6*i.SkidMarkIndex+5]=4*i.SkidMarkIndex+1,i.SkidBufferIndices[6*i.SkidMarkIndex+4]=4*i.SkidMarkIndex+3}},i.UpdateSkidMarkManager=function(){null!=i.SkidMarkMesh&&!0===i.SkidMarkUpdated&&(i.SkidMarkUpdated=!1,null!=i.SkidMarkMesh.geometry&&(i.SkidMarkMesh.geometry.updateVerticesDataDirectly(BABYLON.VertexBuffer.PositionKind,i.SkidBufferPositions,0,!1),i.SkidMarkMesh.geometry.updateVerticesDataDirectly(BABYLON.VertexBuffer.NormalKind,i.SkidBufferNormals,0,!1),i.SkidMarkMesh.geometry.updateVerticesDataDirectly(BABYLON.VertexBuffer.TangentKind,i.SkidBufferTangents,0,!1),i.SkidMarkMesh.geometry.updateVerticesDataDirectly(BABYLON.VertexBuffer.ColorKind,i.SkidBufferColors,0,!1),i.SkidMarkMesh.geometry.updateVerticesDataDirectly(BABYLON.VertexBuffer.UVKind,i.SkidBufferUvs,0,!1),i.SkidMarkMesh.geometry.updateIndices(i.SkidBufferIndices,0,i.GPU_TRIANGLES)))},i.MAX_MARKS=1024,i.GROUND_OFFSET=.01,i.GPU_TRIANGLES=!0,i.MARK_COLOR=BABYLON.Color3.Black(),i.MARK_WIDTH=.3,i.TEX_INTENSITY=1,i.MIN_DISTANCE=.1,i.MIN_SQR_DISTANCE=i.MIN_DISTANCE*i.MIN_DISTANCE,i.TEXTURE_MARKS=null,i.SkidBufferPositions=null,i.SkidBufferNormals=null,i.SkidBufferTangents=null,i.SkidBufferColors=null,i.SkidBufferUvs=null,i.SkidBufferIndices=null,i.SkidMarkSections=null,i.SkidMarkIndex=0,i.SkidMarkMesh=null,i.SkidMarkUpdated=!1,i.TempVector3_POS=new BABYLON.Vector3(0,0,0),i.TempVector3_DIR=new BABYLON.Vector3(0,0,0),i.TempVector3_XDIR=new BABYLON.Vector3(0,0,0),i.TempVector3_SDIR=new BABYLON.Vector3(0,0,0),i}(n.ScriptComponent);e.SkidMarkManager=i,n.SceneManager.RegisterClass("PROJECT.SkidMarkManager",i)}(r||(r={})),function(e){var t=function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e.MIN_RPM=800,e.MAX_RPM=8e3,e._animator=null,e._rigidbody=null,e._engineAudioSource=null,e._skidAudioSource=null,e._nosAudioSource=null,e._positionLocked=!1,e._prevHandBrakeRequested=!1,e._donutEngineScale=1,e._donutEntryBlend=0,e._donutEntrySpeedMps=0,e.steeringWheelHub=null,e.steeringWheelAxis=2,e.maxSteeringAngle=65,e.maxSteeringSpeed=15,e.gearIndex=0,e.shiftingTime=0,e.shiftingSide=1,e.shiftingBrake=1,e.engineForce=0,e.footBraking=!1,e.handBraking=!1,e.linearDamping=0,e.angularDamping=0,e.forwardSpeed=0,e.absoluteSpeed=0,e.americanSpeed=0,e.gradientSpeed=0,e.smoothedGradientSpeed=0,e.smoothedSteeringSpeed=0,e.frontWheelPower=0,e.backWheelPower=0,e.wheelBrakingForce=0,e.enginePitchLevel=0,e.smokeIntensityFactor=0,e.handBrakingHoldTimer=0,e.raycastVehicle=null,e.brakeLightsMesh=null,e.brakeLightsTrans=null,e.reverseLightsMesh=null,e.reverseLightsTrans=null,e.frontLeftWheelTrans=null,e.frontRightWheelTrans=null,e.backLeftWheelTrans=null,e.backRightWheelTrans=null,e.frontLeftWheelMesh=null,e.frontRightWheelMesh=null,e.backLeftWheelMesh=null,e.backRightWheelMesh=null,e.frontLeftWheelEmitter=null,e.frontRightWheelEmitter=null,e.backLeftWheelEmitter=null,e.backRightWheelEmitter=null,e.frontLeftWheelParticle=null,e.frontRightWheelParticle=null,e.backLeftWheelParticle=null,e.backRightWheelParticle=null,e.frontLeftWheelCollider=null,e.frontRightWheelCollider=null,e.backLeftWheelCollider=null,e.backRightWheelCollider=null,e.engineTorqueCurve=null,e.physicsSteerAngleL=0,e.physicsSteerAngleR=0,e.visualSteerAngleL=0,e.visualSteerAngleR=0,e.visualSteerBoostL=0,e.visualSteerBoostR=0,e.idleNoiseDelta=0,e.driveNoiseDelta=0,e.boostSpeedTimer=0,e.burnoutMeter=0,e.donutMeter=0,e.wheelRadius=0,e.engineRPM=0,e.pitchRPM=0,e.shiftRPM=0,e.wheelRPM=0,e.transmissionInputRPM=0,e.actualEngineRPM=0,e.targetEngineRPM=0,e.throttleRPM=0,e.engineLoad=0,e.gearShiftCooldown=0,e.isShifting=!1,e.shiftDirection=0,e.clutchEngagement=1,e.engineBraking=0,e.shiftHysteresis=200,e.SKID_FL=0,e.SKID_FR=0,e.SKID_RL=0,e.SKID_RR=0,e.PITCH_FL=0,e.PITCH_FR=0,e.PITCH_RL=0,e.PITCH_RR=0,e.FRONT_LEFT=-1,e.FRONT_RIGHT=-1,e.BACK_LEFT=-1,e.BACK_RIGHT=-1,e.WHEEL_SKID_PITCH=0,e.POWER_BOOST_PITCH=0,e.SPIN_FL_Rotation=new BABYLON.Vector3(0,0,0),e.SPIN_FR_Rotation=new BABYLON.Vector3(0,0,0),e.SPIN_RL_Rotation=new BABYLON.Vector3(0,0,0),e.SPIN_RR_Rotation=new BABYLON.Vector3(0,0,0),e.smokeTexture=null,e.skidThreashold=.65,e.wheelDrawVelocity=.02,e.smokeIntensity=150,e.smokeOpacity=.1,e.smokeDonuts=2,e.burnoutTurnFactor=1,e.maxSteerBoost=4,e.overSteerSpeed=1,e.overSteerTimeout=.2,e.topEngineSpeed=200,e.topBoosterSpeed=150,e.powerChangeRate=5,e.powerCoefficient=1,e.boosterCoefficient=8,e.gravitationalForce=1,e.driftSpeedDampener=1,e.lowGearCoefficient=.8,e.lowGearDampener=.1,e.stationaryBoost=1.1,e.lowSpeedSteering=.1,e.highSpeedSteering=1,e.steeringInputCurve=1.8,e.maximumYawRateLow=60,e.maximumYawRateHigh=30,e.debugBurnout=!1,e.debugBurnoutEveryNFrames=6,e.debugSteering=!1,e.debugSteeringEveryNFrames=6,e._debugSteeringCounter=0,e.debugDonut=!0,e.debugDonutEveryNFrames=30,e._donutLogCounter=0,e.donutTurningRadius=5,e.donutPowerBlend=.35,e.donutSpeedScaling=1,e.donutRotationBoost=8,e.donutAngularDamping=0,e.donutFrontFriction=.85,e.donutRearFriction=.35,e.donutFrontWheelPull=.2,e.donutYawDegPerSec=72,e.donutYawResponse=4,e.donutSlipAngle=62,e.donutEntryTime=.92,e.donutVelocityPinEnabled=!0,e.donutVelocityPinResponse=8,e.roadConnectAccel=6,e.smoothFlyingImpulse=8,e.stableDownImpulse=.8,e.constImpulseForce=.1,e.transmissionRatio=.75,e.differentialRatio=3.55,e.burnoutFirstGearMultiplier=1,e.maxBoosterTime=10,e.minBoosterSpeed=25,e.maxFrontBraking=0,e.maxReversePower=.5,e.minBrakingForce=250,e.maxBrakingForce=500,e.handBrakingForce=1500,e.handBrakingTimer=0,e.defaultBrakingWindow=.65,e.counterSteerLockoutWindowPercent=1,e.counterSteerLockoutDeadzone=.05,e.linearBrakingForce=.85,e.angularBrakingForce=.01,e.frontSkidFriction=0,e.rearSkidFriction=0,e.burnoutTimeDelay=1.5,e.burnoutWheelPitch=.85,e.stationaryBurnoutSkidPitch=.82,e.burnoutPeelAwaySkidPitch=1.1,e.burnoutPeelAwayPitchRampTime=.25,e.burnoutLaunchChirpSound="",e.burnoutCoefficient=5,e.burnoutTriggerMark=20,e.stationaryBurnoutPrimeSpeedMph=.25,e.stationaryBurnoutPrimeHoldTime=.1,e.stationaryBurnoutPrimeReleaseSpeedMph=2,e.stationaryBurnoutRevMinRpmOffset=900,e.stationaryBurnoutRevMaxFactor=.5,e.stationaryBurnoutRevLerpSpeed=5,e.burnoutLaunchRpmCarryTime=.85,e.burnoutLaunchRpmCarryFloorFactor=.72,e.normalLaunchTractionRamp=15,e.normalLaunchTractionMin=.35,e.burnoutLaunchKickDuration=.8,e.burnoutLaunchKickMultiplier=3,e.burnoutLaunchFrictionRestore=2.5,e.debugLaunch=!1,e.debugLaunchEveryNFrames=3,e.debugFrictionRestore=!1,e.debugFrictionRestoreEveryNFrames=1,e.debugFrictionSnapDelta=.03,e.skidSlideEnabled=!0,e.skidSlideMinAngle=6,e.skidSlideMaxAngle=20,e.skidSlideMinSpeed=2.5,e.skidRecoverDuration=1.6,e.skidRecoverCurve=2.6,e.debugSkidSlide=!1,e.debugSkidSlideEveryNFrames=12,e.skidReleaseBrakeFadeTime=.3,e.skidReleaseSnapRatio=.03,e.skidStopFrictionResetSpeed=2,e.skidLaunchFrictionResetSpeed=6,e.burnoutStopFrictionResetSpeed=2,e.burnoutLaunchFrictionResetSpeed=6,e.burnoutExitArcadeFadeTime=.2,e.burnoutExitFrictionRampTime=.4,e.burnoutExitArcadeReleaseTime=.25,e.enableAutoBurnouts=!1,e.grassPenaltyMask=8388608,e.curbPenaltyMask=16777216,e.minPenaltySpeed=65,e.linearWheelDrag=.05,e.frictionWheelSlip=.195,e.showSensorLines=!1,e.powerBooster=!0,e.linkTrackManager=!0,e.playVehicleSounds=!0,e.postNetworkAttributes=!1,e.wheelDriveType=0,e.gearBoxMultiplier=1,e.currentPitchScale=1,e.gearBoxPitchScale=1,e.gearBoxShiftDelay=.5,e.gearBoxShiftRatios=[4.2,2.64,1.78,1.31,1,.82],e.gearBoxShiftUpRanges=[45,75,105,135,160,999],e.gearBoxShiftDownRanges=[0,25,50,80,110,135],e.throttleBrakingForce=0,e.throttleEngineSpeed=0,e.frictionLerpSpeed=.2,e.burnoutLerpSpeed=.05,e.skidTurningAssist=2,e.skidSteeringKick=.1,e.skidSteeringAngle=10,e.skidReleaseWindow=.5,e.skidReleaseLinger=1.5,e.ackermanWheelBase=2.5,e.ackermanRearTrack=1.5,e.ackermanTurnRadius=8,e.ackermanMaxRadius=16,e.ackermanTurnFactor=1,e.radiusBrakingForce=.5,e.steeringSlewTau=.08,e.minSteeringSlew=.6,e.roadSurfaceFactor=1,e.movementTilting=!1,e.surfaceDetection=!1,e.idleShakeRate=5,e.idleShakeNoise=.01,e.maxForwardAngle=3,e.maxLateralAngle=3,e.lerpForwardFactor=10,e.lerpLateralFactor=10,e.shiftForwardExtra=.2,e.shiftLateralExtra=.2,e.forwardPitchFactor=.2,e.lateralRollFactor=.3,e.forwardRecoverRate=.3,e.lateralRecoverRate=.3,e.lowSpeedScale=1,e.highSpeedScale=5,e.lowForwardNoise=.05,e.highForwardNoise=.05,e.lowLateralNoise=.05,e.highLateralNoise=.05,e.speedThreashold=5,e.boosterTransform=null,e.chassisTransform=null,e.tiltChassisEulers=new BABYLON.Vector3(0,0,0),e.m_physicsWorld=null,e.m_frontLeftWheel=null,e.m_frontRightWheel=null,e.m_backLeftWheel=null,e.m_backRightWheel=null,e.m_frontLeftWheelSkid=-1,e.m_frontRightWheelSkid=-1,e.m_backLeftWheelSkid=-1,e.m_backRightWheelSkid=-1,e.m_angularDampener=new BABYLON.Vector3(.5,1,.5),e.m_velocityOffset=new BABYLON.Vector3(0,0,0),e.m_linearVelocity=new BABYLON.Vector3(0,0,0),e.m_lastPosition=new BABYLON.Vector3(0,0,0),e.m_scaledVelocity=0,e.donutButton=!1,e.burnoutButton=!1,e.burnoutTimer=0,e.burnoutElapsed=0,e.restoreTimer=0,e.restoreTimerDuration=0,e.cooldownTimer=0,e.wheelDonuts=!1,e.wheelBurnout=!1,e._prevBurnoutButton=!1,e._burnoutLatchedDriveSign=0,e._stationaryBurnoutPrimed=!1,e._stationaryBurnoutPrimeTimer=0,e._prevStationaryBurnoutWanted=!1,e._burnoutLaunchKickTimer=0,e._burnoutLaunchHoldRpm=0,e._burnoutLaunchRpmCarryTimer=0,e._burnoutLaunchRpmCarryDuration=0,e._burnoutPeelAwayPitchRampTimer=0,e._burnoutPeelAwayPitchRampDuration=0,e._stationaryLaunchSnapActive=!1,e._burnoutLowGearClimbActive=!1,e._burnoutLowGearClimbStationary=!1,e._burnoutLowGearClimbDriveSign=0,e._burnoutStartedFromStationary=!1,e._launchLogCounter=0,e._handBrakeEntrySteerSign=0,e._skidReleaseBrakeTimer=0,e._skidFrictionRestorePending=!1,e._skidRecoverActive=!1,e._skidRecoverElapsed=0,e._skidRecoverFrontStart=0,e._skidRecoverRearStart=0,e._skidSlideLogCounter=0,e._burnoutExitArcadeFadeTimer=0,e._burnoutExitFrictionRampTimer=0,e._burnoutExitArcadeReleaseTimer=0,e._burnoutResidualFrictionRestorePending=!1,e._prevWheelBurnoutState=!1,e._lockedPosition=null,e._lockedRotationQuaternion=null,e.wheelSkidding=!1,e.donutSpinTime=0,e.currentForward=0,e.currentTurning=0,e.rampedTurning=0,e.currentBoosting=!1,e.currentSkidding=!1,e.currentDrivePower=0,e.targetDrivePower=0,e.animatorSteerAngle=0,e.currentPitch=0,e.currentRoll=0,e.previousSpeed=0,e.frontLeftContact=!1,e.frontRightContact=!1,e.rearLeftContact=!1,e.rearRightContact=!1,e.frontLeftContactTag="",e.frontRightContactTag="",e.rearLeftContactTag="",e.rearRightContactTag="",e.frontLeftContactMask=0,e.frontRightContactMask=0,e.rearLeftContactMask=0,e.rearRightContactMask=0,e.frontLeftContactPoint=new BABYLON.Vector3(0,0,0),e.frontRightContactPoint=new BABYLON.Vector3(0,0,0),e.rearLeftContactPoint=new BABYLON.Vector3(0,0,0),e.rearRightContactPoint=new BABYLON.Vector3(0,0,0),e.frontLeftContactNormal=new BABYLON.Vector3(0,0,0),e.frontRightContactNormal=new BABYLON.Vector3(0,0,0),e.rearLeftContactNormal=new BABYLON.Vector3(0,0,0),e.rearRightContactNormal=new BABYLON.Vector3(0,0,0),e.frontLeftFrictionLerping=!1,e.frontRightFrictionLerping=!1,e.rearLeftFrictionLerping=!1,e.rearRightFrictionLerping=!1,e.frontLeftFrictionPenalty=!1,e.frontRightFrictionPenalty=!1,e.rearLeftFrictionPenalty=!1,e.rearRightFrictionPenalty=!1,e.startRaycastPosition=new BABYLON.Vector3(0,0,0),e.endRaycastPosition=new BABYLON.Vector3(0,0,0),e.downDirection=new BABYLON.Vector3(0,-1,0),e.downDistance=2,e}return o(i,t),i.prototype.isBraking=function(){return this.getFootBraking()||this.getHandBraking()},i.prototype.isBoosting=function(){return this.currentBoosting},i.prototype.allowRollingReverseBurnout=function(){return!0===this.burnoutButton&&this.americanSpeed<=this.burnoutTriggerMark&&(this.currentForward<=-.9&&this.forwardSpeed>0||this.currentForward>=.9&&this.forwardSpeed<0)},i.prototype.getFootBraking=function(){return this.footBraking},i.prototype.getHandBraking=function(){return this.handBraking},i.prototype.getLinearVelocity=function(){return this.m_linearVelocity},i.prototype.getCurrentForward=function(){return this.currentForward},i.prototype.getCurrentTurning=function(){return this.currentTurning},i.prototype.getCurrentSkidding=function(){return this.currentSkidding},i.prototype.getBurnoutButton=function(){return this.burnoutButton},i.prototype.getDonutButton=function(){return this.donutButton},i.prototype.getReverseThrottle=function(){return this.currentForward<0&&this.forwardSpeed<0},i.prototype.getEnginePitchLevel=function(){return this.enginePitchLevel},i.prototype.getCurrentBurnout=function(){return this.wheelBurnout||this.restoreTimer>0},i.prototype.getFrontLeftSkid=function(){return this.SKID_FL},i.prototype.getFrontRightSkid=function(){return this.SKID_FR},i.prototype.getBackLeftSkid=function(){return this.SKID_RL},i.prototype.getBackRightSkid=function(){return this.SKID_RR},i.prototype.getWheelSkidPitch=function(){return this.WHEEL_SKID_PITCH},i.prototype.getRigidbodyPhysics=function(){return this._rigidbody},i.prototype.getRaycastVehicle=function(){return this.raycastVehicle},i.prototype.getGradientSpeed=function(){return this.gradientSpeed},i.prototype.getForwardSpeed=function(){return this.forwardSpeed},i.prototype.getAbsoluteSpeed=function(){return this.absoluteSpeed},i.prototype.getAmericanSpeed=function(){return this.americanSpeed},i.prototype.getTopEngineSpeed=function(){return!0===this.currentBoosting?this.topBoosterSpeed:this.topEngineSpeed},i.prototype.getNormalizedSpeed=function(){return this.americanSpeed/this.getTopEngineSpeed()},i.prototype.getMaxReversePower=function(){return this.maxReversePower},i.prototype.getCurrentGearIndex=function(){return this.gearIndex},i.prototype.getCurrentEngineRPM=function(){return this.engineRPM},i.prototype.getCurrentEngineForce=function(){return this.engineForce},i.prototype.getCurrentEnginePitch=function(){return BABYLON.Scalar.Clamp(this.pitchRPM/this.MAX_RPM+.1)},i.prototype.getGearShiftRatioCount=function(){return null!=this.gearBoxShiftRatios?this.gearBoxShiftRatios.length:0},i.prototype.getSmokeTextureMask=function(){return this.smokeTexture},i.prototype.getBrakeLightsMesh=function(){return this.brakeLightsMesh},i.prototype.getReverseLightsMesh=function(){return this.reverseLightsMesh},i.prototype.getFrontLeftWheelNode=function(){return this.frontLeftWheelMesh},i.prototype.getFrontRightWheelNode=function(){return this.frontRightWheelMesh},i.prototype.getBackLeftWheelNode=function(){return this.backLeftWheelMesh},i.prototype.getBackRightWheelNode=function(){return this.backRightWheelMesh},i.prototype.getWheelBurnoutEnabled=function(){return this.wheelBurnout},i.prototype.getWheelDonutsEnabled=function(){return this.wheelDonuts},i.prototype.getCurrentDonutSpinTime=function(){return this.donutSpinTime},i.prototype.isStartPositionLocked=function(){return this._positionLocked},i.prototype.lockStartPosition=function(){if(null!=this.transform&&(this._lockedPosition=this.transform.position.clone(),this._lockedRotationQuaternion=null!=this.transform.rotationQuaternion?this.transform.rotationQuaternion.clone():null),this._positionLocked=!0,!0===this.debugLaunch){var e=null!=this._lockedPosition?this._lockedPosition:BABYLON.Vector3.Zero();console.log("[GRID-LOCK] Position locked at ("+e.x.toFixed(2)+", "+e.y.toFixed(2)+", "+e.z.toFixed(2)+")")}},i.prototype.unlockStartPosition=function(){this._positionLocked=!1,!0==(!0===this.wheelBurnout&&!0===this._stationaryBurnoutPrimed&&!0===this._burnoutStartedFromStationary&&this.currentForward>.9&&this.americanSpeed<=this.stationaryBurnoutPrimeReleaseSpeedMph&&Math.abs(this.forwardSpeed)<=.5)?(this._burnoutLaunchKickTimer=this.burnoutLaunchKickDuration,this._stationaryLaunchSnapActive=!0,this.armBurnoutLowGearClimb(!0),this.armBurnoutLaunchAudio(),!0===this.debugLaunch&&console.log("[GRID-UNLOCK] >>> BURNOUT LAUNCH KICK FIRED — rpm="+this.engineRPM.toFixed(0)+" kickDur="+this.burnoutLaunchKickDuration.toFixed(2)+" mult="+this.burnoutLaunchKickMultiplier.toFixed(2))):(this._stationaryLaunchSnapActive=!1,!0===this.debugLaunch&&console.log("[GRID-UNLOCK] Position released — normal launch (no burnout built)")),this._lockedPosition=null,this._lockedRotationQuaternion=null},i.prototype.getSmokeIntensityFactor=function(){return this.smokeIntensityFactor},i.prototype.getWheelVelocityOffset=function(){return this.m_velocityOffset},i.prototype.readBurnoutMeter=function(){return this.burnoutMeter},i.prototype.resetBurnoutMeter=function(){this.burnoutMeter=0},i.prototype.readDonutMeter=function(){return this.donutMeter},i.prototype.resetDonutMeter=function(){this.donutMeter=0},i.prototype.getBoosterTime=function(){return this.boostSpeedTimer},i.prototype.setBoosterTime=function(e){this.boostSpeedTimer=e},i.prototype.resetBoosterTime=function(){this.setBoosterTime(this.maxBoosterTime)},i.prototype.awake=function(){this.awakeVehicleState()},i.prototype.start=function(){this.initVehicleState()},i.prototype.update=function(){this.updateVehicleState()},i.prototype.destroy=function(){this.destroyVehicleState()},i.prototype.awakeVehicleState=function(){this.engineForce=0,this.frontWheelPower=0,this.backWheelPower=0,this.wheelBrakingForce=0,this.skidTurningAssist=this.getProperty("skidTurningAssist",this.skidTurningAssist),this.skidSteeringAngle=this.getProperty("skidSteeringAngle",this.skidSteeringAngle),this.skidSteeringKick=this.getProperty("skidSteeringKick",this.skidSteeringKick),this.skidReleaseWindow=this.getProperty("skidReleaseWindow",this.skidReleaseWindow),this.skidReleaseLinger=this.getProperty("skidReleaseLinger",this.skidReleaseLinger),this.skidSlideEnabled=this.getProperty("skidSlideEnabled",this.skidSlideEnabled),this.skidSlideMinAngle=this.getProperty("skidSlideMinAngle",this.skidSlideMinAngle),this.skidSlideMaxAngle=this.getProperty("skidSlideMaxAngle",this.skidSlideMaxAngle),this.skidSlideMinSpeed=this.getProperty("skidSlideMinSpeed",this.skidSlideMinSpeed),this.skidSlideMinAngle<0&&(this.skidSlideMinAngle=0),this.skidSlideMaxAngle<=this.skidSlideMinAngle&&(this.skidSlideMaxAngle=this.skidSlideMinAngle+1),this.skidSlideMinSpeed<0&&(this.skidSlideMinSpeed=0),this.skidRecoverDuration=this.getProperty("skidRecoverDuration",this.skidRecoverDuration),this.skidRecoverCurve=this.getProperty("skidRecoverCurve",this.skidRecoverCurve),this.skidRecoverDuration<.05&&(this.skidRecoverDuration=.05),this.skidRecoverCurve<.1&&(this.skidRecoverCurve=.1),this.debugSkidSlideEveryNFrames<1&&(this.debugSkidSlideEveryNFrames=1),this.ackermanWheelBase=this.getProperty("ackermanWheelBase",this.ackermanWheelBase),this.ackermanRearTrack=this.getProperty("ackermanRearTrack",this.ackermanRearTrack),this.ackermanTurnRadius=this.getProperty("ackermanTurnRadius",this.ackermanTurnRadius),this.ackermanMaxRadius=this.getProperty("ackermanMaxRadius",this.ackermanMaxRadius),this.radiusBrakingForce=this.getProperty("radiusBrakingForce",this.radiusBrakingForce),this.wheelDrawVelocity=this.getProperty("wheelDrawVelocity",this.wheelDrawVelocity),this.skidThreashold=this.getProperty("skidThreashold",this.skidThreashold),this.smokeIntensity=this.getProperty("smokeIntensity",this.smokeIntensity),this.smokeOpacity=this.getProperty("smokeOpacity",this.smokeOpacity),this.smokeDonuts=this.getProperty("smokeDonuts",this.smokeDonuts),this.powerBooster=this.getProperty("powerBooster",this.powerBooster),this.movementTilting=this.getProperty("movementTilting",this.movementTilting),this.surfaceDetection=this.getProperty("surfaceDetection",this.surfaceDetection),this.idleShakeNoise=this.getProperty("idleShakeNoise",this.idleShakeNoise),this.idleShakeRate=this.getProperty("idleShakeRate",this.idleShakeRate),this.maxForwardAngle=this.getProperty("maxForwardAngle",this.maxForwardAngle),this.maxLateralAngle=this.getProperty("maxLateralAngle",this.maxLateralAngle),this.forwardPitchFactor=this.getProperty("forwardPitchFactor",this.forwardPitchFactor),this.lateralRollFactor=this.getProperty("lateralRollFactor",this.lateralRollFactor),this.forwardRecoverRate=this.getProperty("forwardRecoverRate",this.forwardRecoverRate),this.lateralRecoverRate=this.getProperty("lateralRecoverRate",this.lateralRecoverRate),this.lowSpeedScale=this.getProperty("lowSpeedScale",this.lowSpeedScale),this.highSpeedScale=this.getProperty("highSpeedScale",this.highSpeedScale),this.lowForwardNoise=this.getProperty("lowForwardNoise",this.lowForwardNoise),this.highForwardNoise=this.getProperty("highForwardNoise",this.highForwardNoise),this.lowLateralNoise=this.getProperty("lowLateralNoise",this.lowLateralNoise),this.highLateralNoise=this.getProperty("highLateralNoise",this.highLateralNoise),this.speedThreashold=this.getProperty("speedThreashold",this.speedThreashold),this.shiftForwardExtra=this.getProperty("shiftForwardExtra",this.shiftForwardExtra),this.shiftLateralExtra=this.getProperty("shiftLateralExtra",this.shiftLateralExtra),this.lerpForwardFactor=this.getProperty("lerpForwardFactor",this.lerpForwardFactor),this.lerpLateralFactor=this.getProperty("lerpLateralFactor",this.lerpLateralFactor),this.topEngineSpeed=this.getProperty("topEngineSpeed",this.topEngineSpeed),this.topBoosterSpeed=this.getProperty("topBoosterSpeed",this.topBoosterSpeed),this.powerChangeRate=this.getProperty("powerChangeRate",this.powerChangeRate),this.powerCoefficient=this.getProperty("powerCoefficient",this.powerCoefficient),this.boosterCoefficient=this.getProperty("boosterCoefficient",this.boosterCoefficient),this.maxBoosterTime=this.getProperty("maxBoosterTime",this.maxBoosterTime),this.minBoosterSpeed=this.getProperty("minBoosterSpeed",this.minBoosterSpeed),this.maxFrontBraking=this.getProperty("maxFrontBraking",this.maxFrontBraking),this.maxReversePower=this.getProperty("maxReversePower",this.maxReversePower),this.minPenaltySpeed=this.getProperty("minPenaltySpeed",this.minPenaltySpeed),this.linearWheelDrag=this.getProperty("linearWheelDrag",this.linearWheelDrag),this.frictionWheelSlip=this.getProperty("frictionWheelSlip",this.frictionWheelSlip),this.showSensorLines=this.getProperty("showSensorLines",this.showSensorLines),this.stableDownImpulse=this.getProperty("stableDownImpulse",this.stableDownImpulse),this.roadConnectAccel=this.getProperty("roadConnectAccel",this.roadConnectAccel),this.gravitationalForce=this.getProperty("gravityMultiplier",this.gravitationalForce),this.smoothFlyingImpulse=this.getProperty("smoothFlyingImpulse",this.smoothFlyingImpulse),this.constImpulseForce=this.getProperty("constImpulseForce",this.constImpulseForce),this.frictionLerpSpeed=this.getProperty("frictionLerpSpeed",this.frictionLerpSpeed),this.skidReleaseBrakeFadeTime=this.getProperty("skidReleaseBrakeFadeTime",this.skidReleaseBrakeFadeTime),this.skidReleaseSnapRatio=this.getProperty("skidReleaseSnapRatio",this.skidReleaseSnapRatio),this.skidStopFrictionResetSpeed=this.getProperty("skidStopFrictionResetSpeed",this.skidStopFrictionResetSpeed),this.skidLaunchFrictionResetSpeed=this.getProperty("skidLaunchFrictionResetSpeed",this.skidLaunchFrictionResetSpeed),this.burnoutStopFrictionResetSpeed=this.getProperty("burnoutStopFrictionResetSpeed",this.burnoutStopFrictionResetSpeed),this.burnoutLaunchFrictionResetSpeed=this.getProperty("burnoutLaunchFrictionResetSpeed",this.burnoutLaunchFrictionResetSpeed),this.burnoutExitArcadeFadeTime=this.getProperty("burnoutExitArcadeFadeTime",this.burnoutExitArcadeFadeTime),this.burnoutExitFrictionRampTime=this.getProperty("burnoutExitFrictionRampTime",this.burnoutExitFrictionRampTime),this.burnoutExitArcadeReleaseTime=this.getProperty("burnoutExitArcadeReleaseTime",this.burnoutExitArcadeReleaseTime),this.frontSkidFriction=this.getProperty("frontSkidFriction",this.frontSkidFriction),this.rearSkidFriction=this.getProperty("rearSkidFriction",this.rearSkidFriction),this.burnoutTurnFactor=this.getProperty("burnoutTurnFactor",this.burnoutTurnFactor),this.maxSteerBoost=this.getProperty("maxSteerBoost",this.maxSteerBoost),this.overSteerSpeed=this.getProperty("overSteerSpeed",this.overSteerSpeed),this.overSteerTimeout=this.getProperty("overSteerTimeout",this.overSteerTimeout),this.wheelDriveType=this.getProperty("wheelDriveType",this.wheelDriveType),this.minBrakingForce=this.getProperty("minBrakingForce",this.minBrakingForce),this.maxBrakingForce=this.getProperty("maxBrakingForce",this.maxBrakingForce),this.handBrakingForce=this.getProperty("handBrakingForce",this.handBrakingForce),this.defaultBrakingWindow=this.getProperty("defaultBrakingWindow",this.defaultBrakingWindow),this.counterSteerLockoutWindowPercent=this.getProperty("counterSteerLockoutWindowPercent",this.counterSteerLockoutWindowPercent),this.counterSteerLockoutDeadzone=this.getProperty("counterSteerLockoutDeadzone",this.counterSteerLockoutDeadzone),this.linearBrakingForce=this.getProperty("linearBrakingForce",this.linearBrakingForce),this.angularBrakingForce=this.getProperty("angularBrakingForce",this.angularBrakingForce),this.steeringWheelAxis=this.getProperty("steeringWheelAxis",this.steeringWheelAxis),this.maxSteeringAngle=this.getProperty("maxSteeringAngle",this.maxSteeringAngle),this.maxSteeringSpeed=this.getProperty("maxSteeringSpeed",this.maxSteeringSpeed),this.steeringSlewTau=this.getProperty("steeringSlewTau",this.steeringSlewTau),this.minSteeringSlew=this.getProperty("minSteeringSlew",this.minSteeringSlew),this.lowGearDampener=this.getProperty("lowGearDampener",this.lowGearDampener),this.lowGearCoefficient=this.getProperty("lowGearCoefficient",this.lowGearCoefficient),this.stationaryBoost=this.getProperty("stationaryBoost",this.stationaryBoost),this.driftSpeedDampener=this.getProperty("driftSpeedDampener",this.driftSpeedDampener),this.lowSpeedSteering=this.getProperty("lowSpeedSteering",this.lowSpeedSteering),this.highSpeedSteering=this.getProperty("highSpeedSteering",this.highSpeedSteering),this.steeringInputCurve=this.getProperty("steeringInputCurve",this.steeringInputCurve),this.maximumYawRateLow=this.getProperty("maximumYawRateLow",this.maximumYawRateLow),this.maximumYawRateHigh=this.getProperty("maximumYawRateHigh",this.maximumYawRateHigh),this.donutTurningRadius=this.getProperty("donutTurningRadius",this.donutTurningRadius),this.donutSpeedScaling=this.getProperty("donutSpeedScaling",this.donutSpeedScaling),this.donutAngularDamping=this.getProperty("donutAngularDamping",this.donutAngularDamping),this.donutFrontFriction=this.getProperty("donutFrontFriction",this.donutFrontFriction),this.donutRearFriction=this.getProperty("donutRearFriction",this.donutRearFriction),this.donutFrontWheelPull=this.getProperty("donutFrontWheelPull",this.donutFrontWheelPull),this.donutRotationBoost=this.getProperty("donutRotationBoost",this.donutRotationBoost),this.donutYawDegPerSec=this.getProperty("donutYawDegPerSec",this.donutYawDegPerSec),this.donutYawResponse=this.getProperty("donutYawResponse",this.donutYawResponse),this.donutSlipAngle=this.getProperty("donutSlipAngle",this.donutSlipAngle),this.donutEntryTime=this.getProperty("donutEntryTime",this.donutEntryTime),this.donutVelocityPinEnabled=this.getProperty("donutVelocityPinEnabled",this.donutVelocityPinEnabled),this.donutVelocityPinResponse=this.getProperty("donutVelocityPinResponse",this.donutVelocityPinResponse),this.brakeLightsTrans=this.getProperty("brakeLightsMesh",this.brakeLightsTrans),this.reverseLightsTrans=this.getProperty("reverseLightsMesh",this.reverseLightsTrans),this.frontLeftWheelTrans=this.getProperty("frontLeftWheelMesh",this.frontLeftWheelTrans),this.frontRightWheelTrans=this.getProperty("frontRightWheelMesh",this.frontRightWheelTrans),this.backLeftWheelTrans=this.getProperty("rearLeftWheelMesh",this.backLeftWheelTrans),this.backRightWheelTrans=this.getProperty("rearRightWheelMesh",this.backRightWheelTrans),this.frontLeftWheelCollider=this.getProperty("frontLeftWheelCollider",this.frontLeftWheelCollider),this.frontRightWheelCollider=this.getProperty("frontRightWheelCollider",this.frontRightWheelCollider),this.backLeftWheelCollider=this.getProperty("rearLeftWheelCollider",this.backLeftWheelCollider),this.backRightWheelCollider=this.getProperty("rearRightWheelCollider",this.backRightWheelCollider),this.burnoutTimeDelay=this.getProperty("burnoutTimeDelay",this.burnoutTimeDelay),this.burnoutWheelPitch=this.getProperty("burnoutWheelPitch",this.burnoutWheelPitch),this.burnoutCoefficient=this.getProperty("burnoutCoefficient",this.burnoutCoefficient),this.burnoutTriggerMark=this.getProperty("burnoutTriggerMark",this.burnoutTriggerMark),this.enableAutoBurnouts=this.getProperty("enableAutoBurnouts",this.enableAutoBurnouts),this.postNetworkAttributes=this.getProperty("postNetworkAttributes",this.postNetworkAttributes),this.linkTrackManager=this.getProperty("linkTrackManager",this.linkTrackManager),this.playVehicleSounds=this.getProperty("playVehicleSounds",this.playVehicleSounds),this.differentialRatio=this.getProperty("gearBoxDifferential",this.differentialRatio),this.transmissionRatio=this.getProperty("gearBoxOverdrive",this.transmissionRatio),this.gearBoxMultiplier=this.getProperty("gearBoxMultiplier",this.gearBoxMultiplier),this.gearBoxPitchScale=this.getProperty("gearBoxPitchScale",this.gearBoxPitchScale),this.gearBoxShiftDelay=this.getProperty("gearBoxShiftDelay",this.gearBoxShiftDelay),this.gearBoxShiftRatios=this.getProperty("gearBoxShiftRatios",this.gearBoxShiftRatios),this.gearBoxShiftUpRanges=this.getProperty("gearBoxShiftUpRanges",this.gearBoxShiftUpRanges),this.gearBoxShiftDownRanges=this.getProperty("gearBoxShiftDownRanges",this.gearBoxShiftDownRanges),this.MIN_RPM=this.getProperty("gearBoxMinPower",this.MIN_RPM),this.MAX_RPM=this.getProperty("gearBoxMaxPower",this.MAX_RPM),this.driftSpeedDampener<=0&&(this.driftSpeedDampener=1),this.burnoutTurnFactor<=0&&(this.burnoutTurnFactor=1),this.stableDownImpulse<=0&&(this.stableDownImpulse=.8),this.roadConnectAccel<=0&&(this.roadConnectAccel=6),this.smoothFlyingImpulse<=0&&(this.smoothFlyingImpulse=8),this.maxFrontBraking<=0&&(this.maxFrontBraking=0),this.maxReversePower<=0&&(this.maxReversePower=.5),this.lowSpeedSteering<=0&&(this.lowSpeedSteering=.1),this.highSpeedSteering<=0&&(this.highSpeedSteering=1),this.lowGearCoefficient<=0&&(this.lowGearCoefficient=1),this.lowGearDampener<0&&(this.lowGearDampener=0),this.stationaryBoost<=0&&(this.stationaryBoost=1.1),this.steeringInputCurve<1&&(this.steeringInputCurve=1),this.donutTurningRadius<=0&&(this.donutTurningRadius=5),this.donutSpeedScaling<=0&&(this.donutSpeedScaling=1),this.donutAngularDamping<0&&(this.donutAngularDamping=0),this.donutFrontFriction=BABYLON.Scalar.Clamp(this.donutFrontFriction,.01,5),this.donutRearFriction=BABYLON.Scalar.Clamp(this.donutRearFriction,.01,5),this.donutFrontWheelPull=BABYLON.Scalar.Clamp(this.donutFrontWheelPull,0,1),this.donutRotationBoost<0&&(this.donutRotationBoost=0),this.donutYawDegPerSec<0&&(this.donutYawDegPerSec=0),this.donutYawResponse<0&&(this.donutYawResponse=0),this.donutSlipAngle=BABYLON.Scalar.Clamp(this.donutSlipAngle,0,85),this.donutEntryTime<0&&(this.donutEntryTime=0),this.donutVelocityPinResponse<0&&(this.donutVelocityPinResponse=0),this.topBoosterSpeed<=0&&(this.topBoosterSpeed=150),this.gearBoxMultiplier<=0&&(this.gearBoxMultiplier=1),this.gearBoxPitchScale<=0&&(this.gearBoxPitchScale=1),this.gearBoxShiftDelay<=0&&(this.gearBoxShiftDelay=.35),this.transmissionRatio<=0&&(this.transmissionRatio=1),this.differentialRatio<=0&&(this.differentialRatio=1),this.frictionLerpSpeed<=0&&(this.frictionLerpSpeed=1),this.skidReleaseBrakeFadeTime<0&&(this.skidReleaseBrakeFadeTime=0),this.skidReleaseSnapRatio=BABYLON.Scalar.Clamp(this.skidReleaseSnapRatio,0,.25),this.skidStopFrictionResetSpeed<0&&(this.skidStopFrictionResetSpeed=0),this.skidLaunchFrictionResetSpeed<0&&(this.skidLaunchFrictionResetSpeed=0),this.burnoutStopFrictionResetSpeed<0&&(this.burnoutStopFrictionResetSpeed=0),this.burnoutLaunchFrictionResetSpeed<0&&(this.burnoutLaunchFrictionResetSpeed=0),this.burnoutExitArcadeFadeTime<0&&(this.burnoutExitArcadeFadeTime=0),this.burnoutExitFrictionRampTime<0&&(this.burnoutExitFrictionRampTime=0),this.burnoutExitArcadeReleaseTime<0&&(this.burnoutExitArcadeReleaseTime=0),this.burnoutLerpSpeed<=0&&(this.burnoutLerpSpeed=1),this.skidTurningAssist<=0&&(this.skidTurningAssist=1),this.burnoutTimeDelay<=0&&(this.burnoutTimeDelay=1),this.burnoutWheelPitch<=0&&(this.burnoutWheelPitch=1),this.stationaryBurnoutSkidPitch=BABYLON.Scalar.Clamp(this.stationaryBurnoutSkidPitch,.5,5),this.burnoutPeelAwaySkidPitch=BABYLON.Scalar.Clamp(this.burnoutPeelAwaySkidPitch,.5,5),this.burnoutPeelAwayPitchRampTime<0&&(this.burnoutPeelAwayPitchRampTime=0),null==this.burnoutLaunchChirpSound&&(this.burnoutLaunchChirpSound=""),this.burnoutTriggerMark<=0&&(this.burnoutTriggerMark=20),this.stationaryBurnoutPrimeSpeedMph<0&&(this.stationaryBurnoutPrimeSpeedMph=0),this.stationaryBurnoutPrimeHoldTime<0&&(this.stationaryBurnoutPrimeHoldTime=0),this.stationaryBurnoutPrimeReleaseSpeedMph<this.stationaryBurnoutPrimeSpeedMph&&(this.stationaryBurnoutPrimeReleaseSpeedMph=this.stationaryBurnoutPrimeSpeedMph),this.stationaryBurnoutRevMinRpmOffset<0&&(this.stationaryBurnoutRevMinRpmOffset=0),this.stationaryBurnoutRevMaxFactor=BABYLON.Scalar.Clamp(this.stationaryBurnoutRevMaxFactor,.1,1),this.stationaryBurnoutRevLerpSpeed<=0&&(this.stationaryBurnoutRevLerpSpeed=1),this.burnoutLaunchRpmCarryTime<0&&(this.burnoutLaunchRpmCarryTime=0),this.burnoutLaunchRpmCarryFloorFactor=BABYLON.Scalar.Clamp(this.burnoutLaunchRpmCarryFloorFactor,.1,1),this.normalLaunchTractionRamp<0&&(this.normalLaunchTractionRamp=0),this.normalLaunchTractionMin=BABYLON.Scalar.Clamp(this.normalLaunchTractionMin,.05,1),this.burnoutLaunchKickDuration<0&&(this.burnoutLaunchKickDuration=0),this.burnoutLaunchKickMultiplier<1&&(this.burnoutLaunchKickMultiplier=1),this.burnoutLaunchFrictionRestore<.1&&(this.burnoutLaunchFrictionRestore=.1),this.counterSteerLockoutWindowPercent=BABYLON.Scalar.Clamp(this.counterSteerLockoutWindowPercent,0,1),this.counterSteerLockoutDeadzone=BABYLON.Scalar.Clamp(this.counterSteerLockoutDeadzone,0,.5),this.powerCoefficient<=0&&(this.powerCoefficient=1),this.powerCoefficient>3&&(this.powerCoefficient=3),this.topEngineSpeed<=0&&(this.topEngineSpeed=100),this.topEngineSpeed>300&&(this.topEngineSpeed=300),this.minBoosterSpeed<=0&&(this.minBoosterSpeed=0),this.maxBoosterTime<=0&&(this.maxBoosterTime=0),this.setBoosterTime(this.maxBoosterTime),this.throttleRPM=this.MIN_RPM;var e=this.getProperty("chassisTransform");null!=e&&null!=e.name&&""!==e.name&&(this.chassisTransform=this.getChildNode(e.name,n.SearchType.IndexOf,!1));var t=this.getProperty("boosterTransform");null!=t&&null!=t.name&&""!==t.name&&(this.boosterTransform=this.getChildNode(t.name,n.SearchType.IndexOf,!1),null!=this.boosterTransform&&(this._nosAudioSource=n.SceneManager.FindScriptComponent(this.boosterTransform,"TOOLKIT.AudioSource")));var i=this.getProperty("steeringWheelHub");null!=i&&null!=i.name&&""!==i.name&&(this.steeringWheelHub=this.getChildNode(i.name,n.SearchType.IndexOf,!1));var r=this.getProperty("angularDampener");null!=r&&(this.m_angularDampener=n.Utilities.ParseVector3(r));var o=this.getProperty("smokeTexture");null!=o&&(this.smokeTexture=n.Utilities.ParseTexture(o,this.scene));var a=this.getProperty("engineTorque");null!=a&&null!=a.animation&&(this.engineTorqueCurve=BABYLON.Animation.Parse(a.animation)),null==this.engineTorqueCurve&&n.SceneManager.LogWarning("Failed to parse engine torque curve for: "+this.transform.name)},i.prototype.initVehicleState=function(){if(n.Utilities.ValidateTransformQuaternion(this.transform),!0===this.linkTrackManager&&e.RaceTrackManager.RegisterVehicle(this.transform),this._animator=this.getComponent("TOOLKIT.AnimationState"),null==this._animator){var t=this.getChildWithScript("TOOLKIT.AnimationState");null!=t&&(this._animator=n.SceneManager.FindScriptComponent(t,"TOOLKIT.AnimationState"))}if(this._engineAudioSource=this.getComponent("TOOLKIT.AudioSource"),null==this._engineAudioSource&&n.SceneManager.LogWarning("No engine audio source manager found for: "+this.transform.name),this._rigidbody=this.getComponent("TOOLKIT.RigidbodyPhysics"),null!=this._rigidbody)if(this.raycastVehicle=n.RaycastVehicle.GetInstance(this.scene,this._rigidbody),null!=this.transform.physicsBody&&null!=this._rigidbody&&null!=this.raycastVehicle){this.linearDamping=this.transform.physicsBody.getLinearDamping(),this.angularDamping=this.transform.physicsBody.getAngularDamping(),this.transform.physicsBody.setGravityFactor(this.gravitationalForce);var i=null!=this.brakeLightsTrans&&null!=this.brakeLightsTrans.name&&""!==this.brakeLightsTrans.name?this.brakeLightsTrans.name:null,r=null!=this.reverseLightsTrans&&null!=this.reverseLightsTrans.name&&""!==this.reverseLightsTrans.name?this.reverseLightsTrans.name:null,o=null!=this.frontLeftWheelTrans&&null!=this.frontLeftWheelTrans.name&&""!==this.frontLeftWheelTrans.name?this.frontLeftWheelTrans.name:null,a=null!=this.frontRightWheelTrans&&null!=this.frontRightWheelTrans.name&&""!==this.frontRightWheelTrans.name?this.frontRightWheelTrans.name:null,s=null!=this.backLeftWheelTrans&&null!=this.backLeftWheelTrans.name&&""!==this.backLeftWheelTrans.name?this.backLeftWheelTrans.name:null,l=null!=this.backRightWheelTrans&&null!=this.backRightWheelTrans.name&&""!==this.backRightWheelTrans.name?this.backRightWheelTrans.name:null,u=null!=this.frontLeftWheelCollider&&null!=this.frontLeftWheelCollider.name&&""!==this.frontLeftWheelCollider.name?this.frontLeftWheelCollider.name:null,h=null!=this.frontRightWheelCollider&&null!=this.frontRightWheelCollider.name&&""!==this.frontRightWheelCollider.name?this.frontRightWheelCollider.name:null,c=null!=this.backLeftWheelCollider&&null!=this.backLeftWheelCollider.name&&""!==this.backLeftWheelCollider.name?this.backLeftWheelCollider.name:null,d=null!=this.backRightWheelCollider&&null!=this.backRightWheelCollider.name&&""!==this.backRightWheelCollider.name?this.backRightWheelCollider.name:null;null!=u&&(this.FRONT_LEFT=this.raycastVehicle.getWheelIndexByName(u)),null!=h&&(this.FRONT_RIGHT=this.raycastVehicle.getWheelIndexByName(h)),null!=c&&(this.BACK_LEFT=this.raycastVehicle.getWheelIndexByName(c)),null!=d&&(this.BACK_RIGHT=this.raycastVehicle.getWheelIndexByName(d)),null!=i&&(this.brakeLightsMesh=this.getChildNode(i,n.SearchType.IndexOf,!1),null!=this.brakeLightsMesh&&(this.brakeLightsMesh.isVisible=!1)),null!=r&&(this.reverseLightsMesh=this.getChildNode(r,n.SearchType.IndexOf,!1),null!=this.reverseLightsMesh&&(this.reverseLightsMesh.isVisible=!1)),this.raycastVehicle.getNumWheels()>=4?(this.BACK_LEFT>=0&&null!=s&&(this.m_backLeftWheel=this.raycastVehicle.getWheelInfo(this.BACK_LEFT),this.backLeftWheelMesh=this.getChildNode(s,n.SearchType.IndexOf,!1),null!=this.backLeftWheelMesh&&(this.m_backLeftWheel.spinner=n.SceneManager.FindChildTransformNode(this.backLeftWheelMesh,"Wheel",n.SearchType.IndexOf,!0),this.raycastVehicle.setWheelTransformMesh(this.BACK_LEFT,this.backLeftWheelMesh),this.backLeftWheelEmitter=new BABYLON.Mesh("Emitter_RL"),this.backLeftWheelEmitter.parent=this.m_backLeftWheel.spinner||this.backLeftWheelMesh,this.backLeftWheelEmitter.position=new BABYLON.Vector3(0,0,0),this.backLeftWheelParticle=this.createSmokeParticleSystem(this.transform.name+"Smoke_RL",this.backLeftWheelEmitter),0!==this.wheelDriveType&&2!==this.wheelDriveType||this.wheelRadius<=0&&null!=this.m_backLeftWheel&&(this.wheelRadius=this.m_backLeftWheel.wheelRadius))),this.BACK_RIGHT>=0&&null!=l&&(this.m_backRightWheel=this.raycastVehicle.getWheelInfo(this.BACK_RIGHT),this.backRightWheelMesh=this.getChildNode(l,n.SearchType.IndexOf,!1),null!=this.backRightWheelMesh&&(this.m_backRightWheel.spinner=n.SceneManager.FindChildTransformNode(this.backRightWheelMesh,"Wheel",n.SearchType.IndexOf,!0),this.raycastVehicle.setWheelTransformMesh(this.BACK_RIGHT,this.backRightWheelMesh),this.backRightWheelEmitter=new BABYLON.Mesh("Emitter_RR"),this.backRightWheelEmitter.parent=this.m_backRightWheel.spinner||this.backRightWheelMesh,this.backRightWheelEmitter.position=new BABYLON.Vector3(0,0,0),this.backRightWheelParticle=this.createSmokeParticleSystem(this.transform.name+"Smoke_RR",this.backRightWheelEmitter),0!==this.wheelDriveType&&2!==this.wheelDriveType||this.wheelRadius<=0&&null!=this.m_backRightWheel&&(this.wheelRadius=this.m_backRightWheel.wheelRadius))),this.FRONT_LEFT>=0&&null!=o&&(this.m_frontLeftWheel=this.raycastVehicle.getWheelInfo(this.FRONT_LEFT),this.frontLeftWheelMesh=this.getChildNode(o,n.SearchType.IndexOf,!1),null!=this.frontLeftWheelMesh&&(this.m_frontLeftWheel.spinner=n.SceneManager.FindChildTransformNode(this.frontLeftWheelMesh,"Wheel",n.SearchType.IndexOf,!0),this.raycastVehicle.setWheelTransformMesh(this.FRONT_LEFT,this.frontLeftWheelMesh),this.frontLeftWheelEmitter=new BABYLON.Mesh("Emitter_FL"),this.frontLeftWheelEmitter.parent=this.m_frontLeftWheel.spinner||this.frontLeftWheelMesh,this.frontLeftWheelEmitter.position=new BABYLON.Vector3(0,0,0),this.frontLeftWheelParticle=this.createSmokeParticleSystem(this.transform.name+"Smoke_FL",this.frontLeftWheelEmitter),1!==this.wheelDriveType&&2!==this.wheelDriveType||this.wheelRadius<=0&&null!=this.m_frontLeftWheel&&(this.wheelRadius=this.m_frontLeftWheel.wheelRadius))),this.FRONT_RIGHT>=0&&null!=a&&(this.m_frontRightWheel=this.raycastVehicle.getWheelInfo(this.FRONT_RIGHT),this.frontRightWheelMesh=this.getChildNode(a,n.SearchType.IndexOf,!1),null!=this.frontRightWheelMesh&&(this.m_frontRightWheel.spinner=n.SceneManager.FindChildTransformNode(this.frontRightWheelMesh,"Wheel",n.SearchType.IndexOf,!0),this.raycastVehicle.setWheelTransformMesh(this.FRONT_RIGHT,this.frontRightWheelMesh),this.frontRightWheelEmitter=new BABYLON.Mesh("Emitter_FR"),this.frontRightWheelEmitter.parent=this.m_frontRightWheel.spinner||this.frontRightWheelMesh,this.frontRightWheelEmitter.position=new BABYLON.Vector3(0,0,0),this.frontRightWheelParticle=this.createSmokeParticleSystem(this.transform.name+"Smoke_FR",this.frontRightWheelEmitter),1!==this.wheelDriveType&&2!==this.wheelDriveType||this.wheelRadius<=0&&null!=this.m_frontRightWheel&&(this.wheelRadius=this.m_frontRightWheel.wheelRadius))),this.raycastVehicle.setEnableMultiRaycast(!0),this.raycastVehicle.setMinimumWheelContacts(4),this.raycastVehicle.setTrackConnectionAccel(this.roadConnectAccel),this.raycastVehicle.setSmoothFlyingImpulse(this.smoothFlyingImpulse),this.raycastVehicle.setDownforceCoefficient(this.stableDownImpulse),this.raycastVehicle.setConstantDownforce(this.constImpulseForce),this.raycastVehicle.setAngularDampingControl(this.m_angularDampener),this.raycastVehicle.setArcadeSteeringAssist(this.skidTurningAssist),this.raycastVehicle.setMaximumYawRateLow(this.maximumYawRateLow),this.raycastVehicle.setMaximumYawRateHigh(this.maximumYawRateHigh),this.raycastVehicle.setArcadeBurnoutDirectionChangeSpeed(this.burnoutTriggerMark),null==this._skidAudioSource&&null!=this.backRightWheelMesh&&(this._skidAudioSource=n.SceneManager.FindScriptComponent(this.backRightWheelMesh,"TOOLKIT.AudioSource")),null==this._skidAudioSource&&null!=this.backLeftWheelMesh&&(this._skidAudioSource=n.SceneManager.FindScriptComponent(this.backLeftWheelMesh,"TOOLKIT.AudioSource")),null==this._skidAudioSource&&null!=this.frontRightWheelMesh&&(this._skidAudioSource=n.SceneManager.FindScriptComponent(this.frontRightWheelMesh,"TOOLKIT.AudioSource")),null==this._skidAudioSource&&null!=this.frontLeftWheelMesh&&(this._skidAudioSource=n.SceneManager.FindScriptComponent(this.frontLeftWheelMesh,"TOOLKIT.AudioSource")),null==this._skidAudioSource&&n.SceneManager.LogWarning("No skid audio source manager found for: "+this.transform.name)):n.SceneManager.LogWarning("Invalid vehicle controller wheel count info for: "+this.transform.name)}else n.SceneManager.LogWarning("No wheel collider information found for: "+this.transform.name);else n.SceneManager.LogWarning("Failed to get rigidbody component: "+this.transform.name)},i.prototype.updateVehicleState=function(){this.m_linearVelocity=this.transform.absolutePosition.subtract(this.m_lastPosition),this.m_scaledVelocity=this.m_linearVelocity.length()/this.getDeltaSeconds(),this.m_linearVelocity.normalize(),this.m_linearVelocity.scaleInPlace(this.m_scaledVelocity),this.wheelDrawVelocity>0?(this.m_velocityOffset.copyFrom(this.m_linearVelocity),this.m_velocityOffset.scaleInPlace(this.wheelDrawVelocity)):this.m_velocityOffset.set(0,0,0),this.m_lastPosition.copyFrom(this.transform.absolutePosition)},i.prototype.destroyVehicleState=function(){this._rigidbody=null,this._engineAudioSource=null,this._skidAudioSource=null,null!=this.m_frontLeftWheel&&(this.m_frontLeftWheel=null),null!=this.m_frontRightWheel&&(this.m_frontRightWheel=null),null!=this.m_backLeftWheel&&(this.m_backLeftWheel=null),null!=this.m_backRightWheel&&(this.m_backRightWheel=null),this.m_physicsWorld=null,this.raycastVehicle=null,this.frontLeftWheelMesh=null,this.frontRightWheelMesh=null,this.backLeftWheelMesh=null,this.backRightWheelMesh=null,this.frontLeftWheelTrans=null,this.frontRightWheelTrans=null,this.backLeftWheelTrans=null,this.backRightWheelTrans=null,this.frontLeftWheelCollider=null,this.frontRightWheelCollider=null,this.backLeftWheelCollider=null,this.backRightWheelCollider=null},i.prototype.drive=function(t,i,n,r,o,a,s,l){void 0===o&&(o=0),void 0===a&&(a=!1),void 0===s&&(s=!1),void 0===l&&(l=!1);var u=this.getDeltaSeconds(),h=this._burnoutExitFrictionRampTimer>0;this._burnoutExitArcadeFadeTimer>0&&(this._burnoutExitArcadeFadeTimer-=u,this._burnoutExitArcadeFadeTimer<0&&(this._burnoutExitArcadeFadeTimer=0)),this._burnoutExitFrictionRampTimer>0&&(this._burnoutExitFrictionRampTimer-=u,this._burnoutExitFrictionRampTimer<0&&(this._burnoutExitFrictionRampTimer=0)),this._burnoutExitArcadeReleaseTimer>0&&(this._burnoutExitArcadeReleaseTimer-=u,this._burnoutExitArcadeReleaseTimer<0&&(this._burnoutExitArcadeReleaseTimer=0)),this.currentForward=BABYLON.Scalar.Clamp(t,-1,1),this.currentTurning=BABYLON.Scalar.Clamp(i,-1,1),this.currentSkidding=n,this.burnoutButton=r,this.donutButton=l,this.updateBurnoutLowGearClimbState(),this.currentBoosting=!0===s&&!0===this.powerBooster&&!1===this.wheelBurnout&&this.boostSpeedTimer>0&&this.americanSpeed>=this.minBoosterSpeed,this.targetDrivePower=!0===this.currentBoosting?this.boosterCoefficient:this.powerCoefficient+o,this.gearIndex<=1&&this.lowGearCoefficient>0&&!1===this.isBurnoutLowGearClimbActive()&&(this.targetDrivePower*=this.lowGearCoefficient),!0===this.isBurnoutLowGearClimbActive()&&!0===this._burnoutLowGearClimbStationary&&this.stationaryBoost>0&&(this.targetDrivePower*=this.stationaryBoost),this.currentDrivePower=BABYLON.Scalar.Lerp(this.currentDrivePower,this.targetDrivePower,this.powerChangeRate*u),this.currentPitchScale=this.gearBoxPitchScale,this.footBraking=(this.currentForward<0&&this.forwardSpeed>e.StandardCarController.DEFAULT_BRAKE_DEADZONE||this.currentForward>0&&this.forwardSpeed<-e.StandardCarController.DEFAULT_BRAKE_DEADZONE)&&!1===this.allowRollingReverseBurnout()&&!1===this.burnoutButton;var c=!0===this.getCurrentSkidding()&&this.handBrakingForce>0,d=this.americanSpeed<=this.stationaryBurnoutPrimeSpeedMph,m=this._stationaryBurnoutPrimed;!0===d?(this._stationaryBurnoutPrimeTimer+=u,this._stationaryBurnoutPrimeTimer>=this.stationaryBurnoutPrimeHoldTime&&(this._stationaryBurnoutPrimed=!0)):(this._stationaryBurnoutPrimeTimer=0,this.americanSpeed>this.stationaryBurnoutPrimeReleaseSpeedMph&&(this._stationaryBurnoutPrimed=!1)),!0===this.debugBurnout&&m!==this._stationaryBurnoutPrimed&&console.log("[BURNOUT] PRIMED "+(this._stationaryBurnoutPrimed?"SET":"CLEAR")+" | mph="+this.americanSpeed.toFixed(2)+" | wheelBurnout="+this.wheelBurnout+" | timer="+this.burnoutTimer.toFixed(3));var p=!0===this.burnoutButton&&!0===c&&Math.abs(this.currentForward)>.9&&this.americanSpeed<=this.burnoutTriggerMark&&!1===this.currentBoosting&&!0===this._stationaryBurnoutPrimed;!0===this.debugBurnout&&p!==this._prevStationaryBurnoutWanted&&console.log("[BURNOUT] STATIONARY-WANTED "+(p?"TRUE":"FALSE")+" | mph="+this.americanSpeed.toFixed(2)+" | btn="+this.burnoutButton+" | hb="+c+" | thr="+this.currentForward.toFixed(2)+" | primed="+this._stationaryBurnoutPrimed+" | wheelBurnout="+this.wheelBurnout+" | startedFromStat="+this._burnoutStartedFromStationary+" | timer="+this.burnoutTimer.toFixed(3)+" | cooldown="+this.cooldownTimer.toFixed(3)),!0===this._prevStationaryBurnoutWanted&&!1===p&&!0===this.wheelBurnout&&!0===this._burnoutStartedFromStationary&&this.currentForward>.9&&!1===this._positionLocked&&!0==(this.americanSpeed<=this.stationaryBurnoutPrimeReleaseSpeedMph&&Math.abs(this.forwardSpeed)<=.5)&&(this._burnoutLaunchKickTimer=this.burnoutLaunchKickDuration,this._burnoutLaunchHoldRpm=Math.max(this.engineRPM,this.actualEngineRPM,this.getIdleRPM()),this._stationaryLaunchSnapActive=!0,this.armBurnoutLaunchAudio(),!0===this.debugLaunch&&console.log("[LAUNCH-KICK] >>> BURNOUT LAUNCH — rpm="+this.engineRPM.toFixed(0)+" kickDur="+this.burnoutLaunchKickDuration.toFixed(2)+" mult="+this.burnoutLaunchKickMultiplier.toFixed(2))),this._prevStationaryBurnoutWanted=p,this._burnoutLaunchKickTimer>0&&(this._burnoutLaunchKickTimer-=u,this._burnoutLaunchKickTimer<0&&(this._burnoutLaunchKickTimer=0)),this._burnoutLaunchRpmCarryTimer>0&&(this._burnoutLaunchRpmCarryTimer-=u,this._burnoutLaunchRpmCarryTimer<0&&(this._burnoutLaunchRpmCarryTimer=0)),this._burnoutPeelAwayPitchRampTimer>0&&(this._burnoutPeelAwayPitchRampTimer-=u,this._burnoutPeelAwayPitchRampTimer<0&&(this._burnoutPeelAwayPitchRampTimer=0)),this._burnoutLaunchKickTimer<=0&&this._burnoutLaunchRpmCarryTimer<=0&&0!==this._burnoutLaunchHoldRpm&&(this._burnoutLaunchHoldRpm=0),this._burnoutLaunchKickTimer<=0&&(this._stationaryLaunchSnapActive=!1),!0===c&&!1===this._prevHandBrakeRequested&&(this.handBrakingHoldTimer=this.defaultBrakingWindow,this._handBrakeEntrySteerSign=Math.abs(this.currentTurning)>=this.counterSteerLockoutDeadzone?Math.sign(this.currentTurning):0),this._prevHandBrakeRequested=c,this.handBrakingHoldTimer>0&&(this.handBrakingHoldTimer-=u);var f=!0===p,g=this.handBraking;if(!0===f?(this.handBrakingHoldTimer=0,this.handBraking=c):this.handBraking=!0===c||this.handBrakingHoldTimer>0,!0===g&&!1===this.handBraking&&!1===f&&(this._skidReleaseBrakeTimer=this.skidReleaseBrakeFadeTime,this._skidFrictionRestorePending=!0),!0===this.handBraking&&(this._skidReleaseBrakeTimer=0),this._skidReleaseBrakeTimer>0&&(this._skidReleaseBrakeTimer-=u,this._skidReleaseBrakeTimer<0&&(this._skidReleaseBrakeTimer=0)),this.resetSkidFrictionForStopOrLaunch(),!0===this.handBraking?this.handBrakingTimer+=u:(this.handBrakingTimer=0,this._handBrakeEntrySteerSign=0),null!=this._rigidbody&&null!=this.raycastVehicle){if(this.FRONT_LEFT>=0&&this.FRONT_RIGHT>=0&&this.BACK_LEFT>=0&&this.BACK_RIGHT>=0){var y=this.wheelBurnout,v=this._prevWheelBurnoutState,S=this.restoreTimer>0;this.engineForce=0,this.wheelBrakingForce=0,this.frontWheelPower=0,this.backWheelPower=0;var _=this.americanSpeed<=this.burnoutTriggerMark,b=this.currentForward<-.9||this.currentForward>.9,B=this.currentTurning<-.9||this.currentTurning>.9,C=this.throttleEngineSpeed>0?this.throttleEngineSpeed:this.getTopEngineSpeed();if((this._burnoutLaunchKickTimer>0||this._burnoutLaunchRpmCarryTimer>0)&&!0===this.wheelBurnout&&!1===this.wheelDonuts&&Math.abs(this.currentForward)>.9&&this._burnoutLaunchHoldRpm>this.getIdleRPM()){var A=this.getBurnoutLaunchRpmCarryFloor();this.engineRPM<A&&(this.engineRPM=A),this.actualEngineRPM<A&&(this.actualEngineRPM=A)}var T=null!=this.gearBoxShiftRatios&&this.gearBoxShiftRatios.length>this.gearIndex?this.gearBoxShiftRatios[this.gearIndex]:1;0===this.gearIndex&&!0===this.wheelBurnout&&(T*=this.burnoutFirstGearMultiplier);var M=T*this.differentialRatio*this.transmissionRatio,L=this.getVehicleEngineTorque(this.engineRPM,this.currentDrivePower)*Math.abs(this.currentForward)*M;if(this.currentForward>0){if(this.engineForce=L,!1===this.wheelBurnout&&this._burnoutLaunchKickTimer<=0&&0===this.gearIndex&&this.normalLaunchTractionRamp>0&&this.americanSpeed<this.normalLaunchTractionRamp){var P=BABYLON.Scalar.Clamp(this.americanSpeed/this.normalLaunchTractionRamp,0,1),w=BABYLON.Scalar.Lerp(this.normalLaunchTractionMin,1,P);this.engineForce*=w}this.wheelBrakingForce=0}else if(this.currentForward<0){var x=this.forwardSpeed<-.5;this.engineForce=x?-L*this.maxReversePower:-L,this.wheelBrakingForce=0}else this.engineForce=0,this.wheelBrakingForce=this.americanSpeed<10?50:0;!1===this.currentBoosting&&this.americanSpeed>this.topEngineSpeed&&(this.engineForce=0,this.wheelBrakingForce=100);var O=0;(this.shiftingTime>0||this.americanSpeed>C)&&(O=this.shiftingBrake,this.engineForce=0),!0===this.footBraking&&(this.wheelBrakingForce=BABYLON.Scalar.Lerp(this.minBrakingForce,this.maxFrontBraking,this.americanSpeed/this.topEngineSpeed)),this.processAckermanSteering(u,a,0,0,0);var R=2*Math.abs(this.currentTurning);this.currentTurning>0?R=BABYLON.Scalar.Clamp(R,0,1):this.currentTurning<0&&(R=-BABYLON.Scalar.Clamp(R,0,1));var I=this.overSteerSpeed>0&&!0===this.handBraking&&this.handBrakingTimer>this.overSteerTimeout?R:-R;if(this.animatorSteerAngle=BABYLON.Scalar.Lerp(this.animatorSteerAngle,I,this.maxSteeringSpeed*u),null!=this.steeringWheelHub){null==this.steeringWheelHub.rotationQuaternion&&(this.steeringWheelHub.rotationQuaternion=BABYLON.Quaternion.FromEulerVector(this.steeringWheelHub.rotation));var N=this.animatorSteerAngle*this.maxSteeringAngle,k=BABYLON.Tools.ToRadians(N),F=0===this.steeringWheelAxis?k:0,D=1===this.steeringWheelAxis?k:0,E=2===this.steeringWheelAxis?k:0;BABYLON.Quaternion.SlerpToRef(this.steeringWheelHub.rotationQuaternion,BABYLON.Quaternion.FromEulerAngles(F,D,E),this.maxSteeringSpeed*u,this.steeringWheelHub.rotationQuaternion)}null!=this._animator&&this._animator.setFloat("TurnAngle",this.animatorSteerAngle);var V=!0,Y=u*this.frictionLerpSpeed,U=0;if(!0===this.handBraking&&!1===p){!0!==this.debugBurnout||!0!==this.wheelBurnout&&!0!==this.wheelDonuts||console.log("[BURNOUT] <<< EXIT (HANDBRAKE-OVERRIDE) | wasBurnout="+this.wheelBurnout+" | wasDonut="+this.wheelDonuts+" | mph="+this.americanSpeed.toFixed(2)+" | timer="+this.burnoutTimer.toFixed(3)+" | elapsed="+this.burnoutElapsed.toFixed(3));var W=!0===this.wheelBurnout||!0===this.wheelDonuts||this.burnoutTimer>0||this.restoreTimer>0;this.wheelBurnout=!1,this._burnoutStartedFromStationary=!1,this._stationaryLaunchSnapActive=!1,!0===W&&this.armBurnoutExitSmoothing(!0),this.wheelDonuts=!1,this.burnoutTimer=0,this.cooldownTimer=0,null==this.raycastVehicle.lockedWheelIndexes&&(this.raycastVehicle.lockedWheelIndexes=[this.BACK_LEFT,this.BACK_RIGHT]),this.americanSpeed>=5&&!1===this.wheelSkidding&&(this.wheelSkidding=!0,this._skidFrictionRestorePending=!0,null!=this.m_frontLeftWheel&&(this.m_frontLeftWheel.frictionSlip=this.frontSkidFriction),null!=this.m_frontRightWheel&&(this.m_frontRightWheel.frictionSlip=this.frontSkidFriction),null!=this.m_backLeftWheel&&(this.m_backLeftWheel.frictionSlip=this.rearSkidFriction),null!=this.m_backRightWheel&&(this.m_backRightWheel.frictionSlip=this.rearSkidFriction),this.frontLeftFrictionPenalty=!1,this.frontRightFrictionPenalty=!1,this.rearLeftFrictionPenalty=!1,this.rearRightFrictionPenalty=!1,V=!1),this.updateCurrentBrakeDamping(this.linearBrakingForce,this.angularBrakingForce),!0===V&&this.updateCurrentFrictionSlip(Y),this.updateCurrentRotationDelta(0),this.updateCurrentRotationBoost(0),this.raycastVehicle.setVisualSteeringAngle(this.visualSteerAngleL,this.FRONT_LEFT),this.raycastVehicle.setVisualSteeringAngle(this.visualSteerAngleR,this.FRONT_RIGHT),this.raycastVehicle.setPhysicsSteeringAngle(this.physicsSteerAngleL,this.FRONT_LEFT),this.raycastVehicle.setPhysicsSteeringAngle(this.physicsSteerAngleR,this.FRONT_RIGHT),this.raycastVehicle.setEngineForce(0,this.FRONT_LEFT),this.raycastVehicle.setEngineForce(0,this.FRONT_RIGHT),this.raycastVehicle.setEngineForce(0,this.BACK_LEFT),this.raycastVehicle.setEngineForce(0,this.BACK_RIGHT),this.raycastVehicle.setBrakingForce(0,this.FRONT_LEFT),this.raycastVehicle.setBrakingForce(0,this.FRONT_RIGHT),this.raycastVehicle.setBrakingForce(this.handBrakingForce,this.BACK_LEFT),this.raycastVehicle.setBrakingForce(this.handBrakingForce,this.BACK_RIGHT)}else{null!=this.raycastVehicle.lockedWheelIndexes&&(this.raycastVehicle.lockedWheelIndexes=null,this.updateCurrentRotationDelta(0),this.updateCurrentRotationBoost(0)),this.wheelSkidding=this._skidReleaseBrakeTimer>0,this.burnoutCoefficient=BABYLON.Scalar.Clamp(this.burnoutCoefficient,1,10),this.burnoutTriggerMark=BABYLON.Scalar.Clamp(this.burnoutTriggerMark,1,40);var G=this.currentForward>=.9?1:this.currentForward<=-.9?-1:0,H=!0===this.burnoutButton&&!1===this._prevBurnoutButton,z=0!==this._burnoutLatchedDriveSign&&0!==G&&G!==this._burnoutLatchedDriveSign;if(!0===p&&(this.cooldownTimer=0),(H||z)&&!0===this.burnoutButton&&!0===b&&!0===_&&(this.cooldownTimer=0),(!0===this.enableAutoBurnouts||!0===p)&&!0===this.burnoutButton&&this.burnoutTimer<=0&&this.cooldownTimer<=0&&!0===b&&!0===_&&(this.burnoutTimer=this.burnoutTimeDelay,this.burnoutElapsed=0,this.wheelDonuts=!1,this.wheelBurnout=!0,this._burnoutLatchedDriveSign=G,this._burnoutStartedFromStationary=!0===p&&this.americanSpeed<=this.stationaryBurnoutPrimeSpeedMph,this.armBurnoutLowGearClimb(this._burnoutStartedFromStationary),!0===this.debugBurnout)){var K=!0===p?"STATIONARY-WANTED":"AUTO";console.log("[BURNOUT] >>> ENTER ("+K+") | startedFromStat="+this._burnoutStartedFromStationary+" | mph="+this.americanSpeed.toFixed(2)+" | thr="+this.currentForward.toFixed(2)+" | turn="+this.currentTurning.toFixed(2)+" | btn="+this.burnoutButton+" | primed="+this._stationaryBurnoutPrimed+" | timer="+this.burnoutTimer.toFixed(3)+" | cooldown="+this.cooldownTimer.toFixed(3)+" | restore="+this.restoreTimer.toFixed(3))}if(this.restoreTimer>0){if(this.restoreTimer-=u,this.restoreTimer<0&&(this.restoreTimer=0),Y*=this.burnoutLerpSpeed,this.restoreTimerDuration>0&&this.burnoutCoefficient>1){var X=this.restoreTimer/this.restoreTimerDuration,Q=BABYLON.Scalar.Lerp(1,this.burnoutCoefficient,X);this.engineForce*=Q}}else this._burnoutExitFrictionRampTimer>0&&this.burnoutExitFrictionRampTime>0&&(P=1-BABYLON.Scalar.Clamp(this._burnoutExitFrictionRampTimer/this.burnoutExitFrictionRampTime,0,1),Y*=BABYLON.Scalar.Lerp(this.burnoutLerpSpeed,1,P));if(this.cooldownTimer>0&&(this.cooldownTimer-=u,this.cooldownTimer<0&&(this.cooldownTimer=0)),!0===this.wheelDonuts){this.donutSpinTime+=u;var j=this.donutEntryTime>0?BABYLON.Scalar.Clamp(this.donutSpinTime/this.donutEntryTime,0,1):1;this._donutEntryBlend=j*j*(3-2*j),!1===B&&(this.burnoutTimer=0)}else this.donutSpinTime=0,this._donutEntryBlend=0;if(this.burnoutTimer>0&&!0===b){if(!1===this.burnoutButton&&(!0===this.debugBurnout&&console.log("[BURNOUT] <<< EXIT (EARLY-RELEASE button=false) | mph="+this.americanSpeed.toFixed(2)+" | thr="+this.currentForward.toFixed(2)+" | elapsed="+this.burnoutElapsed.toFixed(3)+" | restore="+(.25*this.burnoutTimeDelay).toFixed(3)+" | startedFromStat="+this._burnoutStartedFromStationary),this.wheelBurnout=!1,this._burnoutStartedFromStationary=!1,this._stationaryLaunchSnapActive=!1,this.burnoutTimer=0,this.restoreTimer=.25*this.burnoutTimeDelay,this.restoreTimerDuration=this.restoreTimer,this.armBurnoutExitSmoothing(!1),this.cooldownTimer=this.restoreTimer),U=.2,!0===p&&!1===this.wheelDonuts&&(U=2.5),!0===this.wheelDonuts&&(U=Math.max(U,this.donutRotationBoost)),!0===this.wheelDonuts){if(this._donutEngineScale=this.donutSpeedScaling,this.engineForce*=this._donutEngineScale,!0===this.donutVelocityPinEnabled&&null!=this.transform&&null!=this.transform.physicsBody){var Z=this.transform.physicsBody.getLinearVelocity();if(null!=Z&&null!=this.transform.forward&&null!=this.transform.right&&null!=this.transform.up){var J=this.transform.forward,q=this.transform.right,$=BABYLON.Vector3.Dot(Z,J),ee=BABYLON.Vector3.Dot(Z,q),te=Math.abs(BABYLON.Tools.ToRadians(this.donutYawDegPerSec)),ie=this.donutTurningRadius*te,ne=this.transform.physicsBody.getAngularVelocity(),re=null!=ne&&null!=this.transform.up?Math.abs(BABYLON.Vector3.Dot(ne,this.transform.up)):0,oe=te>1e-4?BABYLON.Scalar.Clamp(re/te,0,1):0,ae=BABYLON.Scalar.Lerp(this._donutEntrySpeedMps,ie,oe),se=BABYLON.Tools.ToRadians(this.donutSlipAngle)*oe,le=0;if(null!=ne){var ue=BABYLON.Vector3.Cross(Z,ne),he=BABYLON.Vector3.Dot(q,ue);Math.abs(he)>.001&&(le=Math.sign(he))}var ce=ae*Math.cos(se),de=ae*Math.sin(se)*le,me=BABYLON.Scalar.Clamp(u*this.donutVelocityPinResponse,0,1),pe=BABYLON.Scalar.Lerp($,ce,me),fe=BABYLON.Scalar.Lerp(ee,de,me),ge=J.x*pe+q.x*fe,ye=J.z*pe+q.z*fe;this.transform.physicsBody.setLinearVelocity(new BABYLON.Vector3(ge,Z.y,ye))}}}else this.burnoutCoefficient>=1&&(this._donutEngineScale=this.donutSpeedScaling,this.engineForce*=this.burnoutCoefficient);1!==this.wheelDriveType&&2!==this.wheelDriveType||(null!=this.m_frontLeftWheel&&(this.m_frontLeftWheel.frictionSlip=1),null!=this.m_frontRightWheel&&(this.m_frontRightWheel.frictionSlip=1),this.frontLeftFrictionPenalty=!1,this.frontRightFrictionPenalty=!1),0!==this.wheelDriveType&&2!==this.wheelDriveType||(null!=this.m_backLeftWheel&&(this.m_backLeftWheel.frictionSlip=1),null!=this.m_backRightWheel&&(this.m_backRightWheel.frictionSlip=1),this.rearLeftFrictionPenalty=!1,this.rearRightFrictionPenalty=!1),!0===this.wheelDonuts&&(null!=this.m_frontLeftWheel&&(this.m_frontLeftWheel.frictionSlip=this.donutFrontFriction),null!=this.m_frontRightWheel&&(this.m_frontRightWheel.frictionSlip=this.donutFrontFriction),null!=this.m_backLeftWheel&&(this.m_backLeftWheel.frictionSlip=this.donutRearFriction),null!=this.m_backRightWheel&&(this.m_backRightWheel.frictionSlip=this.donutRearFriction),this.frontLeftFrictionPenalty=!1,this.frontRightFrictionPenalty=!1,this.rearLeftFrictionPenalty=!1,this.rearRightFrictionPenalty=!1),V=!1,this.burnoutElapsed+=u,this.burnoutTimer-=u;var ve=!0===this.donutButton&&!0===this.wheelBurnout&&!0===_&&this.currentForward>0,Se=!0===this.donutButton&&!0===this.wheelBurnout&&this.currentForward>0,_e=!0===this.wheelDonuts?Se:ve;if(_e&&!1===this.wheelDonuts?(this.wheelDonuts=!0,this._donutEntrySpeedMps=this.absoluteSpeed/3.6,this.burnoutTimer=Math.max(this.burnoutTimer,this.burnoutTimeDelay)):_e&&!0===this.wheelDonuts?this.burnoutTimer=Math.max(this.burnoutTimer,.5*this.burnoutTimeDelay):_e||!0!==this.wheelDonuts||(this.wheelDonuts=!1,this.donutSpinTime=0,this.cooldownTimer=2*this.burnoutTimeDelay,this.burnoutTimer=0),!0===p&&!0===this.wheelBurnout&&!1===this.wheelDonuts&&(this.burnoutTimer=Math.max(this.burnoutTimer,.5*this.burnoutTimeDelay)),this.burnoutTimer<=0&&(this.burnoutTimer=0,this.donutSpinTime=0,!0===this.wheelDonuts&&(this.wheelDonuts=!1,this.cooldownTimer=1*this.burnoutTimeDelay),!0===this.wheelBurnout)){if(!0===this.debugBurnout){var be=!0===this.burnoutButton&&!0===b&&!0===B&&!1===this.allowRollingReverseBurnout();console.log("[BURNOUT] <<< EXIT (TIMER-EXPIRED) | mph="+this.americanSpeed.toFixed(2)+" | thr="+this.currentForward.toFixed(2)+" | turn="+this.currentTurning.toFixed(2)+" | btn="+this.burnoutButton+" | elapsed="+this.burnoutElapsed.toFixed(3)+" | restore="+(.5*this.burnoutTimeDelay).toFixed(3)+" | holdingSame="+be+" | extendedCooldown="+(be?(2*this.burnoutTimeDelay).toFixed(3):(.5*this.burnoutTimeDelay).toFixed(3))+" | startedFromStat="+this._burnoutStartedFromStationary+" | primed="+this._stationaryBurnoutPrimed+" | statWanted="+p)}this.wheelBurnout=!1,this._burnoutStartedFromStationary=!1,this._stationaryLaunchSnapActive=!1,this.restoreTimer=.5*this.burnoutTimeDelay,this.restoreTimerDuration=this.restoreTimer,this.armBurnoutExitSmoothing(!1);var Be=!0===this.burnoutButton&&!0===b&&!0===B&&!1===this.allowRollingReverseBurnout();this.cooldownTimer=Be?2*this.burnoutTimeDelay:this.restoreTimer}}else{if(this.americanSpeed>=this.minPenaltySpeed&&this.frictionWheelSlip>0){var Ce=0|this.grassPenaltyMask;if(!1===this.frontLeftFrictionLerping&&this.hasPenaltyContactMask(this.frontLeftContactMask,Ce)&&null!=this.m_frontLeftWheel&&null!=this.m_frontLeftWheel.defaultFriction){var Ae=this.m_frontLeftWheel.defaultFriction*(1.25*this.frictionWheelSlip);this.m_frontLeftWheel.frictionSlip=Ae,this.frontLeftFrictionPenalty=!0,V=!1}if(!1===this.frontRightFrictionLerping&&this.hasPenaltyContactMask(this.frontRightContactMask,Ce)&&null!=this.m_frontRightWheel&&null!=this.m_frontRightWheel.defaultFriction){var Te=this.m_frontRightWheel.defaultFriction*(1.25*this.frictionWheelSlip);this.m_frontRightWheel.frictionSlip=Te,this.frontRightFrictionPenalty=!0,V=!1}if(!1===this.rearLeftFrictionLerping&&this.hasPenaltyContactMask(this.rearLeftContactMask,Ce)&&null!=this.m_backLeftWheel&&null!=this.m_backLeftWheel.defaultFriction){var Me=this.m_backLeftWheel.defaultFriction*this.frictionWheelSlip;this.m_backLeftWheel.frictionSlip=Me,this.rearLeftFrictionPenalty=!0,V=!1}if(!1===this.rearRightFrictionLerping&&this.hasPenaltyContactMask(this.rearRightContactMask,Ce)&&null!=this.m_backRightWheel&&null!=this.m_backRightWheel.defaultFriction){var Le=this.m_backRightWheel.defaultFriction*this.frictionWheelSlip;this.m_backRightWheel.frictionSlip=Le,this.rearRightFrictionPenalty=!0,V=!1}}this.burnoutTimer=0,this.donutSpinTime=0,!0===this.wheelDonuts&&(this.wheelDonuts=!1,this.cooldownTimer=1*this.burnoutTimeDelay),!0===this.wheelBurnout&&(this.wheelBurnout=!1,this._burnoutStartedFromStationary=!1,this._stationaryLaunchSnapActive=!1,this.restoreTimer=.5*this.burnoutTimeDelay,this.restoreTimerDuration=this.restoreTimer,this.armBurnoutExitSmoothing(!1),this.cooldownTimer=this.restoreTimer)}if(this._burnoutLaunchKickTimer>0&&!0===this.wheelBurnout&&!0===this._burnoutStartedFromStationary&&!0===this._stationaryLaunchSnapActive){this.engineForce*=this.burnoutLaunchKickMultiplier;var Pe=this.burnoutLaunchFrictionRestore;null!=this.m_backLeftWheel&&(this.m_backLeftWheel.frictionSlip=Math.max(this.m_backLeftWheel.frictionSlip,Pe)),null!=this.m_backRightWheel&&(this.m_backRightWheel.frictionSlip=Math.max(this.m_backRightWheel.frictionSlip,Pe))}if(!0===this.wheelBurnout&&!0===this.wheelDonuts?this.frontWheelPower=this.engineForce*this.donutFrontWheelPull:1!==this.wheelDriveType&&2!==this.wheelDriveType||(this.frontWheelPower=this.engineForce),0!==this.wheelDriveType&&2!==this.wheelDriveType||(this.backWheelPower=this.engineForce),!0===this.footBraking?this.updateCurrentBrakeDamping(.1*this.linearBrakingForce,.1*this.angularBrakingForce):this.throttleBrakingForce>0?this.updateCurrentBrakeDamping(this.throttleBrakingForce,this.angularDamping):0!==this.engineForce?this.updateCurrentBrakeDamping(O,this.angularDamping):this.updateCurrentBrakeDamping(this.linearDamping,this.angularDamping),!0===V&&this.updateCurrentFrictionSlip(Y),this.updateCurrentRotationBoost(U),this.raycastVehicle.setVisualSteeringAngle(this.visualSteerAngleL,this.FRONT_LEFT),this.raycastVehicle.setVisualSteeringAngle(this.visualSteerAngleR,this.FRONT_RIGHT),this.raycastVehicle.setPhysicsSteeringAngle(this.physicsSteerAngleL,this.FRONT_LEFT),this.raycastVehicle.setPhysicsSteeringAngle(this.physicsSteerAngleR,this.FRONT_RIGHT),!0===p&&!0===this.wheelBurnout){this.raycastVehicle.setEngineForce(this.frontWheelPower,this.FRONT_LEFT),this.raycastVehicle.setEngineForce(this.frontWheelPower,this.FRONT_RIGHT),this.raycastVehicle.setEngineForce(this.backWheelPower,this.BACK_LEFT),this.raycastVehicle.setEngineForce(this.backWheelPower,this.BACK_RIGHT);var we=Math.max(this.handBrakingForce,2*this.maxBrakingForce),xe=2===this.wheelDriveType?.25*we:0;1===this.wheelDriveType?(this.raycastVehicle.setBrakingForce(0,this.FRONT_LEFT),this.raycastVehicle.setBrakingForce(0,this.FRONT_RIGHT),this.raycastVehicle.setBrakingForce(we,this.BACK_LEFT),this.raycastVehicle.setBrakingForce(we,this.BACK_RIGHT)):(this.raycastVehicle.setBrakingForce(we,this.FRONT_LEFT),this.raycastVehicle.setBrakingForce(we,this.FRONT_RIGHT),this.raycastVehicle.setBrakingForce(xe,this.BACK_LEFT),this.raycastVehicle.setBrakingForce(xe,this.BACK_RIGHT))}else if(!0===this.footBraking)this.raycastVehicle.setEngineForce(0,this.FRONT_LEFT),this.raycastVehicle.setEngineForce(0,this.FRONT_RIGHT),this.raycastVehicle.setEngineForce(0,this.BACK_LEFT),this.raycastVehicle.setEngineForce(0,this.BACK_RIGHT),this.maxFrontBraking>0?(this.raycastVehicle.setBrakingForce(this.wheelBrakingForce*this.maxFrontBraking,this.FRONT_LEFT),this.raycastVehicle.setBrakingForce(this.wheelBrakingForce*this.maxFrontBraking,this.FRONT_RIGHT)):(this.raycastVehicle.setBrakingForce(this.wheelBrakingForce,this.FRONT_LEFT),this.raycastVehicle.setBrakingForce(this.wheelBrakingForce,this.FRONT_RIGHT)),this.raycastVehicle.setBrakingForce(this.wheelBrakingForce,this.BACK_LEFT),this.raycastVehicle.setBrakingForce(this.wheelBrakingForce,this.BACK_RIGHT);else{var Oe=this._skidReleaseBrakeTimer>0&&this.skidReleaseBrakeFadeTime>0?this.handBrakingForce*BABYLON.Scalar.Clamp(this._skidReleaseBrakeTimer/this.skidReleaseBrakeFadeTime,0,1):0;this.raycastVehicle.setEngineForce(this.frontWheelPower,this.FRONT_LEFT),this.raycastVehicle.setEngineForce(this.frontWheelPower,this.FRONT_RIGHT),this.raycastVehicle.setEngineForce(this.backWheelPower,this.BACK_LEFT),this.raycastVehicle.setEngineForce(this.backWheelPower,this.BACK_RIGHT),this.raycastVehicle.setBrakingForce(0,this.FRONT_LEFT),this.raycastVehicle.setBrakingForce(0,this.FRONT_RIGHT),this.raycastVehicle.setBrakingForce(Oe,this.BACK_LEFT),this.raycastVehicle.setBrakingForce(Oe,this.BACK_RIGHT)}}!0!==y&&!0!==v||!1!==this.wheelBurnout||this.armBurnoutExitSmoothing(this.restoreTimer<=0),!1===S&&this.restoreTimer>0&&!1===this.wheelBurnout&&this.armBurnoutExitSmoothing(!1),!0===S&&this.restoreTimer<=0&&this.armBurnoutExitSmoothing(!0),!0===h&&this._burnoutExitFrictionRampTimer<=0&&(this._burnoutExitArcadeReleaseTimer=Math.max(this._burnoutExitArcadeReleaseTimer,this.burnoutExitArcadeReleaseTime)),this.resetBurnoutFrictionForStopOrLaunch(),this.raycastVehicle.setSmoothedGradientSpeed(this.smoothedGradientSpeed),this.raycastVehicle.setArcadeFootBrakeActive(this.footBraking);var Re=!0===this.handBraking||this._skidReleaseBrakeTimer>0;this.raycastVehicle.setArcadeHandBrakeActive(Re);var Ie=this._burnoutExitArcadeFadeTimer>0||this._burnoutExitFrictionRampTimer>0||this._burnoutExitArcadeReleaseTimer>0,Ne=!0===this.wheelBurnout||this.restoreTimer>0||Ie;if(this.raycastVehicle.setArcadeBurnoutActive(Ne),this.raycastVehicle.setArcadeDonutActive(this.wheelDonuts),!0===this.wheelDonuts&&this.raycastVehicle.setArcadeDonutDirectYawDegPerSec(this.donutYawDegPerSec*this._donutEntryBlend),!0===this._positionLocked){this.raycastVehicle.setEngineForce(0,this.FRONT_LEFT),this.raycastVehicle.setEngineForce(0,this.FRONT_RIGHT),this.raycastVehicle.setEngineForce(0,this.BACK_LEFT),this.raycastVehicle.setEngineForce(0,this.BACK_RIGHT);var ke=20*this.maxBrakingForce;this.raycastVehicle.setBrakingForce(ke,this.FRONT_LEFT),this.raycastVehicle.setBrakingForce(ke,this.FRONT_RIGHT),this.raycastVehicle.setBrakingForce(ke,this.BACK_LEFT),this.raycastVehicle.setBrakingForce(ke,this.BACK_RIGHT),null!=this._rigidbody&&(this.transform.physicsBody.setLinearVelocity(BABYLON.Vector3.Zero()),this.transform.physicsBody.setAngularVelocity(BABYLON.Vector3.Zero())),null!=this._lockedPosition&&null!=this.transform&&(this.transform.position.copyFrom(this._lockedPosition),null!=this._lockedRotationQuaternion&&null!=this.transform.rotationQuaternion&&this.transform.rotationQuaternion.copyFrom(this._lockedRotationQuaternion))}if(this._prevBurnoutButton=this.burnoutButton,!1===this.burnoutButton&&!1===this.wheelBurnout&&this.burnoutTimer<=0&&this.cooldownTimer<=0&&this.restoreTimer<=0&&(this._burnoutLatchedDriveSign=0),!0===this.debugLaunch){var Fe=this._burnoutLaunchKickTimer>0,De=!0===this.wheelBurnout&&!p&&this.americanSpeed<50&&this.currentForward>.5,Ee=!1===this.wheelBurnout&&!Fe&&0===this.gearIndex&&this.americanSpeed<this.normalLaunchTractionRamp&&this.currentForward>.5;if(Fe||De||Ee){if(this._launchLogCounter++,this._launchLogCounter%Math.max(1,0|this.debugLaunchEveryNFrames)===1){P=this.normalLaunchTractionRamp>0?BABYLON.Scalar.Clamp(this.americanSpeed/this.normalLaunchTractionRamp,0,1):1;var Ve=BABYLON.Scalar.Lerp(this.normalLaunchTractionMin,1,P),Ye=null!=this.m_backLeftWheel?this.m_backLeftWheel.frictionSlip.toFixed(3):"n/a",Ue=null!=this.m_backRightWheel?this.m_backRightWheel.frictionSlip.toFixed(3):"n/a",We=Fe?"KICK":De?"BURNOUT-LAUNCH":"NORMAL-LAUNCH";console.log("[LAUNCH:"+We+"] mph="+this.americanSpeed.toFixed(1)+" | gear="+(this.gearIndex+1)+" | rpm="+this.engineRPM.toFixed(0)+" | actRpm="+this.actualEngineRPM.toFixed(0)+" | engF="+this.engineForce.toFixed(1)+" | kickTmr="+this._burnoutLaunchKickTimer.toFixed(3)+" | holdRpm="+this._burnoutLaunchHoldRpm.toFixed(0)+" | rampFac="+Ve.toFixed(3)+" | rlFric="+Ye+" rrFric="+Ue+" | burnout="+this.wheelBurnout+" | burnBtn="+this.burnoutButton+" | primed="+this._stationaryBurnoutPrimed)}}else this._launchLogCounter=0}this._prevWheelBurnoutState=this.wheelBurnout}this.syncVehicleState(u),this.syncVehicleTilting(u)}},i.prototype.processAckermanSteering=function(e,t,i,r,o){var a=this.smoothedGradientSpeed,s=this.donutTurningRadius,l=BABYLON.Scalar.Lerp(this.ackermanTurnRadius,this.ackermanMaxRadius,a),u=this.currentTurning,h=this.defaultBrakingWindow*this.counterSteerLockoutWindowPercent,c=u;!0==(h>0&&!0===this.handBraking&&this.handBrakingTimer>0&&this.handBrakingTimer<=h&&!1===this.wheelBurnout&&!1===this.wheelDonuts&&Math.abs(this._handBrakeEntrySteerSign)>.5)&&Math.abs(u)>=this.counterSteerLockoutDeadzone&&Math.sign(u)!==this._handBrakeEntrySteerSign&&(c=0);var d=!0===this.wheelBurnout&&!0===this.wheelDonuts,m=!0===t?c:this.steeringInputCurve>1?Math.sign(c)*Math.pow(Math.abs(c),this.steeringInputCurve):c,p=Math.abs(m)>=.02,f=d?s*this.ackermanTurnFactor:l*this.ackermanTurnFactor,g=BABYLON.Scalar.Lerp(this.lowSpeedSteering,this.highSpeedSteering,this.smoothedSteeringSpeed);this.minSteeringSlew>0&&(g=Math.max(g,this.minSteeringSlew));var y=g*e;if(m>0?(this.maxSteerBoost>0&&!0===p&&(o=BABYLON.Tools.ToRadians(this.maxSteerBoost)),i=Math.atan(this.ackermanWheelBase/(f+this.ackermanRearTrack/2))*m,r=Math.atan(this.ackermanWheelBase/(f-this.ackermanRearTrack/2))*m):m<0?(this.maxSteerBoost>0&&!0===p&&(o=-BABYLON.Tools.ToRadians(this.maxSteerBoost)),i=Math.atan(this.ackermanWheelBase/(f-this.ackermanRearTrack/2))*m,r=Math.atan(this.ackermanWheelBase/(f+this.ackermanRearTrack/2))*m):(o=0,i=0,r=0),!0===this.wheelBurnout&&!0===this.wheelDonuts);else{var v=BABYLON.Scalar.Lerp(1,this.driftSpeedDampener,a);i*=v,r*=v}if(this.visualSteerBoostL=i+o,this.visualSteerBoostR=r+o,!0===d&&(this.visualSteerBoostL*=.5,this.visualSteerBoostR*=.5),this.overSteerSpeed>0&&!0===this.handBraking&&(this.handBrakingTimer,this.overSteerTimeout),this.visualSteerAngleL=n.Utilities.MoveTowards(this.visualSteerAngleL,this.visualSteerBoostL,y),this.visualSteerAngleR=n.Utilities.MoveTowards(this.visualSteerAngleR,this.visualSteerBoostR,y),this.physicsSteerAngleL=n.Utilities.MoveTowards(this.physicsSteerAngleL,i,y),this.physicsSteerAngleR=n.Utilities.MoveTowards(this.physicsSteerAngleR,r,y),!0===this.debugDonut&&!0===d){this._donutLogCounter++;var S=Math.max(1,0|this.debugDonutEveryNFrames);if(this._donutLogCounter>=S){this._donutLogCounter=0;var _=0,b=0,B=0;if(null!=this.transform&&null!=this.transform.physicsBody){var C=this.transform.physicsBody.getAngularVelocity();null!=C&&(_=BABYLON.Tools.ToDegrees(C.y));var A=this.transform.physicsBody.getLinearVelocity();null!=A&&null!=this.transform.forward&&null!=this.transform.right&&(b=BABYLON.Vector3.Dot(A,this.transform.forward),B=BABYLON.Vector3.Dot(A,this.transform.right))}var T=Math.sqrt(b*b+B*B),M=Math.abs(BABYLON.Tools.ToRadians(_)),L=M>.01?T/M:999,P=this.donutTurningRadius*Math.abs(BABYLON.Tools.ToRadians(this.donutYawDegPerSec)),w=BABYLON.Tools.ToDegrees(Math.atan2(Math.abs(B),Math.abs(b)));console.log("[DONUT] mph="+this.americanSpeed.toFixed(1)+" yaw="+_.toFixed(1)+"deg/s radius="+L.toFixed(2)+"m(tgt="+this.donutTurningRadius.toFixed(1)+") slip="+w.toFixed(1)+"deg(tgt="+this.donutSlipAngle.toFixed(0)+") bodyVel fwd="+b.toFixed(2)+" lat="+B.toFixed(2)+" engF="+this.engineForce.toFixed(1)+" pin="+(this.donutVelocityPinEnabled?"on":"off")+"(|v|="+P.toFixed(2)+") spinT="+this.donutSpinTime.toFixed(2))}}else!1===d&&(this._donutLogCounter=0,this._donutEngineScale=this.donutSpeedScaling)},i.prototype.syncVehicleState=function(t){var i=this.getGearShiftRatioCount();if(this.shiftingTime>0&&(this.shiftingTime-=t,this.shiftingTime<0&&(this.shiftingTime=0)),!0===this.currentBoosting&&this.boostSpeedTimer>0&&(this.boostSpeedTimer-=t,this.boostSpeedTimer<0&&(this.boostSpeedTimer=0)),null!=this._rigidbody&&null!=this.raycastVehicle){this.forwardSpeed=this.raycastVehicle.getRawCurrentSpeedKph(),Math.abs(this.forwardSpeed)<.2&&(this.forwardSpeed=0),this.absoluteSpeed=this.raycastVehicle.getAbsCurrentSpeedKph(),this.absoluteSpeed<.2&&(this.absoluteSpeed=0),this.americanSpeed=this.absoluteSpeed*n.System.Kph2Mph,this.gradientSpeed=BABYLON.Scalar.Clamp(this.absoluteSpeed/this.getTopEngineSpeed());var r=Math.max(1e-4,this.radiusBrakingForce),o=1-Math.exp(-t/r);this.smoothedGradientSpeed+=(this.gradientSpeed-this.smoothedGradientSpeed)*o;var a=Math.max(1e-4,this.steeringSlewTau),s=1-Math.exp(-t/a);if(this.smoothedSteeringSpeed+=(this.gradientSpeed-this.smoothedSteeringSpeed)*s,null!=this.gearBoxShiftRatios&&this.gearIndex>=0&&this.gearIndex<i){var l=2*this.wheelRadius,u=Math.PI*l,h=this.absoluteSpeed/3.6;this.wheelRPM=60*h/u,this.transmissionInputRPM=this.wheelRPM*this.differentialRatio*this.transmissionRatio,this.targetEngineRPM=this.transmissionInputRPM*this.gearBoxShiftRatios[this.gearIndex],this.engineLoad=Math.abs(this.currentForward)*this.currentDrivePower,this.updateGearShifting(t),this.updateClutchEngagement(t);var c=!0===this.wheelBurnout&&!1===this.wheelDonuts&&!0===this.burnoutButton&&!0===this.handBraking&&Math.abs(this.currentForward)>.9&&this.americanSpeed<=this.burnoutTriggerMark+2&&!0===this._stationaryBurnoutPrimed,d=(this._burnoutLaunchKickTimer>0||this._burnoutLaunchRpmCarryTimer>0)&&!0===this.wheelBurnout&&!1===this.wheelDonuts&&Math.abs(this.currentForward)>.9;if(!0===c){var m=BABYLON.Scalar.Lerp(this.MIN_RPM+this.stationaryBurnoutRevMinRpmOffset,this.MAX_RPM*this.stationaryBurnoutRevMaxFactor,BABYLON.Scalar.Clamp(Math.abs(this.currentForward),0,1));this.actualEngineRPM=BABYLON.Scalar.Lerp(this.actualEngineRPM,m,t*this.stationaryBurnoutRevLerpSpeed)}else if(!0===d){var p=this.getBurnoutLaunchRpmCarryFloor();this.actualEngineRPM=BABYLON.Scalar.Lerp(this.actualEngineRPM,p,t*(this.stationaryBurnoutRevLerpSpeed+3)),this.actualEngineRPM<p&&(this.actualEngineRPM=p)}else if(this.isShifting&&this.clutchEngagement<1){var f=BABYLON.Scalar.Lerp(this.actualEngineRPM,this.targetEngineRPM+this.getIdleRPM(),.1);this.actualEngineRPM=BABYLON.Scalar.Lerp(f,this.targetEngineRPM,this.clutchEngagement)}else{var g=this.getIdleRPM()+2500*Math.abs(this.currentForward),y=Math.max(this.targetEngineRPM,this.getIdleRPM());this.throttleRPM||(this.throttleRPM=this.getIdleRPM()),Math.abs(this.currentForward)>.1?this.throttleRPM=BABYLON.Scalar.Lerp(this.throttleRPM,g,1500*t/1e3):this.throttleRPM=BABYLON.Scalar.Lerp(this.throttleRPM,this.getIdleRPM(),2e3*t/1e3),this.americanSpeed<15&&Math.abs(this.currentForward)>.1?this.actualEngineRPM=this.throttleRPM:this.actualEngineRPM=Math.max(this.throttleRPM,y)}if(this.actualEngineRPM=Math.max(this.actualEngineRPM,this.getIdleRPM()),this.currentForward>=0&&this.engineLoad<.1?this.engineBraking=BABYLON.Scalar.Lerp(this.engineBraking,.3,2*t):this.engineBraking=BABYLON.Scalar.Lerp(this.engineBraking,0,4*t),this.engineRPM=this.actualEngineRPM,!0===this.wheelDonuts||!0===this.wheelBurnout){var v=Math.min(.85*this.MAX_RPM,this.engineRPM+1500);this.pitchRPM=BABYLON.Scalar.Lerp(this.pitchRPM,v,4*t)}else if(this.isShifting){var S=1-this.shiftingTime/this.gearBoxShiftDelay,_=BABYLON.Scalar.Lerp(this.shiftRPM,this.engineRPM,S);this.pitchRPM=BABYLON.Scalar.Lerp(this.pitchRPM,_,6*t)}else this.pitchRPM=BABYLON.Scalar.Lerp(this.pitchRPM,this.engineRPM,8*t);this.gearIndex<0?this.gearIndex=0:this.gearIndex>=i&&(this.gearIndex=i-1)}}this.enginePitchLevel=this.getCurrentEnginePitch()*e.StandardCarController.DEFAULT_PITCH_FACTOR*this.currentPitchScale,!0===this.playVehicleSounds&&null!=this._engineAudioSource&&this._engineAudioSource.setPitch(this.enginePitchLevel),this.POWER_BOOST_PITCH=!0===this.currentBoosting?1:0,!0===this.playVehicleSounds&&null!=this._nosAudioSource&&this._nosAudioSource.setPitch(this.POWER_BOOST_PITCH),this.smokeDonuts=BABYLON.Scalar.Clamp(this.smokeDonuts,1,10),this.smokeIntensityFactor=this.smokeIntensity,!0===this.wheelBurnout&&!0===this.wheelDonuts&&(this.smokeIntensityFactor*=this.smokeDonuts),this.SKID_FL=0,this.SKID_FR=0,this.SKID_RL=0,this.SKID_RR=0;var b=this.computeSlideSkid();if(null!=this.m_frontLeftWheel){var B=0!==this.m_frontLeftWheel.raycastInfo.groundObject;if(this.frontLeftContactMask=!0===B?this.updateCurrentContactMask(this.FRONT_LEFT):0,this.SKID_FL=Math.max(this.updateCurrentSkidInfo(this.m_frontLeftWheel),b),this.SKID_FL<this.skidThreashold&&(this.SKID_FL=0),this.SKID_FL>0&&!0===B){var C=this.m_frontLeftWheel.raycastInfo.contactPointWS,A=this.m_frontLeftWheel.raycastInfo.contactNormalWS,T=new BABYLON.Vector3(C.x,C.y,C.z),M=new BABYLON.Vector3(A.x,A.y,A.z),L=BABYLON.Scalar.Normalize(this.SKID_FL,this.skidThreashold,1);if(this.wheelDrawVelocity>0&&T.addInPlace(this.m_velocityOffset),this.m_frontLeftWheelSkid=e.SkidMarkManager.AddSkidMarkSegment(T,M,L,this.m_frontLeftWheelSkid),!0===this.wheelDonuts&&(this.donutMeter+=this.SKID_FL),this.burnoutMeter+=this.SKID_FL,null!=this.frontLeftWheelParticle){!1===this.frontLeftWheelParticle.isStarted()&&this.frontLeftWheelParticle.start();var P=this.SKID_FL*this.SKID_FL;this.frontLeftWheelParticle.emitRate=this.smokeIntensityFactor*P,this.frontLeftWheelParticle.minSize=.2*P+.2,this.frontLeftWheelParticle.maxSize=1.5*P+1.2}}else null!=this.frontLeftWheelParticle&&(this.frontLeftWheelParticle.emitRate=0),this.m_frontLeftWheelSkid=-1}if(null!=this.m_frontRightWheel){var w=0!==this.m_frontRightWheel.raycastInfo.groundObject;if(this.frontRightContactMask=!0===w?this.updateCurrentContactMask(this.FRONT_RIGHT):0,this.SKID_FR=Math.max(this.updateCurrentSkidInfo(this.m_frontRightWheel),b),this.SKID_FR<this.skidThreashold&&(this.SKID_FR=0),this.SKID_FR>0&&!0===w){var x=this.m_frontRightWheel.raycastInfo.contactPointWS,O=this.m_frontRightWheel.raycastInfo.contactNormalWS,R=new BABYLON.Vector3(x.x,x.y,x.z),I=new BABYLON.Vector3(O.x,O.y,O.z),N=BABYLON.Scalar.Normalize(this.SKID_FR,this.skidThreashold,1);if(this.wheelDrawVelocity>0&&R.addInPlace(this.m_velocityOffset),this.m_frontRightWheelSkid=e.SkidMarkManager.AddSkidMarkSegment(R,I,N,this.m_frontRightWheelSkid),!0===this.wheelDonuts&&(this.donutMeter+=this.SKID_FR),this.burnoutMeter+=this.SKID_FR,null!=this.frontRightWheelParticle){!1===this.frontRightWheelParticle.isStarted()&&this.frontRightWheelParticle.start();var k=this.SKID_FR*this.SKID_FR;this.frontRightWheelParticle.emitRate=this.smokeIntensityFactor*k,this.frontRightWheelParticle.minSize=.2*k+.2,this.frontRightWheelParticle.maxSize=1.5*k+1.2}}else null!=this.frontRightWheelParticle&&(this.frontRightWheelParticle.emitRate=0),this.m_frontRightWheelSkid=-1}if(this.PITCH_FL=this.SKID_FL,this.PITCH_FR=this.SKID_FR,this.PITCH_FL*=.75,this.PITCH_FR*=.75,null!=this.m_backLeftWheel){var F=0!==this.m_backLeftWheel.raycastInfo.groundObject;if(this.rearLeftContactMask=!0===F?this.updateCurrentContactMask(this.BACK_LEFT):0,this.SKID_RL=Math.max(this.updateCurrentSkidInfo(this.m_backLeftWheel),b),this.SKID_RL<this.skidThreashold&&(this.SKID_RL=0),this.SKID_RL>0&&!0===F){var D=this.m_backLeftWheel.raycastInfo.contactPointWS,E=this.m_backLeftWheel.raycastInfo.contactNormalWS,V=new BABYLON.Vector3(D.x,D.y,D.z),Y=new BABYLON.Vector3(E.x,E.y,E.z),U=BABYLON.Scalar.Normalize(this.SKID_RL,this.skidThreashold,1);if(this.wheelDrawVelocity>0&&V.addInPlace(this.m_velocityOffset),this.m_backLeftWheelSkid=e.SkidMarkManager.AddSkidMarkSegment(V,Y,U,this.m_backLeftWheelSkid),!0===this.wheelDonuts&&(this.donutMeter+=this.SKID_RL),this.burnoutMeter+=this.SKID_RL,null!=this.backLeftWheelParticle){!1===this.backLeftWheelParticle.isStarted()&&this.backLeftWheelParticle.start();var W=this.SKID_RL*this.SKID_RL;this.backLeftWheelParticle.emitRate=this.smokeIntensityFactor*W,this.backLeftWheelParticle.minSize=.2*W+.2,this.backLeftWheelParticle.maxSize=1.5*W+1.2}}else null!=this.backLeftWheelParticle&&(this.backLeftWheelParticle.emitRate=0),this.m_backLeftWheelSkid=-1}if(null!=this.m_backRightWheel){var G=0!==this.m_backRightWheel.raycastInfo.groundObject;if(this.rearRightContactMask=!0===G?this.updateCurrentContactMask(this.BACK_RIGHT):0,this.SKID_RR=Math.max(this.updateCurrentSkidInfo(this.m_backRightWheel),b),this.SKID_RR<this.skidThreashold&&(this.SKID_RR=0),this.SKID_RR>0&&!0===G){var H=this.m_backRightWheel.raycastInfo.contactPointWS,z=this.m_backRightWheel.raycastInfo.contactNormalWS,K=new BABYLON.Vector3(H.x,H.y,H.z),X=new BABYLON.Vector3(z.x,z.y,z.z),Q=BABYLON.Scalar.Normalize(this.SKID_RR,this.skidThreashold,1);if(this.wheelDrawVelocity>0&&K.addInPlace(this.m_velocityOffset),this.m_backRightWheelSkid=e.SkidMarkManager.AddSkidMarkSegment(K,X,Q,this.m_backRightWheelSkid),!0===this.wheelDonuts&&(this.donutMeter+=this.SKID_RR),this.burnoutMeter+=this.SKID_RR,null!=this.backRightWheelParticle){!1===this.backRightWheelParticle.isStarted()&&this.backRightWheelParticle.start();var j=this.SKID_RR*this.SKID_RR;this.backRightWheelParticle.emitRate=this.smokeIntensityFactor*j,this.backRightWheelParticle.minSize=.2*j+.2,this.backRightWheelParticle.maxSize=1.5*j+1.2}}else null!=this.backRightWheelParticle&&(this.backRightWheelParticle.emitRate=0),this.m_backRightWheelSkid=-1}if(this.PITCH_RL=this.SKID_RL,this.PITCH_RR=this.SKID_RR,this.WHEEL_SKID_PITCH=0,this.PITCH_FL>this.WHEEL_SKID_PITCH&&(this.WHEEL_SKID_PITCH=this.PITCH_FL),this.PITCH_FR>this.WHEEL_SKID_PITCH&&(this.WHEEL_SKID_PITCH=this.PITCH_FR),this.PITCH_RL>this.WHEEL_SKID_PITCH&&(this.WHEEL_SKID_PITCH=this.PITCH_RL),this.PITCH_RR>this.WHEEL_SKID_PITCH&&(this.WHEEL_SKID_PITCH=this.PITCH_RR),this.WHEEL_SKID_PITCH*=this.getWheelSkidAudioPitchScale(),!0===this.playVehicleSounds&&null!=this._skidAudioSource&&this._skidAudioSource.setPitch(this.WHEEL_SKID_PITCH),this.logSkidSlide(),null!=this.brakeLightsMesh&&(this.brakeLightsMesh.isVisible=this.isBraking()),null!=this.reverseLightsMesh&&(this.reverseLightsMesh.isVisible=this.getReverseThrottle()),0===this.SKID_FL&&0===this.SKID_FL&&0===this.SKID_FL&&0===this.SKID_FL&&(this.smokeIntensityFactor=0),1==this.postNetworkAttributes&&n.EntityController.HasNetworkEntity(this.transform)){var Z=this.isBraking()?1:0,J=this.getEnginePitchLevel(),q=this.getReverseThrottle()?1:0,$=this.getCurrentBurnout()||this.getBurnoutButton()?1:0,ee=this.getFrontLeftSkid(),te=this.getFrontRightSkid(),ie=this.getBackLeftSkid(),ne=this.getBackRightSkid(),re=this.m_frontLeftWheel.spinner,oe=this.m_frontRightWheel.spinner,ae=this.m_backLeftWheel.spinner,se=this.m_backRightWheel.spinner;n.EntityController.PostBufferedAttribute(this.transform,0,J),n.EntityController.PostBufferedAttribute(this.transform,1,Z),n.EntityController.PostBufferedAttribute(this.transform,2,q),n.EntityController.PostBufferedAttribute(this.transform,3,$),n.EntityController.PostBufferedAttribute(this.transform,4,ee),n.EntityController.PostBufferedAttribute(this.transform,5,te),n.EntityController.PostBufferedAttribute(this.transform,6,ie),n.EntityController.PostBufferedAttribute(this.transform,7,ne),null!=re&&null!=re.rotationQuaternion?(re.rotationQuaternion.toEulerAnglesToRef(this.SPIN_FL_Rotation),n.EntityController.PostBufferedAttribute(this.transform,8,this.SPIN_FL_Rotation.x)):n.EntityController.PostBufferedAttribute(this.transform,8,0),null!=oe&&null!=oe.rotationQuaternion?(oe.rotationQuaternion.toEulerAnglesToRef(this.SPIN_FR_Rotation),n.EntityController.PostBufferedAttribute(this.transform,9,this.SPIN_FR_Rotation.x)):n.EntityController.PostBufferedAttribute(this.transform,9,0),null!=ae&&null!=ae.rotationQuaternion?(ae.rotationQuaternion.toEulerAnglesToRef(this.SPIN_RL_Rotation),n.EntityController.PostBufferedAttribute(this.transform,10,this.SPIN_RL_Rotation.x)):n.EntityController.PostBufferedAttribute(this.transform,10,0),null!=se&&null!=se.rotationQuaternion?(se.rotationQuaternion.toEulerAnglesToRef(this.SPIN_RR_Rotation),n.EntityController.PostBufferedAttribute(this.transform,11,this.SPIN_RR_Rotation.x)):n.EntityController.PostBufferedAttribute(this.transform,11,0),n.EntityController.PostBufferedAttribute(this.transform,12,this.animatorSteerAngle)}this.writeTransformMetadata()},i.prototype.syncVehicleTilting=function(t){var i=this.raycastVehicle.getInternalVehicle();if(null!=i){var n=i.getCurrentSpeedKmHour(),r=n-this.previousSpeed,o=i.getRigidBody().getAngularVelocity().y;r>0?this.currentPitch-=this.forwardPitchFactor*Math.min(r,10)*t:r<0&&(!0===this.getFootBraking()||!0===this.getHandBraking()&&this.americanSpeed<10)&&(this.currentPitch+=this.forwardPitchFactor*Math.min(-r,10)*t),this.currentRoll+=this.lateralRollFactor*o*t,this.currentPitch*=1-this.forwardRecoverRate,this.currentRoll*=1-this.lateralRecoverRate;var a=BABYLON.Tools.ToRadians(this.maxForwardAngle),s=BABYLON.Tools.ToRadians(this.maxLateralAngle);if(this.currentPitch=Math.max(-a,Math.min(a,this.currentPitch)),this.currentRoll=Math.max(-s,Math.min(s,this.currentRoll)),this.shiftingTime>0){var l=Math.sin(this.shiftingTime*Math.PI),u=(this.currentForward>0?1:-1)*l*this.shiftForwardExtra*.015,h=this.shiftingSide*l*this.shiftLateralExtra*.015;this.currentPitch+=u,this.currentRoll+=h}if(!0===this.surfaceDetection){this.idleNoiseDelta+=t*this.idleShakeRate*3,this.driveNoiseDelta+=t*BABYLON.Scalar.Lerp(this.lowSpeedScale,this.highSpeedScale,this.gradientSpeed)*3;var c=Math.abs(n);if(c>=1){if(c>=this.speedThreashold&&!1===this.handBraking){if(this.lowForwardNoise>0||this.highForwardNoise>0){var d=BABYLON.Scalar.Lerp(this.lowForwardNoise,this.highForwardNoise,this.gradientSpeed);this.currentPitch+=e.StandardCarController.SimplexNoise2D(this.driveNoiseDelta,0)*d*.065*this.roadSurfaceFactor}if(this.lowLateralNoise>0||this.highLateralNoise>0){var m=BABYLON.Scalar.Lerp(this.lowLateralNoise,this.highLateralNoise,this.gradientSpeed);this.currentRoll+=e.StandardCarController.SimplexNoise2D(this.driveNoiseDelta,1)*m*.065*this.roadSurfaceFactor}}}else this.idleShakeNoise>0&&(this.currentPitch+=e.StandardCarController.SimplexNoise2D(this.idleNoiseDelta,0)*this.idleShakeNoise*.065,this.currentRoll+=e.StandardCarController.SimplexNoise2D(this.idleNoiseDelta,1)*this.idleShakeNoise*.065)}if(null!=this.chassisTransform&&null!=this.chassisTransform.rotationQuaternion){this.chassisTransform.rotationQuaternion.toEulerAnglesToRef(this.tiltChassisEulers);var p=BABYLON.Scalar.Lerp(this.tiltChassisEulers.x,this.currentPitch,this.lerpForwardFactor*t),f=BABYLON.Scalar.Lerp(this.tiltChassisEulers.z,this.currentRoll,this.lerpLateralFactor*t);BABYLON.Quaternion.FromEulerAnglesToRef(p,this.tiltChassisEulers.y,f,this.chassisTransform.rotationQuaternion)}this.previousSpeed=n}},i.prototype.updateGearShifting=function(e){var t=this.gearBoxShiftRatios.length;if(this.gearShiftCooldown>0&&(this.gearShiftCooldown-=e),this.shiftingTime>0&&(this.shiftingTime-=e,this.shiftingTime<=0&&(this.isShifting=!1)),!this.currentBoosting&&!this.wheelBurnout&&this.gearShiftCooldown<=0)if(this.americanSpeed<3)0!==this.gearIndex&&this.initiateGearShift(0);else if(!(0===this.gearIndex&&this.americanSpeed<15&&(this.engineLoad<.6||this.americanSpeed<12))){var i=null!=this.gearBoxShiftUpRanges&&this.gearBoxShiftUpRanges.length>this.gearIndex?this.gearBoxShiftUpRanges[this.gearIndex]:999,n=null!=this.gearBoxShiftDownRanges&&this.gearBoxShiftDownRanges.length>this.gearIndex?this.gearBoxShiftDownRanges[this.gearIndex]:0;this.gearIndex<t-1&&this.shouldUpshift(i)?this.initiateGearShift(this.gearIndex+1):this.gearIndex>0&&this.shouldDownshift(n)&&this.initiateGearShift(this.gearIndex-1)}},i.prototype.shouldUpshift=function(e){if(this.wheelBurnout)return!1;if(this.actualEngineRPM<this.MIN_RPM+600)return!1;if(Math.abs(this.currentForward)<.2)return!1;if(this.gearIndex+1<this.gearBoxShiftRatios.length){var t=this.gearBoxShiftRatios[this.gearIndex+1],i=this.gearBoxShiftRatios[this.gearIndex];if(this.actualEngineRPM*(t/i)<this.MIN_RPM+400)return!1}if(this._burnoutLaunchKickTimer<=0&&this.actualEngineRPM>=.85*this.MAX_RPM)return!0;if(this.americanSpeed>=e-1)return!0;var n=this.getTopEngineSpeed();if(n>0&&this.americanSpeed>=n-5){var r=this.gearIndex+1,o=null!=this.gearBoxShiftDownRanges&&this.gearBoxShiftDownRanges.length>r?this.gearBoxShiftDownRanges[r]:0;if(this.americanSpeed>o+1)return!0}return!1},i.prototype.shouldDownshift=function(e){if(this.americanSpeed>e+1)return!1;var t=this.actualEngineRPM<this.MIN_RPM+500;if(this.gearIndex>0){var i=this.gearBoxShiftRatios[this.gearIndex-1],n=this.gearBoxShiftRatios[this.gearIndex];if(this.actualEngineRPM*(i/n)>this.MAX_RPM-300)return!1}return!!(Math.abs(this.currentForward)>.3&&t)||this.americanSpeed<e},i.prototype.initiateGearShift=function(e){var t=this.gearIndex;this.gearIndex=BABYLON.Scalar.Clamp(e,0,this.gearBoxShiftRatios.length-1),this.gearIndex!==t&&(this.gearIndex>1&&this.resetBurnoutLowGearClimb(),this.isShifting=!0,this.shiftDirection=this.gearIndex>t?1:-1,this.shiftingTime=this.gearBoxShiftDelay,this.gearShiftCooldown=.3,this.shiftingSide=n.Utilities.GetRandomRange(-10,10)>0?1:-1,this.shiftRPM=this.actualEngineRPM)},i.prototype.armBurnoutLowGearClimb=function(e){this.gearIndex>1||(this._burnoutLowGearClimbActive=!0,this._burnoutLowGearClimbStationary=!0===this._burnoutLowGearClimbStationary||!0===e,this._burnoutLowGearClimbDriveSign=this.currentForward>=0?1:-1)},i.prototype.resetBurnoutLowGearClimb=function(){this._burnoutLowGearClimbActive=!1,this._burnoutLowGearClimbStationary=!1,this._burnoutLowGearClimbDriveSign=0},i.prototype.isBurnoutLowGearClimbActive=function(){return!0===this._burnoutLowGearClimbActive&&this.gearIndex<=1},i.prototype.updateBurnoutLowGearClimbState=function(){if(!1!==this._burnoutLowGearClimbActive)if(this.gearIndex>1)this.resetBurnoutLowGearClimb();else{var e=this.currentForward>.2?1:this.currentForward<-.2?-1:0;if(0===e||0===this._burnoutLowGearClimbDriveSign||e===this._burnoutLowGearClimbDriveSign){var t=!0===this.wheelBurnout||this.restoreTimer>0||this._burnoutLaunchKickTimer>0||this.burnoutTimer>0;this.americanSpeed<3&&!1===t&&Math.abs(this.currentForward)<.2&&this.resetBurnoutLowGearClimb()}else this.resetBurnoutLowGearClimb()}},i.prototype.armBurnoutLaunchAudio=function(){var e=Math.max(this.burnoutPeelAwayPitchRampTime,0);this._burnoutPeelAwayPitchRampDuration=e,this._burnoutPeelAwayPitchRampTimer=e;var t=Math.max(this.burnoutLaunchRpmCarryTime,this.burnoutLaunchKickDuration,e);this._burnoutLaunchRpmCarryDuration=t,this._burnoutLaunchRpmCarryTimer=t;var i=null!=this.burnoutLaunchChirpSound?this.burnoutLaunchChirpSound:"";!0===this.playVehicleSounds&&""!==i&&!0===n.SceneManager.HasSoundManager()&&!1===n.SceneManager.IsSoundEffectPlaying(i)&&n.SceneManager.PlayOneShot(i)},i.prototype.isStationaryBurnoutSkidAudioActive=function(){return!0===this.wheelBurnout&&!0===this._burnoutStartedFromStationary&&this._burnoutLaunchKickTimer<=0&&!1===this._stationaryLaunchSnapActive&&this.americanSpeed<=this.stationaryBurnoutPrimeReleaseSpeedMph},i.prototype.isBurnoutPeelAwaySkidAudioActive=function(){return this._burnoutLaunchKickTimer>0||this._burnoutPeelAwayPitchRampTimer>0||!0===this.wheelBurnout&&!0===this._burnoutStartedFromStationary&&!1===this.isStationaryBurnoutSkidAudioActive()},i.prototype.getWheelSkidAudioPitchScale=function(){if(!0===this.isStationaryBurnoutSkidAudioActive())return this.stationaryBurnoutSkidPitch;if(!0===this.isBurnoutPeelAwaySkidAudioActive()){var e=1;return this._burnoutPeelAwayPitchRampTimer>0&&this._burnoutPeelAwayPitchRampDuration>0&&(e=1-BABYLON.Scalar.Clamp(this._burnoutPeelAwayPitchRampTimer/this._burnoutPeelAwayPitchRampDuration,0,1)),BABYLON.Scalar.Lerp(this.stationaryBurnoutSkidPitch,this.burnoutPeelAwaySkidPitch,e)}return!0===this.wheelBurnout||this.restoreTimer>0?this.burnoutWheelPitch:1},i.prototype.getBurnoutLaunchRpmCarryFloor=function(){if(this._burnoutLaunchHoldRpm<=this.getIdleRPM())return this.getIdleRPM();var e=1;this._burnoutLaunchRpmCarryTimer>0&&this._burnoutLaunchRpmCarryDuration>0&&(e=BABYLON.Scalar.Clamp(this._burnoutLaunchRpmCarryTimer/this._burnoutLaunchRpmCarryDuration,0,1));var t=this._burnoutLaunchHoldRpm*BABYLON.Scalar.Lerp(this.burnoutLaunchRpmCarryFloorFactor,1,e),i=this.getIdleRPM()+Math.abs(this.currentForward)*this.stationaryBurnoutRevMinRpmOffset;return Math.max(t,i,this.targetEngineRPM,this.getIdleRPM())},i.prototype.updateClutchEngagement=function(e){this.isShifting?this.clutchEngagement=BABYLON.Scalar.Lerp(this.clutchEngagement,.2,8*e):this.clutchEngagement=BABYLON.Scalar.Lerp(this.clutchEngagement,1,6*e)},i.prototype.getIdleRPM=function(){return this.MIN_RPM+100*this.engineLoad},i.prototype.writeTransformMetadata=function(){null==this.transform.metadata&&(this.transform.metadata={}),null==this.transform.metadata.car&&(this.transform.metadata.car={}),this.transform.metadata.car.forwardSpeed=this.forwardSpeed,this.transform.metadata.car.reversePower=this.maxReversePower,this.transform.metadata.car.americanSpeed=this.americanSpeed,this.transform.metadata.car.gradientSpeed=this.gradientSpeed,this.transform.metadata.car.currentForward=this.currentForward,this.transform.metadata.car.linearVelocity=this.getLinearVelocity().length(),this.transform.metadata.car.normalizedSpeed=this.getNormalizedSpeed()},i.prototype.getVehicleEngineTorque=function(e,t){var i=0;return null!=this.engineTorqueCurve&&(i=n.Utilities.SampleAnimationFloat(this.engineTorqueCurve,BABYLON.Scalar.Clamp(e,this.MIN_RPM,this.MAX_RPM),BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE,!1)*t),i},i.prototype.createSmokeParticleSystem=function(e,t){var i=new BABYLON.ParticleSystem(e,1e4,this.scene);return i.blendMode=BABYLON.ParticleSystem.BLENDMODE_STANDARD,i.renderingGroupId=n.Utilities.DefaultRenderGroup(),i.particleTexture=this.smokeTexture,i.emitter=t,i.emitRate=0,i.updateSpeed=.01,i.minSize=.2,i.maxSize=1.3,i.minAngularSpeed=-1.5,i.maxAngularSpeed=1.5,i.minLifeTime=3,i.maxLifeTime=5,i.addVelocityGradient(0,1),i.addVelocityGradient(.1,.7),i.addVelocityGradient(.7,.2),i.addVelocityGradient(1,.05),i.gravity=new BABYLON.Vector3(0,-.1,0),i.minEmitBox=new BABYLON.Vector3(0,-.25,0),i.maxEmitBox=new BABYLON.Vector3(0,-.25,0),i.direction1=new BABYLON.Vector3(-1,-1,-1),i.direction2=new BABYLON.Vector3(1,1,1),i.color1=new BABYLON.Color4(.95,.95,.95,this.smokeOpacity),i.color2=new BABYLON.Color4(.85,.85,.85,this.smokeOpacity),i.colorDead=new BABYLON.Color4(.9,.9,.9,.5*this.smokeOpacity),i},i.prototype.updateCurrentSkidInfo=function(e){return BABYLON.Scalar.Clamp(1-e.skidInfo)},i.prototype.computeSlideSkid=function(){if(!0!==this.skidSlideEnabled)return 0;if(null==this.transform||null==this.transform.physicsBody)return 0;if(null==this.transform.forward||null==this.transform.right)return 0;var e=this.transform.physicsBody.getLinearVelocity();if(null==e)return 0;var t=BABYLON.Vector3.Dot(e,this.transform.forward),i=BABYLON.Vector3.Dot(e,this.transform.right);if(Math.sqrt(t*t+i*i)<this.skidSlideMinSpeed)return 0;var n=BABYLON.Tools.ToDegrees(Math.atan2(Math.abs(i),Math.abs(t)));if(n<=this.skidSlideMinAngle)return 0;var r=Math.max(this.skidSlideMaxAngle-this.skidSlideMinAngle,.1),o=BABYLON.Scalar.Clamp((n-this.skidSlideMinAngle)/r,0,1);return BABYLON.Scalar.Lerp(this.skidThreashold,1,o)},i.prototype.logSkidSlide=function(){if(!0===this.debugSkidSlide){var e=this.SKID_FL>0||this.SKID_FR>0||this.SKID_RL>0||this.SKID_RR>0,t=!0===this._skidFrictionRestorePending||!0===this.wheelSkidding||!0===this._skidRecoverActive;if(!1!==e||!1!==t){if(this._skidSlideLogCounter++,!(this._skidSlideLogCounter<this.debugSkidSlideEveryNFrames)){this._skidSlideLogCounter=0;var i=0;if(null!=this.transform&&null!=this.transform.physicsBody&&null!=this.transform.forward&&null!=this.transform.right){var n=this.transform.physicsBody.getLinearVelocity();null!=n&&(i=BABYLON.Tools.ToDegrees(Math.atan2(Math.abs(BABYLON.Vector3.Dot(n,this.transform.right)),Math.abs(BABYLON.Vector3.Dot(n,this.transform.forward)))))}var r=null!=this.m_frontLeftWheel&&this.m_frontLeftWheel.defaultFriction?this.m_frontLeftWheel.defaultFriction:1,o=null!=this.m_backLeftWheel&&this.m_backLeftWheel.defaultFriction?this.m_backLeftWheel.defaultFriction:1,a=null!=this.m_frontLeftWheel?this.m_frontLeftWheel.frictionSlip/r:0,s=null!=this.m_backLeftWheel?this.m_backLeftWheel.frictionSlip/o:0,l=BABYLON.Scalar.Clamp(this._skidRecoverElapsed/Math.max(this.skidRecoverDuration,.05),0,1);console.log("[SKID] hb="+(this.handBraking?1:0)+" mph="+this.americanSpeed.toFixed(0)+" slip="+i.toFixed(0)+"d SKID="+this.SKID_FL.toFixed(2)+"/"+this.SKID_FR.toFixed(2)+"/"+this.SKID_RL.toFixed(2)+"/"+this.SKID_RR.toFixed(2)+" grip(F/R)="+(100*a).toFixed(0)+"%/"+(100*s).toFixed(0)+"% recover="+(this._skidRecoverActive?l.toFixed(2):"-"))}}else this._skidSlideLogCounter=0}},i.prototype.updateCurrentContactMask=function(e){var t=0;return null!=this.raycastVehicle&&(t=this.raycastVehicle.getWheelInfo(e).contactMembershipMask),t},i.prototype.hasPenaltyContactMask=function(e,t){return e>0&&t>0&&0!==(e&t)},i.prototype.updateCurrentBrakeDamping=function(e,t){var i=0;if(this.americanSpeed>=this.minPenaltySpeed&&this.linearWheelDrag>0){var n=this.curbPenaltyMask|this.grassPenaltyMask|0;this.hasPenaltyContactMask(this.frontLeftContactMask,n)&&(i+=this.linearWheelDrag),this.hasPenaltyContactMask(this.frontRightContactMask,n)&&(i+=this.linearWheelDrag),this.hasPenaltyContactMask(this.rearLeftContactMask,n)&&(i+=this.linearWheelDrag),this.hasPenaltyContactMask(this.rearRightContactMask,n)&&(i+=this.linearWheelDrag)}this.gearIndex<=1&&this.lowGearDampener>0&&!1===this.isBurnoutLowGearClimbActive()&&(i+=this.lowGearDampener),null!=this.transform.physicsBody&&(this.transform.physicsBody.setLinearDamping(e+i),this.transform.physicsBody.setAngularDamping(t))},i.prototype.updateCurrentRotationDelta=function(e){null!=this.m_frontLeftWheel&&(this.m_frontLeftWheel.deltaRotation=e),null!=this.m_frontRightWheel&&(this.m_frontRightWheel.deltaRotation=e),null!=this.m_backLeftWheel&&(this.m_backLeftWheel.deltaRotation=e),null!=this.m_backRightWheel&&(this.m_backRightWheel.deltaRotation=e)},i.prototype.updateCurrentRotationBoost=function(e){e<=0||(1!==this.wheelDriveType&&2!==this.wheelDriveType||(null!=this.m_frontLeftWheel&&(this.m_frontLeftWheel.rotationBoost=e),null!=this.m_frontRightWheel&&(this.m_frontRightWheel.rotationBoost=e)),0!==this.wheelDriveType&&2!==this.wheelDriveType||(null!=this.m_backLeftWheel&&(this.m_backLeftWheel.rotationBoost=e),null!=this.m_backRightWheel&&(this.m_backRightWheel.rotationBoost=e)))},i.prototype.clearWheelRotationBoost=function(){null!=this.m_frontLeftWheel&&(this.m_frontLeftWheel.rotationBoost=0),null!=this.m_frontRightWheel&&(this.m_frontRightWheel.rotationBoost=0),null!=this.m_backLeftWheel&&(this.m_backLeftWheel.rotationBoost=0),null!=this.m_backRightWheel&&(this.m_backRightWheel.rotationBoost=0)},i.prototype.hasBurnoutResidualState=function(){if(this.restoreTimer>0||this._burnoutExitArcadeFadeTimer>0||this._burnoutExitFrictionRampTimer>0||this._burnoutExitArcadeReleaseTimer>0)return!0;if(this.cooldownTimer>0||0!==this._burnoutLatchedDriveSign)return!0;var e=.001;return null!=this.m_frontLeftWheel&&this.m_frontLeftWheel.rotationBoost>e||null!=this.m_frontRightWheel&&this.m_frontRightWheel.rotationBoost>e||null!=this.m_backLeftWheel&&this.m_backLeftWheel.rotationBoost>e||null!=this.m_backRightWheel&&this.m_backRightWheel.rotationBoost>e||!0===this._burnoutResidualFrictionRestorePending&&!1===this.isWheelFrictionAtDefault()},i.prototype.resetBurnoutFrictionForStopOrLaunch=function(){if(!0!==this.burnoutButton&&!0!==this.wheelBurnout&&!0!==this.handBraking&&!(this._burnoutLaunchKickTimer>0||!0===this._stationaryLaunchSnapActive)&&!1!==this.hasBurnoutResidualState()){var t=this.burnoutStopFrictionResetSpeed>0&&this.americanSpeed<=this.burnoutStopFrictionResetSpeed&&Math.abs(this.forwardSpeed)<=e.StandardCarController.DEFAULT_BRAKE_DEADZONE,i=this.burnoutLaunchFrictionResetSpeed>0&&this.restoreTimer<=0&&this.americanSpeed<=this.burnoutLaunchFrictionResetSpeed&&Math.abs(this.currentForward)>.9;!1===t&&!1===i||!1===t&&(!0===this._skidFrictionRestorePending||this._skidReleaseBrakeTimer>0||!0===this.wheelSkidding)||(this.burnoutTimer=0,this.burnoutElapsed=0,this.restoreTimer=0,this.restoreTimerDuration=0,this.cooldownTimer=0,this.wheelDonuts=!1,this._burnoutLatchedDriveSign=0,this._burnoutStartedFromStationary=!1,this._stationaryLaunchSnapActive=!1,this._burnoutLaunchKickTimer=0,this._burnoutLaunchHoldRpm=0,this._burnoutLaunchRpmCarryTimer=0,this._burnoutLaunchRpmCarryDuration=0,!0===t&&(this._burnoutPeelAwayPitchRampTimer=0,this._burnoutPeelAwayPitchRampDuration=0),this._burnoutResidualFrictionRestorePending=!1,this._skidReleaseBrakeTimer=0,this._skidFrictionRestorePending=!1,this.wheelSkidding=!1,this.resetBurnoutLowGearClimb(),this.clearBurnoutExitSmoothing(),this.clearWheelRotationBoost(),this.restoreWheelFrictionToDefault(),null!=this.raycastVehicle&&(this.raycastVehicle.setArcadeBurnoutActive(!1),this.raycastVehicle.setArcadeDonutActive(!1)),!0===this.debugFrictionRestore&&console.log("[FRICTION-RESET] burnout residual cleared | reason="+(t?"stopped":"launch")+" | mph="+this.americanSpeed.toFixed(2)+" | thr="+this.currentForward.toFixed(2)))}},i.prototype.resetSkidFrictionForStopOrLaunch=function(){if(!1!==this._skidFrictionRestorePending&&!0!==this.handBraking&&!(!0===this.wheelBurnout||this.restoreTimer>0||this._burnoutLaunchKickTimer>0)){var e=this.skidStopFrictionResetSpeed>0&&this.americanSpeed<=this.skidStopFrictionResetSpeed,t=this.skidLaunchFrictionResetSpeed>0&&this.americanSpeed<=this.skidLaunchFrictionResetSpeed&&Math.abs(this.currentForward)>.9;!1===e&&!1===t||(this._skidReleaseBrakeTimer=0,this.wheelSkidding=!1,this.restoreWheelFrictionToDefault(),!1===this.wheelBurnout&&this.restoreTimer<=0&&this.burnoutTimer<=0&&this.clearBurnoutExitSmoothing(),this._skidFrictionRestorePending=!1)}},i.prototype.restoreWheelFrictionToDefault=function(){this.frontLeftFrictionPenalty=!1,this.frontRightFrictionPenalty=!1,this.rearLeftFrictionPenalty=!1,this.rearRightFrictionPenalty=!1,this.frontLeftFrictionLerping=!1,this.frontRightFrictionLerping=!1,this.rearLeftFrictionLerping=!1,this.rearRightFrictionLerping=!1,null!=this.m_frontLeftWheel&&null!=this.m_frontLeftWheel.defaultFriction&&(this.m_frontLeftWheel.frictionSlip=this.m_frontLeftWheel.defaultFriction),null!=this.m_frontRightWheel&&null!=this.m_frontRightWheel.defaultFriction&&(this.m_frontRightWheel.frictionSlip=this.m_frontRightWheel.defaultFriction),null!=this.m_backLeftWheel&&null!=this.m_backLeftWheel.defaultFriction&&(this.m_backLeftWheel.frictionSlip=this.m_backLeftWheel.defaultFriction),null!=this.m_backRightWheel&&null!=this.m_backRightWheel.defaultFriction&&(this.m_backRightWheel.frictionSlip=this.m_backRightWheel.defaultFriction)},i.prototype.isWheelFrictionAtDefault=function(){var e=.001,t=null==this.m_frontLeftWheel||null==this.m_frontLeftWheel.defaultFriction||Math.abs(this.m_frontLeftWheel.frictionSlip-this.m_frontLeftWheel.defaultFriction)<=e,i=null==this.m_frontRightWheel||null==this.m_frontRightWheel.defaultFriction||Math.abs(this.m_frontRightWheel.frictionSlip-this.m_frontRightWheel.defaultFriction)<=e,n=null==this.m_backLeftWheel||null==this.m_backLeftWheel.defaultFriction||Math.abs(this.m_backLeftWheel.frictionSlip-this.m_backLeftWheel.defaultFriction)<=e,r=null==this.m_backRightWheel||null==this.m_backRightWheel.defaultFriction||Math.abs(this.m_backRightWheel.frictionSlip-this.m_backRightWheel.defaultFriction)<=e;return t&&i&&n&&r},i.prototype.updateSkidFrictionRecovery=function(){!1===this._skidRecoverActive?(this._skidRecoverActive=!0,this._skidRecoverElapsed=0,this._skidRecoverFrontStart=null!=this.m_frontLeftWheel?this.m_frontLeftWheel.frictionSlip:this.frontSkidFriction,this._skidRecoverRearStart=null!=this.m_backLeftWheel?this.m_backLeftWheel.frictionSlip:this.rearSkidFriction):this._skidRecoverElapsed+=this.getDeltaSeconds();var e=Math.max(this.skidRecoverDuration,.05),t=BABYLON.Scalar.Clamp(this._skidRecoverElapsed/e,0,1),i=Math.pow(t,Math.max(this.skidRecoverCurve,.1)),n=t>=1,r=function(e,t){if(null==e||null==e.defaultFriction)return 0;var r=n?e.defaultFriction:BABYLON.Scalar.Lerp(t,e.defaultFriction,i);return e.frictionSlip=r,r};r(this.m_frontLeftWheel,this._skidRecoverFrontStart),r(this.m_frontRightWheel,this._skidRecoverFrontStart),r(this.m_backLeftWheel,this._skidRecoverRearStart),r(this.m_backRightWheel,this._skidRecoverRearStart),this.frontLeftFrictionLerping=!n,this.frontRightFrictionLerping=!n,this.rearLeftFrictionLerping=!n,this.rearRightFrictionLerping=!n,this.frontLeftFrictionPenalty=!1,this.frontRightFrictionPenalty=!1,this.rearLeftFrictionPenalty=!1,this.rearRightFrictionPenalty=!1},i.prototype.updateCurrentFrictionSlip=function(e){var t=!0===this._skidFrictionRestorePending&&!1===this.handBraking&&!1===this.wheelBurnout&&this.restoreTimer<=0;if(!0===t)return this.updateSkidFrictionRecovery(),void(!0===this._skidFrictionRestorePending&&this._skidReleaseBrakeTimer<=0&&!0===this.isWheelFrictionAtDefault()&&(this._skidFrictionRestorePending=!1));this._skidRecoverActive=!1;var i=.1,n=.001;if(null!=this.m_frontLeftWheel&&null!=this.m_frontLeftWheel.defaultFriction){var r=t?Math.max(i,this.m_frontLeftWheel.defaultFriction*this.skidReleaseSnapRatio):i,o=this.m_frontLeftWheel.frictionSlip;o<this.m_frontLeftWheel.defaultFriction-r?(this.frontLeftFrictionLerping=!0,o=BABYLON.Scalar.Lerp(o,this.m_frontLeftWheel.defaultFriction,!0===this.frontLeftFrictionPenalty?3*e:e),this.m_frontLeftWheel.frictionSlip=o):(this.frontLeftFrictionPenalty=!1,this.frontLeftFrictionLerping=!1,this.m_frontLeftWheel.frictionSlip=this.m_frontLeftWheel.defaultFriction)}if(null!=this.m_frontRightWheel&&null!=this.m_frontRightWheel.defaultFriction){var a=t?Math.max(i,this.m_frontRightWheel.defaultFriction*this.skidReleaseSnapRatio):i,s=this.m_frontRightWheel.frictionSlip;s<this.m_frontRightWheel.defaultFriction-a?(this.frontRightFrictionLerping=!0,s=BABYLON.Scalar.Lerp(s,this.m_frontRightWheel.defaultFriction,!0===this.frontRightFrictionPenalty?3*e:e),this.m_frontRightWheel.frictionSlip=s):(this.frontRightFrictionPenalty=!1,this.frontRightFrictionLerping=!1,this.m_frontRightWheel.frictionSlip=this.m_frontRightWheel.defaultFriction)}if(null!=this.m_backLeftWheel&&null!=this.m_backLeftWheel.defaultFriction){var l=t?Math.max(n,this.m_backLeftWheel.defaultFriction*this.skidReleaseSnapRatio):n,u=this.m_backLeftWheel.frictionSlip;u<this.m_backLeftWheel.defaultFriction-l?(this.rearLeftFrictionLerping=!0,u=BABYLON.Scalar.Lerp(u,this.m_backLeftWheel.defaultFriction,!0===this.rearLeftFrictionPenalty?3*e:e),this.m_backLeftWheel.frictionSlip=u):(this.rearLeftFrictionPenalty=!1,this.rearLeftFrictionLerping=!1,this.m_backLeftWheel.frictionSlip=this.m_backLeftWheel.defaultFriction)}if(null!=this.m_backRightWheel&&null!=this.m_backRightWheel.defaultFriction){var h=t?Math.max(n,this.m_backRightWheel.defaultFriction*this.skidReleaseSnapRatio):n,c=this.m_backRightWheel.frictionSlip;c<this.m_backRightWheel.defaultFriction-h?(this.rearRightFrictionLerping=!0,c=BABYLON.Scalar.Lerp(c,this.m_backRightWheel.defaultFriction,!0===this.rearRightFrictionPenalty?3*e:e),this.m_backRightWheel.frictionSlip=c):(this.rearRightFrictionPenalty=!1,this.rearRightFrictionLerping=!1,this.m_backRightWheel.frictionSlip=this.m_backRightWheel.defaultFriction)}!0===this._skidFrictionRestorePending&&this._skidReleaseBrakeTimer<=0&&!0===this.isWheelFrictionAtDefault()&&(this._skidFrictionRestorePending=!1),!0===this._burnoutResidualFrictionRestorePending&&this.restoreTimer<=0&&this._burnoutExitFrictionRampTimer<=0&&!0===this.isWheelFrictionAtDefault()&&(this._burnoutResidualFrictionRestorePending=!1)},i.prototype.armBurnoutExitSmoothing=function(e){void 0===e&&(e=!1);var t=Math.max(this.burnoutExitArcadeFadeTime,.12),i=Math.max(this.burnoutExitFrictionRampTime,.25);this._burnoutResidualFrictionRestorePending=!0,this._burnoutExitArcadeFadeTimer=Math.max(this._burnoutExitArcadeFadeTimer,t),(!0===e||this.restoreTimer<=0)&&(this._burnoutExitFrictionRampTimer=Math.max(this._burnoutExitFrictionRampTimer,i))},i.prototype.clearBurnoutExitSmoothing=function(){this._burnoutExitArcadeFadeTimer=0,this._burnoutExitFrictionRampTimer=0,this._burnoutExitArcadeReleaseTimer=0},i.prototype.getFrontLeftWheelContact=function(){return this.frontLeftContact},i.prototype.getFrontRightWheelContact=function(){return this.frontRightContact},i.prototype.getRearLeftWheelContact=function(){return this.rearLeftContact},i.prototype.getRearRightWheelContact=function(){return this.rearRightContact},i.prototype.getFrontLeftWheelContactTag=function(){return this.frontLeftContactTag},i.prototype.getFrontRightWheelContactTag=function(){return this.frontRightContactTag},i.prototype.getRearLeftWheelContactTag=function(){return this.rearLeftContactTag},i.prototype.getRearRightWheelContactTag=function(){return this.rearRightContactTag},i.prototype.getFrontLeftWheelContactPoint=function(){return this.frontLeftContactPoint},i.prototype.getFrontRightWheelContactPoint=function(){return this.frontRightContactPoint},i.prototype.getRearLeftWheelContactPoint=function(){return this.rearLeftContactPoint},i.prototype.getRearRightWheelContactPoint=function(){return this.rearRightContactPoint},i.prototype.getFrontLeftWheelContactNormal=function(){return this.frontLeftContactNormal},i.prototype.getFrontRightWheelContactNormal=function(){return this.frontRightContactNormal},i.prototype.getRearLeftWheelContactNormal=function(){return this.rearLeftContactNormal},i.prototype.getRearRightWheelContactNormal=function(){return this.rearRightContactNormal},i.DEFAULT_SKID_FACTOR=1,i.DEFAULT_PITCH_FACTOR=1,i.DEFAULT_SPEED_FACTOR=1,i.DEFAULT_DONUT_FACTOR=1,i.DEFAULT_BRAKE_DEADZONE=.5,i.SimplexNoise2D=n.SimplexNoise.createNoise2D(),i}(n.ScriptComponent);e.StandardCarController=t}(r||(r={})),function(e){var t=function(t){function i(e,i,r,o){void 0===r&&(r={}),void 0===o&&(o="PROJECT.VehicleCameraManager");var a=t.call(this,e,i,r,o)||this;return a.enableCamera=!1,a.followTarget=!1,a.followHeight=1.25,a.pitchingAngle=0,a.rotationDamping=5,a.minimumDistance=4,a.maximumDistance=5,a.buttonCamera=BABYLON.Xbox360Button.Y,a.keyboardCamera=n.UserInputKey.P,a.tickRemoteEntities=!1,a.fastMotionBlur=!1,a.lowSpeedBlurring=0,a.highSpeedBlurring=20,a.motionBlurSamples=32,a.isObjectBasedBlur=!0,a.fastCameraShake=!1,a.lowSpeedShaking=1,a.highSpeedShaking=1,a.autoAttachCamera=!1,a.firstPerson=!1,a.cameraPivot=null,a.targetEulers=BABYLON.Vector3.Zero(),a.cameraRotation=BABYLON.Quaternion.Zero(),a.cameraPivotOffset=BABYLON.Vector3.Zero(),a.motionBlurAttached=!1,a.m_freeCamera=null,a.m_motionBlur=null,a.m_cameraTransform=null,a.m_inputController=null,a.m_standardController=null,a.m_firstPersonOffset=new BABYLON.Vector3(0,1.15,.15),a}return o(i,t),i.prototype.awake=function(){this.awakeCameraManager()},i.prototype.start=function(){this.initCameraManager()},i.prototype.late=function(){this.lateUpdateCameraManager()},i.prototype.destroy=function(){this.destroyCameraManager()},i.prototype.awakeCameraManager=function(){this.enableCamera=this.getProperty("enableCamera",this.enableCamera),this.followTarget=this.getProperty("followTarget",this.followTarget),this.followHeight=this.getProperty("followHeight",this.followHeight),this.pitchingAngle=this.getProperty("pitchingAngle",this.pitchingAngle),this.rotationDamping=this.getProperty("rotationDamping",this.rotationDamping),this.minimumDistance=this.getProperty("minimumDistance",this.minimumDistance),this.maximumDistance=this.getProperty("maximumDistance",this.maximumDistance),this.autoAttachCamera=this.getProperty("attachCamera",this.autoAttachCamera),this.tickRemoteEntities=this.getProperty("tickRemoteEntities",this.tickRemoteEntities),this.fastMotionBlur=this.getProperty("fastMotionBlur",this.fastMotionBlur),this.lowSpeedBlurring=this.getProperty("lowSpeedBlurring",this.lowSpeedBlurring),this.highSpeedBlurring=this.getProperty("highSpeedBlurring",this.highSpeedBlurring),this.motionBlurSamples=this.getProperty("motionBlurSamples",this.motionBlurSamples),this.isObjectBasedBlur=this.getProperty("isObjectBasedBlur",this.isObjectBasedBlur),this.fastCameraShake=this.getProperty("fastCameraShake",this.fastCameraShake),this.lowSpeedShaking=this.getProperty("lowSpeedShaking",this.lowSpeedShaking),this.highSpeedShaking=this.getProperty("highSpeedShaking",this.highSpeedShaking);var e=this.getProperty("firstPersonOffset");null!=e&&(this.m_firstPersonOffset=n.Utilities.ParseVector3(e)),this.rotationDamping<=0&&(this.rotationDamping=1)},i.prototype.initCameraManager=function(){var e=this;this.m_standardController=this.getComponent("PROJECT.StandardCarController"),this.m_inputController=this.getComponent("PROJECT.VehicleInputController"),null!=this.m_inputController&&(n.InputController.OnKeyboardPress(this.keyboardCamera,function(){e.togglePlayerCamera()}),n.InputController.OnGamepadButtonPress(this.buttonCamera,function(){e.togglePlayerCamera()}))},i.prototype.lateUpdateCameraManager=function(){null==this.m_cameraTransform&&!0===this.autoAttachCamera&&null!=this.m_inputController&&this.attachPlayerCamera(this.m_inputController.playerNumber),!0===this.firstPerson?this.firstPersonCamera():this.thirdPersonCamera(),null!=this.m_freeCamera&&null!=this.m_motionBlur&&null!=this.m_standardController&&(this.m_standardController.isBoosting()?(!1===this.motionBlurAttached&&(this.m_freeCamera.attachPostProcess(this.m_motionBlur),this.motionBlurAttached=!0),this.m_motionBlur.motionStrength=BABYLON.Scalar.Lerp(this.lowSpeedBlurring,this.highSpeedBlurring,this.m_standardController.getGradientSpeed())):(this.m_motionBlur.motionStrength=this.lowSpeedBlurring,!0===this.motionBlurAttached&&(this.m_freeCamera.detachPostProcess(this.m_motionBlur),this.motionBlurAttached=!1)))},i.prototype.destroyCameraManager=function(){this.m_standardController=null,this.m_cameraTransform=null},i.prototype.attachPlayerCamera=function(t){if(null==this.m_cameraTransform){var i=t<=0||t>4?1:t;if(this.m_freeCamera=e.DefaultCameraSystem.GetMainCamera(this.scene),this.m_cameraTransform=e.DefaultCameraSystem.GetCameraTransform(this.scene,i),null!=this.m_cameraTransform&&!0===this.followTarget&&(null==this.cameraPivot&&(this.cameraPivot=new BABYLON.TransformNode(this.transform.name+".CameraPivot",this.scene),this.cameraPivot.parent=null,this.cameraPivot.position=this.transform.position.clone(),this.cameraPivot.rotationQuaternion=this.transform.rotationQuaternion.clone()),this.m_cameraTransform.parent=this.cameraPivot,this.m_cameraTransform.position.set(0,0,0),this.m_cameraTransform.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1)),null==this.m_motionBlur&&null!=this.m_freeCamera&&!0===this.fastMotionBlur){try{this.m_motionBlur=new BABYLON.MotionBlurPostProcess("FastMotionBlur",this.scene,1,this.m_freeCamera)}catch(e){console.warn(e)}try{null!=this.m_motionBlur&&(this.m_freeCamera.detachPostProcess(this.m_motionBlur),this.m_motionBlur.isObjectBased=this.isObjectBasedBlur,this.m_motionBlur.motionStrength=this.lowSpeedBlurring,this.m_motionBlur.motionBlurSamples=this.motionBlurSamples,this.motionBlurAttached=!1)}catch(e){console.warn(e)}}}},i.prototype.togglePlayerCamera=function(){this.firstPerson=!this.firstPerson},i.prototype.firstPersonCamera=function(){!0===this.enableCamera&&null!=this.m_cameraTransform&&null!=this.m_standardController&&(!0===this.followTarget?null!=this.cameraPivot&&(n.Utilities.GetAbsolutePositionToRef(this.transform,this.cameraPivot.position),this.cameraPivot.rotationQuaternion.copyFrom(this.transform.rotationQuaternion),this.m_cameraTransform.position.copyFrom(this.m_firstPersonOffset),n.Utilities.FromEulerToRef(0,0,0,this.m_cameraTransform.rotationQuaternion)):this.m_cameraTransform.lookAt(this.transform.position))},i.prototype.thirdPersonCamera=function(){if(!0===this.enableCamera&&null!=this.m_cameraTransform&&null!=this.m_standardController)if(!0===this.followTarget){if(null!=this.cameraPivot){var e=this.getDeltaSeconds();this.cameraPivotOffset.set(0,this.followHeight,0),n.Utilities.GetAbsolutePositionToRef(this.transform,this.cameraPivot.position,this.cameraPivotOffset);var t=e*this.rotationDamping;this.transform.rotationQuaternion.toEulerAnglesToRef(this.targetEulers),BABYLON.Quaternion.FromEulerAnglesToRef(this.targetEulers.x+BABYLON.Tools.ToRadians(this.pitchingAngle),this.targetEulers.y,0,this.cameraRotation),BABYLON.Quaternion.SlerpToRef(this.cameraPivot.rotationQuaternion,this.cameraRotation,t,this.cameraPivot.rotationQuaternion);var i=BABYLON.Scalar.Lerp(this.minimumDistance,this.maximumDistance,this.m_standardController.getGradientSpeed());this.m_cameraTransform.position.set(0,0,-i)}}else this.m_cameraTransform.lookAt(this.transform.position)},i}(n.ScriptComponent);e.VehicleCameraManager=t,n.SceneManager.RegisterClass("PROJECT.VehicleCameraManager",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,r,o){void 0===r&&(r={}),void 0===o&&(o="PROJECT.VehicleInputController");var a=e.call(this,t,i,r,o)||this;return a.playerDeltaX=0,a.playerDeltaY=0,a.playerMouseX=0,a.playerMouseY=0,a.ackermanRadius=.85,a.autoturnRadius=.85,a.recoveryRadius=.25,a.waypointPosition=BABYLON.Vector3.Zero(),a.waypointCount=0,a.waypointIndex=0,a.noMovementTime=0,a.reverseFixMode=!1,a.recoveryFixMode=!1,a.nextTargetSpeed=0,a.prevTargetSpeed=0,a.vehicleResetCheck=0,a.randomSkillFactor=0,a.showChaseRabbit=!1,a.showSensorLines=!1,a.steeringWheelMode=-1,a.rabbitTrackerLine=null,a.rabbitTrackerColor=new BABYLON.Color3(1,1,1),a.greenTrackingColor=new BABYLON.Color3(0,1,0),a.redTrackingColor=new BABYLON.Color3(1,0,0),a.localTargetPosition=new BABYLON.Vector3(0,0,0),a.avoidPositionOffset=new BABYLON.Vector3(0,0,0),a.avoidanceLerp=0,a.avoidanceTimer=0,a.avoidanceValue=0,a._avoidanceSteerSmoothed=0,a._debugAvoidanceCounter=0,a._frontThreatHit=!1,a._frontThreatDistance=0,a._frontThreatSensor="",a._frontThreatTag="",a.randomTurning=0,a.randomBoosting=0,a.randomDistance=0,a.lastCheckpoint=-1,a.mainCenterSensorLine=null,a.mainRightSensorLine=null,a.mainLeftSensorLine=null,a.angleRightSensorLine=null,a.angleLeftSensorLine=null,a.sideRightSensorLine=null,a.sideLeftSensorLine=null,a.backRightSensorLine=null,a.backLeftSensorLine=null,a.sidewaysOffsetVector=BABYLON.Vector3.Zero(),a.backBumperEdgeVector=BABYLON.Vector3.Zero(),a.sensorStartPos=BABYLON.Vector3.Zero(),a.sensorPointPos=BABYLON.Vector3.Zero(),a.sensorAnglePos=BABYLON.Vector3.Zero(),a.rsideStartPos=BABYLON.Vector3.Zero(),a.rsidePointPos=BABYLON.Vector3.Zero(),a.lsideStartPos=BABYLON.Vector3.Zero(),a.lsidePointPos=BABYLON.Vector3.Zero(),a.tempScaleVector=BABYLON.Vector3.Zero(),a.rbackStartPos=BABYLON.Vector3.Zero(),a.rbackPointPos=BABYLON.Vector3.Zero(),a.lbackStartPos=BABYLON.Vector3.Zero(),a.lbackPointPos=BABYLON.Vector3.Zero(),a.trackVehiclePosition=BABYLON.Vector3.Zero(),a.trackRabbitPosition=BABYLON.Vector3.Zero(),a.enableInput=!1,a.resetTiming=3,a.playerNumber=n.PlayerNumber.One,a.pedelForward=7,a.triggerForward=n.Xbox360Trigger.Right,a.keyboardForawrd=n.UserInputKey.W,a.auxKeyboardForawrd=n.UserInputKey.UpArrow,a.pedalBackward=6,a.triggerBackwards=n.Xbox360Trigger.Left,a.keyboardBackwards=n.UserInputKey.S,a.auxKeyboardBackwards=n.UserInputKey.DownArrow,a.pedalBooster=1,a.keyboardBooster=n.UserInputKey.Ctrl,a.leftButtonBooster=BABYLON.Xbox360Button.LB,a.rightButtonBooster=BABYLON.Xbox360Button.RB,a.buttonHandbrake=BABYLON.Xbox360Button.X,a.keyboardHandbrake=n.UserInputKey.SpaceBar,a.leftWheelHandbrake=4,a.rightWheelHandbrake=5,a.keyboardBurnout=n.UserInputKey.Shift,a.buttonBurnout=BABYLON.Xbox360Button.B,a.leftWheelBurnout=10,a.rightWheelBurnout=11,a.keyboardDonut=n.UserInputKey.Alt,a.buttonDonut=BABYLON.Xbox360Button.LeftStick,a.leftWheelDonut=12,a.rightWheelDonut=13,a.raceLineNode=0,a.minLookAhead=5,a.maxLookAhead=50,a.driverSkillLevel=1,a.chaseRabbitSpeed=1,a.throttleSensitivity=1,a.steeringSensitivity=1,a.brakingSensitivity=1,a.brakingTurnAngle=15,a.brakingSpeedLimit=90,a.skiddingSpeedLimit=100,a.linearDampenForce=.1,a.driveSpeedMultiplier=5,a.driveLineDistance=1,a.resetMovingTimeout=3,a.reverseThrottleTime=3,a.maxRaceTrackSpeed=0,a.trackManagerIdentity="TrackManager",a.vehicleTag="Vehicle",a.obstacleTag="Obstacle",a.sensorLength=12,a.spacerWidths=.85,a.angleFactors=1.5,a.initialOffsetX=1,a.initialOffsetY=.5,a.initialOffsetZ=2,a.sidewaysLength=1.5,a.sidewaysOffset=.5,a.backBumperEdge=2.5,a.powerBoosting=.5,a.wonderDistance=1,a.avoidanceFactor=.5,a.avoidanceSpeed=3,a.avoidanceTimeout=3,a.avoidanceDistance=2,a.avoidanceSteeringGain=.6,a.avoidanceSteeringGainHigh=.3,a.avoidanceSteerSmoothing=.2,a.avoidanceSteerDeadband=.2,a.frontSlowdownGain=.75,a.frontSlowdownMinThrottle=.1,a.frontBrakeProximity=.45,a.frontBrakeForce=.7,a.frontHardBrakeProximity=.75,a.frontHardBrakeStrength=.8,a.avoidanceProximityBoost=1.5,a.avoidanceSteerCarryover=.5,a.debugAvoidance=!0,a.debugAvoidanceEveryNFrames=30,a.reversingFlag=!1,a.reversingTime=0,a.reversingWait=2,a.reversingFor=1.5,a.m_chasePointMesh=null,a.m_chaseRabbitMesh=null,a.m_circuitInterfaces=null,a.m_circuitRaceLine_1=null,a.m_circuitRaceLine_2=null,a.m_circuitRaceLine_3=null,a.m_circuitRaceLine_4=null,a.m_circuitRaceLine_5=null,a.m_rigidbodyPhysics=null,a.m_checkpointManager=null,a.m_standardCarController=null,a.autoDriveRaycastResult=new BABYLON.PhysicsRaycastResult,a}return o(t,e),t.prototype.getPlayerDeltaX=function(){return this.playerDeltaX},t.prototype.getPlayerDeltaY=function(){return this.playerDeltaY},t.prototype.getPlayerMouseX=function(){return this.playerMouseX},t.prototype.getPlayerMouseY=function(){return this.playerMouseY},t.prototype.getWaypointIndex=function(){return this.waypointIndex},t.prototype.getChaseRabbitMesh=function(){return this.m_chaseRabbitMesh},t.prototype.resetChaseRabbitMesh=function(){null!=this.m_chaseRabbitMesh&&(this.m_chaseRabbitMesh.position=this.transform.position.clone(),this.m_chaseRabbitMesh.rotationQuaternion=this.transform.rotationQuaternion.clone())},t.prototype.getChasePointMesh=function(){return this.m_chasePointMesh},t.prototype.resetChasePointMesh=function(){null!=this.m_chasePointMesh&&(this.m_chasePointMesh.position=this.transform.position.clone(),this.m_chasePointMesh.rotationQuaternion=this.transform.rotationQuaternion.clone())},t.prototype.awake=function(){this.awakeVehicleController()},t.prototype.start=function(){this.initVehicleController()},t.prototype.update=function(){this.updateVehicleController()},t.prototype.destroy=function(){this.destroyVehicleController()},t.prototype.awakeVehicleController=function(){var e=this;this.enableInput=this.getProperty("enableInput",this.enableInput),this.resetTiming=this.getProperty("resetTiming",this.resetTiming),this.playerNumber=this.getProperty("playerNumber",this.playerNumber),this.ackermanRadius=this.getProperty("ackermanRadius",this.ackermanRadius),this.autoturnRadius=this.getProperty("autoturnRadius",this.autoturnRadius),this.recoveryRadius=this.getProperty("recoveryRadius",this.recoveryRadius),this.showChaseRabbit=this.getProperty("showChaseRabbit",this.showChaseRabbit),this.showSensorLines=this.getProperty("showSensorLines",this.showSensorLines),this.minLookAhead=this.getProperty("minLookAhead",this.minLookAhead),this.maxLookAhead=this.getProperty("maxLookAhead",this.maxLookAhead),this.driverSkillLevel=this.getProperty("driverSkillLevel",this.driverSkillLevel),this.throttleSensitivity=this.getProperty("throttleSensitivity",this.throttleSensitivity),this.steeringSensitivity=this.getProperty("steeringSensitivity",this.steeringSensitivity),this.brakingSensitivity=this.getProperty("brakingSensitivity",this.brakingSensitivity),this.brakingTurnAngle=this.getProperty("brakingTurnAngle",this.brakingTurnAngle),this.brakingSpeedLimit=this.getProperty("brakingSpeedLimit",this.brakingSpeedLimit),this.skiddingSpeedLimit=this.getProperty("skiddingSpeedLimit",this.skiddingSpeedLimit),this.linearDampenForce=this.getProperty("linearDampenForce",this.linearDampenForce),this.resetMovingTimeout=this.getProperty("resetMovingTimeout",this.resetMovingTimeout),this.reverseThrottleTime=this.getProperty("reverseThrottleTime",this.reverseThrottleTime),this.driveSpeedMultiplier=this.getProperty("driveSpeedMultiplier",this.driveSpeedMultiplier),this.driveLineDistance=this.getProperty("driveLineDistance",this.driveLineDistance),this.maxRaceTrackSpeed=this.getProperty("maxRaceTrackSpeed",this.maxRaceTrackSpeed),this.trackManagerIdentity=this.getProperty("trackManagerIdentity",this.trackManagerIdentity),this.vehicleTag=this.getProperty("vehicleTag",this.vehicleTag),this.obstacleTag=this.getProperty("obstacleTag",this.obstacleTag),this.sensorLength=this.getProperty("sensorLength",this.sensorLength),this.spacerWidths=this.getProperty("spacerWidths",this.spacerWidths),this.angleFactors=this.getProperty("angleFactors",this.angleFactors),this.initialOffsetX=this.getProperty("initialOffsetX",this.initialOffsetX),this.initialOffsetY=this.getProperty("initialOffsetY",this.initialOffsetY),this.initialOffsetZ=this.getProperty("initialOffsetZ",this.initialOffsetZ),this.sidewaysLength=this.getProperty("sidewaysLength",this.sidewaysLength),this.sidewaysOffset=this.getProperty("sidewaysOffset",this.sidewaysOffset),this.backBumperEdge=this.getProperty("backBumperEdge",this.backBumperEdge),this.powerBoosting=this.getProperty("powerBoosting",this.powerBoosting),this.wonderDistance=this.getProperty("wonderDistance",this.wonderDistance),this.avoidanceFactor=this.getProperty("avoidanceFactor",this.avoidanceFactor),this.avoidanceSpeed=this.getProperty("avoidanceSpeed",this.avoidanceSpeed),this.avoidanceTimeout=this.getProperty("avoidanceTimeout",this.avoidanceTimeout),this.avoidanceDistance=this.getProperty("avoidanceDistance",this.avoidanceDistance),this.avoidanceSteeringGain=this.getProperty("avoidanceSteeringGain",this.avoidanceSteeringGain),this.avoidanceSteeringGainHigh=this.getProperty("avoidanceSteeringGainHigh",this.avoidanceSteeringGainHigh),this.avoidanceSteerSmoothing=this.getProperty("avoidanceSteerSmoothing",this.avoidanceSteerSmoothing),this.avoidanceSteerDeadband=this.getProperty("avoidanceSteerDeadband",this.avoidanceSteerDeadband),this.frontSlowdownGain=this.getProperty("frontSlowdownGain",this.frontSlowdownGain),this.frontSlowdownMinThrottle=this.getProperty("frontSlowdownMinThrottle",this.frontSlowdownMinThrottle),this.frontBrakeProximity=this.getProperty("frontBrakeProximity",this.frontBrakeProximity),this.frontBrakeForce=this.getProperty("frontBrakeForce",this.frontBrakeForce),this.frontHardBrakeProximity=this.getProperty("frontHardBrakeProximity",this.frontHardBrakeProximity),this.frontHardBrakeStrength=this.getProperty("frontHardBrakeStrength",this.frontHardBrakeStrength),this.avoidanceProximityBoost=this.getProperty("avoidanceProximityBoost",this.avoidanceProximityBoost),this.avoidanceSteerCarryover=this.getProperty("avoidanceSteerCarryover",this.avoidanceSteerCarryover),this.debugAvoidance=this.getProperty("debugAvoidance",this.debugAvoidance),this.debugAvoidanceEveryNFrames=this.getProperty("debugAvoidanceEveryNFrames",this.debugAvoidanceEveryNFrames),this.ackermanRadius<=0&&(this.ackermanRadius=1),this.autoturnRadius<=0&&(this.autoturnRadius=1),this.recoveryRadius<=0&&(this.recoveryRadius=1),this.resetMovingTimeout<=0&&(this.resetMovingTimeout=3),this.reverseThrottleTime<=0&&(this.reverseThrottleTime=3),this.throttleSensitivity<=0&&(this.throttleSensitivity=1),this.steeringSensitivity<=0&&(this.steeringSensitivity=1),this.brakingSensitivity<=0&&(this.brakingSensitivity=1),this.linearDampenForce<=0&&(this.linearDampenForce=.1),this.angleFactors<=0&&(this.angleFactors=1.5),this.sensorLength<=0&&(this.sensorLength=12),this.sidewaysLength<=0&&(this.sidewaysLength=1),this.brakingSpeedLimit<=0&&(this.brakingSpeedLimit=40),this.skiddingSpeedLimit<=0&&(this.skiddingSpeedLimit=80),this.driveSpeedMultiplier<=1&&(this.driveSpeedMultiplier=5),null!=this.trackManagerIdentity&&""!==this.trackManagerIdentity||(this.trackManagerIdentity="TrackManager");var t=this.getProperty("initialRaceLineNode",1);this.raceLineNode=t-1;var i=1e3*this.getRandomNumber(10,15);n.WindowManager.SetInterval(i,function(){e.randomSkillFactor=e.getRandomNumber(1,20)})},t.prototype.initVehicleController=function(){var e=this;this.m_rigidbodyPhysics=this.getComponent("TOOLKIT.RigidbodyPhysics"),this.m_checkpointManager=this.getComponent("PROJECT.CheckpointManager"),null!=this.m_rigidbodyPhysics?(this.m_rigidbodyPhysics.onCollisionEnterObservable.add(function(t){n.SceneManager.GetTransformTag(t),e.vehicleTag}),this.m_rigidbodyPhysics.onCollisionStayObservable.add(function(t){null!=t&&(n.SceneManager.GetTransformTag(t),e.vehicleTag)}),this.m_rigidbodyPhysics.onCollisionExitObservable.add(function(t){null!=t&&(n.SceneManager.GetTransformTag(t),e.vehicleTag)})):n.SceneManager.LogWarning("Null rigidbody physics for: "+this.transform.name),this.m_standardCarController=this.getComponent("PROJECT.StandardCarController");var t=n.SceneManager.GetTransformNode(this.scene,this.trackManagerIdentity);if(null!=t){var i=n.SceneManager.FindScriptComponent(t,"PROJECT.RaceTrackManager");null!=i?(this.waypointCount=0,this.waypointIndex=0,this.m_circuitInterfaces=i.getTrackNodes(),this.m_circuitRaceLine_1=i.getControlPoints(0),this.m_circuitRaceLine_2=i.getControlPoints(1),this.m_circuitRaceLine_3=i.getControlPoints(2),this.m_circuitRaceLine_4=i.getControlPoints(3),this.m_circuitRaceLine_5=i.getControlPoints(4),null!=this.m_circuitInterfaces&&this.m_circuitInterfaces.length>0&&(this.waypointCount=this.m_circuitInterfaces.length)):n.SceneManager.LogWarning("Fail to locate race track manager for: "+this.transform.name)}else n.SceneManager.LogWarning("Fail to locate race track manager '"+this.trackManagerIdentity+"' for: "+this.transform.name)},t.prototype.updateVehicleController=function(){if(!0===this.enableInput&&(0===this.playerNumber?this.updateAutoPilotDrive():this.updateManualInputDrive()),this.resetTiming>0&&null!=this.m_standardCarController){var e=n.SceneManager.GetGameTime();(this.transform.up.y>.5||this.m_standardCarController.getAbsoluteSpeed()>1)&&(this.vehicleResetCheck=e),e>this.vehicleResetCheck+this.resetTiming&&(this.transform.position.addInPlace(BABYLON.Vector3.Up().scale(.5)),n.Utilities.LookRotationToRef(this.transform.forward,this.transform.rotationQuaternion))}},t.prototype.updateManualInputDrive=function(){if(null!=this.m_standardCarController){this.playerDeltaX=n.InputController.GetUserInput(n.UserInputAxis.Horizontal,this.playerNumber),this.playerDeltaY=n.InputController.GetUserInput(n.UserInputAxis.Vertical,this.playerNumber),this.playerMouseX=n.InputController.GetUserInput(n.UserInputAxis.MouseX,this.playerNumber),this.playerMouseY=n.InputController.GetUserInput(n.UserInputAxis.MouseY,this.playerNumber);var e,t,i,r,o,a=n.InputController.GetKeyboardInput(this.auxKeyboardForawrd),s=n.InputController.GetKeyboardInput(this.keyboardForawrd),l=n.InputController.GetGamepadTriggerInput(this.triggerForward,this.playerNumber),u=n.InputController.GetGamepadButtonInput(this.pedelForward,this.playerNumber),h=n.InputController.GetKeyboardInput(this.auxKeyboardBackwards),c=n.InputController.GetKeyboardInput(this.keyboardBackwards),d=n.InputController.GetGamepadTriggerInput(this.triggerBackwards,this.playerNumber),m=n.InputController.GetGamepadButtonInput(this.pedalBackward,this.playerNumber),p=n.InputController.GetGamepadButtonInput(this.pedalBooster,this.playerNumber),f=n.InputController.GetKeyboardInput(this.keyboardBooster),g=n.InputController.GetGamepadButtonInput(this.leftButtonBooster,this.playerNumber),y=n.InputController.GetGamepadButtonInput(this.rightButtonBooster,this.playerNumber),v=n.InputController.GetKeyboardInput(this.keyboardHandbrake),S=n.InputController.GetGamepadButtonInput(this.leftWheelHandbrake,this.playerNumber),_=n.InputController.GetGamepadButtonInput(this.rightWheelHandbrake,this.playerNumber),b=n.InputController.GetGamepadButtonInput(this.buttonHandbrake,this.playerNumber),B=n.InputController.GetKeyboardInput(this.keyboardBurnout),C=n.InputController.GetGamepadButtonInput(this.leftWheelBurnout,this.playerNumber),A=n.InputController.GetGamepadButtonInput(this.rightWheelBurnout,this.playerNumber),T=n.InputController.GetGamepadButtonInput(this.buttonBurnout,this.playerNumber),M=n.InputController.GetKeyboardInput(this.keyboardDonut),L=n.InputController.GetGamepadButtonInput(this.leftWheelDonut,this.playerNumber),P=n.InputController.GetGamepadButtonInput(this.rightWheelDonut,this.playerNumber),w=n.InputController.GetGamepadButtonInput(this.buttonDonut,this.playerNumber),x=0,O=!1;if(l>.2?x=l:!0===u?(x=1,O=!0):this.playerNumber!==n.PlayerNumber.One||!0!==s&&!0!==a?!0===n.InputController.AllowMobileControls&&!0===n.InputController.MobileControlsActive&&this.playerDeltaY>0&&(x=this.playerDeltaY):x=1,d>.2?x=-d:!0===m?(x=-1,O=!0):this.playerNumber!==n.PlayerNumber.One||!0!==c&&!0!==h?!0===n.InputController.AllowMobileControls&&!0===n.InputController.MobileControlsActive&&this.playerDeltaY<0&&(x=this.playerDeltaY):x=-1,e=this.playerDeltaX,t=!0===v||!0===b||!0===S||!0===_,i=!0===B||!0===T||!0===C||!0===A,r=!0===M||!0===w||!0===L||!0===P,o=!0===f||!0===g||!0===y||!0===p,-1===this.steeringWheelMode&&null!=n.UserInputOptions.SupportedInputDevices&&n.UserInputOptions.SupportedInputDevices.length>0){var R=n.InputController.GetGamepad(this.playerNumber);if(null!=R&&null!=R.id){for(var I=!1,N=0;N<n.UserInputOptions.SupportedInputDevices.length;N++){var k=n.UserInputOptions.SupportedInputDevices[N];if(null!=k&&null!=k.deviceName&&R.id.toLowerCase().indexOf(k.deviceName.toLowerCase())>=0){k.forwardButton>-1&&(this.pedelForward=k.forwardButton),k.backwardButton>-1&&(this.pedalBackward=k.backwardButton),k.leftHandBrake>-1&&(this.leftWheelHandbrake=k.leftHandBrake),k.rightHandBrake>-1&&(this.rightWheelHandbrake=k.rightHandBrake),k.leftBurnoutBoost>-1&&(this.leftWheelBurnout=k.leftBurnoutBoost),k.rightBurnoutBoost>-1&&(this.rightWheelBurnout=k.rightBurnoutBoost),k.leftDonutBoost>-1&&(this.leftWheelDonut=k.leftDonutBoost),k.rightDonutBoost>-1&&(this.rightWheelDonut=k.rightDonutBoost),I=!0,console.warn(R.id+" steering wheel controls attached to: "+this.transform.name);break}}this.steeringWheelMode=!0===I?1:0}}this.m_standardCarController.ackermanTurnFactor=!0===O?this.ackermanRadius:1,this.m_standardCarController.throttleEngineSpeed=0,this.m_standardCarController.throttleBrakingForce=0,this.m_standardCarController.drive(x,e,t,i,0,!1,o,r)}},t.prototype.updateAutoPilotDrive=function(){var e=this;if(null!=this.m_standardCarController){this.getGameTime();var t=this.getDeltaSeconds(),i=this.transform.getAbsolutePosition();this.raceLineNode=BABYLON.Scalar.Clamp(this.raceLineNode,0,4),null==this.m_chaseRabbitMesh&&(this.m_chaseRabbitMesh=BABYLON.MeshBuilder.CreateSphere(this.transform.name+".Rabbit",{segments:24,diameter:1},this.scene),this.m_chaseRabbitMesh.checkCollisions=!1,this.m_chaseRabbitMesh.receiveShadows=!1,this.m_chaseRabbitMesh.visibility=1,this.m_chaseRabbitMesh.isVisible=!1,this.resetChaseRabbitMesh()),null!=this.m_chaseRabbitMesh&&(!0===this.m_chaseRabbitMesh.isVisible&&!1===this.showChaseRabbit&&(this.m_chaseRabbitMesh.isVisible=!1),!1===this.m_chaseRabbitMesh.isVisible&&!0===this.showChaseRabbit&&(this.m_chaseRabbitMesh.isVisible=!0)),null==this.m_chasePointMesh&&(this.m_chasePointMesh=BABYLON.MeshBuilder.CreateBox(this.transform.name+".Point",{size:.9},this.scene),this.m_chasePointMesh.checkCollisions=!1,this.m_chasePointMesh.receiveShadows=!1,this.m_chasePointMesh.visibility=1,this.m_chasePointMesh.isVisible=!1,this.resetChasePointMesh()),null!=this.m_chasePointMesh&&(!0===this.m_chasePointMesh.isVisible&&!1===this.showChaseRabbit&&(this.m_chasePointMesh.isVisible=!1),!1===this.m_chasePointMesh.isVisible&&!0===this.showChaseRabbit&&(this.m_chasePointMesh.isVisible=!0)),this.avoidanceTimer>0&&(this.avoidanceTimer-=t,this.avoidanceTimer<=0&&(this.avoidanceTimer=0,this.avoidanceValue=0));var r="",o=!1,a=this.autoDriveRaycastResult,s=0,l=null!=this.transform?this.transform.physicsBody:null;this._frontThreatHit=!1,this._frontThreatDistance=0,this._frontThreatSensor="",this._frontThreatTag="",this.sidewaysOffsetVector.set(0,0,-this.sidewaysOffset),this.backBumperEdgeVector.set(0,0,-this.backBumperEdge),this.sensorStartPos.copyFrom(i),this.transform.up.scaleAndAddToRef(this.initialOffsetY,this.sensorStartPos),this.transform.forward.scaleAndAddToRef(this.initialOffsetZ,this.sensorStartPos),this.sensorPointPos.copyFrom(this.sensorStartPos),this.transform.forward.scaleAndAddToRef(this.sensorLength,this.sensorPointPos),this.sensorAnglePos.copyFrom(this.sensorPointPos),n.Utilities.GetAbsolutePositionToRef(this.transform,this.rsideStartPos,this.sidewaysOffsetVector),this.transform.up.scaleAndAddToRef(this.initialOffsetY,this.rsideStartPos),this.transform.right.scaleAndAddToRef(this.initialOffsetX,this.rsideStartPos),this.rsidePointPos.copyFrom(this.rsideStartPos),this.transform.right.scaleAndAddToRef(this.sidewaysLength,this.rsidePointPos),n.Utilities.GetAbsolutePositionToRef(this.transform,this.rbackStartPos,this.backBumperEdgeVector),this.transform.up.scaleAndAddToRef(this.initialOffsetY,this.rbackStartPos),this.transform.right.scaleAndAddToRef(this.initialOffsetX,this.rbackStartPos),this.rbackPointPos.copyFrom(this.rbackStartPos),this.transform.right.scaleAndAddToRef(this.sidewaysLength,this.rbackPointPos),n.Utilities.GetAbsolutePositionToRef(this.transform,this.lsideStartPos,this.sidewaysOffsetVector),this.transform.up.scaleAndAddToRef(this.initialOffsetY,this.lsideStartPos),this.transform.right.scaleAndAddToRef(-this.initialOffsetX,this.lsideStartPos),this.lsidePointPos.copyFrom(this.lsideStartPos),this.transform.right.scaleAndAddToRef(-this.sidewaysLength,this.lsidePointPos),n.Utilities.GetAbsolutePositionToRef(this.transform,this.lbackStartPos,this.backBumperEdgeVector),this.transform.up.scaleAndAddToRef(this.initialOffsetY,this.lbackStartPos),this.transform.right.scaleAndAddToRef(-this.initialOffsetX,this.lbackStartPos),this.lbackPointPos.copyFrom(this.lbackStartPos),this.transform.right.scaleAndAddToRef(-this.sidewaysLength,this.lbackPointPos);var u=this.sensorStartPos.clone(),h=this.sensorPointPos.clone(),c=!1;if(this.transform.right.scaleToRef(this.spacerWidths,this.tempScaleVector),this.sensorStartPos.addInPlace(this.tempScaleVector),this.sensorPointPos.addInPlace(this.tempScaleVector),r="",o=!1,a.reset(),n.RigidbodyPhysics.RaycastToRef(this.sensorStartPos,this.sensorPointPos,a),!0===a.hasHit&&null!=a.body&&a.body!==l&&null!=a.body.transformNode&&!0==(o=(r=n.SceneManager.GetTransformTag(a.body.transformNode))==this.vehicleTag||r===this.obstacleTag)){c=!0,s-=1;var d=a.hitDistance;(!1===this._frontThreatHit||d<this._frontThreatDistance)&&(this._frontThreatHit=!0,this._frontThreatDistance=d,this._frontThreatSensor="MainR",this._frontThreatTag=r)}!0===this.showSensorLines&&(null==this.mainRightSensorLine&&(this.mainRightSensorLine=new n.LinesMeshRenderer(this.transform.name+".MainRightSensorLine",this.scene)),!0===o?this.mainRightSensorLine.drawLine([this.sensorStartPos,a.hitPoint],BABYLON.Color3.Yellow()):this.mainRightSensorLine.drawLine([this.sensorStartPos,this.sensorPointPos],BABYLON.Color3.Blue()));var m=!1;this.transform.right.scaleToRef(2*this.spacerWidths*this.angleFactors,this.tempScaleVector),this.sensorAnglePos.addInPlace(this.tempScaleVector),r="",o=!1,a.reset(),n.RigidbodyPhysics.RaycastToRef(this.sensorStartPos,this.sensorAnglePos,a),!1===c&&!0===a.hasHit&&null!=a.body&&a.body!==l&&null!=a.body.transformNode&&!0==(o=(r=n.SceneManager.GetTransformTag(a.body.transformNode))==this.vehicleTag||r===this.obstacleTag)&&(m=!0,s-=.5,d=a.hitDistance,(!1===this._frontThreatHit||d<this._frontThreatDistance)&&(this._frontThreatHit=!0,this._frontThreatDistance=d,this._frontThreatSensor="AngR",this._frontThreatTag=r)),!0===this.showSensorLines&&(null==this.angleRightSensorLine&&(this.angleRightSensorLine=new n.LinesMeshRenderer(this.transform.name+".AngleRightSensorLine",this.scene)),!0===o?this.angleRightSensorLine.drawLine([this.sensorStartPos,a.hitPoint],BABYLON.Color3.Yellow()):this.angleRightSensorLine.drawLine([this.sensorStartPos,this.sensorAnglePos],BABYLON.Color3.Blue()));var p=!1;r="",o=!1,a.reset(),n.RigidbodyPhysics.RaycastToRef(this.rsideStartPos,this.rsidePointPos,a),!1===c&&!1===m&&!0===a.hasHit&&null!=a.body&&a.body!==l&&null!=a.body.transformNode&&!0==(o=(r=n.SceneManager.GetTransformTag(a.body.transformNode))==this.vehicleTag||r===this.obstacleTag)&&(p=!0,s-=.5),!0===this.showSensorLines&&(null==this.sideRightSensorLine&&(this.sideRightSensorLine=new n.LinesMeshRenderer(this.transform.name+".SideRightSensorLine",this.scene)),!0===o?this.sideRightSensorLine.drawLine([this.rsideStartPos,a.hitPoint],BABYLON.Color3.Yellow()):this.sideRightSensorLine.drawLine([this.rsideStartPos,this.rsidePointPos],BABYLON.Color3.Blue())),r="",o=!1,a.reset(),n.RigidbodyPhysics.RaycastToRef(this.rbackStartPos,this.rbackPointPos,a),!1===c&&!1===m&&!1===p&&!0===a.hasHit&&null!=a.body&&a.body!==l&&null!=a.body.transformNode&&!0==(o=(r=n.SceneManager.GetTransformTag(a.body.transformNode))==this.vehicleTag||r===this.obstacleTag)&&(s-=.5),!0===this.showSensorLines&&(null==this.backRightSensorLine&&(this.backRightSensorLine=new n.LinesMeshRenderer(this.transform.name+".BackRightSensorLine",this.scene)),!0===o?this.backRightSensorLine.drawLine([this.rbackStartPos,a.hitPoint],BABYLON.Color3.Yellow()):this.backRightSensorLine.drawLine([this.rbackStartPos,this.rbackPointPos],BABYLON.Color3.Blue()));var f=!1;this.transform.right.scaleToRef(-2*this.spacerWidths,this.tempScaleVector),this.sensorStartPos.addInPlace(this.tempScaleVector),this.sensorPointPos.addInPlace(this.tempScaleVector),r="",o=!1,a.reset(),n.RigidbodyPhysics.RaycastToRef(this.sensorStartPos,this.sensorPointPos,a),!0===a.hasHit&&null!=a.body&&a.body!==l&&null!=a.body.transformNode&&!0==(o=(r=n.SceneManager.GetTransformTag(a.body.transformNode))==this.vehicleTag||r===this.obstacleTag)&&(f=!0,s+=1,d=a.hitDistance,(!1===this._frontThreatHit||d<this._frontThreatDistance)&&(this._frontThreatHit=!0,this._frontThreatDistance=d,this._frontThreatSensor="MainL",this._frontThreatTag=r)),!0===this.showSensorLines&&(null==this.mainLeftSensorLine&&(this.mainLeftSensorLine=new n.LinesMeshRenderer(this.transform.name+".MainLeftSensorLine",this.scene)),!0===o?this.mainLeftSensorLine.drawLine([this.sensorStartPos,a.hitPoint],BABYLON.Color3.Yellow()):this.mainLeftSensorLine.drawLine([this.sensorStartPos,this.sensorPointPos],BABYLON.Color3.Blue()));var g=!1;this.transform.right.scaleToRef(-4*this.spacerWidths*this.angleFactors,this.tempScaleVector),this.sensorAnglePos.addInPlace(this.tempScaleVector),r="",o=!1,a.reset(),n.RigidbodyPhysics.RaycastToRef(this.sensorStartPos,this.sensorAnglePos,a),!1===f&&!0===a.hasHit&&null!=a.body&&a.body!==l&&null!=a.body.transformNode&&!0==(o=(r=n.SceneManager.GetTransformTag(a.body.transformNode))==this.vehicleTag||r===this.obstacleTag)&&(g=!0,s+=.5,d=a.hitDistance,(!1===this._frontThreatHit||d<this._frontThreatDistance)&&(this._frontThreatHit=!0,this._frontThreatDistance=d,this._frontThreatSensor="AngL",this._frontThreatTag=r)),!0===this.showSensorLines&&(null==this.angleLeftSensorLine&&(this.angleLeftSensorLine=new n.LinesMeshRenderer(this.transform.name+".AngleLeftSensorLine",this.scene)),!0===o?this.angleLeftSensorLine.drawLine([this.sensorStartPos,a.hitPoint],BABYLON.Color3.Yellow()):this.angleLeftSensorLine.drawLine([this.sensorStartPos,this.sensorAnglePos],BABYLON.Color3.Blue()));var y=!1;if(r="",o=!1,a.reset(),n.RigidbodyPhysics.RaycastToRef(this.lsideStartPos,this.lsidePointPos,a),!1===f&&!1===g&&!0===a.hasHit&&null!=a.body&&a.body!==l&&null!=a.body.transformNode&&!0==(o=(r=n.SceneManager.GetTransformTag(a.body.transformNode))==this.vehicleTag||r===this.obstacleTag)&&(y=!0,s+=.5),!0===this.showSensorLines&&(null==this.sideLeftSensorLine&&(this.sideLeftSensorLine=new n.LinesMeshRenderer(this.transform.name+".SideLeftSensorLine",this.scene)),!0===o?this.sideLeftSensorLine.drawLine([this.lsideStartPos,a.hitPoint],BABYLON.Color3.Yellow()):this.sideLeftSensorLine.drawLine([this.lsideStartPos,this.lsidePointPos],BABYLON.Color3.Blue())),r="",o=!1,a.reset(),n.RigidbodyPhysics.RaycastToRef(this.lbackStartPos,this.lbackPointPos,a),!1===f&&!1===g&&!1===y&&!0===a.hasHit&&null!=a.body&&a.body!==l&&null!=a.body.transformNode&&!0==(o=(r=n.SceneManager.GetTransformTag(a.body.transformNode))==this.vehicleTag||r===this.obstacleTag)&&(s+=.5),!0===this.showSensorLines&&(null==this.backLeftSensorLine&&(this.backLeftSensorLine=new n.LinesMeshRenderer(this.transform.name+".BackLeftSensorLine",this.scene)),!0===o?this.backLeftSensorLine.drawLine([this.lbackStartPos,a.hitPoint],BABYLON.Color3.Yellow()):this.backLeftSensorLine.drawLine([this.lbackStartPos,this.lbackPointPos],BABYLON.Color3.Blue())),r="",o=!1,a.reset(),n.RigidbodyPhysics.RaycastToRef(u,h,a),0===s&&!0===a.hasHit&&null!=a.body&&a.body!==l&&null!=a.body.transformNode&&!0==(o=(r=n.SceneManager.GetTransformTag(a.body.transformNode))==this.vehicleTag||r===this.obstacleTag)&&(s=a.hitNormal.x<0?-1:1,d=a.hitDistance,(!1===this._frontThreatHit||d<this._frontThreatDistance)&&(this._frontThreatHit=!0,this._frontThreatDistance=d,this._frontThreatSensor="Center",this._frontThreatTag=r)),!0===this.showSensorLines&&(null==this.mainCenterSensorLine&&(this.mainCenterSensorLine=new n.LinesMeshRenderer(this.transform.name+".MainCenterSensorLine",this.scene)),!0===o?this.mainCenterSensorLine.drawLine([u,a.hitPoint],BABYLON.Color3.Yellow()):this.mainCenterSensorLine.drawLine([u,h],BABYLON.Color3.Blue())),!0===this.debugAvoidance){this._debugAvoidanceCounter++;var v=Math.max(1,0|this.debugAvoidanceEveryNFrames);if(this._debugAvoidanceCounter>=v){this._debugAvoidanceCounter=0;var S=(c?"MR ":"-- ")+(m?"AR ":"-- ")+(p?"SR ":"-- ")+(f?"ML ":"-- ")+(g?"AL ":"-- ")+(y?"SL ":"-- "),_=this._frontThreatHit?this._frontThreatSensor+"@"+this._frontThreatDistance.toFixed(2)+"m tag="+this._frontThreatTag:"none";console.log("[AVOID "+this.transform.name+"] avoid="+s.toFixed(2)+" sensors=["+S.trim()+"] front="+_+" timer="+this.avoidanceTimer.toFixed(2)+" lerp="+this.avoidanceLerp.toFixed(2))}}var b=this.getCurrentTrackNode(this.waypointIndex),B=this.getCurrentControlPoint(this.raceLineNode,this.waypointIndex);if(null!=this.m_chaseRabbitMesh&&this.waypointCount>0&&null!=b&&null!=B){this.waypointPosition.set(B.position.x,B.position.y,B.position.z);var C=(B.speed>0?B.speed:100)*this.getDriverSkillFactor(),A=1*b.radius,T=BABYLON.Vector3.Distance(this.waypointPosition,i);T<A?(this.prevTargetSpeed<=0&&(this.prevTargetSpeed=C),this.nextTargetSpeed=BABYLON.Scalar.Lerp(this.prevTargetSpeed,C,1-T/A),!0===this.showChaseRabbit&&(this.rabbitTrackerColor=this.redTrackingColor)):(this.nextTargetSpeed=C,!0===this.showChaseRabbit&&(this.rabbitTrackerColor=this.greenTrackingColor));var M=this.m_standardCarController.getGradientSpeed(),L=this.m_standardCarController.getAmericanSpeed(),P=this.m_standardCarController.getCurrentSkidding(),w=BABYLON.Scalar.Lerp(this.minLookAhead,this.maxLookAhead,M),x=this.m_chaseRabbitMesh.getAbsolutePosition();if(BABYLON.Vector3.Distance(i,x)<=w&&(this.chaseRabbitSpeed=BABYLON.Scalar.Lerp(1,this.driveSpeedMultiplier,M),this.m_chaseRabbitMesh.lookAt(this.waypointPosition),this.m_chaseRabbitMesh.translate(BABYLON.Axis.Z,this.chaseRabbitSpeed)),0!==s&&(this.avoidanceValue=s,this.avoidanceTimer=this.avoidanceTimeout),null!=this.m_checkpointManager){var O=this.m_checkpointManager.getCheckPoint();if(O!=this.lastCheckpoint){if(this.randomTurning=this.generateRandonNumber(0,3),this.powerBoosting>0&&(this.randomBoosting=this.generateRandonNumber(0,this.powerBoosting)),this.wonderDistance>0){var R=this.driveLineDistance,I=Math.sign(this.generateRandonNumber(-1,1));this.randomDistance=this.generateRandonNumber(R,R+this.wonderDistance)*I}this.lastCheckpoint=O}}else this.randomTurning=0,this.randomBoosting=0,this.randomDistance=0;var N=this.avoidanceTimer>0&&0!==this.avoidanceValue,k=N?this.avoidanceDistance*Math.sign(this.avoidanceValue):0;!1===N&&(k+=this.randomDistance),this.avoidanceLerp=BABYLON.Scalar.Lerp(this.avoidanceLerp,k,this.avoidanceSpeed*t),this.avoidPositionOffset.set(this.avoidanceLerp,0,0),n.Utilities.GetAbsolutePositionToRef(this.m_chaseRabbitMesh,this.m_chasePointMesh.position,this.avoidPositionOffset),!0===this.showChaseRabbit&&(this.trackVehiclePosition.set(i.x,i.y+.5,i.z),this.trackRabbitPosition.set(this.m_chasePointMesh.position.x,this.m_chasePointMesh.position.y+.25,this.m_chasePointMesh.position.z),null==this.rabbitTrackerLine&&(this.rabbitTrackerLine=new n.LinesMeshRenderer(this.transform.name+".TrackingLine",this.scene)),null!=this.rabbitTrackerLine&&this.rabbitTrackerLine.drawLine([this.trackVehiclePosition,this.trackRabbitPosition],this.rabbitTrackerColor)),BABYLON.Vector3.Distance(x,this.waypointPosition)<=5&&(this.prevTargetSpeed=this.nextTargetSpeed,this.waypointIndex++,this.waypointIndex>=this.waypointCount&&(this.waypointIndex=0)),n.Utilities.InverseTransformPointToRef(this.transform,this.m_chasePointMesh.position,this.localTargetPosition);var F=BABYLON.Tools.ToDegrees(Math.atan2(this.localTargetPosition.x,this.localTargetPosition.z)),D=BABYLON.Scalar.Clamp(Math.abs(F),0,90),E=D/90,V=0,Y=0,U=this.randomBoosting,W=this.maxRaceTrackSpeed,G=1*this.throttleSensitivity,H=BABYLON.Scalar.Clamp(F/45*this.steeringSensitivity,-1,1),z=s;0===z&&this.avoidanceTimer>0&&0!==this.avoidanceValue&&this.avoidanceSteerCarryover>0&&(z=this.avoidanceValue*this.avoidanceSteerCarryover);var K=1;!0===this._frontThreatHit&&this.avoidanceProximityBoost>0&&(K=1+BABYLON.Scalar.Clamp(1-this._frontThreatDistance/Math.max(.001,this.sensorLength),0,1)*this.avoidanceProximityBoost);var X=0;if(this.avoidanceFactor>0&&Math.abs(z)>this.avoidanceSteerDeadband){var Q=this.avoidanceSteeringGain*this.avoidanceFactor,j=this.avoidanceSteeringGainHigh*this.avoidanceFactor;X=z*BABYLON.Scalar.Lerp(Q,j,M)*K,X=BABYLON.Scalar.Clamp(X,-1,1)}var Z=Math.max(1e-4,this.avoidanceSteerSmoothing),J=1-Math.exp(-t/Z);this._avoidanceSteerSmoothed+=(X-this._avoidanceSteerSmoothed)*J,H+=this._avoidanceSteerSmoothed;var q=!1;if(this.nextTargetSpeed<=0&&(this.nextTargetSpeed=C),L>this.nextTargetSpeed&&(Y=BABYLON.Scalar.Lerp(0,this.linearDampenForce,M),G*=.2),this.brakingTurnAngle>0&&D>=this.brakingTurnAngle-this.randomTurning&&L>=this.brakingSpeedLimit){V=BABYLON.Scalar.Lerp(0,1+M,E),Y=0;var $=!0===P?this.brakingSpeedLimit:this.skiddingSpeedLimit;!0==(q=V>0&&L>=$)&&(V=1)}if(V>0&&(V=BABYLON.Scalar.Clamp(V*this.brakingSensitivity,0,1)),V>0&&(G=-V),!0===this._frontThreatHit&&this.frontSlowdownGain>0){var ee=BABYLON.Scalar.Clamp(1-this._frontThreatDistance/Math.max(.001,this.sensorLength),0,1);if(G>0&&(G*=BABYLON.Scalar.Clamp(1-ee*this.frontSlowdownGain,this.frontSlowdownMinThrottle,1)),ee>this.frontBrakeProximity&&this.frontBrakeForce>0){var te=(ee-this.frontBrakeProximity)/Math.max(.001,1-this.frontBrakeProximity),ie=BABYLON.Scalar.Clamp(te,0,1)*this.frontBrakeForce;Y=Math.max(Y,ie)}if(ee>this.frontHardBrakeProximity&&this.frontHardBrakeStrength>0){var ne=(ee-this.frontHardBrakeProximity)/Math.max(.001,1-this.frontHardBrakeProximity),re=-BABYLON.Scalar.Clamp(ne,0,1)*this.frontHardBrakeStrength;re<G&&(G=re)}!0===this.debugAvoidance&&0===this._debugAvoidanceCounter&&console.log("[AVOID "+this.transform.name+"] front-slowdown: dist="+this._frontThreatDistance.toFixed(2)+" prox="+ee.toFixed(2)+" throttle="+G.toFixed(2)+" slowdown="+Y.toFixed(2))}if(!0===this.reverseFixMode&&(G=-1,U=0,H=0,Y=0,q=!1),G>=.1&&L<2?this.noMovementTime+=t:this.noMovementTime=0,this.noMovementTime>=this.resetMovingTimeout){this.noMovementTime=0,this.reverseFixMode=!0,this.recoveryFixMode=!0;var oe=1e3*this.reverseThrottleTime,ae=1e3*this.reverseThrottleTime*3;n.WindowManager.SetTimeout(oe,function(){e.reverseFixMode=!1}),n.WindowManager.SetTimeout(ae,function(){e.recoveryFixMode=!1})}this.m_standardCarController.ackermanTurnFactor=!0===this.recoveryFixMode?this.recoveryRadius:this.autoturnRadius,this.m_standardCarController.throttleEngineSpeed=W,this.m_standardCarController.throttleBrakingForce=Y,this.m_standardCarController.drive(G,H,q,!1,U,!0,!1)}}},t.prototype.getDriverSkillFactor=function(){var e=.6,t=this.driverSkillLevel;switch(this.randomSkillFactor>=18?t+=2:this.randomSkillFactor>=12&&(t+=1),t=BABYLON.Scalar.Clamp(t,1,10)){case 10:e=1;break;case 9:e=.98;break;case 8:e=.95;break;case 7:e=.9;break;case 6:e=.85;break;case 5:e=.8;break;case 4:e=.75;break;case 3:e=.7;break;case 2:e=.65;break;case 1:e=.6}return e},t.prototype.getCurrentTrackNode=function(e){var t=null;return e>=0&&e<this.waypointCount&&(t=this.m_circuitInterfaces[e]),t},t.prototype.getCurrentControlPoint=function(e,t){var i=null;if(t>=0&&t<this.waypointCount)switch(e){case 0:i=this.m_circuitRaceLine_1[t];break;case 1:i=this.m_circuitRaceLine_2[t];break;case 2:i=this.m_circuitRaceLine_3[t];break;case 3:i=this.m_circuitRaceLine_4[t];break;case 4:i=this.m_circuitRaceLine_5[t]}return i},t.prototype.getRandomNumber=function(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e},t.prototype.generateRandonNumber=function(e,t,i){void 0===i&&(i=2);var n=(Math.random()*(t-e)+e).toFixed(i);return parseFloat(n)},t.prototype.destroyVehicleController=function(){this.m_circuitInterfaces=null,this.m_circuitRaceLine_1=null,this.m_circuitRaceLine_2=null,this.m_circuitRaceLine_3=null,this.m_circuitRaceLine_4=null,this.m_circuitRaceLine_5=null,this.m_rigidbodyPhysics=null,this.m_standardCarController=null,null!=this.m_chasePointMesh&&(this.m_chasePointMesh.dispose(),this.m_chasePointMesh=null),null!=this.m_chaseRabbitMesh&&(this.m_chaseRabbitMesh.dispose(),this.m_chaseRabbitMesh=null)},t}(n.ScriptComponent);e.VehicleInputController=t,n.SceneManager.RegisterClass("PROJECT.VehicleInputController",t)}(r||(r={})),function(e){var t=function(t){function i(e,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.VehicleNetworkLabel");var o=t.call(this,e,i,n,r)||this;return o.label=null,o.autoCreate=!0,o.offsetX=0,o.offsetY=0,o.labelColor=new BABYLON.Color3(1,1,1),o.borderColor=new BABYLON.Color3(0,.8431373,.827451),o.backgroundColor=new BABYLON.Color3(0,.4745098,.4666667),o.labelCreated=!1,o}return o(i,t),i.prototype.update=function(){!1===this.labelCreated&&!0===this.autoCreate&&this.isReady()},i.prototype.createLabel=function(t){var i=e.VehicleNetworkLabel.GetFullscreenUI(this.scene);this.label=new BABYLON.GUI.TextBlock,this.label.text=t,this.label.color=this.labelColor.toHexString(),this.label.fontSize=24,this.rect=new BABYLON.GUI.Rectangle,this.rect.width="200px",this.rect.height="40px",this.rect.cornerRadius=10,this.rect.color=this.borderColor.toHexString(),this.rect.thickness=4,this.rect.background=this.backgroundColor.toHexString(),this.rect.addControl(this.label),i.addControl(this.rect),this.rect.linkWithMesh(this.transform),this.rect.linkOffsetXInPixels=this.offsetX,this.rect.linkOffsetYInPixels=this.offsetY},i.prototype.destroy=function(){console.warn("*** GOT DESTROY MESSAGE ***"),null!=this.label&&(this.label.dispose(),this.label=null),null!=this.rect&&(this.rect.dispose(),this.rect=null)},i.GetFullscreenUI=function(t,i){return void 0===i&&(i=BABYLON.Texture.BILINEAR_SAMPLINGMODE),null==e.VehicleNetworkLabel.AdvDynamicTexture&&(e.VehicleNetworkLabel.AdvDynamicTexture=BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("Default-Screen-UI",!0,t,i)),e.VehicleNetworkLabel.AdvDynamicTexture},i.AdvDynamicTexture=null,i}(n.ScriptComponent);e.VehicleNetworkLabel=t,n.SceneManager.RegisterClass("PROJECT.VehicleNetworkLabel",t)}(r||(r={})),function(e){var t=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.shader=n.getShaderName(),n}return o(t,e),t.prototype.awake=function(){this.backFaceCulling=!1,this.twoSidedLighting=!0},t.prototype.update=function(){},t.prototype.getShaderName=function(){return"DoubleSided"},t}(n.CustomShaderMaterial);e.DoubleSided=t,n.SceneManager.RegisterClass("PROJECT.DoubleSided",t)}(r||(r={})),function(e){var t=function(t){function i(i,n){var r=t.call(this,i,n)||this;return r.shader=r.getShaderName(),r.plugin=new e.VertexSplatPlugin(r,r.shader),r}return o(i,t),i.prototype.awake=function(){},i.prototype.update=function(){},i.prototype.getShaderName=function(){return"VertexSplat"},i.prototype.getCustomVertexCode=function(e){return e?"\n varying Splat3UV: vec2<f32>;\n ":"\n #ifdef VERTEXSPLAT\n varying vec2 Splat3UV;\n uniform vec2 Splat3Infos;\n uniform mat4 Splat3Matrix;\n #endif\n "},i}(n.CustomShaderMaterial);e.VertexSplat=t;var i=function(e){function t(t,i){return e.call(this,t,i,100,{VERTEXSPLAT:!1})||this}return o(t,e),t.prototype.isCompatible=function(e){return e===BABYLON.ShaderLanguage.WGSL||e===BABYLON.ShaderLanguage.GLSL},t.prototype.getCustomCode=function(e,t){if("vertex"===e){if(t===BABYLON.ShaderLanguage.WGSL)return{CUSTOM_VERTEX_DEFINITIONS:this.vertexDefinitions,CUSTOM_VERTEX_MAIN_END:"\n #ifdef VERTEXSPLAT\n if (uniforms.Splat3Infos.x == 0.) {\n vertexOutputs.Splat3UV = (uniforms.Splat3Matrix * vec4<f32>(input.uv, 1.0, 0.0)).xy;\n } else {\n vertexOutputs.Splat3UV = (uniforms.Splat3Matrix * vec4<f32>(input.uv2, 1.0, 0.0)).xy;\n }\n #endif\n "};if(t===BABYLON.ShaderLanguage.GLSL)return{CUSTOM_VERTEX_DEFINITIONS:this.vertexDefinitions,CUSTOM_VERTEX_MAIN_END:"\n #ifdef VERTEXSPLAT\n if (Splat3Infos.x == 0.) {\n Splat3UV = vec2(Splat3Matrix * vec4(uv, 1.0, 0.0));\n } else {\n Splat3UV = vec2(Splat3Matrix * vec4(uv2, 1.0, 0.0));\n }\n #endif\n "}}else if("fragment"===e){if(t===BABYLON.ShaderLanguage.WGSL)return{CUSTOM_FRAGMENT_DEFINITIONS:(this.fragmentDefinitions||"")+"\n varying Splat3UV: vec2<f32>;\n ",CUSTOM_FRAGMENT_BEFORE_LIGHTS:"\n #ifdef VERTEXSPLAT\n #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\n // Undo vertex color multiply applied by PBR albedo block\n var splatVColor: vec3<f32> = max(fragmentInputs.vColor.rgb, vec3<f32>(0.001));\n surfaceAlbedo = surfaceAlbedo / splatVColor;\n // Splat blend: mix Splat3 overlay with base albedo using vertex blue channel\n var splatBase: vec3<f32> = surfaceAlbedo * uniforms.IntensityA;\n var splatRaw: vec4<f32> = textureSample(Splat3, Splat3Sampler, fragmentInputs.Splat3UV);\n splatRaw = vec4<f32>(pow(splatRaw.rgb, vec3<f32>(2.2)), splatRaw.a);\n var splatOverlay: vec4<f32> = splatRaw * uniforms.ColorC * uniforms.IntensityC * 1.25;\n surfaceAlbedo = mix(splatOverlay.rgb, splatBase, fragmentInputs.vColor.b);\n #endif\n #endif\n "};if(t===BABYLON.ShaderLanguage.GLSL)return{CUSTOM_FRAGMENT_DEFINITIONS:"\n #ifdef VERTEXSPLAT\n varying vec2 Splat3UV;\n #endif\n ",CUSTOM_FRAGMENT_BEFORE_LIGHTS:"\n #ifdef VERTEXSPLAT\n #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\n // Undo vertex color multiply applied by PBR albedo block\n surfaceAlbedo.rgb /= max(vColor.rgb, vec3(0.001));\n // Splat blend: mix Splat3 overlay with base albedo using vertex blue channel\n vec3 splat1 = surfaceAlbedo.rgb * IntensityA;\n vec4 splat3Raw = texture2D(Splat3, Splat3UV);\n splat3Raw = vec4(pow(splat3Raw.rgb, vec3(2.2)), splat3Raw.a);\n vec4 splat3 = splat3Raw * ColorC * IntensityC * 1.25;\n surfaceAlbedo.rgb = mix(splat3.rgb, splat1.rgb, vColor.b);\n #endif\n #endif\n "}}return null},t.prototype.getUniforms=function(e){var t=e===BABYLON.ShaderLanguage.WGSL;return this.vertexDefinitions=this.getCustomShaderMaterial().getCustomVertexCode(t),this.fragmentDefinitions=!0===t?this.getCustomShaderMaterial().getCustomFragmentCode(t):null,this.getCustomShaderMaterial().getCustomUniforms(t)},t.prototype.getSamplers=function(e){var t=this.getCustomShaderMaterial().getCustomSamplers();null!=t&&t.length>0&&e.push.apply(e,t)},t.prototype.getAttributes=function(e,t,i){var n=this.getCustomShaderMaterial().getCustomAttributes();null!=n&&n.length>0&&e.push.apply(e,n)},t.prototype.prepareDefines=function(e,t,i){this.getIsEnabled()&&this.getCustomShaderMaterial().prepareCustomDefines(e)},t.prototype.bindForSubMesh=function(e,t,i,n){this.getIsEnabled()&&this.getCustomShaderMaterial().updateCustomBindings(e)},t}(n.CustomShaderMaterialPlugin);e.VertexSplatPlugin=i,n.SceneManager.RegisterClass("PROJECT.VertexSplat",t),n.SceneManager.RegisterClass("PROJECT.VertexSplatPlugin",i)}(r||(r={})),function(e){var t=function(t){function i(i,n,r,o){void 0===r&&(r={}),void 0===o&&(o="PROJECT.DefaultCameraSystem");var a=t.call(this,i,n,r,o)||this;return a.mainCamera=!1,a.cameraType=0,a.cameraInertia=.9,a.cameraController=null,a.immersiveOptions=null,a.arcRotateConfig=null,a.multiPlayerSetup=null,a.fullScreenToggle=0,a.setPointerLock=!1,a.setCameraTarget=null,a.setSpatialAudio=!0,a.editorPostProcessing=null,a.m_cameraRig=null,a.targetCameraOffset=new BABYLON.Vector3(0,0,0),a.cameraNode=null,a.cameraPivot=null,a.cameraDistance=0,a.cameraPivotOffset=new BABYLON.Vector3(0,0,0),a.cameraBoomPosition=new BABYLON.Vector3(0,0,0),a.dollyDirection=new BABYLON.Vector3(0,0,0),a.rotationEulers=new BABYLON.Vector3(0,0,0),a.scaledCamDirection=new BABYLON.Vector3(0,0,0),a.scaledMaxDirection=new BABYLON.Vector3(0,0,0),a.parentNodePosition=new BABYLON.Vector3(0,0,0),a.maximumCameraPos=new BABYLON.Vector3(0,0,0),a.cameraRaycastShape=null,a.targetRotationVector=BABYLON.Vector2.Zero(),a.smoothBoomArmLength=null,a.smoothBoomArmSpeed=null,e.DefaultCameraSystem.cameraInstance=a,a}return o(i,t),i.GetRenderingPipeline=function(){return e.DefaultCameraSystem.renderingPipeline},i.GetScreenSpacePipeline=function(){return e.DefaultCameraSystem.screenSpacePipeline},i.IsCameraSystemReady=function(){return e.DefaultCameraSystem.cameraReady},i.prototype.isMainCamera=function(){return this.mainCamera},i.prototype.getCameraType=function(){return this.cameraType},i.prototype.getTargetTransform=function(){return this.setCameraTarget},i.prototype.setTargetTransform=function(e){this.setCameraTarget=e},i.prototype.enableSpatialAudio=function(e){this.setSpatialAudio=e},i.prototype.awake=function(){this.awakeCameraSystemState()},i.prototype.start=function(){this.startCameraSystemState()},i.prototype.update=function(){this.updateCameraSystemState()},i.prototype.destroy=function(){this.destroyCameraSystemState()},i.prototype.awakeCameraSystemState=function(){var e=this;this.mainCamera="MainCamera"===this.getTransformTag(),this.cameraType=this.getProperty("mainCameraType",this.cameraType),this.cameraInertia=this.getProperty("setCameraInertia",this.cameraInertia),this.fullScreenToggle=this.getProperty("fullScreenToggle",this.fullScreenToggle),this.setSpatialAudio=this.getProperty("setSpatialAudio",this.setSpatialAudio),this.setPointerLock=this.getProperty("setPointerLock",this.setPointerLock),this.immersiveOptions=this.getProperty("immersiveOptions",this.immersiveOptions),this.arcRotateConfig=this.getProperty("arcRotateConfig",this.arcRotateConfig),this.multiPlayerSetup=this.getProperty("multiPlayerSetup",this.multiPlayerSetup),this.cameraController=this.getProperty("cameraController",this.cameraController),this.editorPostProcessing=this.getProperty("renderingPipeline",this.editorPostProcessing),this.cleanCameraSystemState(),0===this.fullScreenToggle&&n.InputController.OnKeyboardPress(n.UserInputKey.F,function(){n.SceneManager.EnterFullscreenMode(e.scene,e.setPointerLock)})},i.prototype.startCameraSystemState=function(){return s(this,void 0,void 0,function(){var t,i,r,o,a,s,u,h,c,d,m,p,f,g,y,v,S,_,b,B,C,A,T,M,L,P,w,x,O,R=this;return l(this,function(l){switch(l.label){case 0:if(n.Utilities.ValidateTransformQuaternion(this.transform),null!=this.multiPlayerSetup&&(e.DefaultCameraSystem.startupMode=this.multiPlayerSetup.playerStartupMode,e.DefaultCameraSystem.stereoCameras=this.multiPlayerSetup.stereoSideBySide),this.m_cameraRig=this.getCameraRig(),null==this.m_cameraRig)return[3,6];if(this.m_cameraRig.inertia=this.cameraInertia,this.m_cameraRig.layerMask=~n.SceneManager.HiddenLayerMask,!0===this.setSpatialAudio&&!n.AudioSource.IsLegacyEngine())try{n.AudioSource.AttachSpatialCamera(this.m_cameraRig)}catch(e){n.SceneManager.LogError("Failed to attach spatial audio to camera rig: "+e.message)}return null!=this.cameraController&&(this.m_cameraRig.speed=this.cameraController.cameraSpeed,this.m_cameraRig.inverseRotationSpeed=this.cameraController.invRotationSpeed,this.m_cameraRig instanceof BABYLON.UniversalCamera&&(this.m_cameraRig.gamepadAngularSensibility=this.cameraController.gamepadRotation,this.m_cameraRig.gamepadMoveSensibility=this.cameraController.gamepadMovement,this.m_cameraRig.touchAngularSensibility=this.cameraController.touchRotation,this.m_cameraRig.touchMoveSensibility=this.cameraController.touchMovement),!0===this.cameraController.keyboardWASD&&null!=this.m_cameraRig.inputs&&null!=this.m_cameraRig.inputs.attached&&null!=this.m_cameraRig.inputs.attached.keyboard&&this.m_cameraRig.inputs.attached.keyboard instanceof BABYLON.FreeCameraKeyboardMoveInput&&((t=this.m_cameraRig.inputs.attached.keyboard).keysUp.push(n.UserInputKey.W),t.keysLeft.push(n.UserInputKey.A),t.keysDown.push(n.UserInputKey.S),t.keysRight.push(n.UserInputKey.D),t.rotationSpeed=this.cameraController.rotationSpeed,!0===this.cameraController.arrowKeyRotation&&(t.keysLeft=[n.UserInputKey.A],t.keysRight=[n.UserInputKey.D],t.keysRotateLeft=[n.UserInputKey.LeftArrow],t.keysRotateRight=[n.UserInputKey.RightArrow]))),null!=this.m_cameraRig.inputs&&null!=this.m_cameraRig.inputs.attached&&null!=this.m_cameraRig.inputs.attached.mouse&&(i=this.m_cameraRig.inputs.attached.mouse,n.Utilities.HasOwnProperty(i,"touchEnabled")&&(i.touchEnabled=!0)),0!==this.cameraType&&4!==this.cameraType?[3,1]:(e.DefaultCameraSystem.PlayerOneCamera=this.m_cameraRig,e.DefaultCameraSystem.PlayerOneCamera.inertia=this.cameraInertia,e.DefaultCameraSystem.PlayerOneCamera.transform=this.transform,[3,5]);case 1:if(1!==this.cameraType&&2!==this.cameraType)return[3,4];if(e.DefaultCameraSystem.PlayerOneCamera=this.m_cameraRig,e.DefaultCameraSystem.PlayerOneCamera.inertia=this.cameraInertia,e.DefaultCameraSystem.PlayerOneCamera.transform=this.transform,null==this.immersiveOptions)return[3,3];if(!(!1==(r=!0===this.immersiveOptions.localStorageOption)||!0===r&&n.WindowManager.GetVirtualRealityEnabled()))return[3,3];switch(o=null,null,s=1===this.cameraType?"immersive-ar":"immersive-vr",u="local-floor",this.immersiveOptions.referenceSpaceType){case 0:u="viewer";break;case 1:u="local";break;case 2:default:u="local-floor";break;case 4:u="unbounded"}return null!=this.immersiveOptions.setFloorMeshesTags&&""!==this.immersiveOptions.setFloorMeshesTags||(this.immersiveOptions.setFloorMeshesTags="Navigation"),!0===this.immersiveOptions.defaultTeleportationSetup.useTeleportation&&(o=this.scene.getMeshesByTags(this.immersiveOptions.setFloorMeshesTags)),a=!0===this.immersiveOptions.defaultTeleportationSetup.useTeleportation&&null!=o&&o.length>0?{floorMeshes:o,optionalFeatures:this.immersiveOptions.optionalFeatures,useStablePlugins:this.immersiveOptions.useStablePlugins,renderingGroupId:this.immersiveOptions.renderingGroupNum,disableDefaultUI:this.immersiveOptions.disableUserInterface,disableTeleportation:!1===this.immersiveOptions.defaultTeleportationSetup.useTeleportation,disablePointerSelection:this.immersiveOptions.disablePointerSelect,ignoreNativeCameraTransformation:this.immersiveOptions.ignoreNativeCamera,inputOptions:{doNotLoadControllerMeshes:this.immersiveOptions.experienceInputOptions.disableMeshLoad,forceInputProfile:this.immersiveOptions.experienceInputOptions.forceInputProfile,disableOnlineControllerRepository:this.immersiveOptions.experienceInputOptions.disableRepository,customControllersRepositoryURL:this.immersiveOptions.experienceInputOptions.customRepository,disableControllerAnimation:this.immersiveOptions.experienceInputOptions.disableModelAnim,controllerOptions:{disableMotionControllerAnimation:this.immersiveOptions.experienceInputOptions.controllerOptions.disableCtrlAnim,doNotLoadControllerMesh:this.immersiveOptions.experienceInputOptions.controllerOptions.disableCtrlMesh,forceControllerProfile:this.immersiveOptions.experienceInputOptions.controllerOptions.forceCtrlProfile,renderingGroupId:this.immersiveOptions.experienceInputOptions.controllerOptions.renderingGroup}},uiOptions:{sessionMode:s,referenceSpaceType:u}}:{optionalFeatures:this.immersiveOptions.optionalFeatures,useStablePlugins:this.immersiveOptions.useStablePlugins,renderingGroupId:this.immersiveOptions.renderingGroupNum,disableDefaultUI:this.immersiveOptions.disableUserInterface,disableTeleportation:!1===this.immersiveOptions.defaultTeleportationSetup.useTeleportation,disablePointerSelection:this.immersiveOptions.disablePointerSelect,ignoreNativeCameraTransformation:this.immersiveOptions.ignoreNativeCamera,inputOptions:{doNotLoadControllerMeshes:this.immersiveOptions.experienceInputOptions.disableMeshLoad,forceInputProfile:this.immersiveOptions.experienceInputOptions.forceInputProfile,disableOnlineControllerRepository:this.immersiveOptions.experienceInputOptions.disableRepository,customControllersRepositoryURL:this.immersiveOptions.experienceInputOptions.customRepository,disableControllerAnimation:this.immersiveOptions.experienceInputOptions.disableModelAnim,controllerOptions:{disableMotionControllerAnimation:this.immersiveOptions.experienceInputOptions.controllerOptions.disableCtrlAnim,doNotLoadControllerMesh:this.immersiveOptions.experienceInputOptions.controllerOptions.disableCtrlMesh,forceControllerProfile:this.immersiveOptions.experienceInputOptions.controllerOptions.forceCtrlProfile,renderingGroupId:this.immersiveOptions.renderingGroupNum}},uiOptions:{sessionMode:s,referenceSpaceType:u}},h=e.DefaultCameraSystem,[4,this.scene.createDefaultXRExperienceAsync(a)];case 2:h.XRExperienceHelper=l.sent(),null!=e.DefaultCameraSystem.XRExperienceHelper&&null!=e.DefaultCameraSystem.XRExperienceHelper.baseExperience?(null!=e.DefaultCameraSystem.XRExperienceHelper.teleportation&&(e.DefaultCameraSystem.XRExperienceHelper.teleportation.rotationAngle=BABYLON.Tools.ToRadians(this.immersiveOptions.defaultTeleportationSetup.turningAxisAngle),e.DefaultCameraSystem.XRExperienceHelper.teleportation.rotationEnabled=this.immersiveOptions.defaultTeleportationSetup.rotationsEnabled,e.DefaultCameraSystem.XRExperienceHelper.teleportation.backwardsMovementEnabled=this.immersiveOptions.defaultTeleportationSetup.backwardsEnabled,e.DefaultCameraSystem.XRExperienceHelper.teleportation.backwardsTeleportationDistance=this.immersiveOptions.defaultTeleportationSetup.backwardsDistance,e.DefaultCameraSystem.XRExperienceHelper.teleportation.parabolicCheckRadius=this.immersiveOptions.defaultTeleportationSetup.parabolicRadius),e.DefaultCameraSystem.OnXRExperienceHelperObservable&&e.DefaultCameraSystem.OnXRExperienceHelperObservable.hasObservers()&&e.DefaultCameraSystem.OnXRExperienceHelperObservable.notifyObservers(e.DefaultCameraSystem.XRExperienceHelper),n.SceneManager.HasNavigationData()?(c=n.SceneManager.GetNavigationMesh(),e.DefaultCameraSystem.SetupNavigationWebXR(c,this.immersiveOptions.setFloorMeshesTags)):n.SceneManager.OnNavMeshReadyObservable.addOnce(function(t){e.DefaultCameraSystem.SetupNavigationWebXR(t,R.immersiveOptions.setFloorMeshesTags)})):n.SceneManager.LogWarning("WebXR not supported in current browser."),l.label=3;case 3:return[3,5];case 4:3===this.cameraType&&(d=this.m_cameraRig.name,(m=new BABYLON.TransformNode("Player Camera 1",this.scene)).rotationQuaternion=this.transform.rotationQuaternion.clone(),m.position=this.transform.position.clone(),m.parent=this.transform.parent,p=d+".1",(f=this.m_cameraRig.clone(p)).name=p,f.parent=m,f.position=new BABYLON.Vector3(0,0,0),f.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1),f.viewport=new BABYLON.Viewport(0,0,0,0),f.setEnabled(!1),e.DefaultCameraSystem.PlayerOneCamera=f,e.DefaultCameraSystem.PlayerOneCamera.inertia=this.cameraInertia,e.DefaultCameraSystem.PlayerOneCamera.transform=m,m.cameraRig=e.DefaultCameraSystem.PlayerOneCamera,(g=new BABYLON.TransformNode("Player Camera 2",this.scene)).rotationQuaternion=this.transform.rotationQuaternion.clone(),g.position=this.transform.position.clone(),g.parent=this.transform.parent,y=d+".2",(v=this.m_cameraRig.clone(y)).name=y,v.parent=g,v.position=new BABYLON.Vector3(0,0,0),v.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1),v.viewport=new BABYLON.Viewport(0,0,0,0),v.setEnabled(!1),e.DefaultCameraSystem.PlayerTwoCamera=v,e.DefaultCameraSystem.PlayerTwoCamera.inertia=this.cameraInertia,e.DefaultCameraSystem.PlayerTwoCamera.transform=g,g.cameraRig=e.DefaultCameraSystem.PlayerTwoCamera,(S=new BABYLON.TransformNode("Player Camera 3",this.scene)).rotationQuaternion=this.transform.rotationQuaternion.clone(),S.position=this.transform.position.clone(),S.parent=this.transform.parent,_=d+".3",(b=this.m_cameraRig.clone(_)).name=_,b.parent=S,b.position=new BABYLON.Vector3(0,0,0),b.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1),b.viewport=new BABYLON.Viewport(0,0,0,0),b.setEnabled(!1),e.DefaultCameraSystem.PlayerThreeCamera=b,e.DefaultCameraSystem.PlayerThreeCamera.inertia=this.cameraInertia,e.DefaultCameraSystem.PlayerThreeCamera.transform=S,S.cameraRig=e.DefaultCameraSystem.PlayerThreeCamera,(B=new BABYLON.TransformNode("Player Camera 4",this.scene)).rotationQuaternion=this.transform.rotationQuaternion.clone(),B.position=this.transform.position.clone(),B.parent=this.transform.parent,C=d+".4",(A=this.m_cameraRig.clone(C)).name=C,A.parent=B,A.position=new BABYLON.Vector3(0,0,0),A.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1),A.viewport=new BABYLON.Viewport(0,0,0,0),A.setEnabled(!1),e.DefaultCameraSystem.PlayerFourCamera=A,e.DefaultCameraSystem.PlayerFourCamera.inertia=this.cameraInertia,e.DefaultCameraSystem.PlayerFourCamera.transform=B,B.cameraRig=e.DefaultCameraSystem.PlayerFourCamera,e.DefaultCameraSystem.multiPlayerView=!0,e.DefaultCameraSystem.SetMultiPlayerViewLayout(this.scene,e.DefaultCameraSystem.startupMode)),l.label=5;case 5:1!==this.cameraController.cameraControl&&2!==this.cameraController.cameraControl||(this.m_cameraRig.parent=null,this.m_cameraRig.position.copyFrom(this.transform.position),this.m_cameraRig.rotationQuaternion=null!=this.transform.rotationQuaternion?this.transform.rotationQuaternion.clone():BABYLON.Quaternion.FromEulerAngles(this.transform.rotation.x,this.transform.rotation.y,this.transform.rotation.z),null!=(T=this.transform.getChildren(null,!0))&&T.forEach(function(e){e.parent=R.m_cameraRig}),this.m_cameraRig instanceof BABYLON.FreeCamera&&(this.m_cameraRig.checkCollisions=this.cameraController.checkCollisions,this.m_cameraRig.applyGravity=this.cameraController.setApplyGravity),1===this.cameraController.cameraControl&&this.m_cameraRig.attachControl(this.cameraController.preventDefault)),l.label=6;case 6:return!0==(n.RenderQuality.High===n.RenderQuality.High)&&null!=this.editorPostProcessing&&!0===this.editorPostProcessing.usePostProcessing&&(e.DefaultCameraSystem.renderingPipeline=new BABYLON.DefaultRenderingPipeline("DefaultCameraSystem",this.editorPostProcessing.highDynamicRange,this.scene,this.scene.cameras,!0),!0===e.DefaultCameraSystem.renderingPipeline.isSupported?((M=e.DefaultCameraSystem.renderingPipeline).samples=this.editorPostProcessing.screenAntiAliasing.msaaSamples,M.imageProcessingEnabled=this.editorPostProcessing.imageProcessingConfig.imageProcessing,M.imageProcessingEnabled&&(M.imageProcessing.contrast=this.editorPostProcessing.imageProcessingConfig.imageContrast,M.imageProcessing.exposure=this.editorPostProcessing.imageProcessingConfig.imageExposure,M.imageProcessing.toneMappingEnabled=this.editorPostProcessing.imageProcessingConfig.toneMapping,M.imageProcessing.toneMappingType=this.editorPostProcessing.imageProcessingConfig.toneMapType,M.imageProcessing.vignetteEnabled=this.editorPostProcessing.imageProcessingConfig.vignetteEnabled,M.imageProcessing.vignetteEnabled&&(M.imageProcessing.vignetteBlendMode=this.editorPostProcessing.imageProcessingConfig.vignetteBlendMode,M.imageProcessing.vignetteCameraFov=this.editorPostProcessing.imageProcessingConfig.vignetteCameraFov,M.imageProcessing.vignetteCentreX=this.editorPostProcessing.imageProcessingConfig.vignetteCentreX,M.imageProcessing.vignetteCentreY=this.editorPostProcessing.imageProcessingConfig.vignetteCentreY,M.imageProcessing.vignetteStretch=this.editorPostProcessing.imageProcessingConfig.vignetteStretch,M.imageProcessing.vignetteWeight=this.editorPostProcessing.imageProcessingConfig.vignetteWeight,null!=this.editorPostProcessing.imageProcessingConfig.vignetteColor&&null!=(L=n.Utilities.ParseColor4(this.editorPostProcessing.imageProcessingConfig.vignetteColor))&&(M.imageProcessing.vignetteColor=L)),M.imageProcessing.colorGradingEnabled=this.editorPostProcessing.imageProcessingConfig.useColorGrading,M.imageProcessing.colorGradingEnabled&&null!=this.editorPostProcessing.imageProcessingConfig.setGradingTexture&&((P=n.Utilities.ParseTexture(this.editorPostProcessing.imageProcessingConfig.setGradingTexture,this.scene,!0,!1)).wrapU=BABYLON.Texture.CLAMP_ADDRESSMODE,P.wrapV=BABYLON.Texture.CLAMP_ADDRESSMODE,M.imageProcessing.colorGradingTexture=P,M.imageProcessing.colorGradingWithGreenDepth=!1),M.imageProcessing.colorCurvesEnabled=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.curvesEnabled,M.imageProcessing.colorCurvesEnabled&&((w=new BABYLON.ColorCurves).globalDensity=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.globalDen,w.globalExposure=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.globalExp,w.globalHue=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.globalHue,w.globalSaturation=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.globalSat,w.highlightsDensity=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.highlightsDen,w.highlightsExposure=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.highlightsExp,w.highlightsHue=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.highlightsHue,w.highlightsSaturation=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.highlightsSat,w.midtonesDensity=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.midtonesDen,w.midtonesExposure=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.midtonesExp,w.midtonesHue=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.midtonesHue,w.midtonesSaturation=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.midtonesSat,w.shadowsDensity=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.shadowsDen,w.shadowsExposure=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.shadowsExp,w.shadowsHue=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.shadowsHue,w.shadowsSaturation=this.editorPostProcessing.imageProcessingConfig.imagingColorCurves.shadowsSat,M.imageProcessing.colorCurves=w)),M.bloomEnabled=this.editorPostProcessing.bloomEffectProperties.bloomEnabled,M.bloomEnabled&&(M.bloomKernel=this.editorPostProcessing.bloomEffectProperties.bloomKernel,M.bloomScale=this.editorPostProcessing.bloomEffectProperties.bloomScale,M.bloomWeight=this.editorPostProcessing.bloomEffectProperties.bloomWeight,M.bloomThreshold=this.editorPostProcessing.bloomEffectProperties.bloomThreshold),M.chromaticAberrationEnabled=this.editorPostProcessing.chromaticAberration.aberrationEnabled,M.chromaticAberrationEnabled&&(M.chromaticAberration.aberrationAmount=this.editorPostProcessing.chromaticAberration.aberrationAmount,M.chromaticAberration.adaptScaleToCurrentViewport=this.editorPostProcessing.chromaticAberration.adaptScaleViewport,M.chromaticAberration.alphaMode=this.editorPostProcessing.chromaticAberration.alphaMode,M.chromaticAberration.alwaysForcePOT=this.editorPostProcessing.chromaticAberration.alwaysForcePOT,M.chromaticAberration.enablePixelPerfectMode=this.editorPostProcessing.chromaticAberration.pixelPerfectMode,M.chromaticAberration.forceFullscreenViewport=this.editorPostProcessing.chromaticAberration.fullscreenViewport),M.depthOfFieldEnabled=this.editorPostProcessing.focalDepthOfField.depthOfField,M.depthOfFieldEnabled&&M.depthOfField.isSupported&&(M.depthOfFieldBlurLevel=this.editorPostProcessing.focalDepthOfField.blurLevel,M.depthOfField.fStop=this.editorPostProcessing.focalDepthOfField.focalStop,M.depthOfField.focalLength=this.editorPostProcessing.focalDepthOfField.focalLength,M.depthOfField.focusDistance=this.editorPostProcessing.focalDepthOfField.focusDistance,M.depthOfField.lensSize=this.editorPostProcessing.focalDepthOfField.maxLensSize),M.fxaaEnabled=this.editorPostProcessing.screenAntiAliasing.fxaaEnabled,M.fxaaEnabled&&(M.fxaa.samples=this.editorPostProcessing.screenAntiAliasing.fxaaSamples,M.fxaa.adaptScaleToCurrentViewport=this.editorPostProcessing.screenAntiAliasing.fxaaScaling),M.glowLayerEnabled=this.editorPostProcessing.glowLayerProperties.glowEnabled,M.glowLayerEnabled&&(M.glowLayer.intensity=this.editorPostProcessing.glowLayerProperties.glowIntensity,M.glowLayer.blurKernelSize=this.editorPostProcessing.glowLayerProperties.blurKernelSize),M.grainEnabled=this.editorPostProcessing.grainEffectProperties.grainEnabled,M.grainEnabled&&(M.grain.animated=this.editorPostProcessing.grainEffectProperties.grainAnimated,M.grain.intensity=this.editorPostProcessing.grainEffectProperties.grainIntensity,M.grain.adaptScaleToCurrentViewport=this.editorPostProcessing.grainEffectProperties.adaptScaleViewport),M.sharpenEnabled=this.editorPostProcessing.sharpEffectProperties.sharpenEnabled,M.sharpenEnabled&&(M.sharpen.edgeAmount=this.editorPostProcessing.sharpEffectProperties.sharpEdgeAmount,M.sharpen.colorAmount=this.editorPostProcessing.sharpEffectProperties.sharpColorAmount,M.sharpen.adaptScaleToCurrentViewport=this.editorPostProcessing.sharpEffectProperties.adaptScaleViewport)):n.SceneManager.LogWarning("Babylon.js default rendering pipeline not supported"),null!=this.editorPostProcessing.screenSpaceRendering&&!0===this.editorPostProcessing.screenSpaceRendering.SSAO&&(x={ssaoRatio:this.editorPostProcessing.screenSpaceRendering.SSAORatio,combineRatio:this.editorPostProcessing.screenSpaceRendering.combineRatio},e.DefaultCameraSystem.screenSpacePipeline=new BABYLON.SSAORenderingPipeline("DefaultCameraSystem-SSAO",this.scene,x,this.scene.cameras),!0===e.DefaultCameraSystem.screenSpacePipeline.isSupported?((O=e.DefaultCameraSystem.screenSpacePipeline).fallOff=this.editorPostProcessing.screenSpaceRendering.fallOff,O.area=this.editorPostProcessing.screenSpaceRendering.area,O.radius=this.editorPostProcessing.screenSpaceRendering.radius,O.totalStrength=this.editorPostProcessing.screenSpaceRendering.totalStrength,O.base=this.editorPostProcessing.screenSpaceRendering.baseValue):n.SceneManager.LogWarning("Babylon.js SSAO rendering pipeline not supported"))),e.DefaultCameraSystem.cameraReady=!0,[2]}})})},i.prototype.updateCameraSystemState=function(){if(null!=this.m_cameraRig&&(0===this.cameraType||1===this.cameraType||2===this.cameraType||this.cameraType),3===this.cameraController.cameraControl){var t=this.getDeltaSeconds(),i=n.InputController.GetUserInput(n.UserInputAxis.MouseX,this.cameraController.playerNumber),r=n.InputController.GetUserInput(n.UserInputAxis.MouseY,this.cameraController.playerNumber);this.targetRotationVector.y+=i*this.cameraController.rotateSpeed*t,this.targetRotationVector.x+=-r*this.cameraController.rotateSpeed*t,this.targetRotationVector.x=BABYLON.Scalar.Clamp(this.targetRotationVector.x,-BABYLON.Tools.ToRadians(this.cameraController.downLookLimit),BABYLON.Tools.ToRadians(this.cameraController.topLookLimit)),!0===this.cameraController.autoUpdate&&e.DefaultCameraSystem.UpdateFollowTarget()}},i.prototype.cleanCameraSystemState=function(){null!=e.DefaultCameraSystem.PlayerOneCamera&&(e.DefaultCameraSystem.PlayerOneCamera=null),null!=e.DefaultCameraSystem.PlayerTwoCamera&&(e.DefaultCameraSystem.PlayerTwoCamera=null),null!=e.DefaultCameraSystem.PlayerThreeCamera&&(e.DefaultCameraSystem.PlayerThreeCamera=null),null!=e.DefaultCameraSystem.PlayerFourCamera&&(e.DefaultCameraSystem.PlayerFourCamera=null)},i.prototype.destroyCameraSystemState=function(){this.immersiveOptions=null,this.cameraPivot=null,this.cameraNode=null},i.prototype.getCameraPivotPosition=function(){return null!=this.cameraPivot?this.cameraPivot.position:null},i.prototype.getCameraPivotRotation=function(){return null!=this.cameraPivot?this.cameraPivot.rotationQuaternion:null},i.prototype.getCameraBoomNode=function(){return this.cameraNode},i.prototype.getCameraTransform=function(){return this.cameraPivot},i.prototype.resetCameraRotation=function(){null!=this.setCameraTarget&&(this.setCameraTarget.rotationQuaternion.toEulerAnglesToRef(this.rotationEulers),this.targetRotationVector.x=this.rotationEulers.x,this.targetRotationVector.y=this.rotationEulers.y)},i.prototype.updateCameraController=function(){var t=this.getDeltaSeconds();if(!1!==this.cameraController.targetTracking&&null!=this.setCameraTarget){if(null==this.cameraRaycastShape&&(this.cameraRaycastShape=new BABYLON.PhysicsShapeSphere(new BABYLON.Vector3(0,0,0),this.cameraController.sphereRadius,this.scene)),null==this.cameraPivot&&(this.resetCameraRotation(),this.cameraPivot=new BABYLON.Mesh(this.setCameraTarget.name+".CameraPivot",this.scene),this.cameraPivot.parent=null,this.cameraPivot.position=this.setCameraTarget.position.clone(),this.cameraPivot.rotationQuaternion=this.setCameraTarget.rotationQuaternion.clone(),this.cameraPivot.checkCollisions=!1,this.cameraPivot.isPickable=!1,n.Utilities.ShowDebugColliders())){var i=BABYLON.MeshBuilder.CreateBox("TestPivot",{width:.25,height:.25,depth:.75},this.scene);i.parent=this.cameraPivot,i.position.set(0,0,0),i.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1),i.visibility=1,i.renderingGroupId=n.Utilities.ColliderRenderGroup(),i.checkCollisions=!1,i.isPickable=!1}if(null==this.cameraNode){var r=null!=this.cameraController.playerNumber?this.cameraController.playerNumber:1,o=r<=0||r>4?1:r,a=e.DefaultCameraSystem.GetCameraTransform(this.scene,o),s=e.DefaultCameraSystem.GetMainCamera(this.scene,!1);null!=a&&null!=s&&(s.detachControl(),this.cameraNode=a,this.cameraNode.parent=this.cameraPivot,this.cameraNode.position.set(this.cameraController.boomPosition.x,this.cameraController.boomPosition.y,this.cameraController.boomPosition.z),this.cameraNode.rotationQuaternion=BABYLON.Quaternion.FromEulerAngles(BABYLON.Tools.ToRadians(this.cameraController.maxTiltAngle),0,0),this.cameraDistance=this.cameraNode.position.length(),this.dollyDirection.copyFrom(this.cameraNode.position),this.dollyDirection.normalize())}if(null!=this.cameraPivot&&(0!==this.targetCameraOffset.x||0!==this.targetCameraOffset.y||0!==this.targetCameraOffset.z?this.cameraPivotOffset.copyFrom(this.targetCameraOffset):this.cameraPivotOffset.set(0,this.cameraController.pivotHeight,0),n.Utilities.GetAbsolutePositionToRef(this.setCameraTarget,this.cameraPivot.position,this.cameraPivotOffset),!0===this.cameraController.rotateCamera&&BABYLON.Quaternion.FromEulerAnglesToRef(this.targetRotationVector.x,this.targetRotationVector.y,0,this.cameraPivot.rotationQuaternion)),!0===this.cameraController.rotateCamera&&null!=this.cameraNode)if(this.cameraController.cameraSmoothing<=0&&(this.cameraController.cameraSmoothing=5),!0===this.cameraController.cameraCollisions){var l=Math.abs(this.cameraController.boomPosition.z),u=this.cameraNode.parent;this.dollyDirection.scaleToRef(l,this.scaledMaxDirection),this.dollyDirection.scaleToRef(this.cameraDistance,this.scaledCamDirection),n.Utilities.GetAbsolutePositionToRef(u,this.parentNodePosition),n.Utilities.TransformPointToRef(u,this.scaledMaxDirection,this.maximumCameraPos);var h=!1,c=0;if(null!=this.cameraRaycastShape){var d={shape:this.cameraRaycastShape,rotation:this.cameraNode.rotationQuaternion,startPosition:this.parentNodePosition,endPosition:this.maximumCameraPos,ignoreBody:this.setCameraTarget.physicsBody,shouldHitTriggers:!1},m=n.RigidbodyPhysics.Shapecast(d);c=!0==(h=null!=m&&null!=m.world&&!0===m.world.hasHit&&null!=m.world.body)?BABYLON.Vector3.Distance(this.parentNodePosition,m.world.hitPoint):0}if(!0===h){if(this.cameraDistance=BABYLON.Scalar.Clamp(c*this.cameraController.distanceFactor,this.cameraController.minDistance,this.cameraController.maxDistance),this.dollyDirection.scaleToRef(this.cameraDistance,this.scaledCamDirection),this.cameraNode.position.x!==this.scaledCamDirection.x||this.cameraNode.position.y!==this.scaledCamDirection.y||this.cameraNode.position.z!==this.scaledCamDirection.z){var p=this.cameraNode.position.subtract(this.scaledCamDirection).length()>.3?.8*this.cameraController.cameraSmoothing:this.cameraController.cameraSmoothing;BABYLON.Vector3.LerpToRef(this.cameraNode.position,this.scaledCamDirection,t*p,this.cameraNode.position)}}else{if(!0===this.cameraController.mouseWheel&&n.InputController.IsWheelScrolling())if((y=n.InputController.GetUserInput(n.UserInputAxis.Wheel))<0){var f=this.cameraController.scrollSpeed*t;this.cameraController.boomPosition.z=BABYLON.Scalar.MoveTowards(this.cameraController.boomPosition.z,-this.cameraController.maxDistance,f)}else if(y>0){var g=this.cameraController.scrollSpeed*t;this.cameraController.boomPosition.z=BABYLON.Scalar.MoveTowards(this.cameraController.boomPosition.z,-this.cameraController.minDistance,g)}this.cameraNode.position.x===this.cameraBoomPosition.x&&this.cameraNode.position.y===this.cameraBoomPosition.y&&this.cameraNode.position.z===this.cameraBoomPosition.z||(this.cameraBoomPosition.set(this.cameraController.boomPosition.x,this.cameraController.boomPosition.y,this.cameraController.boomPosition.z),p=this.cameraNode.position.subtract(this.cameraBoomPosition).length()>.3?.8*this.cameraController.cameraSmoothing:this.cameraController.cameraSmoothing,BABYLON.Vector3.LerpToRef(this.cameraNode.position,this.cameraBoomPosition,t*p,this.cameraNode.position))}}else{var y;!0===this.cameraController.mouseWheel&&n.InputController.IsWheelScrolling()&&((y=n.InputController.GetUserInput(n.UserInputAxis.Wheel))<0?(f=this.cameraController.scrollSpeed*t,this.cameraController.boomPosition.z=BABYLON.Scalar.MoveTowards(this.cameraController.boomPosition.z,-this.cameraController.maxDistance,f)):y>0&&(g=this.cameraController.scrollSpeed*t,this.cameraController.boomPosition.z=BABYLON.Scalar.MoveTowards(this.cameraController.boomPosition.z,-this.cameraController.minDistance,g))),this.cameraNode.position.x===this.cameraController.boomPosition.x&&this.cameraNode.position.y===this.cameraController.boomPosition.y&&this.cameraNode.position.z===this.cameraController.boomPosition.z||(this.cameraBoomPosition.set(this.cameraController.boomPosition.x,this.cameraController.boomPosition.y,this.cameraController.boomPosition.z),BABYLON.Vector3.LerpToRef(this.cameraNode.position,this.cameraBoomPosition,t*this.cameraController.cameraSmoothing,this.cameraNode.position))}this.updateSmoothBoomArmLength()}},i.prototype.getBoomArmMaxDistance=function(){return this.cameraController.maxDistance},i.prototype.setBoomArmMaxDistance=function(e){this.cameraController.maxDistance=Math.abs(e)},i.prototype.setSmoothBoomArmLength=function(e,t,i){void 0===i&&(i=!0);var n=Math.abs(e);this.smoothBoomArmLength=-n,this.smoothBoomArmSpeed=t,!0===i&&n>Math.abs(this.cameraController.maxDistance)&&this.setBoomArmMaxDistance(n)},i.prototype.updateSmoothBoomArmLength=function(){null!=this.smoothBoomArmLength&&null!=this.smoothBoomArmSpeed&&(this.cameraController.boomPosition.z!==this.smoothBoomArmLength?this.cameraController.boomPosition.z=BABYLON.Scalar.MoveTowards(this.cameraController.boomPosition.z,this.smoothBoomArmLength,this.smoothBoomArmSpeed*this.getDeltaSeconds()):(this.smoothBoomArmLength=null,this.smoothBoomArmSpeed=null))},i.EnableTracking=function(t){null!=e.DefaultCameraSystem.cameraInstance&&null!=e.DefaultCameraSystem.cameraInstance.cameraController&&(e.DefaultCameraSystem.cameraInstance.cameraController.targetTracking=t)},i.IsTrackingEnabled=function(){var t=!1;return null!=e.DefaultCameraSystem.cameraInstance&&null!=e.DefaultCameraSystem.cameraInstance.cameraController&&(t=e.DefaultCameraSystem.cameraInstance.cameraController.targetTracking),t},i.SetAutoUpdate=function(t){null!=e.DefaultCameraSystem.cameraInstance&&null!=e.DefaultCameraSystem.cameraInstance.cameraController&&(e.DefaultCameraSystem.cameraInstance.cameraController.autoUpdate=t)},i.IsAutoUpdateEnabled=function(){var t=!1;return null!=e.DefaultCameraSystem.cameraInstance&&null!=e.DefaultCameraSystem.cameraInstance.cameraController&&(t=e.DefaultCameraSystem.cameraInstance.cameraController.autoUpdate),t},i.GetFollowTarget=function(){return null!=e.DefaultCameraSystem.cameraInstance?e.DefaultCameraSystem.cameraInstance.setCameraTarget:null},i.SetFollowTarget=function(t){null!=e.DefaultCameraSystem.cameraInstance&&(e.DefaultCameraSystem.cameraInstance.setCameraTarget=t)},i.ResetFollowTarget=function(){null!=e.DefaultCameraSystem.cameraInstance&&e.DefaultCameraSystem.cameraInstance.resetCameraRotation()},i.UpdateFollowTarget=function(){null!=e.DefaultCameraSystem.cameraInstance&&e.DefaultCameraSystem.cameraInstance.updateCameraController()},i.GetWebXR=function(){return e.DefaultCameraSystem.XRExperienceHelper},i.IsInWebXR=function(){return null!=e.DefaultCameraSystem.XRExperienceHelper&&null!=e.DefaultCameraSystem.XRExperienceHelper.baseExperience&&e.DefaultCameraSystem.XRExperienceHelper.baseExperience.state===BABYLON.WebXRState.IN_XR},i.SetupNavigationWebXR=function(t,i){var n=e.DefaultCameraSystem.XRExperienceHelper;null!=n&&null!=n.teleportation&&null!=t&&null!=i&&""!=i&&!0===BABYLON.Tags.MatchesQuery(t,i)&&n.teleportation.addFloorMesh(t)},i.GetMainCamera=function(t,i){return void 0===i&&(i=!1),e.DefaultCameraSystem.GetPlayerCamera(t,n.PlayerNumber.One,i)},i.GetPlayerCamera=function(t,i,r){void 0===i&&(i=n.PlayerNumber.One),void 0===r&&(r=!1);var o=null,a=e.DefaultCameraSystem.GetCameraTransform(t,i);if(e.DefaultCameraSystem.IsCameraSystemReady()&&(i===n.PlayerNumber.One&&null!=e.DefaultCameraSystem.PlayerOneCamera?o=e.DefaultCameraSystem.PlayerOneCamera:i===n.PlayerNumber.Two&&null!=e.DefaultCameraSystem.PlayerTwoCamera?o=e.DefaultCameraSystem.PlayerTwoCamera:i===n.PlayerNumber.Three&&null!=e.DefaultCameraSystem.PlayerThreeCamera?o=e.DefaultCameraSystem.PlayerThreeCamera:i===n.PlayerNumber.Four&&null!=e.DefaultCameraSystem.PlayerFourCamera&&(o=e.DefaultCameraSystem.PlayerFourCamera),null!=o&&!0===r&&null!=parent&&(o.parent=null,null!=a))){o.position.copyFrom(a.position),o.rotationQuaternion=null!=a.rotationQuaternion?a.rotationQuaternion.clone():BABYLON.Quaternion.FromEulerAngles(a.rotation.x,a.rotation.y,a.rotation.z);var s=a.getChildren(null,!0);null!=s&&s.forEach(function(e){e.parent=o})}return o},i.GetCameraTransform=function(t,i){void 0===i&&(i=n.PlayerNumber.One);var r=null;return e.DefaultCameraSystem.IsCameraSystemReady()&&(i===n.PlayerNumber.One&&null!=e.DefaultCameraSystem.PlayerOneCamera&&null!=e.DefaultCameraSystem.PlayerOneCamera.transform?r=e.DefaultCameraSystem.PlayerOneCamera.transform:i===n.PlayerNumber.Two&&null!=e.DefaultCameraSystem.PlayerTwoCamera&&null!=e.DefaultCameraSystem.PlayerTwoCamera.transform?r=e.DefaultCameraSystem.PlayerTwoCamera.transform:i===n.PlayerNumber.Three&&null!=e.DefaultCameraSystem.PlayerThreeCamera&&null!=e.DefaultCameraSystem.PlayerThreeCamera.transform?r=e.DefaultCameraSystem.PlayerThreeCamera.transform:i===n.PlayerNumber.Four&&null!=e.DefaultCameraSystem.PlayerFourCamera&&null!=e.DefaultCameraSystem.PlayerFourCamera.transform&&(r=e.DefaultCameraSystem.PlayerFourCamera.transform)),r},i.IsStereoCameras=function(){return e.DefaultCameraSystem.stereoCameras},i.IsMultiPlayerView=function(){return e.DefaultCameraSystem.multiPlayerView},i.GetMultiPlayerCount=function(){return e.DefaultCameraSystem.multiPlayerCount},i.ActivateMultiPlayerCameras=function(t){var i=!1;return null!=e.DefaultCameraSystem.multiPlayerCameras&&e.DefaultCameraSystem.multiPlayerCameras.length>0&&(t.activeCameras=e.DefaultCameraSystem.multiPlayerCameras,i=!0),i},i.DisposeMultiPlayerCameras=function(){null!=e.DefaultCameraSystem.PlayerOneCamera&&(e.DefaultCameraSystem.PlayerOneCamera.dispose(),e.DefaultCameraSystem.PlayerOneCamera=null),null!=e.DefaultCameraSystem.PlayerTwoCamera&&(e.DefaultCameraSystem.PlayerTwoCamera.dispose(),e.DefaultCameraSystem.PlayerTwoCamera=null),null!=e.DefaultCameraSystem.PlayerThreeCamera&&(e.DefaultCameraSystem.PlayerThreeCamera.dispose(),e.DefaultCameraSystem.PlayerThreeCamera=null),null!=e.DefaultCameraSystem.PlayerFourCamera&&(e.DefaultCameraSystem.PlayerFourCamera.dispose(),e.DefaultCameraSystem.PlayerFourCamera=null)},i.SetMultiPlayerViewLayout=function(t,i){var r=!1,o=BABYLON.Scalar.Clamp(i,1,4);return e.DefaultCameraSystem.IsMultiPlayerView()?(null!=e.DefaultCameraSystem.PlayerOneCamera&&null!=e.DefaultCameraSystem.PlayerTwoCamera&&null!=e.DefaultCameraSystem.PlayerThreeCamera&&null!=e.DefaultCameraSystem.PlayerFourCamera?(e.DefaultCameraSystem.multiPlayerCameras=[],1===o?(e.DefaultCameraSystem.PlayerOneCamera.viewport=new BABYLON.Viewport(0,0,1,1),e.DefaultCameraSystem.PlayerTwoCamera.viewport=new BABYLON.Viewport(0,0,0,0),e.DefaultCameraSystem.PlayerTwoCamera.setEnabled(!1),e.DefaultCameraSystem.PlayerThreeCamera.viewport=new BABYLON.Viewport(0,0,0,0),e.DefaultCameraSystem.PlayerThreeCamera.setEnabled(!1),e.DefaultCameraSystem.PlayerFourCamera.viewport=new BABYLON.Viewport(0,0,0,0),e.DefaultCameraSystem.PlayerFourCamera.setEnabled(!1),e.DefaultCameraSystem.multiPlayerCameras.push(e.DefaultCameraSystem.PlayerOneCamera)):2===o?(!0===e.DefaultCameraSystem.stereoCameras?(e.DefaultCameraSystem.PlayerOneCamera.viewport=new BABYLON.Viewport(0,0,.5,1),e.DefaultCameraSystem.PlayerTwoCamera.viewport=new BABYLON.Viewport(.5,0,.5,1)):(e.DefaultCameraSystem.PlayerOneCamera.viewport=new BABYLON.Viewport(0,.5,1,.5),e.DefaultCameraSystem.PlayerTwoCamera.viewport=new BABYLON.Viewport(0,0,1,.5)),e.DefaultCameraSystem.PlayerTwoCamera.setEnabled(!0),e.DefaultCameraSystem.PlayerThreeCamera.viewport=new BABYLON.Viewport(0,0,0,0),e.DefaultCameraSystem.PlayerThreeCamera.setEnabled(!1),e.DefaultCameraSystem.PlayerFourCamera.viewport=new BABYLON.Viewport(0,0,0,0),e.DefaultCameraSystem.PlayerFourCamera.setEnabled(!1),e.DefaultCameraSystem.multiPlayerCameras.push(e.DefaultCameraSystem.PlayerOneCamera),e.DefaultCameraSystem.multiPlayerCameras.push(e.DefaultCameraSystem.PlayerTwoCamera)):3===o?(e.DefaultCameraSystem.PlayerOneCamera.viewport=new BABYLON.Viewport(0,0,.5,1),e.DefaultCameraSystem.PlayerTwoCamera.viewport=new BABYLON.Viewport(.5,.5,.5,.5),e.DefaultCameraSystem.PlayerTwoCamera.setEnabled(!0),e.DefaultCameraSystem.PlayerThreeCamera.viewport=new BABYLON.Viewport(.5,0,.5,.5),e.DefaultCameraSystem.PlayerThreeCamera.setEnabled(!0),e.DefaultCameraSystem.PlayerFourCamera.viewport=new BABYLON.Viewport(0,0,0,0),e.DefaultCameraSystem.PlayerFourCamera.setEnabled(!1),e.DefaultCameraSystem.multiPlayerCameras.push(e.DefaultCameraSystem.PlayerOneCamera),e.DefaultCameraSystem.multiPlayerCameras.push(e.DefaultCameraSystem.PlayerTwoCamera),e.DefaultCameraSystem.multiPlayerCameras.push(e.DefaultCameraSystem.PlayerThreeCamera)):4===o?(e.DefaultCameraSystem.PlayerOneCamera.viewport=new BABYLON.Viewport(0,.5,.5,.5),e.DefaultCameraSystem.PlayerTwoCamera.viewport=new BABYLON.Viewport(0,0,.5,.5),e.DefaultCameraSystem.PlayerTwoCamera.setEnabled(!0),e.DefaultCameraSystem.PlayerThreeCamera.viewport=new BABYLON.Viewport(.5,.5,.5,.5),e.DefaultCameraSystem.PlayerThreeCamera.setEnabled(!0),e.DefaultCameraSystem.PlayerFourCamera.viewport=new BABYLON.Viewport(.5,0,.5,.5),e.DefaultCameraSystem.PlayerFourCamera.setEnabled(!0),e.DefaultCameraSystem.multiPlayerCameras.push(e.DefaultCameraSystem.PlayerOneCamera),e.DefaultCameraSystem.multiPlayerCameras.push(e.DefaultCameraSystem.PlayerTwoCamera),e.DefaultCameraSystem.multiPlayerCameras.push(e.DefaultCameraSystem.PlayerThreeCamera),e.DefaultCameraSystem.multiPlayerCameras.push(e.DefaultCameraSystem.PlayerFourCamera)):n.SceneManager.LogWarning("Babylon.js camera rig invalid player count specified: "+o)):n.SceneManager.LogWarning("Babylon.js camera rig failed to initialize multi player cameras"),e.DefaultCameraSystem.multiPlayerCount=o,!1===(r=e.DefaultCameraSystem.ActivateMultiPlayerCameras(t))&&n.SceneManager.LogWarning("Babylon.js camera rig failed to initialize multi player views")):n.SceneManager.LogWarning("Babylon.js camera rig multi player view option not enabled"),r},i.PlayerOneCamera=null,i.PlayerTwoCamera=null,i.PlayerThreeCamera=null,i.PlayerFourCamera=null,i.XRExperienceHelper=null,i.multiPlayerView=!1,i.multiPlayerCount=1,i.multiPlayerCameras=null,i.stereoCameras=!0,i.startupMode=1,i.cameraReady=!1,i.cameraInstance=null,i.renderingPipeline=null,i.screenSpacePipeline=null,i.OnXRExperienceHelperObservable=new BABYLON.Observable,i.FOLLOW_SPEED=1,i}(n.ScriptComponent);e.DefaultCameraSystem=t,n.SceneManager.RegisterClass("PROJECT.DefaultCameraSystem",t)}(r||(r={})),function(e){var t=function(t){function i(e,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.DebugInformation");var o=t.call(this,e,i,n,r)||this;return o.keys=!0,o.show=!0,o.popup=!1,o.views=!1,o.xbox=!1,o.color=BABYLON.Color3.Green(),o}return o(i,t),i.GetVersion=function(){return n.SceneManager.Version},i.prototype.awake=function(){this.keys=this.getProperty("enableDebugKeys",this.keys),this.show=this.getProperty("showDebugLabels",this.show),this.popup=this.getProperty("popupDebugPanel",this.popup),this.views=this.getProperty("togglePlayerViews",this.views),this.xbox=this.getProperty("allowXboxLiveSignIn",this.xbox);var e=this.getProperty("debugOutputTextColor");null!=e&&(this.color=n.Utilities.ParseColor3(e)),n.WindowManager.IsWindows()&&(this.popup=!1),n.SceneManager.LogMessage("Debug information overlay loaded")},i.prototype.start=function(){var t=this;this.show,!0===this.keys&&(!0===this.views&&(n.SceneManager.LogMessage("Enable Multiplayer Keys"),n.InputController.OnKeyboardPress(n.UserInputKey.Num1,function(){e.DefaultCameraSystem.SetMultiPlayerViewLayout(t.scene,1),n.SceneManager.LogMessage("1 player pressed")}),n.InputController.OnKeyboardPress(n.UserInputKey.Num2,function(){e.DefaultCameraSystem.SetMultiPlayerViewLayout(t.scene,2),n.SceneManager.LogMessage("2 players pressed")}),n.InputController.OnKeyboardPress(n.UserInputKey.Num3,function(){e.DefaultCameraSystem.SetMultiPlayerViewLayout(t.scene,3),n.SceneManager.LogMessage("3 players pressed")}),n.InputController.OnKeyboardPress(n.UserInputKey.Num4,function(){e.DefaultCameraSystem.SetMultiPlayerViewLayout(t.scene,4),n.SceneManager.LogMessage("4 players pressed")})),n.InputController.OnKeyboardPress(n.UserInputKey.R,function(){window.location.reload()}),n.InputController.OnKeyboardPress(n.UserInputKey.I,function(){!0===t.popup?n.WindowManager.PopupDebug(t.scene):n.WindowManager.ToggleDebug(t.scene,!0,null)}),n.InputController.OnKeyboardPress(n.UserInputKey.F,function(){t.openFullscreen(window.top.document.documentElement)}));var i=this.color.toHexString(),r=n.SceneManager.GetEngineVersionString(this.scene);n.WindowManager.PrintToScreen(r,i)},i.prototype.destroy=function(){},i.prototype.openFullscreen=function(e){i._RequestFullscreen(e)},i.prototype.closeFullscreen=function(){i._ExitFullscreen()},i._RequestFullscreen=function(e){var t=e.requestFullscreen||e.webkitRequestFullscreen;t&&t.call(e)},i._ExitFullscreen=function(){var e=document;document.exitFullscreen?document.exitFullscreen():e.webkitCancelFullScreen&&e.webkitCancelFullScreen()},i}(n.ScriptComponent);e.DebugInformation=t,n.SceneManager.RegisterClass("PROJECT.DebugInformation",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){return void 0===n&&(n={}),void 0===r&&(r="PROJECT.AssetExporter"),e.call(this,t,i,n,r)||this}return o(t,e),t.prototype.awake=function(){},t.prototype.start=function(){},t.prototype.fixed=function(){},t.prototype.update=function(){},t.prototype.late=function(){},t.prototype.after=function(){},t.prototype.ready=function(){},t.prototype.destroy=function(){},t}(n.ScriptComponent);e.AssetExporter=t,n.SceneManager.RegisterClass("PROJECT.AssetExporter",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.AssetPreloader");var o=e.call(this,t,i,n,r)||this;return o.parentMeshes=!1,o.importMeshes=null,o.assetContainers=null,o}return o(t,e),t.prototype.destroy=function(){this.importMeshes=null,this.assetContainers=null},t.prototype.addPreloaderTasks=function(e){var t=this,i=n.SceneManager.GetRootUrl(this.scene),r=i,o="";null!=this.importMeshes&&this.importMeshes.forEach(function(a,s){r=i,o=a,a.indexOf("://")>=0&&(r=a.substring(0,a.lastIndexOf("/"))+"/",o=a.substring(a.lastIndexOf("/")+1));var l=e.addMeshTask(t.transform.name+".MeshTask."+s.toString(),null,r,o);l.onSuccess=function(e){if(null!=e.loadedMeshes){!0===t.parentMeshes&&(e.loadedMeshes[0].parent=t.transform);var i=e.sceneFilename.toString().toLowerCase();n.SceneManager.RegisterImportMeshes(t.scene,i,e.loadedMeshes)}},l.onError=function(e,t,i){console.error(t,i)}}),null!=this.assetContainers&&this.assetContainers.forEach(function(r,o){var a=i,s=r;r.indexOf("://")>=0&&(a=r.substring(0,r.lastIndexOf("/"))+"/",s=r.substring(r.lastIndexOf("/")+1));var l=e.addContainerTask(t.transform.name+".ContainerTask."+o.toString(),null,a,s);l.onSuccess=function(e){if(null!=e.loadedContainer){var i=e.sceneFilename.toString().toLowerCase();n.SceneManager.RegisterAssetContainer(t.scene,i,e.loadedContainer)}},l.onError=function(e,t,i){console.error(t,i)}})},t}(n.ScriptComponent);e.AssetPreloader=t,n.SceneManager.RegisterClass("PROJECT.AssetPreloader",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.NodeMaterialInstance");var o=e.call(this,t,i,n,r)||this;return o.nodeMaterialData=null,o.setCustomRootUrl=null,o.m_nodeMaterial=null,o}return o(t,e),t.prototype.getMaterialInstance=function(){return this.m_nodeMaterial},t.prototype.awake=function(){if(null!=this.nodeMaterialData){var e=null!=this.setCustomRootUrl&&""!==this.setCustomRootUrl?this.setCustomRootUrl.trim():"";this.m_nodeMaterial=BABYLON.NodeMaterial.Parse(this.nodeMaterialData,this.scene,e),this.m_nodeMaterial.name=this.transform.name+".NodeMaterial"}},t.prototype.destroy=function(){null!=this.m_nodeMaterial&&(this.m_nodeMaterial.dispose(),this.m_nodeMaterial=null)},t}(n.ScriptComponent);e.NodeMaterialInstance=t,n.SceneManager.RegisterClass("PROJECT.NodeMaterialInstance",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.NodeMaterialParticle");var o=e.call(this,t,i,n,r)||this;return o.nodeMaterialEditor=null,o}return o(t,e),t.prototype.awake=function(){},t.prototype.start=function(){if(null!=this.nodeMaterialEditor){var e=n.SceneManager.FindScriptComponent(this.nodeMaterialEditor,"PROJECT.NodeMaterialInstance");if(null!=e){var t=e.getMaterialInstance();null!=t?this.setupNodeMaterial(t):console.warn("Null node material instance on: "+this.nodeMaterialEditor.name)}else console.warn("Failed to locate node material editor on: "+this.nodeMaterialEditor.name)}},t.prototype.setupNodeMaterial=function(e){},t.prototype.update=function(){},t.prototype.late=function(){},t.prototype.after=function(){},t.prototype.fixed=function(){},t.prototype.ready=function(){},t.prototype.destroy=function(){this.nodeMaterialEditor=null},t}(n.ScriptComponent);e.NodeMaterialParticle=t,n.SceneManager.RegisterClass("PROJECT.NodeMaterialParticle",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.NodeMaterialProcess");var o=e.call(this,t,i,n,r)||this;return o.nodeMaterialEditor=null,o.numberOfSamples=1,o.samplingMode=0,o.textureType=0,o.textureFormat=BABYLON.Constants.TEXTUREFORMAT_RGBA,o.sizeRatio=1,o.resuable=!1,o.m_postProcess=null,o}return o(t,e),t.prototype.getPostProcess=function(){return this.m_postProcess},t.prototype.start=function(){if(null!=this.nodeMaterialEditor){var e=n.SceneManager.FindScriptComponent(this.nodeMaterialEditor,"PROJECT.NodeMaterialInstance");if(null!=e){var t=e.getMaterialInstance();null!=t?this.setupNodeMaterial(t):console.warn("Null node material instance on: "+this.nodeMaterialEditor.name)}else console.warn("Failed to locate node material editor on: "+this.nodeMaterialEditor.name)}},t.prototype.setupNodeMaterial=function(e){var t=this.getCameraRig();null!=t?(this.m_postProcess=e.createPostProcess(t,this.sizeRatio,this.samplingMode,this.scene.getEngine(),this.resuable,this.textureType,this.textureFormat),null!=this.m_postProcess?(this.m_postProcess.name=this.transform.name+".Process",this.m_postProcess.samples=this.numberOfSamples):console.warn("Failed to create post process for: "+this.transform.name)):console.warn("Null camera rig for: "+this.transform.name)},t.prototype.destroy=function(){this.nodeMaterialEditor=null,null!=this.m_postProcess&&(this.m_postProcess.dispose(),this.m_postProcess=null)},t}(n.ScriptComponent);e.NodeMaterialProcess=t,n.SceneManager.RegisterClass("PROJECT.NodeMaterialProcess",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.NodeMaterialTexture");var o=e.call(this,t,i,n,r)||this;return o.nodeMaterialEditor=null,o.textureSize=256,o.m_proceduralTexture=null,o}return o(t,e),t.prototype.getProceduralTexture=function(){return this.m_proceduralTexture},t.prototype.start=function(){if(null!=this.nodeMaterialEditor){var e=n.SceneManager.FindScriptComponent(this.nodeMaterialEditor,"PROJECT.NodeMaterialInstance");if(null!=e){var t=e.getMaterialInstance();null!=t?this.setupNodeMaterial(t):console.warn("Null node material instance on: "+this.nodeMaterialEditor.name)}else console.warn("Failed to locate node material editor on: "+this.nodeMaterialEditor.name)}},t.prototype.setupNodeMaterial=function(e){this.m_proceduralTexture=e.createProceduralTexture(this.textureSize,this.scene),null!=this.m_proceduralTexture&&(this.m_proceduralTexture.name=this.transform.name+".Texture")},t.prototype.destroy=function(){this.nodeMaterialEditor=null,null!=this.m_proceduralTexture&&(this.m_proceduralTexture.dispose(),this.m_proceduralTexture=null)},t}(n.ScriptComponent);e.NodeMaterialTexture=t,n.SceneManager.RegisterClass("PROJECT.NodeMaterialTexture",t)}(r||(r={})),function(e){var t=function(t){function i(i,n,r,o){void 0===r&&(r={}),void 0===o&&(o="PROJECT.MobileInputController");var a=t.call(this,i,n,r,o)||this;return a.styleSheet=null,a.controlType=0,a.parentElement="root",a.maxReadyTimeout=200,a.maxMoveDistance=28,a.maxMoveDeadzone=4,a.uiParentElement=null,a.leftBaseElement=null,a.rightBaseElement=null,a.buttonBaseElement=null,a.leftStickStyle=0,a.rightStickStyle=0,a.leftStickFactor=1,a.rightStickFactor=1,a.invertLeftStickY=!0,a.centerLeftJoystick=!1,a.enableLeftJoystick=!0,a.invertRightStickY=!0,a.centerRightJoystick=!1,a.enableRightJoystick=!0,a.enableMouseAxes=!1,a.enableVirtualButtons=!1,a.virtualButtonControls=null,a.m_leftStick=null,a.m_rightStick=null,a.m_mobileDevice=!1,e.MobileInputController.StaticInstance=a,a}return o(i,t),Object.defineProperty(i,"Instance",{get:function(){return e.MobileInputController.StaticInstance},enumerable:!1,configurable:!0}),i.prototype.getLeftStick=function(){return this.m_leftStick},i.prototype.getRightStick=function(){return this.m_rightStick},i.prototype.getLeftStickEnabled=function(){return this.enableLeftJoystick},i.prototype.getRightStickEnabled=function(){return this.enableRightJoystick},i.prototype.getLeftStickElement=function(){return this.leftBaseElement},i.prototype.getRightStickElement=function(){return this.rightBaseElement},i.prototype.showLeftStickElement=function(e){null!=this.leftBaseElement&&(this.leftBaseElement.style.display=!0===e?"block":"none")},i.prototype.showRightStickElement=function(e){null!=this.rightBaseElement&&(this.rightBaseElement.style.display=!0===e?"block":"none")},i.prototype.awake=function(){this.m_mobileDevice=n.WindowManager.IsMobile(),1===this.controlType||this.m_mobileDevice;var e=null!=this.parentElement&&""!==this.parentElement&&"body"!==this.parentElement.toLowerCase()?document.getElementById(this.parentElement):null;this.uiParentElement=null!=e?e:document.body},i.prototype.start=function(){1!==this.controlType&&!0!==this.m_mobileDevice||(this.loadStyleSheet(),this.loadHtmlMarkup())},i.prototype.ready=function(){var e=this;if(1===this.controlType||!0===this.m_mobileDevice){n.SceneManager.VirtualJoystickEnabled=!this.enableMouseAxes;var t=this.maxReadyTimeout>=10?this.maxReadyTimeout:10;n.WindowManager.SetTimeout(t,function(){e.createHtmlElements(),!0===e.enableLeftJoystick&&(e.m_leftStick=new n.TouchJoystickHandler("stick1",e.maxMoveDistance,e.maxMoveDeadzone)),!0===e.enableRightJoystick&&(e.m_rightStick=new n.TouchJoystickHandler("stick2",e.maxMoveDistance,e.maxMoveDeadzone))})}},i.prototype.update=function(){if((1===this.controlType||!0===this.m_mobileDevice)&&!0===n.InputController.AllowMobileControls){if(!0===this.enableLeftJoystick&&null!=this.m_leftStick){n.InputController.MobileControlsActive=!0;var e=this.m_leftStick.getValueX(),t=this.m_leftStick.getValueY(),i=BABYLON.Scalar.Clamp(e*this.leftStickFactor,-1,1),r=BABYLON.Scalar.Clamp(t*this.leftStickFactor,-1,1);n.InputController.SetLeftJoystickBuffer(i,r,this.invertLeftStickY)}if(!0===this.enableRightJoystick&&null!=this.m_rightStick){n.InputController.MobileControlsActive=!0;var o=this.m_rightStick.getValueX(),a=this.m_rightStick.getValueY(),s=BABYLON.Scalar.Clamp(o*this.rightStickFactor,-1,1),l=BABYLON.Scalar.Clamp(a*this.rightStickFactor,-1,1);n.InputController.SetRightJoystickBuffer(s,l,this.invertRightStickY)}!0===this.enableVirtualButtons&&(n.InputController.MobileControlsActive=!0)}},i.prototype.destroy=function(){null!=this.m_leftStick&&(this.m_leftStick.dispose(),this.m_leftStick=null),null!=this.m_rightStick&&(this.m_rightStick.dispose(),this.m_rightStick=null)},i.prototype.loadStyleSheet=function(){if(null!=this.styleSheet&&""!==this.styleSheet){var e=document.createElement("style");e.id="MobileStyleSheet",e.type="text/css",e.styleSheet?e.styleSheet.cssText=this.styleSheet:e.appendChild(document.createTextNode(this.styleSheet)),document.head.appendChild(e)}else console.warn("WARNING: Mobile Style Sheet Not Defined For: "+this.transform.name)},i.prototype.loadHtmlMarkup=function(){},i.prototype.createHtmlElements=function(){var e=this,t=n.SceneManager.GetRootUrl(this.scene),i=this.getProperty("leftStickBase"),r=this.getProperty("rightStickBase"),o=this.getProperty("leftStickImage"),a=this.getProperty("rightStickImage"),s=null!=i?i.filename:"baseImage.png",l=null!=r?r.filename:"baseImage.png",u=null!=o?o.filename:"leftStick.png",h=null!=a?a.filename:"rightStick.png";if(!0===this.enableLeftJoystick){this.leftBaseElement=document.createElement("div"),this.leftBaseElement.id="base1",this.leftBaseElement.style.display=0===this.leftStickStyle?"block":"none",this.leftBaseElement.className=!0===this.centerLeftJoystick?"GamepadCenterStick":"GamepadLeftStick",this.leftBaseElement.oncontextmenu=function(){return!1};var c=document.createElement("img");c.id="image1",c.src=t+s,c.className="GamepadLeftBase",c.oncontextmenu=function(){return!1},c.style.userSelect="none",c.style.webkitUserSelect="none",c.style.setProperty("-webkit-touch-callout","none"),c.style.setProperty("-webkit-user-drag","none"),c.style.setProperty("-webkit-tap-highlight-color","transparent"),c.draggable=!1;var d=document.createElement("div");d.id="stick1",d.className="GamepadLeftContent",d.oncontextmenu=function(){return!1};var m=document.createElement("img");m.id="ball1",m.src=t+u,m.className="GamepadLeftControl",m.oncontextmenu=function(){return!1},d.appendChild(m),this.leftBaseElement.appendChild(c),this.leftBaseElement.appendChild(d),this.uiParentElement.appendChild(this.leftBaseElement)}if(!0===this.enableRightJoystick){this.rightBaseElement=document.createElement("div"),this.rightBaseElement.id="base2",this.rightBaseElement.style.display=0===this.rightStickStyle?"block":"none",this.rightBaseElement.className=!0===this.centerRightJoystick?"GamepadCenterStick":"GamepadRightStick",this.rightBaseElement.oncontextmenu=function(){return!1};var p=document.createElement("img");p.id="image2",p.src=t+l,p.className="GamepadRightBase",p.oncontextmenu=function(){return!1},p.style.userSelect="none",p.style.webkitUserSelect="none",p.style.setProperty("-webkit-touch-callout","none"),p.style.setProperty("-webkit-user-drag","none"),p.style.setProperty("-webkit-tap-highlight-color","transparent"),p.draggable=!1;var f=document.createElement("div");f.id="stick2",f.className="GamepadRightContent",f.oncontextmenu=function(){return!1};var g=document.createElement("img");g.id="ball2",g.src=t+h,g.className="GamepadRightControl",g.oncontextmenu=function(){return!1},f.appendChild(g),this.rightBaseElement.appendChild(p),this.rightBaseElement.appendChild(f),this.uiParentElement.appendChild(this.rightBaseElement)}!0===this.enableVirtualButtons&&(this.buttonBaseElement=document.createElement("div"),this.buttonBaseElement.id="base0",this.buttonBaseElement.style.pointerEvents="none",this.buttonBaseElement.className="GamepadButtonGroup",this.buttonBaseElement.oncontextmenu=function(){return!1},null!=this.virtualButtonControls&&this.virtualButtonControls.forEach(function(i,r){var o=r+1,a=i.buttonImage,s=document.createElement("div");if(s.id="button"+o.toFixed(0),s.style.cursor="pointer",s.style.pointerEvents="auto",s.className=i.className,s.oncontextmenu=function(){return!1},s.addEventListener("pointerdown",function(e){n.InputController.InputKeyDownHandler(i.inputKeyCode,e)}),s.addEventListener("pointerup",function(e){n.InputController.InputKeyUpHandler(i.inputKeyCode,e)}),null!=a&&null!=a.filename)if(0===i.buttonCover){var l=document.createElement("img");l.id=s.id+".Image",l.src=t+a.filename,l.style.top="0px",l.style.left="0px",l.style.width="100%",l.style.height="100%",l.style.border="none",l.style.margin="0px",l.style.padding="0px",l.style.position="absolute",l.oncontextmenu=function(){return!1},s.appendChild(l)}else s.textContent=i.buttonName,s.style.backgroundImage="url("+t+a.filename+")",s.style.backgroundRepeat="no-repeat",s.style.backgroundSize=1===i.buttonCover?"cover":"contain";else s.textContent=i.buttonName;e.buttonBaseElement.appendChild(s)}),this.uiParentElement.appendChild(this.buttonBaseElement))},i.StaticInstance=null,i}(n.ScriptComponent);e.MobileInputController=t;var i=function(){function e(){this.joystickAngularSensibility=200,this.joystickMoveSensibility=40,this.deadzoneDelta=.1,this._yAxisScale=1,this.LSValues=new BABYLON.Vector2(0,0),this.RSValues=new BABYLON.Vector2(0,0),this._cameraTransform=BABYLON.Matrix.Identity(),this._deltaTransform=BABYLON.Vector3.Zero(),this._vector3=BABYLON.Vector3.Zero(),this._vector2=BABYLON.Vector2.Zero(),this._attached=!1}return Object.defineProperty(e.prototype,"invertYAxis",{get:function(){return 1!==this._yAxisScale},set:function(e){this._yAxisScale=e?-1:1},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){this._attached=!0},e.prototype.detachControl=function(e){this._attached=!1},e.prototype.checkInputs=function(){if(null!=this.camera&&null!=this.controller&&!0===this._attached){var e=this.controller.getLeftStick();null!=e?(this.LSValues.set(e.getValueX(),e.getValueY()),0!==this.joystickMoveSensibility&&(this.LSValues.x=Math.abs(this.LSValues.x)>this.deadzoneDelta?this.LSValues.x/this.joystickMoveSensibility:0,this.LSValues.y=Math.abs(this.LSValues.y)>this.deadzoneDelta?this.LSValues.y/this.joystickMoveSensibility:0)):this.LSValues.set(0,0);var t=this.controller.getRightStick();null!=t?(this.RSValues.set(t.getValueX(),t.getValueY()),0!==this.joystickAngularSensibility&&(this.RSValues.x=Math.abs(this.RSValues.x)>this.deadzoneDelta?this.RSValues.x/this.joystickAngularSensibility:0,this.RSValues.y=(Math.abs(this.RSValues.y)>this.deadzoneDelta?this.RSValues.y/this.joystickAngularSensibility:0)*this._yAxisScale)):this.RSValues.set(0,0),this.camera.rotationQuaternion?this.camera.rotationQuaternion.toRotationMatrix(this._cameraTransform):BABYLON.Matrix.RotationYawPitchRollToRef(this.camera.rotation.y,this.camera.rotation.x,0,this._cameraTransform);var i=50*this.camera._computeLocalCameraSpeed();this._vector3.copyFromFloats(this.LSValues.x*i,0,-this.LSValues.y*i),BABYLON.Vector3.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),this.camera.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(this.RSValues.y,this.RSValues.x),this.camera.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return"FreeCameraTouchJoystickInput"},e.prototype.getSimpleName=function(){return"joystick"},e}();e.FreeCameraTouchJoystickInput=i,BABYLON.CameraInputTypes.FreeCameraTouchJoystickInput=e.FreeCameraTouchJoystickInput,n.SceneManager.RegisterClass("PROJECT.MobileInputController",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.MobileOccludeMaterial");var o=e.call(this,t,i,n,r)||this;return o.applyToMaterial=!0,o}return o(t,e),t.prototype.awake=function(){!0===this.applyToMaterial&&this.transform instanceof BABYLON.AbstractMesh&&(this.transform.material.disableColorWrite=!0)},t}(n.ScriptComponent);e.MobileOccludeMaterial=t,n.SceneManager.RegisterClass("PROJECT.MobileOccludeMaterial",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.MobileShadowMaterial");var o=e.call(this,t,i,n,r)||this;return o.createNewMaterial=!0,o}return o(t,e),t.prototype.awake=function(){if(!0===this.createNewMaterial&&this.transform instanceof BABYLON.AbstractMesh){var e=this.transform.name.replace(" ","")+".ShadowMaterial";this.transform.material=new BABYLON.ShadowOnlyMaterial(e,this.scene)}},t.prototype.destroy=function(){!0===this.createNewMaterial&&this.transform instanceof BABYLON.AbstractMesh&&null!=this.transform.material&&this.transform.material instanceof BABYLON.ShadowOnlyMaterial&&this.transform.material.dispose()},t}(n.ScriptComponent);e.MobileShadowMaterial=t,n.SceneManager.RegisterClass("PROJECT.MobileShadowMaterial",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.BallSocketJoint");var o=e.call(this,t,i,n,r)||this;return o.bodyA=null,o.bodyB=null,o.pivotA=new BABYLON.Vector3(-.5,0,-.5),o.pivotB=new BABYLON.Vector3(-.5,0,.5),o.axisA=new BABYLON.Vector3(0,1,0),o.axisB=new BABYLON.Vector3(0,1,0),o.constraint=null,o.collisionsEnabled=!1,o}return o(t,e),t.prototype.awake=function(){var e=this.getProperty("bodyA"),t=this.getProperty("bodyB");null!=e&&null!=t&&(this.bodyA=this.transform.name===e.name?this.transform:this.getChildNode(e.name),this.bodyB=this.getChildNode(t.name),null!=this.bodyA&&null!=this.bodyB&&null!=this.bodyA.physicsBody&&null!=this.bodyB.physicsBody&&(this.constraint=new BABYLON.BallAndSocketConstraint(this.pivotA,this.pivotB,this.axisA,this.axisB,this.scene),this.bodyA.physicsBody.addConstraint(this.bodyB.physicsBody,this.constraint),this.constraint.isCollisionsEnabled=this.collisionsEnabled))},t.prototype.destroy=function(){this.bodyA=null,this.bodyB=null,null!=this.constraint&&(this.constraint.dispose(),this.constraint=null)},t}(n.ScriptComponent);e.BallSocketJoint=t,n.SceneManager.RegisterClass("PROJECT.BallSocketJoint",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.DistanceJoint");var o=e.call(this,t,i,n,r)||this;return o.bodyA=null,o.bodyB=null,o.maxDistance=0,o.constraint=null,o.collisionsEnabled=!1,o}return o(t,e),t.prototype.awake=function(){var e=this.getProperty("bodyA"),t=this.getProperty("bodyB");null!=e&&null!=t&&(this.bodyA=this.transform.name===e.name?this.transform:this.getChildNode(e.name),this.bodyB=this.getChildNode(t.name),null!=this.bodyA&&null!=this.bodyB&&null!=this.bodyA.physicsBody&&null!=this.bodyB.physicsBody&&(this.constraint=new BABYLON.DistanceConstraint(this.maxDistance,this.scene),this.bodyA.physicsBody.addConstraint(this.bodyB.physicsBody,this.constraint),this.constraint.isCollisionsEnabled=this.collisionsEnabled))},t.prototype.destroy=function(){this.bodyA=null,this.bodyB=null,null!=this.constraint&&(this.constraint.dispose(),this.constraint=null)},t}(n.ScriptComponent);e.DistanceJoint=t,n.SceneManager.RegisterClass("PROJECT.DistanceJoint",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.FixedHingeJoint");var o=e.call(this,t,i,n,r)||this;return o.bodyA=null,o.bodyB=null,o.pivotA=new BABYLON.Vector3(0,0,-.5),o.pivotB=new BABYLON.Vector3(0,0,.5),o.constraint=null,o.collisionsEnabled=!1,o}return o(t,e),t.prototype.awake=function(){var e=this.getProperty("bodyA"),t=this.getProperty("bodyB");null!=e&&null!=t&&(this.bodyA=this.transform.name===e.name?this.transform:this.getChildNode(e.name),this.bodyB=this.getChildNode(t.name),null!=this.bodyA&&null!=this.bodyB&&null!=this.bodyA.physicsBody&&null!=this.bodyB.physicsBody&&(this.constraint=new BABYLON.HingeConstraint(this.pivotA,this.pivotB,void 0,void 0,this.scene),this.bodyA.physicsBody.addConstraint(this.bodyB.physicsBody,this.constraint),this.constraint.isCollisionsEnabled=this.collisionsEnabled))},t.prototype.destroy=function(){this.bodyA=null,this.bodyB=null,null!=this.constraint&&(this.constraint.dispose(),this.constraint=null)},t}(n.ScriptComponent);e.FixedHingeJoint=t,n.SceneManager.RegisterClass("PROJECT.FixedHingeJoint",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.LockedJoint");var o=e.call(this,t,i,n,r)||this;return o.bodyA=null,o.bodyB=null,o.pivotA=new BABYLON.Vector3(.5,.5,-.5),o.pivotB=new BABYLON.Vector3(-.5,-.5,.5),o.axisA=new BABYLON.Vector3(0,1,0),o.axisB=new BABYLON.Vector3(0,1,0),o.constraint=null,o.collisionsEnabled=!1,o}return o(t,e),t.prototype.awake=function(){var e=this.getProperty("bodyA"),t=this.getProperty("bodyB");null!=e&&null!=t&&(this.bodyA=this.transform.name===e.name?this.transform:this.getChildNode(e.name),this.bodyB=this.getChildNode(t.name),null!=this.bodyA&&null!=this.bodyB&&null!=this.bodyA.physicsBody&&null!=this.bodyB.physicsBody&&(this.constraint=new BABYLON.LockConstraint(this.pivotA,this.pivotB,this.axisA,this.axisB,this.scene),this.bodyA.physicsBody.addConstraint(this.bodyB.physicsBody,this.constraint),this.constraint.isCollisionsEnabled=this.collisionsEnabled))},t.prototype.destroy=function(){this.bodyA=null,this.bodyB=null,null!=this.constraint&&(this.constraint.dispose(),this.constraint=null)},t}(n.ScriptComponent);e.LockedJoint=t,n.SceneManager.RegisterClass("PROJECT.LockedJoint",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.PrismaticJoint");var o=e.call(this,t,i,n,r)||this;return o.bodyA=null,o.bodyB=null,o.pivotA=new BABYLON.Vector3(0,0,-.2),o.pivotB=new BABYLON.Vector3(0,0,.25),o.axisA=new BABYLON.Vector3(0,1,0),o.axisB=new BABYLON.Vector3(0,1,0),o.constraint=null,o.collisionsEnabled=!1,o}return o(t,e),t.prototype.awake=function(){var e=this.getProperty("bodyA"),t=this.getProperty("bodyB");null!=e&&null!=t&&(this.bodyA=this.transform.name===e.name?this.transform:this.getChildNode(e.name),this.bodyB=this.getChildNode(t.name),null!=this.bodyA&&null!=this.bodyB&&null!=this.bodyA.physicsBody&&null!=this.bodyB.physicsBody&&(this.constraint=new BABYLON.PrismaticConstraint(this.pivotA,this.pivotB,this.axisA,this.axisB,this.scene),this.bodyA.physicsBody.addConstraint(this.bodyB.physicsBody,this.constraint),this.constraint.isCollisionsEnabled=this.collisionsEnabled))},t.prototype.destroy=function(){this.bodyA=null,this.bodyB=null,null!=this.constraint&&(this.constraint.dispose(),this.constraint=null)},t}(n.ScriptComponent);e.PrismaticJoint=t,n.SceneManager.RegisterClass("PROJECT.PrismaticJoint",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.SixdofJoint");var o=e.call(this,t,i,n,r)||this;return o.bodyA=null,o.bodyB=null,o.pivotA=new BABYLON.Vector3(0,-.5,0),o.pivotB=new BABYLON.Vector3(0,.5,0),o.perpAxisA=new BABYLON.Vector3(1,0,0),o.perpAxisB=new BABYLON.Vector3(1,0,0),o.axisLimits=null,o.constraint=null,o.collisionsEnabled=!1,o}return o(t,e),t.prototype.awake=function(){var e=this.getProperty("bodyA"),t=this.getProperty("bodyB");null!=e&&null!=t&&(this.bodyA=this.transform.name===e.name?this.transform:this.getChildNode(e.name),this.bodyB=this.getChildNode(t.name),null!=this.bodyA&&null!=this.bodyB&&null!=this.bodyA.physicsBody&&null!=this.bodyB.physicsBody&&(this.constraint=new BABYLON.Physics6DoFConstraint({pivotA:this.pivotA,pivotB:this.pivotB,perpAxisA:this.perpAxisA,perpAxisB:this.perpAxisB},this.axisLimits,this.scene),this.bodyA.physicsBody.addConstraint(this.bodyB.physicsBody,this.constraint),this.constraint.isCollisionsEnabled=this.collisionsEnabled))},t.prototype.destroy=function(){this.bodyA=null,this.bodyB=null,null!=this.constraint&&(this.constraint.dispose(),this.constraint=null)},t}(n.ScriptComponent);e.SixdofJoint=t,n.SceneManager.RegisterClass("PROJECT.SixdofJoint",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.SliderJoint");var o=e.call(this,t,i,n,r)||this;return o.bodyA=null,o.bodyB=null,o.pivotA=new BABYLON.Vector3(0,0,-.2),o.pivotB=new BABYLON.Vector3(0,0,.25),o.axisA=new BABYLON.Vector3(0,1,0),o.axisB=new BABYLON.Vector3(0,1,0),o.constraint=null,o.collisionsEnabled=!1,o}return o(t,e),t.prototype.awake=function(){var e=this.getProperty("bodyA"),t=this.getProperty("bodyB");null!=e&&null!=t&&(this.bodyA=this.transform.name===e.name?this.transform:this.getChildNode(e.name),this.bodyB=this.getChildNode(t.name),null!=this.bodyA&&null!=this.bodyB&&null!=this.bodyA.physicsBody&&null!=this.bodyB.physicsBody&&(this.constraint=new BABYLON.SliderConstraint(this.pivotA,this.pivotB,this.axisA,this.axisB,this.scene),this.bodyA.physicsBody.addConstraint(this.bodyB.physicsBody,this.constraint),this.constraint.isCollisionsEnabled=this.collisionsEnabled))},t.prototype.destroy=function(){this.bodyA=null,this.bodyB=null,null!=this.constraint&&(this.constraint.dispose(),this.constraint=null)},t}(n.ScriptComponent);e.SliderJoint=t,n.SceneManager.RegisterClass("PROJECT.SliderJoint",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.RemotePlayerController");var o=e.call(this,t,i,n,r)||this;return o.updateStateParams=!0,o.smoothMotionTime=0,o.smoothInputVectors=!1,o.animationState=null,o.animationStateParams=null,o}return o(t,e),t.prototype.awake=function(){this.updateStateParams=this.getProperty("updateStateParams",this.updateStateParams),this.smoothMotionTime=this.getProperty("smoothMotionTime",this.smoothMotionTime),this.smoothInputVectors=this.getProperty("smoothInputVectors",this.smoothInputVectors),this.animationStateParams=this.getProperty("animationStateParams",this.animationStateParams)},t.prototype.update=function(){var e=this.getDeltaSeconds();if(null==this.animationState&&this.attachAnimationController(),n.EntityController.HasNetworkEntity(this.transform)){var t=n.EntityController.QueryBufferedAttribute(this.transform,0),i=n.EntityController.QueryBufferedAttribute(this.transform,1),r=n.EntityController.QueryBufferedAttribute(this.transform,2),o=n.EntityController.QueryBufferedAttribute(this.transform,3),a=n.EntityController.QueryBufferedAttribute(this.transform,4),s=n.EntityController.QueryBufferedAttribute(this.transform,5),l=n.EntityController.QueryBufferedAttribute(this.transform,6),u=n.EntityController.QueryBufferedAttribute(this.transform,7),h=n.EntityController.QueryBufferedAttribute(this.transform,8),c=n.EntityController.QueryBufferedAttribute(this.transform,9),d=n.EntityController.QueryBufferedAttribute(this.transform,10),m=n.EntityController.QueryBufferedAttribute(this.transform,11),p=n.EntityController.QueryBufferedAttribute(this.transform,12),f=n.EntityController.QueryBufferedAttribute(this.transform,13);null!=this.animationState&&!0===this.updateStateParams&&(this.validateAnimationStateParams(),this.animationState.setInteger(this.animationStateParams.moveDirection,t),this.animationState.setFloat(this.animationStateParams.heightInput,l),this.animationState.setBool(this.animationStateParams.jumpFrame,0!==c),this.animationState.setBool(this.animationStateParams.jumpState,0!==d),this.animationState.setInteger(this.animationStateParams.actionState,h),this.animationState.setBool(this.animationStateParams.fallingState,0!==m),this.animationState.setBool(this.animationStateParams.slidingState,0!==p),this.animationState.setBool(this.animationStateParams.groundedState,0!==f),this.smoothMotionTime>0?(!0===this.smoothInputVectors?(this.animationState.setSmoothFloat(this.animationStateParams.horizontalInput,r,this.smoothMotionTime*e),this.animationState.setSmoothFloat(this.animationStateParams.verticalInput,o,this.smoothMotionTime*e),this.animationState.setSmoothFloat(this.animationStateParams.mouseXInput,a,this.smoothMotionTime*e),this.animationState.setSmoothFloat(this.animationStateParams.mouseYInput,s,this.smoothMotionTime*e)):(this.animationState.setFloat(this.animationStateParams.horizontalInput,r),this.animationState.setFloat(this.animationStateParams.verticalInput,o),this.animationState.setFloat(this.animationStateParams.mouseXInput,a),this.animationState.setFloat(this.animationStateParams.mouseYInput,s)),this.animationState.setSmoothFloat(this.animationStateParams.inputMagnitude,i,this.smoothMotionTime*e),this.animationState.setSmoothFloat(this.animationStateParams.speedInput,u,this.smoothMotionTime*e)):(this.animationState.setFloat(this.animationStateParams.horizontalInput,r),this.animationState.setFloat(this.animationStateParams.verticalInput,o),this.animationState.setFloat(this.animationStateParams.mouseXInput,a),this.animationState.setFloat(this.animationStateParams.mouseYInput,s),this.animationState.setFloat(this.animationStateParams.inputMagnitude,i),this.animationState.setFloat(this.animationStateParams.speedInput,u)))}},t.prototype.destroy=function(){this.animationState=null,this.animationStateParams=null},t.prototype.attachAnimationController=function(){var e=this;if(null==this.animationState&&(this.animationState=this.getComponent("TOOLKIT.AnimationState"),null==this.animationState)){var t=this.getChildWithScript("TOOLKIT.AnimationState");null!=t&&(this.animationState=n.SceneManager.FindScriptComponent(t,"TOOLKIT.AnimationState"))}null!=this.animationState&&this.animationState.onAnimationUpdateObservable.add(function(){e.animationState.ikFrameEnabled()})},t.prototype.validateAnimationStateParams=function(){null==this.animationStateParams&&(this.animationStateParams={moveDirection:"Direction",inputMagnitude:"Magnitude",horizontalInput:"Horizontal",verticalInput:"Vertical",mouseXInput:"MouseX",mouseYInput:"MouseY",heightInput:"Height",speedInput:"Speed",jumpFrame:"Jumped",jumpState:"Jump",actionState:"Action",fallingState:"FreeFall",slidingState:"Sliding",groundedState:"Grounded"})},t}(n.ScriptComponent);e.RemotePlayerController=t,n.SceneManager.RegisterClass("PROJECT.RemotePlayerController",t)}(r||(r={})),function(e){var t,i,r,a=function(t){function i(i,r,o,a){void 0===a&&(a="PROJECT.StandardPlayerController");var s=t.call(this,i,r,o,a)||this;return s.enableInput=!1,s.attachCamera=!1,s.rotateCamera=!0,s.mouseWheel=!0,s.toggleView=!0,s.freeLooking=!1,s.requireSprintButton=!1,s.gravitationalForce=3,s.minFallVelocity=1,s.verticalStepSpeed=1,s.minStepUpHeight=.15,s.rigidBodyMass=85,s.airbornTimeout=.5,s.maxAngle=45,s.speedFactor=1,s.rootMotion=!1,s.moveSpeed=5.335,s.walkSpeed=2,s.lookSpeed=2,s.jumpSpeed=10,s.jumpDelay=.25,s.eyesHeight=1.55,s.pivotHeight=1.35,s.maxDistance=5,s.scrollSpeed=25,s.topLookLimit=60,s.downLookLimit=30,s.lowTurnSpeed=15,s.highTurnSpeed=25,s.smoothDampTime=0,s.smoothInputVectors=!1,s.smoothAcceleration=!1,s.accelerationSpeed=.1,s.decelerationSpeed=.1,s.avatarSkinTag="Skin",s.climbVolumeTag="Climb",s.vaultVolumeTag="Vault",s.maxHeightRanges=null,s.useClimbSystem=!1,s.distanceFactor=.85,s.cameraSmoothing=8,s.cameraCollisions=!0,s.inputMagnitude=0,s.landingEpsilon=.1,s.minimumDistance=.5,s.movementAllowed=!0,s.playerInputX=0,s.playerInputZ=0,s.playerMouseX=0,s.playerMouseY=0,s.runKeyRequired=!0,s.buttonRun=BABYLON.Xbox360Button.LeftStick,s.keyboardRun=n.UserInputKey.Shift,s.buttonJump=BABYLON.Xbox360Button.A,s.keyboardJump=n.UserInputKey.SpaceBar,s.buttonCamera=BABYLON.Xbox360Button.Y,s.keyboardCamera=n.UserInputKey.P,s.postNetworkAttributes=!1,s.playerNumber=n.PlayerNumber.One,s.boomPosition=new BABYLON.Vector3(0,0,0),s.airbornVelocity=new BABYLON.Vector3(0,0,0),s.movementVelocity=new BABYLON.Vector3(0,0,0),s.targetCameraOffset=new BABYLON.Vector3(0,0,0),s.rayClimbOffset=.35,s.rayClimbLength=.85,s.canClimbObstaclePredicate=null,s.rayHeightOffset=5,s.rayHeightLength=6,s.abstractMesh=null,s.cameraDistance=0,s.forwardCamera=!0,s.avatarRadius=.5,s.groundingObject=null,s.groundingCallback=null,s.dollyDirection=new BABYLON.Vector3(0,0,0),s.cameraEulers=new BABYLON.Vector3(0,0,0),s.rotationEulers=new BABYLON.Vector3(0,0,0),s.cameraPivotOffset=new BABYLON.Vector3(0,0,0),s.cameraForwardVector=new BABYLON.Vector3(0,0,0),s.cameraRightVector=new BABYLON.Vector3(0,0,0),s.desiredForwardVector=new BABYLON.Vector3(0,0,0),s.desiredRightVector=new BABYLON.Vector3(0,0,0),s.lastRotationQuaternion=new BABYLON.Quaternion(0,0,0,1),s.scaledCamDirection=new BABYLON.Vector3(0,0,0),s.scaledMaxDirection=new BABYLON.Vector3(0,0,0),s.parentNodePosition=new BABYLON.Vector3(0,0,0),s.maximumCameraPos=new BABYLON.Vector3(0,0,0),s.tempWorldPosition=new BABYLON.Vector3(0,0,0),s.cameraRaycastShape=null,s.defaultRaycastGroup=n.CollisionFilters.DefaultFilter,s.defaultRaycastMask=n.CollisionFilters.StaticFilter,s.cameraRaycastMask=n.CollisionFilters.DefaultFilter|n.CollisionFilters.StaticFilter|n.CollisionFilters.KinematicFilter,s.avatarSkins=null,s.cameraNode=null,s.cameraPivot=null,s.navigationAgent=null,s.characterController=null,s.verticalVelocity=0,s.smoothMotionSpeed=!1,s.movementSpeed=0,s.isRunPressed=!1,s.isJumpPressed=!1,s.isCharacterSliding=!1,s.isCharacterFalling=!1,s.isCharacterGrounded=!1,s.isCharacterFallTriggered=!1,s.isCharacterJumpFrame=!1,s.isCharacterJumping=!1,s.isCharacterLanding=!1,s.isCharacterRising=!1,s.isCharacterNavigating=!1,s.navigationAngularSpeed=0,s.updateStateParams=!0,s.animationStateParams=null,s.sphereCollisionShape=null,s.hasGroundedContact=!1,s.showDebugColliders=!1,s.colliderVisibility=0,s.colliderRenderGroup=0,s.groundCheckDistance=.25,s.deltaTime=0,s.minJumpTimer=0,s.delayJumpTimer=0,s.playerControl=0,s.canPlayerJump=!0,s.animationState=null,s.lastJumpVelocity=new BABYLON.Vector3(0,0,0),s.inputMovementVector=new BABYLON.Vector3(0,0,0),s.playerLookRotation=new BABYLON.Vector3(0,0,0),s.playerRotationVector=BABYLON.Vector2.Zero(),s.playerMovementVelocity=new BABYLON.Vector3(0,0,0),s.playerRotationQuaternion=BABYLON.Quaternion.Zero(),s.playerMoveDirection=e.PlayerMoveDirection.Stationary,s.forwardDirection=new BABYLON.Vector3(0,0,1),s.downDirection=new BABYLON.Vector3(0,-1,0),s.climbContact=!1,s.climbContactNode=null,s.climbContactAngle=0,s.climbContactPoint=new BABYLON.Vector3(0,0,0),s.climbContactNormal=new BABYLON.Vector3(0,0,0),s.climbContactDistance=0,s.climbSensorLine=null,s.offsetClimbRaycastPosition=new BABYLON.Vector3(0,0,0),s.startClimbRaycastPosition=new BABYLON.Vector3(0,0,0),s.endClimbRaycastPosition=new BABYLON.Vector3(0,0,0),s.heightContact=!1,s.heightContactNode=null,s.heightContactAngle=0,s.heightContactPoint=new BABYLON.Vector3(0,0,0),s.heightContactNormal=new BABYLON.Vector3(0,0,0),s.heightContactDistance=0,s.heightSensorLine=null,s.offsetHeightRaycastPosition=new BABYLON.Vector3(0,0,0),s.startHeightRaycastPosition=new BABYLON.Vector3(0,0,0),s.endHeightRaycastPosition=new BABYLON.Vector3(0,0,0),s.m_velocityOffset=new BABYLON.Vector3(0,0,0),s.m_actualVelocity=new BABYLON.Vector3(0,0,0),s.m_linearVelocity=new BABYLON.Vector3(0,0,0),s.m_lastPosition=new BABYLON.Vector3(0,0,0),s.m_positionCenter=new BABYLON.Vector3(0,0,0),s.m_scaledVelocity=0,s.playerDrawVelocity=0,s.onPreUpdateObservable=new BABYLON.Observable,s.onBeforeMoveObservable=new BABYLON.Observable,s.onPostUpdateObservable=new BABYLON.Observable,s.onPlayerInputObservable=new BABYLON.Observable,s.onPlayerPositionObservable=new BABYLON.Observable,s.onUpdateActionObservable=new BABYLON.Observable,s._deltaMotionPosition=new BABYLON.Vector3(0,0,0),s._deltaMotionRotation=new BABYLON.Quaternion(0,0,0,0),s.isPerformingAction=!1,s.isRootMotionAction=!1,s.isActionInterruptable=!1,s.afterActionHandler=null,s.performActionTimer=0,s.performActionNumber=0,s.playerRotationSpeed=10,s.rotatePlayerTowards=!1,s.matchStartTime=0,s.matchTargetTime=0,s.matchTargetOffset=0,s.matchTargetHeight=!1,s.lockTargetHeight=!1,s.lastStartHeight=null,s.lastTargetHeight=null,s.lastTargetNormal=new BABYLON.Vector3(0,0,0),s.lastTargetRotation=new BABYLON.Quaternion(0,0,0,1),s.lastDeltaPosition=new BABYLON.Vector3(0,0,0),s.lastDeltaRotation=new BABYLON.Quaternion(0,0,0,1),s.ikLeftFootTarget=null,s.ikLeftPoleTarget=null,s.ikRightFootTarget=null,s.ikRightPoleTarget=null,s.abstractSkinMesh=null,s.rootBoneTransform=null,s.leftFootTransform=null,s.leftFootPoleOffset=new BABYLON.Vector3(-.1,.5,.5),s.leftFootMaxAngle=90,s.rightFootTransform=null,s.rightFootPoleOffset=new BABYLON.Vector3(.1,.5,.5),s.rightFootMaxAngle=90,s.ikLeftController=null,s.ikRightController=null,s.onAnimatorIK=null,s.smoothBoomArmLength=null,s.smoothBoomArmSpeed=null,s}return o(i,t),i.prototype.isAnimationEnabled=function(){return this.updateStateParams},i.prototype.isRunButtonPressed=function(){return this.isRunPressed},i.prototype.isJumpButtonPressed=function(){return this.isJumpPressed},i.prototype.getPlayerJumped=function(){return this.isCharacterJumpFrame},i.prototype.getPlayerJumping=function(){return this.isCharacterJumping},i.prototype.getPlayerFalling=function(){return this.isCharacterFalling},i.prototype.getPlayerSliding=function(){return this.isCharacterSliding},i.prototype.getPlayerGrounded=function(){return this.isCharacterGrounded},i.prototype.getFallTriggered=function(){return this.isCharacterFallTriggered},i.prototype.getMovementSpeed=function(){return this.movementSpeed},i.prototype.getCameraBoomNode=function(){return this.cameraNode},i.prototype.getCameraTransform=function(){return this.cameraPivot},i.prototype.getAnimationState=function(){return this.animationState},i.prototype.getVerticalVelocity=function(){return this.getCheckedVerticalVelocity()},i.prototype.getCharacterController=function(){return this.characterController},i.prototype.getPlayerLookRotation=function(){return this.playerLookRotation},i.prototype.getPlayerMoveDirection=function(){return this.playerMoveDirection},i.prototype.getInputMovementVector=function(){return this.inputMovementVector},i.prototype.getInputMagnitudeValue=function(){return this.inputMagnitude},i.prototype.getCameraPivotPosition=function(){return null!=this.cameraPivot?this.cameraPivot.position:null},i.prototype.getCameraPivotRotation=function(){return null!=this.cameraPivot?this.cameraPivot.rotationQuaternion:null},i.prototype.getClimbContact=function(){return this.climbContact},i.prototype.getClimbContactNode=function(){return this.climbContactNode},i.prototype.getClimbContactPoint=function(){return this.climbContactPoint},i.prototype.getClimbContactAngle=function(){return this.climbContactAngle},i.prototype.getClimbContactNormal=function(){return this.climbContactNormal},i.prototype.getClimbContactDistance=function(){return this.climbContactDistance},i.prototype.getHeightContact=function(){return this.heightContact},i.prototype.getHeightContactNode=function(){return this.heightContactNode},i.prototype.getHeightContactPoint=function(){return this.heightContactPoint},i.prototype.getHeightContactAngle=function(){return this.heightContactAngle},i.prototype.getHeightContactNormal=function(){return this.heightContactNormal},i.prototype.getHeightContactDistance=function(){return this.heightContactDistance},i.prototype.awake=function(){this.awakePlayerController()},i.prototype.start=function(){this.startPlayerController()},i.prototype.after=function(){this.afterPlayerController()},i.prototype.update=function(){this.updatePlayerController()},i.prototype.destroy=function(){this.destroyPlayerController()},i.prototype.getDeltaMotionPosition=function(){if(this._deltaMotionPosition.set(0,0,0),null!=this.animationState){var e=this.animationState.getDeltaRootMotionPosition();null!=e&&this._deltaMotionPosition.copyFrom(e)}return this._deltaMotionPosition},i.prototype.getDeltaMotionRotation=function(){if(this._deltaMotionRotation.set(0,0,0,0),null!=this.animationState){var e=this.animationState.getDeltaRootMotionRotation();null!=e&&this._deltaMotionRotation.copyFrom(e)}return this._deltaMotionRotation},i.prototype.getIsPerformingAction=function(){return this.isPerformingAction},i.prototype.getIsRootMotionAction=function(){return this.isRootMotionAction},i.prototype.getIsActionInterruptable=function(){return this.isActionInterruptable},i.prototype.playActionAnimation=function(e,t,i,n){void 0===t&&(t=!0),void 0===i&&(i=!1),void 0===n&&(n=null),!1===this.isPerformingAction&&null!=this.animationState&&e>=0&&(this.isPerformingAction=!0,this.performActionTimer=0,this.performActionNumber=e,this.afterActionHandler=n,this.isActionInterruptable=t,this.isRootMotionAction=i,this.playerRotationSpeed=10,this.rotatePlayerTowards=!1,this.matchStartTime=0,this.matchTargetTime=0,this.matchTargetOffset=0,this.matchTargetHeight=!1,this.lockTargetHeight=!1,this.lastStartHeight=null,this.lastTargetHeight=null,this.lastTargetNormal.set(0,0,0),this.lastTargetRotation.set(0,0,0,1),!0===this.isRootMotionAction&&this.enableCharacterController(!1))},i.prototype.resetActionAnimationState=function(){if(null!=this.afterActionHandler)try{this.afterActionHandler()}catch(e){}!0===this.isRootMotionAction&&this.enableCharacterController(!0),this.performActionTimer=0,this.performActionNumber=0,this.isPerformingAction=!1,this.isRootMotionAction=!1,this.isActionInterruptable=!1,this.afterActionHandler=null,this.playerRotationSpeed=10,this.rotatePlayerTowards=!1,this.matchStartTime=0,this.matchTargetTime=0,this.matchTargetOffset=0,this.matchTargetHeight=!1,this.lockTargetHeight=!1,this.lastStartHeight=null,this.lastTargetHeight=null,this.lastTargetNormal.set(0,0,0),this.lastTargetRotation.set(0,0,0,1)},i.prototype.updateAnimationActionState=function(){var t=this.getDeltaSeconds(),i=this.matchTargetTime-this.matchStartTime;if(null!=this.animationState&&!0===this.isRootMotionAction){var r=this.transform.absolutePosition.y;if(this.lastDeltaPosition.copyFrom(this.getDeltaMotionPosition()),BABYLON.Vector3.TransformNormalToRef(this.lastDeltaPosition,this.transform.getWorldMatrix(),this.lastDeltaPosition),!0===this.matchTargetHeight&&(null==this.lastStartHeight&&this.performActionTimer>=this.matchStartTime&&(this.lastStartHeight=r),null!=this.lastStartHeight&&null!=this.lastTargetHeight)){this.lastDeltaPosition.y=0;var o=this.lastTargetHeight+this.matchTargetOffset;if(this.performActionTimer<this.matchTargetTime){this.animationState.setSmoothFloat(e.ThirdPersonPlayerController.PLAYER_HEIGHT,o,i*t);var a=this.animationState.getFloat(e.ThirdPersonPlayerController.PLAYER_HEIGHT);this.lastDeltaPosition.y=a-r}else!1===this.lockTargetHeight&&this.performActionTimer>=this.matchTargetTime&&(this.lastDeltaPosition.y=o-r,this.lockTargetHeight=!0)}if(this.transform.position.addInPlace(this.lastDeltaPosition),!0===this.rotatePlayerTowards){if(!0===this.climbContact){this.lastTargetNormal.set(-this.climbContactNormal.x,-this.climbContactNormal.y,-this.climbContactNormal.z),n.Utilities.LookRotationToRef(this.lastTargetNormal,this.lastTargetRotation);var s=BABYLON.Scalar.Clamp(this.playerRotationSpeed*t);BABYLON.Quaternion.SlerpToRef(this.transform.rotationQuaternion,this.lastTargetRotation,s,this.transform.rotationQuaternion)}}else this.lastDeltaRotation.copyFrom(this.getDeltaMotionRotation()),this.transform.rotationQuaternion.multiplyInPlace(this.lastDeltaRotation)}this.performActionTimer+=t},i.prototype.setWorldPosition=function(e,t,i){null!=this.characterController&&this.characterController.set(e,t,i)},i.prototype.setPlayerControl=function(t){this.playerControl=t,this.playerControl===e.PlayerInputControl.ThirdPersonStrafing?this.showAvatarSkins(!0):this.showAvatarSkins(!1),this.forwardCamera=!1},i.prototype.togglePlayerControl=function(){!0===this.toggleView&&(this.playerControl===e.PlayerInputControl.FirstPersonStrafing?this.setPlayerControl(e.PlayerInputControl.ThirdPersonStrafing):this.setPlayerControl(e.PlayerInputControl.FirstPersonStrafing))},i.prototype.showAvatarSkins=function(e){null!=this.avatarSkins&&this.avatarSkins.forEach(function(t){t.isVisible=e})},i.prototype.attachPlayerCamera=function(t){if(null==this.cameraNode){var i=t<=0||t>4?1:t;this.cameraNode=e.DefaultCameraSystem.GetCameraTransform(this.scene,i),null!=this.cameraNode&&(this.cameraNode.parent=this.cameraPivot,this.cameraNode.position.copyFrom(this.boomPosition),this.cameraNode.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1),this.cameraDistance=this.cameraNode.position.length(),this.dollyDirection.copyFrom(this.cameraNode.position),this.dollyDirection.normalize())}},i.prototype.getPlayerMesh=function(){return this.abstractSkinMesh},i.prototype.getRootHipBone=function(){return null!=this.rootBoneTransform?this.rootBoneTransform._linkedBone:null},i.prototype.getLeftFootBone=function(){return null!=this.leftFootTransform?this.leftFootTransform._linkedBone:null},i.prototype.getRightFootBone=function(){return null!=this.rightFootTransform?this.rightFootTransform._linkedBone:null},i.prototype.getLeftFootTarget=function(){return this.ikLeftFootTarget},i.prototype.getRightFootTarget=function(){return this.ikRightFootTarget},i.prototype.getLeftFootPoleTarget=function(){return this.ikLeftPoleTarget},i.prototype.getRightFootPoleTarget=function(){return this.ikRightPoleTarget},i.prototype.getRootBoneTransform=function(){return this.rootBoneTransform},i.prototype.getLeftFootTransform=function(){return this.leftFootTransform},i.prototype.getRightFootTransform=function(){return this.rightFootTransform},i.prototype.getLeftFootController=function(){return this.ikLeftController},i.prototype.getRightFootController=function(){return this.ikRightController},i.prototype.isGroundedFootIKActive=function(){return!0===this.isCharacterGrounded&&null!=this.animationState&&this.animationState.ikFrameEnabled()},i.prototype.setupBoneControllers=function(){if(!0===this.getProperty("createFootIKRig")){var e=this.getProperty("displayHandles"),t=this.getProperty("abstractSkinMesh");null!=t&&(this.abstractSkinMesh=this.getChildNode(t.name,n.SearchType.ExactMatch,!1));var i=this.getProperty("rootBoneTransform");null!=i&&(this.rootBoneTransform=this.getChildNode(i.name,n.SearchType.ExactMatch,!1));var r=this.getProperty("leftFootTransform");null!=r&&(this.leftFootTransform=this.getChildNode(r.name,n.SearchType.ExactMatch,!1));var o=this.getProperty("leftFootPoleOffset");null!=o&&this.leftFootPoleOffset.copyFrom(n.Utilities.ParseVector3(o)),this.leftFootMaxAngle=this.getProperty("leftFootMaxAngle",this.leftFootMaxAngle);var a=this.getProperty("rightFootTransform");null!=a&&(this.rightFootTransform=this.getChildNode(a.name,n.SearchType.ExactMatch,!1));var s=this.getProperty("rightFootPoleOffset");if(null!=s&&this.rightFootPoleOffset.copyFrom(n.Utilities.ParseVector3(s)),this.rightFootMaxAngle=this.getProperty("rightFootMaxAngle",this.rightFootMaxAngle),null!=this.abstractSkinMesh&&null!=this.rootBoneTransform){var l=this.scene.getMaterialByName("M_TARGET_MESH");null==l&&((l=new BABYLON.StandardMaterial("M_TARGET_MESH",this.scene)).diffuseColor=new BABYLON.Color3(1,.5,.25)),null!=this.leftFootTransform&&null!=this.leftFootTransform._linkedBone&&(this.ikLeftFootTarget=BABYLON.MeshBuilder.CreateBox(this.transform.name+".LeftFootTarget",{width:.1,height:.1,depth:.1},this.scene),this.ikLeftFootTarget.parent=this.leftFootTransform,this.ikLeftFootTarget.position.set(0,0,0),this.ikLeftFootTarget.material=l,this.ikLeftFootTarget.isVisible=e,this.ikLeftPoleTarget=BABYLON.MeshBuilder.CreateSphere(this.transform.name+".LeftFootPole",{diameter:.1},this.scene),this.ikLeftPoleTarget.parent=this.abstractSkinMesh,this.ikLeftPoleTarget.position.copyFrom(this.leftFootPoleOffset),this.ikLeftPoleTarget.isVisible=e),null!=this.rightFootTransform&&null!=this.rightFootTransform._linkedBone&&(this.ikRightFootTarget=BABYLON.MeshBuilder.CreateBox(this.transform.name+".RightFootTarget",{width:.1,height:.1,depth:.1},this.scene),this.ikRightFootTarget.parent=this.rightFootTransform,this.ikRightFootTarget.position.set(0,0,0),this.ikRightFootTarget.material=l,this.ikRightFootTarget.isVisible=e,this.ikRightPoleTarget=BABYLON.MeshBuilder.CreateSphere(this.transform.name+".RightFootPole",{diameter:.1},this.scene),this.ikRightPoleTarget.parent=this.abstractSkinMesh,this.ikRightPoleTarget.position.copyFrom(this.rightFootPoleOffset),this.ikRightPoleTarget.isVisible=e)}}},i.prototype.attachAnimationController=function(){var e=this;null==this.animationState&&(this.animationState=this.getComponent("TOOLKIT.AnimationState",!0)),null!=this.animationState&&(this.animationState.onAnimationEndObservable.add(function(){!0===e.isPerformingAction&&e.resetActionAnimationState()}),this.animationState.onAnimationUpdateObservable.add(function(){null!=e.onAnimatorIK?e.onAnimatorIK():(e.updateAnimatorTargetMeshes(),null!=e.ikLeftController&&e.ikLeftController.update(),null!=e.ikRightController&&e.ikRightController.update())}))},i.prototype.updateAnimatorTargetMeshes=function(){},i.prototype.enableCharacterController=function(e){!0===e?(this.movementAllowed=!0,this.resetPlayerJumpingState(),null!=this.characterController&&(this.characterController.setGravityFactor(this.gravitationalForce),this.characterController.setCollisionState(!0))):(this.movementAllowed=!1,this.resetPlayerJumpingState(),null!=this.characterController&&(this.characterController.setGravityFactor(0),this.characterController.setCollisionState(!1)))},i.prototype.resetPlayerRotation=function(){this.transform.rotationQuaternion.toEulerAnglesToRef(this.rotationEulers),this.playerRotationVector.x=this.rotationEulers.x,this.playerRotationVector.y=this.rotationEulers.y},i.prototype.resetPlayerJumpingState=function(){this.minJumpTimer=0,this.isCharacterJumping=!1,this.isCharacterLanding=!1,this.isCharacterRising=!1,this.isCharacterJumpFrame=!1,null!=this.characterController&&this.characterController.jump(0)},i.prototype.awakePlayerController=function(){var e=this;this.gravitationalForce=this.getProperty("gravityMultiplier",this.gravitationalForce),this.verticalStepSpeed=this.getProperty("stepUpVelocity",this.verticalStepSpeed),this.minStepUpHeight=this.getProperty("minStepHeight",this.minStepUpHeight),this.rigidBodyMass=this.getProperty("rigidBodyMass",this.rigidBodyMass),this.rotateCamera=this.getProperty("rotateCamera",this.rotateCamera),this.mouseWheel=this.getProperty("mouseWheel",this.mouseWheel),this.rayClimbLength=this.getProperty("rayClimbLength",this.rayClimbLength),this.rayClimbOffset=this.getProperty("rayClimbOffset",this.rayClimbOffset),this.rayHeightLength=this.getProperty("rayHeightLength",this.rayHeightLength),this.rayHeightOffset=this.getProperty("rayHeightOffset",this.rayHeightOffset),this.maxAngle=this.getProperty("maxAngle",this.maxAngle),this.landingEpsilon=this.getProperty("landingEpsilon",this.landingEpsilon),this.minFallVelocity=this.getProperty("minFallVelocity",this.minFallVelocity),this.airbornTimeout=this.getProperty("airbornTimeout",this.airbornTimeout),this.rootMotion=this.getProperty("rootMotion",this.rootMotion),this.moveSpeed=this.getProperty("moveSpeed",this.moveSpeed),this.walkSpeed=this.getProperty("walkSpeed",this.walkSpeed),this.lookSpeed=this.getProperty("lookSpeed",this.lookSpeed),this.jumpSpeed=this.getProperty("jumpSpeed",this.jumpSpeed),this.jumpDelay=this.getProperty("jumpDelay",this.jumpDelay),this.eyesHeight=this.getProperty("eyesHeight",this.eyesHeight),this.pivotHeight=this.getProperty("pivotHeight",this.pivotHeight),this.maxDistance=this.getProperty("maxDistance",this.maxDistance),this.scrollSpeed=this.getProperty("scrollSpeed",this.scrollSpeed),this.topLookLimit=this.getProperty("topLookLimit",this.topLookLimit),this.downLookLimit=this.getProperty("downLookLimit",this.downLookLimit),this.lowTurnSpeed=this.getProperty("lowTurnSpeed",this.lowTurnSpeed),this.highTurnSpeed=this.getProperty("highTurnSpeed",this.highTurnSpeed),this.enableInput=this.getProperty("enableInput",this.enableInput),this.playerNumber=this.getProperty("playerNumber",this.playerNumber),this.attachCamera=this.getProperty("attachCamera",this.attachCamera),this.freeLooking=this.getProperty("freeLooking",this.freeLooking),this.toggleView=this.getProperty("toggleView",this.toggleView),this.avatarSkinTag=this.getProperty("avatarSkinTag",this.avatarSkinTag),this.runKeyRequired=this.getProperty("runKeyRequired",this.runKeyRequired),this.cameraCollisions=this.getProperty("cameraCollisions",this.cameraCollisions),this.cameraSmoothing=this.getProperty("cameraSmoothing",this.cameraSmoothing),this.distanceFactor=this.getProperty("distanceFactor",this.distanceFactor),this.minimumDistance=this.getProperty("minimumDistance",this.minimumDistance),this.smoothDampTime=this.getProperty("smoothDampTime",this.smoothDampTime),this.smoothInputVectors=this.getProperty("smoothInputVectors",this.smoothInputVectors),this.smoothAcceleration=this.getProperty("smoothAcceleration",this.smoothAcceleration),this.accelerationSpeed=this.getProperty("accelerationSpeed",this.accelerationSpeed),this.decelerationSpeed=this.getProperty("decelerationSpeed",this.decelerationSpeed),this.climbVolumeTag=this.getProperty("climbVolumeTag",this.climbVolumeTag),this.vaultVolumeTag=this.getProperty("vaultVolumeTag",this.vaultVolumeTag),this.useClimbSystem=this.getProperty("useClimbSystem",this.useClimbSystem),this.maxHeightRanges=this.getProperty("maxHeightRanges",this.maxHeightRanges),this.smoothMotionSpeed=this.getProperty("smoothMotionSpeed",this.smoothMotionSpeed),this.updateStateParams=this.getProperty("updateStateParams",this.updateStateParams),this.animationStateParams=this.getProperty("animationStateParams",this.animationStateParams),this.postNetworkAttributes=this.getProperty("postNetworkAttribs",this.postNetworkAttributes),this.groundCheckDistance=this.getProperty("groundCheckDist",this.groundCheckDistance),!0===this.getProperty("arrowKeyRotation")&&(n.UserInputOptions.UseArrowKeyRotation=!0);var t=this.getProperty("boomPosition");null!=t&&(this.boomPosition=n.Utilities.ParseVector3(t));var i=this.getProperty("sphereRadius",.65);this.cameraRaycastShape=new BABYLON.PhysicsShapeSphere(new BABYLON.Vector3(0,0,0),i,this.scene),this.abstractMesh=this.getAbstractMesh(),this.showDebugColliders=n.Utilities.ShowDebugColliders(),this.colliderVisibility=n.Utilities.ColliderVisibility(),this.colliderRenderGroup=n.Utilities.ColliderRenderGroup(),null!=this.avatarSkinTag&&""!==this.avatarSkinTag&&(this.avatarSkins=this.getChildrenWithTags(this.avatarSkinTag,!1));var r=this.getProperty("playerControl",this.playerControl);if(this.setPlayerControl(r),this.resetPlayerRotation(),this.cameraPivot=new BABYLON.Mesh(this.transform.name+".CameraPivot",this.scene),this.cameraPivot.parent=null,this.cameraPivot.position=this.transform.position.clone(),this.cameraPivot.rotationQuaternion=this.transform.rotationQuaternion.clone(),this.cameraPivot.checkCollisions=!1,this.cameraPivot.isPickable=!1,!0===this.showDebugColliders){var o=BABYLON.MeshBuilder.CreateBox("TestPivot",{width:.25,height:.25,depth:.5},this.scene);o.parent=this.cameraPivot,o.position.set(0,0,0),o.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1),o.visibility=.5,o.renderingGroupId=this.colliderRenderGroup,o.checkCollisions=!1,o.isPickable=!1}this.getComponent("TOOLKIT.CharacterController"),this.setupBoneControllers(),n.InputController.OnKeyboardPress(this.keyboardCamera,function(){e.togglePlayerControl()}),n.InputController.OnGamepadButtonPress(this.buttonCamera,function(){e.togglePlayerControl()})},i.prototype.startPlayerController=function(){var e=this;!0===this.attachCamera&&this.attachPlayerCamera(this.playerNumber),this.navigationAgent=this.getComponent("TOOLKIT.NavigationAgent"),this.characterController=this.getComponent("TOOLKIT.CharacterController"),null!=this.characterController?(this.avatarRadius=this.characterController.getAvatarRadius(),this.characterController.enableGravity=!0,this.characterController.enableStepOffset=!0,this.characterController.useMultiRaycast=!0,this.characterController.multiRaycastCount=5,this.characterController.stepUpVelocityFactor=.5,this.characterController.groundCheckDistance=this.groundCheckDistance,this.characterController.setRigidBodyMass(this.rigidBodyMass),this.characterController.setGravityFactor(this.gravitationalForce),this.characterController.onUpdatePositionObservable.add(function(){e.updatePlayerPosition(),e.updateCameraController()}),n.SceneManager.LogWarning("Starting player controller in physic engine mode for: "+this.transform.name)):n.SceneManager.LogWarning("No character controller found for: "+this.transform.name)},i.prototype.updatePlayerPosition=function(){this.onPlayerPositionObservable&&this.onPlayerPositionObservable.hasObservers()&&this.onPlayerPositionObservable.notifyObservers(this.transform)},i.prototype.updatePlayerController=function(){if(this.deltaTime=this.getDeltaSeconds(),this.m_actualVelocity=this.transform.absolutePosition.subtract(this.m_lastPosition),this.m_linearVelocity.copyFrom(this.m_actualVelocity),this.m_scaledVelocity=this.m_linearVelocity.length()/this.deltaTime,this.m_linearVelocity.normalize(),this.m_linearVelocity.scaleInPlace(this.m_scaledVelocity),this.playerDrawVelocity>0?(this.m_velocityOffset.copyFrom(this.m_linearVelocity),this.m_velocityOffset.scaleInPlace(this.playerDrawVelocity)):this.m_velocityOffset.set(0,0,0),this.m_lastPosition.copyFrom(this.transform.absolutePosition),!0===this.updateStateParams&&null==this.animationState&&this.attachAnimationController(),this.minJumpTimer>0&&(this.minJumpTimer-=this.deltaTime,this.minJumpTimer<0&&(this.minJumpTimer=0)),!0===this.isCharacterGrounded&&this.delayJumpTimer>0&&(this.delayJumpTimer-=this.deltaTime,this.delayJumpTimer<0&&(this.delayJumpTimer=0)),this.canPlayerJump=!0,!0===this.isPerformingAction&&(this.updateAnimationActionState(),this.onUpdateActionObservable&&this.onUpdateActionObservable.hasObservers()&&this.onUpdateActionObservable.notifyObservers(this.transform)),!1!==this.enableInput){var t=n.InputController.GetUserInput(n.UserInputAxis.Horizontal,this.playerNumber),i=n.InputController.GetUserInput(n.UserInputAxis.Vertical,this.playerNumber),r=n.InputController.GetUserInput(n.UserInputAxis.MouseX,this.playerNumber),o=n.InputController.GetUserInput(n.UserInputAxis.MouseY,this.playerNumber);!0===this.smoothAcceleration?(t>0?(this.playerInputX+=this.accelerationSpeed*this.deltaTime,this.playerInputX>1&&(this.playerInputX=1)):t<0?(this.playerInputX-=this.accelerationSpeed*this.deltaTime,this.playerInputX<-1&&(this.playerInputX=-1)):this.playerInputX<0?(this.playerInputX+=this.decelerationSpeed*this.deltaTime,this.playerInputX>0&&(this.playerInputX=0)):this.playerInputX>0&&(this.playerInputX-=this.decelerationSpeed*this.deltaTime,this.playerInputX<0&&(this.playerInputX=0)),i>0?(this.playerInputZ+=this.accelerationSpeed*this.deltaTime,this.playerInputZ>1&&(this.playerInputZ=1)):i<0?(this.playerInputZ-=this.accelerationSpeed*this.deltaTime,this.playerInputZ<-1&&(this.playerInputZ=-1)):this.playerInputZ<0?(this.playerInputZ+=this.decelerationSpeed*this.deltaTime,this.playerInputZ>0&&(this.playerInputZ=0)):this.playerInputZ>0&&(this.playerInputZ-=this.decelerationSpeed*this.deltaTime,this.playerInputZ<0&&(this.playerInputZ=0))):(this.playerInputX=t,this.playerInputZ=i),this.playerMouseX=r,this.playerMouseY=o,!0===this.isPerformingAction&&!0===this.isActionInterruptable&&(0===this.playerInputX&&0===this.playerInputZ||this.resetActionAnimationState()),!0===this.isPerformingAction&&(this.canPlayerJump=!1,this.playerInputX=0,this.playerInputZ=0),this.onPlayerInputObservable&&this.onPlayerInputObservable.hasObservers()&&this.onPlayerInputObservable.notifyObservers(this.transform),this.inputMovementVector.set(this.playerInputX,0,this.playerInputZ),this.inputMovementVector.length()>1&&this.inputMovementVector.normalize(),this.inputMagnitude=this.inputMovementVector.length();var a=this.playerInputZ>0,s=this.playerInputZ<0,l=this.playerInputX>0,u=this.playerInputX<0;if(this.playerMoveDirection=!0===a?!0===u?e.PlayerMoveDirection.ForwardLeft:!0===l?e.PlayerMoveDirection.ForwardRight:e.PlayerMoveDirection.Forward:!0===s?!0===u?e.PlayerMoveDirection.BackwardLeft:!0===l?e.PlayerMoveDirection.BackwardRight:e.PlayerMoveDirection.Backward:!0===u?e.PlayerMoveDirection.StrafingLeft:!0===l?e.PlayerMoveDirection.StrafingRight:e.PlayerMoveDirection.Stationary,this.onPreUpdateObservable&&this.onPreUpdateObservable.hasObservers()&&this.onPreUpdateObservable.notifyObservers(this.transform),this.cameraForwardVector=this.scene.activeCamera.getForwardRay().direction,this.cameraForwardVector.y=0,this.cameraForwardVector.normalize(),this.cameraForwardVector.scaleToRef(this.playerInputZ,this.desiredForwardVector),this.cameraRightVector=BABYLON.Vector3.Cross(this.cameraForwardVector,BABYLON.Vector3.Up()),this.cameraRightVector.y=0,this.cameraRightVector.normalize(),this.cameraRightVector.scaleToRef(this.playerInputX,this.desiredRightVector),this.playerRotationVector.y+=this.playerMouseX*this.lookSpeed*this.deltaTime,this.playerRotationVector.x+=-this.playerMouseY*this.lookSpeed*this.deltaTime,this.playerRotationVector.x=BABYLON.Scalar.Clamp(this.playerRotationVector.x,-BABYLON.Tools.ToRadians(this.downLookLimit),BABYLON.Tools.ToRadians(this.topLookLimit)),!1===this.movementAllowed&&(this.canPlayerJump=!1,this.playerInputX=0,this.playerInputZ=0),this.isRunPressed=n.InputController.GetKeyboardInput(this.keyboardRun)||n.InputController.GetGamepadButtonInput(this.buttonRun),this.isJumpPressed=n.InputController.GetKeyboardInput(this.keyboardJump)||n.InputController.GetGamepadButtonInput(this.buttonJump),this.movementSpeed=this.inputMagnitude*this.moveSpeed*this.speedFactor,!0===this.runKeyRequired&&!1===this.isRunPressed&&(this.movementSpeed=BABYLON.Scalar.Clamp(this.movementSpeed,0,this.walkSpeed)),this.desiredForwardVector.addToRef(this.desiredRightVector,this.playerMovementVelocity),this.playerMovementVelocity.scaleInPlace(this.movementSpeed),!0===this.movementAllowed)if(this.playerControl===e.PlayerInputControl.FirstPersonStrafing)BABYLON.Quaternion.FromEulerAnglesToRef(0,this.playerRotationVector.y,0,this.transform.rotationQuaternion);else if(this.playerControl===e.PlayerInputControl.ThirdPersonStrafing)if(!0===this.freeLooking){if(this.inputMagnitude>0){var h=this.playerMovementVelocity.length()/this.moveSpeed,c=BABYLON.Scalar.Lerp(this.highTurnSpeed,this.lowTurnSpeed,h);BABYLON.Quaternion.FromEulerAnglesToRef(0,this.playerRotationVector.y,0,this.playerRotationQuaternion),BABYLON.Quaternion.SlerpToRef(this.transform.rotationQuaternion,this.playerRotationQuaternion,c*this.deltaTime,this.transform.rotationQuaternion)}}else BABYLON.Quaternion.FromEulerAnglesToRef(0,this.playerRotationVector.y,0,this.transform.rotationQuaternion);this.verticalVelocity=this.getVerticalVelocity(),this.movementVelocity.copyFrom(this.playerMovementVelocity),this.hasGroundedContact=!1,this.isCharacterGrounded=!1,this.isCharacterSliding=!1,this.isCharacterFalling=!1,this.isCharacterJumpFrame=!1,this.isCharacterNavigating=null!=this.navigationAgent&&this.navigationAgent.isNavigating(),this.navigationAngularSpeed=null!=this.navigationAgent?this.navigationAgent.angularSpeed:0,this.updateCharacterController(),null!=this.animationState&&!0===this.updateStateParams&&(this.validateAnimationStateParams(),this.animationState.setInteger(this.animationStateParams.moveDirection,this.playerMoveDirection),this.animationState.setFloat(this.animationStateParams.heightInput,this.verticalVelocity),this.animationState.setBool(this.animationStateParams.jumpFrame,this.isCharacterJumpFrame),this.animationState.setBool(this.animationStateParams.jumpState,this.isCharacterJumping),this.animationState.setInteger(this.animationStateParams.actionState,this.performActionNumber),this.animationState.setBool(this.animationStateParams.fallingState,this.isCharacterFalling),this.animationState.setBool(this.animationStateParams.slidingState,this.isCharacterSliding),this.animationState.setBool(this.animationStateParams.groundedState,this.isCharacterGrounded),!0===this.smoothMotionSpeed&&this.smoothDampTime>0?(!0===this.smoothInputVectors?(this.animationState.setSmoothFloat(this.animationStateParams.horizontalInput,this.playerInputX,this.smoothDampTime),this.animationState.setSmoothFloat(this.animationStateParams.verticalInput,this.playerInputZ,this.smoothDampTime),this.animationState.setSmoothFloat(this.animationStateParams.mouseXInput,this.playerMouseX,this.smoothDampTime),this.animationState.setSmoothFloat(this.animationStateParams.mouseYInput,this.playerMouseY,this.smoothDampTime),this.animationState.setSmoothFloat(this.animationStateParams.inputMagnitude,this.inputMagnitude,this.smoothDampTime)):(this.animationState.setFloat(this.animationStateParams.horizontalInput,this.playerInputX),this.animationState.setFloat(this.animationStateParams.verticalInput,this.playerInputZ),this.animationState.setFloat(this.animationStateParams.mouseXInput,this.playerMouseX),this.animationState.setFloat(this.animationStateParams.mouseYInput,this.playerMouseY),this.animationState.setFloat(this.animationStateParams.inputMagnitude,this.inputMagnitude)),this.animationState.setSmoothFloat(this.animationStateParams.speedInput,this.movementSpeed,this.smoothDampTime)):(this.animationState.setFloat(this.animationStateParams.horizontalInput,this.playerInputX),this.animationState.setFloat(this.animationStateParams.verticalInput,this.playerInputZ),this.animationState.setFloat(this.animationStateParams.mouseXInput,this.playerMouseX),this.animationState.setFloat(this.animationStateParams.mouseYInput,this.playerMouseY),this.animationState.setFloat(this.animationStateParams.inputMagnitude,this.inputMagnitude),this.animationState.setFloat(this.animationStateParams.speedInput,this.movementSpeed)),this.isCharacterNavigating),1==this.postNetworkAttributes&&n.EntityController.HasNetworkEntity(this.transform)&&(n.EntityController.PostBufferedAttribute(this.transform,0,this.playerMoveDirection),n.EntityController.PostBufferedAttribute(this.transform,1,this.inputMagnitude),n.EntityController.PostBufferedAttribute(this.transform,2,this.playerInputX),n.EntityController.PostBufferedAttribute(this.transform,3,this.playerInputZ),n.EntityController.PostBufferedAttribute(this.transform,4,this.playerMouseX),n.EntityController.PostBufferedAttribute(this.transform,5,this.playerMouseY),n.EntityController.PostBufferedAttribute(this.transform,6,this.verticalVelocity),n.EntityController.PostBufferedAttribute(this.transform,7,this.movementSpeed),n.EntityController.PostBufferedAttribute(this.transform,8,this.performActionNumber),n.EntityController.PostBufferedAttribute(this.transform,9,this.isCharacterJumpFrame?1:0),n.EntityController.PostBufferedAttribute(this.transform,10,this.isCharacterJumping?1:0),n.EntityController.PostBufferedAttribute(this.transform,11,this.isCharacterFalling?1:0),n.EntityController.PostBufferedAttribute(this.transform,12,this.isCharacterSliding?1:0),n.EntityController.PostBufferedAttribute(this.transform,13,this.isCharacterGrounded?1:0)),this.onPostUpdateObservable&&this.onPostUpdateObservable.hasObservers()&&this.onPostUpdateObservable.notifyObservers(this.transform)}},i.prototype.afterPlayerController=function(){},i.prototype.updateCharacterController=function(){if(null!=this.characterController&&(this.isCharacterRising=1==this.isCharacterJumping&&this.verticalVelocity>0,this.isCharacterLanding=1==this.isCharacterJumping&&this.verticalVelocity<0,1==this.isCharacterRising&&(this.hasGroundedContact=!1),!0===this.hasGroundedContact&&this.minJumpTimer<=0&&(this.isCharacterSliding=!1,this.isCharacterGrounded=!0),!0===this.isCharacterGrounded&&(this.isCharacterJumping=!1),this.isCharacterFalling=!1===this.isCharacterGrounded&&0==this.isCharacterSliding&&0==this.isCharacterJumping&&this.verticalVelocity<0&&Math.abs(this.verticalVelocity)>=this.minFallVelocity,!0===this.isCharacterFalling&&!1===this.isCharacterFallTriggered&&(this.isCharacterFallTriggered=!0,this.jumpDelay>0&&(this.delayJumpTimer=this.jumpDelay)),!0===this.isCharacterGrounded&&(this.isCharacterFallTriggered=!1),!0===this.useClimbSystem&&(this.castPhysicsClimbingVolumeRay(),this.castPhysicsHeightCheckVolumeRay()),!1===this.isCharacterNavigating&&!0===this.movementAllowed&&!0===this.isCharacterGrounded)){if(this.delayJumpTimer<=0&&(this.isCharacterJumpFrame=!0===this.canPlayerJump&&!0===this.isJumpPressed),!1===this.isPerformingAction&&!0===this.isCharacterJumpFrame&&!0===this.useClimbSystem&&!0===this.climbContact&&!0===this.heightContact){var t=-1,i=1,n=!1,r=!1,o=0,a=0,s=0,l=parseFloat(this.heightContactPoint.y.toFixed(2)),u=parseFloat(this.transform.position.y.toFixed(2)),h=parseFloat((l-u).toFixed(2));h>=this.maxHeightRanges.stepUpRange.minimumHeight&&h<=this.maxHeightRanges.stepUpRange.maximumHeight?(t=e.ActionAnimationType.StepUp,i=this.maxHeightRanges.stepUpRange.rotationSpeed,n=this.maxHeightRanges.stepUpRange.rotateTowards,r=this.maxHeightRanges.stepUpRange.matchHeight,o=this.maxHeightRanges.stepUpRange.startTime,a=this.maxHeightRanges.stepUpRange.targetTime,s=this.maxHeightRanges.stepUpRange.targetOffset):h>=this.maxHeightRanges.jumpUpRange.minimumHeight&&h<=this.maxHeightRanges.jumpUpRange.maximumHeight?(t=e.ActionAnimationType.JumpUp,i=this.maxHeightRanges.jumpUpRange.rotationSpeed,n=this.maxHeightRanges.jumpUpRange.rotateTowards,r=this.maxHeightRanges.jumpUpRange.matchHeight,o=this.maxHeightRanges.jumpUpRange.startTime,a=this.maxHeightRanges.jumpUpRange.targetTime,s=this.maxHeightRanges.jumpUpRange.targetOffset):h>=this.maxHeightRanges.climbUpRange.minimumHeight&&h<=this.maxHeightRanges.climbUpRange.maximumHeight&&(t=e.ActionAnimationType.ClimbUp,i=this.maxHeightRanges.climbUpRange.rotationSpeed,n=this.maxHeightRanges.climbUpRange.rotateTowards,r=this.maxHeightRanges.climbUpRange.matchHeight,o=this.maxHeightRanges.climbUpRange.startTime,a=this.maxHeightRanges.climbUpRange.targetTime,s=this.maxHeightRanges.climbUpRange.targetOffset),t>=0&&(null!=this.canClimbObstaclePredicate&&!0!==this.canClimbObstaclePredicate(t)||(this.isCharacterJumpFrame=!1,this.isCharacterJumping=!1,this.isCharacterLanding=!1,this.isCharacterRising=!1,this.playActionAnimation(t,!1,!0),this.playerRotationSpeed=i,this.rotatePlayerTowards=n,this.matchTargetHeight=r,this.matchStartTime=o-e.ThirdPersonPlayerController.MIN_TIMER_OFFSET,this.matchTargetTime=a-e.ThirdPersonPlayerController.MIN_TIMER_OFFSET,this.matchTargetOffset=s,this.lastTargetHeight=l,this.lastStartHeight=null,this.lockTargetHeight=!1))}if(!0===this.isCharacterJumpFrame&&this.jumpSpeed>0&&(this.isCharacterJumping=!0,this.characterController.jump(this.jumpSpeed),this.jumpDelay>0&&(this.delayJumpTimer=this.jumpDelay),this.airbornTimeout>0&&(this.minJumpTimer=this.airbornTimeout+this.deltaTime),this.lastJumpVelocity.set(this.movementVelocity.x,0,this.movementVelocity.z)),this.onBeforeMoveObservable&&this.onBeforeMoveObservable.hasObservers()&&this.onBeforeMoveObservable.notifyObservers(this.transform),null!=this.animationState&&!0===this.rootMotion){var c=this.getDeltaMotionPosition();this.movementVelocity.set(c.x,0,c.z),BABYLON.Vector3.TransformNormalToRef(this.movementVelocity,this.transform.getWorldMatrix(),this.movementVelocity),this.characterController.move(this.movementVelocity)}else this.characterController.move(this.movementVelocity)}},i.prototype.updateCameraController=function(){if(!1!==this.enableInput){if(null!=this.cameraPivot&&(0!==this.targetCameraOffset.x||0!==this.targetCameraOffset.y||0!==this.targetCameraOffset.z?this.cameraPivotOffset.copyFrom(this.targetCameraOffset):this.playerControl===e.PlayerInputControl.ThirdPersonStrafing?this.cameraPivotOffset.set(0,this.pivotHeight,0):this.cameraPivotOffset.set(0,this.eyesHeight,0),n.Utilities.GetAbsolutePositionToRef(this.transform,this.cameraPivot.position,this.cameraPivotOffset),!0===this.rotateCamera&&BABYLON.Quaternion.FromEulerAnglesToRef(this.playerRotationVector.x,this.playerRotationVector.y,0,this.cameraPivot.rotationQuaternion)),!0===this.rotateCamera&&null!=this.cameraNode)if(this.cameraSmoothing<=0&&(this.cameraSmoothing=5),this.playerControl===e.PlayerInputControl.ThirdPersonStrafing)if(!0===this.cameraCollisions){var t=this.cameraNode.parent;this.dollyDirection.scaleToRef(this.maxDistance,this.scaledMaxDirection),this.dollyDirection.scaleToRef(this.cameraDistance,this.scaledCamDirection),n.Utilities.GetAbsolutePositionToRef(t,this.parentNodePosition),n.Utilities.TransformPointToRef(t,this.scaledMaxDirection,this.maximumCameraPos);var i=!1,r=0;if(null!=this.characterController&&null!=this.cameraRaycastShape){var o={shape:this.cameraRaycastShape,rotation:this.cameraNode.rotationQuaternion,startPosition:this.parentNodePosition,endPosition:this.maximumCameraPos,ignoreBody:this.transform.physicsBody,shouldHitTriggers:!1},a=n.RigidbodyPhysics.Shapecast(o);r=!0==(i=null!=a&&null!=a.world&&!0===a.world.hasHit&&null!=a.world.body)?BABYLON.Vector3.Distance(this.parentNodePosition,a.world.hitPoint):0}if(!0===i)this.cameraDistance=BABYLON.Scalar.Clamp(r*this.distanceFactor,this.minimumDistance,this.maxDistance),this.cameraNode.position.x===this.scaledCamDirection.x&&this.cameraNode.position.y===this.scaledCamDirection.y&&this.cameraNode.position.z===this.scaledCamDirection.z||BABYLON.Vector3.LerpToRef(this.cameraNode.position,this.scaledCamDirection,this.deltaTime*this.cameraSmoothing,this.cameraNode.position);else{if(!0===this.mouseWheel&&n.InputController.IsWheelScrolling()){var s=n.InputController.GetUserInput(n.UserInputAxis.Wheel);if(s<0){var l=this.scrollSpeed*this.deltaTime;this.boomPosition.z=BABYLON.Scalar.MoveTowards(this.boomPosition.z,-this.maxDistance,l)}else if(s>0){var u=this.scrollSpeed*this.deltaTime;this.boomPosition.z=BABYLON.Scalar.MoveTowards(this.boomPosition.z,-this.minimumDistance,u)}}this.cameraNode.position.x===this.boomPosition.x&&this.cameraNode.position.y===this.boomPosition.y&&this.cameraNode.position.z===this.boomPosition.z||BABYLON.Vector3.LerpToRef(this.cameraNode.position,this.boomPosition,this.deltaTime*this.cameraSmoothing,this.cameraNode.position)}}else this.cameraNode.position.x===this.boomPosition.x&&this.cameraNode.position.y===this.boomPosition.y&&this.cameraNode.position.z===this.boomPosition.z||BABYLON.Vector3.LerpToRef(this.cameraNode.position,this.boomPosition,this.deltaTime*this.cameraSmoothing,this.cameraNode.position);else 0===this.cameraNode.position.x&&0===this.cameraNode.position.y&&0===this.cameraNode.position.z||this.cameraNode.position.set(0,0,0);this.updateSmoothBoomArmLength()}},i.prototype.getBoomArmMaxDistance=function(){return this.maxDistance},i.prototype.setBoomArmMaxDistance=function(e){this.maxDistance=Math.abs(e)},i.prototype.setSmoothBoomArmLength=function(e,t,i){void 0===i&&(i=!0);var n=Math.abs(e);this.smoothBoomArmLength=-n,this.smoothBoomArmSpeed=t,!0===i&&n>Math.abs(this.maxDistance)&&this.setBoomArmMaxDistance(n)},i.prototype.updateSmoothBoomArmLength=function(){null!=this.smoothBoomArmLength&&null!=this.smoothBoomArmSpeed&&(this.boomPosition.z!==this.smoothBoomArmLength?this.boomPosition.z=BABYLON.Scalar.MoveTowards(this.boomPosition.z,this.smoothBoomArmLength,this.smoothBoomArmSpeed*this.getDeltaSeconds()):(this.smoothBoomArmLength=null,this.smoothBoomArmSpeed=null))},i.prototype.castPhysicsClimbingVolumeRay=function(){var e=null;this.climbContact=!1,this.climbContactNode=null,this.climbContactPoint.set(0,0,0),this.climbContactNormal.set(0,0,0),this.climbContactAngle=0,this.climbContactDistance=0,n.Utilities.TransformDirection(this.transform,this.forwardDirection),this.offsetClimbRaycastPosition.set(0,this.rayClimbOffset,0),n.Utilities.GetAbsolutePositionToRef(this.transform,this.startClimbRaycastPosition,this.offsetClimbRaycastPosition),n.Utilities.GetAbsolutePositionToRef(this.transform,this.endClimbRaycastPosition,this.forwardDirection.scale(this.rayClimbLength)),this.endClimbRaycastPosition.y+=this.rayClimbOffset,!0===e.hasHit&&null!=e.collisionObject&&null!=e.collisionObject.entity&&n.SceneManager.GetTransformTag(e.collisionObject.entity)===this.climbVolumeTag&&(this.climbContact=!0,this.climbContactNode=e.collisionObject.entity,null!=e.hitPoint&&this.climbContactPoint.copyFrom(e.hitPoint),null!=e.hitNormal&&this.climbContactNormal.copyFrom(e.hitNormal),this.climbContactAngle=null!=this.climbContactNormal?Math.abs(n.Utilities.GetAngle(this.climbContactNormal,BABYLON.Vector3.UpReadOnly)):0,this.climbContactDistance=e.hitDistance),!0===this.showDebugColliders&&(null==this.climbSensorLine&&(this.climbSensorLine=new n.LinesMeshRenderer(this.transform.name+".ClimbingSensorLine",this.scene)),!0===this.climbContact?this.climbSensorLine.drawLine([this.startClimbRaycastPosition,e.hitPoint],BABYLON.Color3.Red()):this.climbSensorLine.drawLine([this.startClimbRaycastPosition,this.endClimbRaycastPosition],BABYLON.Color3.Green()))},i.prototype.castPhysicsHeightCheckVolumeRay=function(){this.heightContact=!1,this.heightContactNode=null,this.heightContactPoint.set(0,0,0),this.heightContactNormal.set(0,0,0),this.heightContactAngle=0,this.heightContactDistance=0,n.Utilities.TransformDirection(this.transform,this.downDirection),!0===this.climbContact?(this.endHeightRaycastPosition.copyFrom(this.climbContactPoint),this.startHeightRaycastPosition.copyFrom(this.climbContactPoint),this.startHeightRaycastPosition.addInPlace(BABYLON.Vector3.UpReadOnly.scale(this.rayHeightLength))):(this.offsetHeightRaycastPosition.set(0,this.rayHeightOffset,this.rayClimbLength),n.Utilities.GetAbsolutePositionToRef(this.transform,this.startHeightRaycastPosition,this.offsetHeightRaycastPosition),this.endHeightRaycastPosition.copyFrom(this.startHeightRaycastPosition),this.endHeightRaycastPosition.addInPlace(this.downDirection.scale(this.rayHeightLength))),!0===this.showDebugColliders&&(null==this.heightSensorLine&&(this.heightSensorLine=new n.LinesMeshRenderer(this.transform.name+".HeightCheckSensorLine",this.scene)),this.heightSensorLine.drawLine([this.startHeightRaycastPosition,this.endHeightRaycastPosition],BABYLON.Color3.Green()))},i.prototype.getCheckedVerticalVelocity=function(){var t=null!=this.characterController?this.characterController.getVerticalVelocity():0;return Math.abs(t)>=e.StandardPlayerController.MIN_VERTICAL_VELOCITY?t:0},i.prototype.destroyPlayerController=function(){this.cameraPivot=null,this.cameraNode=null,this.animationState=null,this.characterController=null,this.onPreUpdateObservable.clear(),this.onPreUpdateObservable=null,this.onBeforeMoveObservable.clear(),this.onBeforeMoveObservable=null,this.onPostUpdateObservable.clear(),this.onPostUpdateObservable=null},i.prototype.validateAnimationStateParams=function(){null==this.animationStateParams&&(this.animationStateParams={moveDirection:"Direction",inputMagnitude:"Magnitude",horizontalInput:"Horizontal",verticalInput:"Vertical",mouseXInput:"MouseX",mouseYInput:"MouseY",heightInput:"Height",speedInput:"Speed",jumpFrame:"Jumped",jumpState:"Jump",actionState:"Action",fallingState:"FreeFall",slidingState:"Sliding",groundedState:"Grounded"})},i.MIN_VERTICAL_VELOCITY=.01,i.MIN_GROUND_DISTANCE=.15,i.MIN_MOVE_EPSILON=.001,i.MIN_TIMER_OFFSET=0,i.MIN_SLOPE_LIMIT=0,i.PLAYER_HEIGHT="playerHeight",i}(n.ScriptComponent);e.StandardPlayerController=a,(r=e.PlayerInputControl||(e.PlayerInputControl={}))[r.FirstPersonStrafing=0]="FirstPersonStrafing",r[r.ThirdPersonStrafing=1]="ThirdPersonStrafing",(i=e.PlayerMoveDirection||(e.PlayerMoveDirection={}))[i.Stationary=0]="Stationary",i[i.Forward=1]="Forward",i[i.ForwardLeft=2]="ForwardLeft",i[i.ForwardRight=3]="ForwardRight",i[i.Backward=4]="Backward",i[i.BackwardLeft=5]="BackwardLeft",i[i.BackwardRight=6]="BackwardRight",i[i.StrafingLeft=7]="StrafingLeft",i[i.StrafingRight=8]="StrafingRight",(t=e.ActionAnimationType||(e.ActionAnimationType={}))[t.Neutral=0]="Neutral",t[t.StepUp=1]="StepUp",t[t.JumpUp=2]="JumpUp",t[t.ClimbUp=3]="ClimbUp",t[t.VaultOver=4]="VaultOver",n.SceneManager.RegisterClass("PROJECT.StandardPlayerController",a)}(r||(r={})),function(e){var t,i=function(t){function i(i,r,o,a){void 0===a&&(a="PROJECT.ThirdPersonPlayerController");var s=t.call(this,i,r,o,a)||this;return s.enableInput=!1,s.attachCamera=!1,s.mouseWheel=!0,s.requireSprintButton=!1,s.gravitationalForce=3,s.minFallVelocity=2.5,s.verticalStepSpeed=1,s.minStepUpHeight=.15,s.rigidBodyMass=85,s.airbornTimeout=.5,s.maxAngle=45,s.speedFactor=1,s.rootMotion=!1,s.moveSpeed=5.335,s.walkSpeed=2,s.jumpSpeed=10,s.jumpDelay=.25,s.lowTurnSpeed=15,s.highTurnSpeed=25,s.smoothDampTime=.1,s.smoothInputVectors=!1,s.smoothAcceleration=!1,s.accelerationSpeed=.1,s.decelerationSpeed=.1,s.climbVolumeTag="Climb",s.vaultVolumeTag="Vault",s.maxHeightRanges=null,s.useClimbSystem=!1,s.distanceFactor=.85,s.inputMagnitude=0,s.landingEpsilon=.1,s.minimumDistance=.5,s.movementAllowed=!0,s.playerInputX=0,s.playerInputZ=0,s.playerMouseX=0,s.playerMouseY=0,s.runKeyRequired=!0,s.buttonRun=BABYLON.Xbox360Button.LeftStick,s.keyboardRun=n.UserInputKey.Shift,s.buttonJump=BABYLON.Xbox360Button.A,s.keyboardJump=n.UserInputKey.SpaceBar,s.buttonCamera=BABYLON.Xbox360Button.Y,s.keyboardCamera=n.UserInputKey.P,s.postNetworkAttributes=!1,s.playerNumber=n.PlayerNumber.One,s.airbornVelocity=new BABYLON.Vector3(0,0,0),s.movementVelocity=new BABYLON.Vector3(0,0,0),s.rayClimbOffset=.35,s.rayClimbLength=.85,s.canClimbObstaclePredicate=null,s.rayHeightOffset=5,s.rayHeightLength=6,s.freeCamera=null,s.cameraForwardVector=new BABYLON.Vector3(0,0,0),s.cameraRightVector=new BABYLON.Vector3(0,0,0),s.desiredForwardVector=new BABYLON.Vector3(0,0,0),s.desiredRightVector=new BABYLON.Vector3(0,0,0),s.lastRotationQuaternion=new BABYLON.Quaternion(0,0,0,1),s.avatarSkins=null,s.avatarRadius=.5,s.navigationAgent=null,s.characterController=null,s.verticalVelocity=0,s.smoothMotionSpeed=!1,s.movementSpeed=0,s.isRunPressed=!1,s.isJumpPressed=!1,s.isCharacterSliding=!1,s.isCharacterFalling=!1,s.isCharacterGrounded=!1,s.isCharacterFallTriggered=!1,s.isCharacterJumpFrame=!1,s.isCharacterJumping=!1,s.isCharacterRising=!1,s.isCharacterLanding=!1,s.isCharacterNavigating=!1,s.navigationAngularSpeed=0,s.updateStateParams=!0,s.animationStateParams=null,s.sphereCollisionShape=null,s.hasGroundedContact=!1,s.showDebugColliders=!1,s.colliderVisibility=0,s.colliderRenderGroup=0,s.groundCheckDistance=.25,s.deltaTime=0,s.delayJumpTimer=0,s.canPlayerJump=!0,s.animationState=null,s.lastJumpVelocity=new BABYLON.Vector3(0,0,0),s.inputMovementVector=new BABYLON.Vector3(0,0,0),s.playerLookRotation=new BABYLON.Vector3(0,0,0),s.playerMovementVelocity=new BABYLON.Vector3(0,0,0),s.playerRotationQuaternion=BABYLON.Quaternion.Zero(),s.playerMoveDirection=e.PlayerMoveDirection.Stationary,s.forwardDirection=new BABYLON.Vector3(0,0,1),s.downDirection=new BABYLON.Vector3(0,-1,0),s.climbContact=!1,s.climbContactNode=null,s.climbContactAngle=0,s.climbContactPoint=new BABYLON.Vector3(0,0,0),s.climbContactNormal=new BABYLON.Vector3(0,0,0),s.climbContactDistance=0,s.climbSensorLine=null,s.offsetClimbRaycastPosition=new BABYLON.Vector3(0,0,0),s.startClimbRaycastPosition=new BABYLON.Vector3(0,0,0),s.endClimbRaycastPosition=new BABYLON.Vector3(0,0,0),s.heightContact=!1,s.heightContactNode=null,s.heightContactAngle=0,s.heightContactPoint=new BABYLON.Vector3(0,0,0),s.heightContactNormal=new BABYLON.Vector3(0,0,0),s.heightContactDistance=0,s.heightSensorLine=null,s.offsetHeightRaycastPosition=new BABYLON.Vector3(0,0,0),s.startHeightRaycastPosition=new BABYLON.Vector3(0,0,0),s.endHeightRaycastPosition=new BABYLON.Vector3(0,0,0),s.m_velocityOffset=new BABYLON.Vector3(0,0,0),s.m_actualVelocity=new BABYLON.Vector3(0,0,0),s.m_linearVelocity=new BABYLON.Vector3(0,0,0),s.m_lastPosition=new BABYLON.Vector3(0,0,0),s.m_positionCenter=new BABYLON.Vector3(0,0,0),s.m_scaledVelocity=0,s.playerDrawVelocity=0,s.boomPosition=new BABYLON.Vector3(0,0,-5),s.onPreUpdateObservable=new BABYLON.Observable,s.onBeforeMoveObservable=new BABYLON.Observable,s.onPostUpdateObservable=new BABYLON.Observable,s.onPlayerInputObservable=new BABYLON.Observable,s.onPlayerPositionObservable=new BABYLON.Observable,s.onUpdateActionObservable=new BABYLON.Observable,s.onAnimationStateObservable=new BABYLON.Observable,s._deltaMotionPosition=new BABYLON.Vector3(0,0,0),s._deltaMotionRotation=new BABYLON.Quaternion(0,0,0,0),s.isPerformingAction=!1,s.isRootMotionAction=!1,s.isActionInterruptable=!1,s.afterActionHandler=null,s.performActionTimer=0,s.performActionNumber=0,s.playerRotationSpeed=10,s.rotatePlayerTowards=!1,s.matchStartTime=0,s.matchTargetTime=0,s.matchTargetOffset=0,s.matchTargetHeight=!1,s.lockTargetHeight=!1,s.lastStartHeight=null,s.lastTargetHeight=null,s.lastTargetNormal=new BABYLON.Vector3(0,0,0),s.lastTargetRotation=new BABYLON.Quaternion(0,0,0,1),s.lastDeltaPosition=new BABYLON.Vector3(0,0,0),s.lastDeltaRotation=new BABYLON.Quaternion(0,0,0,1),s.ikLeftFootTarget=null,s.ikLeftPoleTarget=null,s.ikRightFootTarget=null,s.ikRightPoleTarget=null,s.abstractSkinMesh=null,s.rootBoneTransform=null,s.leftFootTransform=null,s.leftFootPoleOffset=new BABYLON.Vector3(-.1,.5,.5),s.leftFootMaxAngle=90,s.rightFootTransform=null,s.rightFootPoleOffset=new BABYLON.Vector3(.1,.5,.5),s.rightFootMaxAngle=90,s.ikLeftController=null,s.ikRightController=null,s.onAnimatorIK=null,s}return o(i,t),i.prototype.isAnimationEnabled=function(){return this.updateStateParams},i.prototype.isRunButtonPressed=function(){return this.isRunPressed},i.prototype.isJumpButtonPressed=function(){return this.isJumpPressed},i.prototype.getPlayerJumped=function(){return this.isCharacterJumpFrame},i.prototype.getPlayerJumping=function(){return this.isCharacterJumping},i.prototype.getPlayerFalling=function(){return this.isCharacterFalling},i.prototype.getPlayerSliding=function(){return this.isCharacterSliding},i.prototype.getPlayerGrounded=function(){return this.isCharacterGrounded},i.prototype.getFallTriggered=function(){return this.isCharacterFallTriggered},i.prototype.getMovementSpeed=function(){return this.movementSpeed},i.prototype.getAnimationState=function(){return this.animationState},i.prototype.getVerticalVelocity=function(){return this.getCheckedVerticalVelocity()},i.prototype.getCharacterController=function(){return this.characterController},i.prototype.getPlayerLookRotation=function(){return this.playerLookRotation},i.prototype.getPlayerMoveDirection=function(){return this.playerMoveDirection},i.prototype.getInputMovementVector=function(){return this.inputMovementVector},i.prototype.getInputMagnitudeValue=function(){return this.inputMagnitude},i.prototype.getClimbContact=function(){return this.climbContact},i.prototype.getClimbContactNode=function(){return this.climbContactNode},i.prototype.getClimbContactPoint=function(){return this.climbContactPoint},i.prototype.getClimbContactAngle=function(){return this.climbContactAngle},i.prototype.getClimbContactNormal=function(){return this.climbContactNormal},i.prototype.getClimbContactDistance=function(){return this.climbContactDistance},i.prototype.getHeightContact=function(){return this.heightContact},i.prototype.getHeightContactNode=function(){return this.heightContactNode},i.prototype.getHeightContactPoint=function(){return this.heightContactPoint},i.prototype.getHeightContactAngle=function(){return this.heightContactAngle},i.prototype.getHeightContactNormal=function(){return this.heightContactNormal},i.prototype.getHeightContactDistance=function(){return this.heightContactDistance},i.prototype.awake=function(){this.awakePlayerController()},i.prototype.start=function(){this.startPlayerController()},i.prototype.after=function(){this.afterPlayerController()},i.prototype.update=function(){this.updatePlayerController()},i.prototype.destroy=function(){this.destroyPlayerController()},i.prototype.getDeltaMotionPosition=function(){if(this._deltaMotionPosition.set(0,0,0),null!=this.animationState){var e=this.animationState.getDeltaRootMotionPosition();null!=e&&this._deltaMotionPosition.copyFrom(e)}return this._deltaMotionPosition},i.prototype.getDeltaMotionRotation=function(){if(this._deltaMotionRotation.set(0,0,0,0),null!=this.animationState){var e=this.animationState.getDeltaRootMotionRotation();null!=e&&this._deltaMotionRotation.copyFrom(e)}return this._deltaMotionRotation},i.prototype.getIsPerformingAction=function(){return this.isPerformingAction},i.prototype.getIsRootMotionAction=function(){return this.isRootMotionAction},i.prototype.getIsActionInterruptable=function(){return this.isActionInterruptable},i.prototype.playActionAnimation=function(e,t,i,n){void 0===t&&(t=!0),void 0===i&&(i=!1),void 0===n&&(n=null),!1===this.isPerformingAction&&null!=this.animationState&&e>=0&&(this.isPerformingAction=!0,this.performActionTimer=0,this.performActionNumber=e,this.afterActionHandler=n,this.isActionInterruptable=t,this.isRootMotionAction=i,this.playerRotationSpeed=10,this.rotatePlayerTowards=!1,this.matchStartTime=0,this.matchTargetTime=0,this.matchTargetOffset=0,this.matchTargetHeight=!1,this.lockTargetHeight=!1,this.lastStartHeight=null,this.lastTargetHeight=null,this.lastTargetNormal.set(0,0,0),this.lastTargetRotation.set(0,0,0,1),!0===this.isRootMotionAction&&this.enableCharacterController(!1))},i.prototype.resetActionAnimationState=function(){if(null!=this.afterActionHandler)try{this.afterActionHandler()}catch(e){}!0===this.isRootMotionAction&&this.enableCharacterController(!0),this.performActionTimer=0,this.performActionNumber=0,this.isPerformingAction=!1,this.isRootMotionAction=!1,this.isActionInterruptable=!1,this.afterActionHandler=null,this.playerRotationSpeed=10,this.rotatePlayerTowards=!1,this.matchStartTime=0,this.matchTargetTime=0,this.matchTargetOffset=0,this.matchTargetHeight=!1,this.lockTargetHeight=!1,this.lastStartHeight=null,this.lastTargetHeight=null,this.lastTargetNormal.set(0,0,0),this.lastTargetRotation.set(0,0,0,1)},i.prototype.updateAnimationActionState=function(){var t=this.getDeltaSeconds(),i=this.matchTargetTime-this.matchStartTime;if(null!=this.animationState&&!0===this.isRootMotionAction){var r=this.transform.absolutePosition.y;if(this.lastDeltaPosition.copyFrom(this.getDeltaMotionPosition()),BABYLON.Vector3.TransformNormalToRef(this.lastDeltaPosition,this.transform.getWorldMatrix(),this.lastDeltaPosition),!0===this.matchTargetHeight&&(null==this.lastStartHeight&&this.performActionTimer>=this.matchStartTime&&(this.lastStartHeight=r),null!=this.lastStartHeight&&null!=this.lastTargetHeight)){this.lastDeltaPosition.y=0;var o=this.lastTargetHeight+this.matchTargetOffset;if(this.performActionTimer<this.matchTargetTime){this.animationState.setSmoothFloat(e.ThirdPersonPlayerController.PLAYER_HEIGHT,o,i*t);var a=this.animationState.getFloat(e.ThirdPersonPlayerController.PLAYER_HEIGHT);this.lastDeltaPosition.y=a-r}else!1===this.lockTargetHeight&&this.performActionTimer>=this.matchTargetTime&&(this.lastDeltaPosition.y=o-r,this.lockTargetHeight=!0)}if(this.transform.position.addInPlace(this.lastDeltaPosition),!0===this.rotatePlayerTowards){if(!0===this.climbContact){this.lastTargetNormal.set(-this.climbContactNormal.x,-this.climbContactNormal.y,-this.climbContactNormal.z),n.Utilities.LookRotationToRef(this.lastTargetNormal,this.lastTargetRotation);var s=BABYLON.Scalar.Clamp(this.playerRotationSpeed*t);BABYLON.Quaternion.SlerpToRef(this.transform.rotationQuaternion,this.lastTargetRotation,s,this.transform.rotationQuaternion)}}else this.lastDeltaRotation.copyFrom(this.getDeltaMotionRotation()),this.transform.rotationQuaternion.multiplyInPlace(this.lastDeltaRotation)}this.performActionTimer+=t},i.prototype.setWorldPosition=function(e,t,i){null!=this.characterController&&this.characterController.set(e,t,i)},i.prototype.getPlayerMesh=function(){return this.abstractSkinMesh},i.prototype.getRootHipBone=function(){return null!=this.rootBoneTransform?this.rootBoneTransform._linkedBone:null},i.prototype.getLeftFootBone=function(){return null!=this.leftFootTransform?this.leftFootTransform._linkedBone:null},i.prototype.getRightFootBone=function(){return null!=this.rightFootTransform?this.rightFootTransform._linkedBone:null},i.prototype.getLeftFootTarget=function(){return this.ikLeftFootTarget},i.prototype.getRightFootTarget=function(){return this.ikRightFootTarget},i.prototype.getLeftFootPoleTarget=function(){return this.ikLeftPoleTarget},i.prototype.getRightFootPoleTarget=function(){return this.ikRightPoleTarget},i.prototype.getRootBoneTransform=function(){return this.rootBoneTransform},i.prototype.getLeftFootTransform=function(){return this.leftFootTransform},i.prototype.getRightFootTransform=function(){return this.rightFootTransform},i.prototype.getLeftFootController=function(){return this.ikLeftController},i.prototype.getRightFootController=function(){return this.ikRightController},i.prototype.isGroundedFootIKActive=function(){return!0===this.isCharacterGrounded&&null!=this.animationState&&this.animationState.ikFrameEnabled()},i.prototype.setupBoneControllers=function(){if(!0===this.getProperty("createFootIKRig")){var e=this.getProperty("displayHandles"),t=this.getProperty("abstractSkinMesh");null!=t&&(this.abstractSkinMesh=this.getChildNode(t.name,n.SearchType.ExactMatch,!1));var i=this.getProperty("rootBoneTransform");null!=i&&(this.rootBoneTransform=this.getChildNode(i.name,n.SearchType.ExactMatch,!1));var r=this.getProperty("leftFootTransform");null!=r&&(this.leftFootTransform=this.getChildNode(r.name,n.SearchType.ExactMatch,!1));var o=this.getProperty("leftFootPoleOffset");null!=o&&this.leftFootPoleOffset.copyFrom(n.Utilities.ParseVector3(o)),this.leftFootMaxAngle=this.getProperty("leftFootMaxAngle",this.leftFootMaxAngle);var a=this.getProperty("rightFootTransform");null!=a&&(this.rightFootTransform=this.getChildNode(a.name,n.SearchType.ExactMatch,!1));var s=this.getProperty("rightFootPoleOffset");if(null!=s&&this.rightFootPoleOffset.copyFrom(n.Utilities.ParseVector3(s)),this.rightFootMaxAngle=this.getProperty("rightFootMaxAngle",this.rightFootMaxAngle),null!=this.abstractSkinMesh&&null!=this.rootBoneTransform){var l=this.scene.getMaterialByName("M_TARGET_MESH");null==l&&((l=new BABYLON.StandardMaterial("M_TARGET_MESH",this.scene)).diffuseColor=new BABYLON.Color3(1,.5,.25)),null!=this.leftFootTransform&&null!=this.leftFootTransform._linkedBone&&(this.ikLeftFootTarget=BABYLON.MeshBuilder.CreateBox(this.transform.name+".LeftFootTarget",{width:.1,height:.1,depth:.1},this.scene),this.ikLeftFootTarget.parent=this.leftFootTransform,this.ikLeftFootTarget.position.set(0,0,0),this.ikLeftFootTarget.material=l,this.ikLeftFootTarget.isVisible=e,this.ikLeftPoleTarget=BABYLON.MeshBuilder.CreateSphere(this.transform.name+".LeftFootPole",{diameter:.1},this.scene),this.ikLeftPoleTarget.parent=this.abstractSkinMesh,this.ikLeftPoleTarget.position.copyFrom(this.leftFootPoleOffset),this.ikLeftPoleTarget.isVisible=e),null!=this.rightFootTransform&&null!=this.rightFootTransform._linkedBone&&(this.ikRightFootTarget=BABYLON.MeshBuilder.CreateBox(this.transform.name+".RightFootTarget",{width:.1,height:.1,depth:.1},this.scene),this.ikRightFootTarget.parent=this.rightFootTransform,this.ikRightFootTarget.position.set(0,0,0),this.ikRightFootTarget.material=l,this.ikRightFootTarget.isVisible=e,this.ikRightPoleTarget=BABYLON.MeshBuilder.CreateSphere(this.transform.name+".RightFootPole",{diameter:.1},this.scene),this.ikRightPoleTarget.parent=this.abstractSkinMesh,this.ikRightPoleTarget.position.copyFrom(this.rightFootPoleOffset),this.ikRightPoleTarget.isVisible=e)}}},i.prototype.attachAnimationController=function(){var e=this;null==this.animationState&&(this.animationState=this.getComponent("TOOLKIT.AnimationState",!0)),null!=this.animationState&&(this.animationState.onAnimationEndObservable.add(function(){!0===e.isPerformingAction&&e.resetActionAnimationState()}),this.animationState.onAnimationUpdateObservable.add(function(){null!=e.onAnimatorIK?e.onAnimatorIK():(e.updateAnimatorTargetMeshes(),null!=e.ikLeftController&&e.ikLeftController.update(),null!=e.ikRightController&&e.ikRightController.update())}))},i.prototype.updateAnimatorTargetMeshes=function(){},i.prototype.enableCharacterController=function(e){!0===e?(this.movementAllowed=!0,this.resetPlayerJumpingState(),null!=this.characterController&&(this.characterController.setGravityFactor(this.gravitationalForce),this.characterController.setCollisionState(!0))):(this.movementAllowed=!1,this.resetPlayerJumpingState(),null!=this.characterController&&(this.characterController.setGravityFactor(0),this.characterController.setCollisionState(!1)))},i.prototype.resetPlayerJumpingState=function(){this.isCharacterJumping=!1,this.isCharacterLanding=!1,this.isCharacterRising=!1,this.isCharacterJumpFrame=!1,null!=this.characterController&&this.characterController.jump(0)},i.prototype.awakePlayerController=function(){this.gravitationalForce=this.getProperty("gravityMultiplier",this.gravitationalForce),this.verticalStepSpeed=this.getProperty("stepUpVelocity",this.verticalStepSpeed),this.minStepUpHeight=this.getProperty("minStepHeight",this.minStepUpHeight),this.rigidBodyMass=this.getProperty("rigidBodyMass",this.rigidBodyMass),this.mouseWheel=this.getProperty("mouseWheel",this.mouseWheel),this.rayClimbLength=this.getProperty("rayClimbLength",this.rayClimbLength),this.rayClimbOffset=this.getProperty("rayClimbOffset",this.rayClimbOffset),this.rayHeightLength=this.getProperty("rayHeightLength",this.rayHeightLength),this.rayHeightOffset=this.getProperty("rayHeightOffset",this.rayHeightOffset),this.maxAngle=this.getProperty("maxAngle",this.maxAngle),this.landingEpsilon=this.getProperty("landingEpsilon",this.landingEpsilon),this.minFallVelocity=this.getProperty("minFallVelocity",this.minFallVelocity),this.airbornTimeout=this.getProperty("airbornTimeout",this.airbornTimeout),this.rootMotion=this.getProperty("rootMotion",this.rootMotion),this.moveSpeed=this.getProperty("moveSpeed",this.moveSpeed),this.walkSpeed=this.getProperty("walkSpeed",this.walkSpeed),this.jumpSpeed=this.getProperty("jumpSpeed",this.jumpSpeed),this.jumpDelay=this.getProperty("jumpDelay",this.jumpDelay),this.lowTurnSpeed=this.getProperty("lowTurnSpeed",this.lowTurnSpeed),this.highTurnSpeed=this.getProperty("highTurnSpeed",this.highTurnSpeed),this.enableInput=this.getProperty("enableInput",this.enableInput),this.attachCamera=this.getProperty("attachCamera",this.attachCamera),this.playerNumber=this.getProperty("playerNumber",this.playerNumber),this.runKeyRequired=this.getProperty("runKeyRequired",this.runKeyRequired),this.distanceFactor=this.getProperty("distanceFactor",this.distanceFactor),this.minimumDistance=this.getProperty("minimumDistance",this.minimumDistance),this.smoothDampTime=this.getProperty("smoothDampTime",this.smoothDampTime),this.smoothInputVectors=this.getProperty("smoothInputVectors",this.smoothInputVectors),this.smoothAcceleration=this.getProperty("smoothAcceleration",this.smoothAcceleration),this.accelerationSpeed=this.getProperty("accelerationSpeed",this.accelerationSpeed),this.decelerationSpeed=this.getProperty("decelerationSpeed",this.decelerationSpeed),this.climbVolumeTag=this.getProperty("climbVolumeTag",this.climbVolumeTag),this.vaultVolumeTag=this.getProperty("vaultVolumeTag",this.vaultVolumeTag),this.useClimbSystem=this.getProperty("useClimbSystem",this.useClimbSystem),this.maxHeightRanges=this.getProperty("maxHeightRanges",this.maxHeightRanges),this.smoothMotionSpeed=this.getProperty("smoothMotionSpeed",this.smoothMotionSpeed),this.updateStateParams=this.getProperty("updateStateParams",this.updateStateParams),this.animationStateParams=this.getProperty("animationStateParams",this.animationStateParams),this.postNetworkAttributes=this.getProperty("postNetworkAttribs",this.postNetworkAttributes),this.groundCheckDistance=this.getProperty("groundCheckDist",this.groundCheckDistance),!0===this.getProperty("arrowKeyRotation")&&(n.UserInputOptions.UseArrowKeyRotation=!0),this.setupBoneControllers()},i.prototype.startPlayerController=function(){var t=this;!0===this.attachCamera&&(e.DefaultCameraSystem.SetAutoUpdate(!1),e.DefaultCameraSystem.SetFollowTarget(this.transform),console.log("Attaching Player Camera: "+this.transform.name)),this.navigationAgent=this.getComponent("TOOLKIT.NavigationAgent"),this.characterController=this.getComponent("TOOLKIT.CharacterController"),null!=this.characterController?(this.avatarRadius=this.characterController.getAvatarRadius(),this.characterController.enableGravity=!0,this.characterController.enableStepOffset=!0,this.characterController.useMultiRaycast=!0,this.characterController.multiRaycastCount=5,this.characterController.stepUpVelocityFactor=.5,this.characterController.groundCheckDistance=this.groundCheckDistance,this.characterController.setRigidBodyMass(this.rigidBodyMass),this.characterController.setGravityFactor(this.gravitationalForce),this.characterController.onUpdatePositionObservable.add(function(){t.updatePlayerPosition(),!0===t.attachCamera&&e.DefaultCameraSystem.UpdateFollowTarget()}),n.SceneManager.LogWarning("Starting player controller in physic engine mode for: "+this.transform.name)):n.SceneManager.LogWarning("No character controller found for: "+this.transform.name)},i.prototype.updatePlayerPosition=function(){this.onPlayerPositionObservable&&this.onPlayerPositionObservable.hasObservers()&&this.onPlayerPositionObservable.notifyObservers(this.transform)},i.prototype.updatePlayerController=function(){if(this.deltaTime=this.getDeltaSeconds(),this.isReady()&&(this.m_actualVelocity=this.transform.absolutePosition.subtract(this.m_lastPosition),this.m_linearVelocity.copyFrom(this.m_actualVelocity),this.m_scaledVelocity=this.m_linearVelocity.length()/this.deltaTime,this.m_linearVelocity.normalize(),this.m_linearVelocity.scaleInPlace(this.m_scaledVelocity),this.playerDrawVelocity>0?(this.m_velocityOffset.copyFrom(this.m_linearVelocity),this.m_velocityOffset.scaleInPlace(this.playerDrawVelocity)):this.m_velocityOffset.set(0,0,0),this.m_lastPosition.copyFrom(this.transform.absolutePosition),!0===this.updateStateParams&&null==this.animationState&&this.attachAnimationController(),!0===this.isCharacterGrounded&&this.delayJumpTimer>0&&(this.delayJumpTimer-=this.deltaTime,this.delayJumpTimer<0&&(this.delayJumpTimer=0)),this.canPlayerJump=!0,!0===this.isPerformingAction&&(this.updateAnimationActionState(),this.onUpdateActionObservable&&this.onUpdateActionObservable.hasObservers()&&this.onUpdateActionObservable.notifyObservers(this.transform)),!1!==this.enableInput)){var t=n.InputController.GetUserInput(n.UserInputAxis.Horizontal,this.playerNumber),i=n.InputController.GetUserInput(n.UserInputAxis.Vertical,this.playerNumber),r=n.InputController.GetUserInput(n.UserInputAxis.MouseX,this.playerNumber),o=n.InputController.GetUserInput(n.UserInputAxis.MouseY,this.playerNumber);!0===this.smoothAcceleration?(t>0?(this.playerInputX+=this.accelerationSpeed*this.deltaTime,this.playerInputX>1&&(this.playerInputX=1)):t<0?(this.playerInputX-=this.accelerationSpeed*this.deltaTime,this.playerInputX<-1&&(this.playerInputX=-1)):this.playerInputX<0?(this.playerInputX+=this.decelerationSpeed*this.deltaTime,this.playerInputX>0&&(this.playerInputX=0)):this.playerInputX>0&&(this.playerInputX-=this.decelerationSpeed*this.deltaTime,this.playerInputX<0&&(this.playerInputX=0)),i>0?(this.playerInputZ+=this.accelerationSpeed*this.deltaTime,this.playerInputZ>1&&(this.playerInputZ=1)):i<0?(this.playerInputZ-=this.accelerationSpeed*this.deltaTime,this.playerInputZ<-1&&(this.playerInputZ=-1)):this.playerInputZ<0?(this.playerInputZ+=this.decelerationSpeed*this.deltaTime,this.playerInputZ>0&&(this.playerInputZ=0)):this.playerInputZ>0&&(this.playerInputZ-=this.decelerationSpeed*this.deltaTime,this.playerInputZ<0&&(this.playerInputZ=0))):(this.playerInputX=t,this.playerInputZ=i),this.playerMouseX=r,this.playerMouseY=o,!0===this.isPerformingAction&&!0===this.isActionInterruptable&&(0===this.playerInputX&&0===this.playerInputZ||this.resetActionAnimationState()),!0===this.isPerformingAction&&(this.canPlayerJump=!1,this.playerInputX=0,this.playerInputZ=0),this.onPlayerInputObservable&&this.onPlayerInputObservable.hasObservers()&&this.onPlayerInputObservable.notifyObservers(this.transform),this.inputMovementVector.set(this.playerInputX,0,this.playerInputZ),this.inputMovementVector.length()>1&&this.inputMovementVector.normalize(),this.inputMagnitude=this.inputMovementVector.length();var a=this.playerInputZ>0,s=this.playerInputZ<0,l=this.playerInputX>0,u=this.playerInputX<0;if(this.playerMoveDirection=!0===a?!0===u?e.PlayerMoveDirection.ForwardLeft:!0===l?e.PlayerMoveDirection.ForwardRight:e.PlayerMoveDirection.Forward:!0===s?!0===u?e.PlayerMoveDirection.BackwardLeft:!0===l?e.PlayerMoveDirection.BackwardRight:e.PlayerMoveDirection.Backward:!0===u?e.PlayerMoveDirection.StrafingLeft:!0===l?e.PlayerMoveDirection.StrafingRight:e.PlayerMoveDirection.Stationary,this.onPreUpdateObservable&&this.onPreUpdateObservable.hasObservers()&&this.onPreUpdateObservable.notifyObservers(this.transform),null==this.freeCamera&&(this.freeCamera=e.DefaultCameraSystem.GetMainCamera(this.scene,!1)),null==this.freeCamera&&(this.freeCamera=this.scene.activeCamera),this.cameraForwardVector=this.freeCamera.getForwardRay().direction,this.cameraForwardVector.y=0,this.cameraForwardVector.normalize(),this.cameraForwardVector.scaleToRef(this.inputMovementVector.z,this.desiredForwardVector),this.cameraRightVector=BABYLON.Vector3.Cross(this.cameraForwardVector,BABYLON.Vector3.Up()),this.cameraRightVector.y=0,this.cameraRightVector.normalize(),this.cameraRightVector.scaleToRef(-this.inputMovementVector.x,this.desiredRightVector),!1===this.movementAllowed&&(this.canPlayerJump=!1,this.playerInputX=0,this.playerInputZ=0),this.isRunPressed=n.InputController.GetKeyboardInput(this.keyboardRun)||n.InputController.GetGamepadButtonInput(this.buttonRun),this.isJumpPressed=n.InputController.GetKeyboardInput(this.keyboardJump)||n.InputController.GetGamepadButtonInput(this.buttonJump),this.movementSpeed=this.inputMagnitude*this.moveSpeed*this.speedFactor,!0===this.runKeyRequired&&!1===this.isRunPressed&&(this.movementSpeed=BABYLON.Scalar.Clamp(this.movementSpeed,0,this.walkSpeed)),this.desiredForwardVector.addToRef(this.desiredRightVector,this.playerMovementVelocity),this.playerLookRotation.copyFrom(this.playerMovementVelocity),this.playerMovementVelocity.scaleInPlace(this.movementSpeed),this.transform.rotationQuaternion.copyFrom(this.lastRotationQuaternion),1==this.movementAllowed&&this.inputMagnitude>0){n.Utilities.LookRotationToRef(this.playerLookRotation,this.playerRotationQuaternion);var h=this.playerLookRotation.length()/this.moveSpeed,c=BABYLON.Scalar.Lerp(this.highTurnSpeed,this.lowTurnSpeed,h),d=Math.abs(BABYLON.Quaternion.Dot(this.transform.rotationQuaternion,this.playerRotationQuaternion))<.85?.85*c:c;BABYLON.Quaternion.SlerpToRef(this.transform.rotationQuaternion,this.playerRotationQuaternion,d*this.deltaTime,this.transform.rotationQuaternion),this.lastRotationQuaternion.copyFrom(this.transform.rotationQuaternion)}this.verticalVelocity=this.getVerticalVelocity(),this.movementVelocity.copyFrom(this.playerMovementVelocity),this.hasGroundedContact=null!=this.characterController&&this.characterController.isGrounded(),this.isCharacterGrounded=!1,this.isCharacterSliding=!1,this.isCharacterFalling=!1,this.isCharacterJumpFrame=!1,this.isCharacterNavigating=null!=this.navigationAgent&&this.navigationAgent.isNavigating(),this.navigationAngularSpeed=null!=this.navigationAgent?this.navigationAgent.angularSpeed:0,this.updateCharacterController(),null!=this.animationState&&!0===this.updateStateParams&&(this.validateAnimationStateParams(),this.animationState.setInteger(this.animationStateParams.moveDirection,this.playerMoveDirection),this.animationState.setFloat(this.animationStateParams.heightInput,this.verticalVelocity),this.animationState.setBool(this.animationStateParams.jumpFrame,this.isCharacterJumpFrame),this.animationState.setBool(this.animationStateParams.jumpState,this.isCharacterJumping),this.animationState.setInteger(this.animationStateParams.actionState,this.performActionNumber),this.animationState.setBool(this.animationStateParams.fallingState,this.isCharacterFalling),this.animationState.setBool(this.animationStateParams.slidingState,this.isCharacterSliding),this.animationState.setBool(this.animationStateParams.groundedState,this.isCharacterGrounded),!0===this.smoothMotionSpeed&&this.smoothDampTime>0?(!0===this.smoothInputVectors?(this.animationState.setSmoothFloat(this.animationStateParams.horizontalInput,this.playerInputX,this.smoothDampTime),this.animationState.setSmoothFloat(this.animationStateParams.verticalInput,this.playerInputZ,this.smoothDampTime),this.animationState.setSmoothFloat(this.animationStateParams.mouseXInput,this.playerMouseX,this.smoothDampTime),this.animationState.setSmoothFloat(this.animationStateParams.mouseYInput,this.playerMouseY,this.smoothDampTime),this.animationState.setSmoothFloat(this.animationStateParams.inputMagnitude,this.inputMagnitude,this.smoothDampTime)):(this.animationState.setFloat(this.animationStateParams.horizontalInput,this.playerInputX),this.animationState.setFloat(this.animationStateParams.verticalInput,this.playerInputZ),this.animationState.setFloat(this.animationStateParams.mouseXInput,this.playerMouseX),this.animationState.setFloat(this.animationStateParams.mouseYInput,this.playerMouseY),this.animationState.setFloat(this.animationStateParams.inputMagnitude,this.inputMagnitude)),this.animationState.setSmoothFloat(this.animationStateParams.speedInput,this.movementSpeed,this.smoothDampTime)):(this.animationState.setFloat(this.animationStateParams.horizontalInput,this.playerInputX),this.animationState.setFloat(this.animationStateParams.verticalInput,this.playerInputZ),this.animationState.setFloat(this.animationStateParams.mouseXInput,this.playerMouseX),this.animationState.setFloat(this.animationStateParams.mouseYInput,this.playerMouseY),this.animationState.setFloat(this.animationStateParams.inputMagnitude,this.inputMagnitude),this.animationState.setFloat(this.animationStateParams.speedInput,this.movementSpeed)),this.isCharacterNavigating,this.onAnimationStateObservable&&this.onAnimationStateObservable.hasObservers()&&this.onAnimationStateObservable.notifyObservers(this.transform)),1==this.postNetworkAttributes&&n.EntityController.HasNetworkEntity(this.transform)&&(n.EntityController.PostBufferedAttribute(this.transform,0,this.playerMoveDirection),n.EntityController.PostBufferedAttribute(this.transform,1,this.inputMagnitude),n.EntityController.PostBufferedAttribute(this.transform,2,this.playerInputX),n.EntityController.PostBufferedAttribute(this.transform,3,this.playerInputZ),n.EntityController.PostBufferedAttribute(this.transform,4,this.playerMouseX),n.EntityController.PostBufferedAttribute(this.transform,5,this.playerMouseY),n.EntityController.PostBufferedAttribute(this.transform,6,this.verticalVelocity),n.EntityController.PostBufferedAttribute(this.transform,7,this.movementSpeed),n.EntityController.PostBufferedAttribute(this.transform,8,this.performActionNumber),n.EntityController.PostBufferedAttribute(this.transform,9,this.isCharacterJumpFrame?1:0),n.EntityController.PostBufferedAttribute(this.transform,10,this.isCharacterJumping?1:0),n.EntityController.PostBufferedAttribute(this.transform,11,this.isCharacterFalling?1:0),n.EntityController.PostBufferedAttribute(this.transform,12,this.isCharacterSliding?1:0),n.EntityController.PostBufferedAttribute(this.transform,13,this.isCharacterGrounded?1:0)),this.onPostUpdateObservable&&this.onPostUpdateObservable.hasObservers()&&this.onPostUpdateObservable.notifyObservers(this.transform)}},i.prototype.afterPlayerController=function(){},i.prototype.updateCharacterController=function(){if(null!=this.characterController){this.isCharacterRising=1==this.isCharacterJumping&&this.verticalVelocity>0,this.isCharacterLanding=1==this.isCharacterJumping&&this.verticalVelocity<0,1==this.isCharacterRising&&(this.hasGroundedContact=!1);var t=this.characterController.getMinJumpTimer();if(!0===this.hasGroundedContact&&t<=0&&(this.isCharacterSliding=!1,this.isCharacterGrounded=!0),!0===this.isCharacterGrounded&&(this.isCharacterJumping=!1),this.isCharacterFalling=!1===this.isCharacterGrounded&&0==this.isCharacterSliding&&0==this.isCharacterJumping&&this.verticalVelocity<0&&Math.abs(this.verticalVelocity)>=this.minFallVelocity,!0===this.isCharacterFalling&&!1===this.isCharacterFallTriggered&&(this.isCharacterFallTriggered=!0,this.jumpDelay>0&&(this.delayJumpTimer=this.jumpDelay)),!0===this.isCharacterGrounded&&(this.isCharacterFallTriggered=!1),!0===this.useClimbSystem&&(this.castPhysicsClimbingVolumeRay(),this.castPhysicsHeightCheckVolumeRay()),!1===this.isCharacterNavigating&&!0===this.movementAllowed&&!0===this.isCharacterGrounded){if(this.delayJumpTimer<=0&&(this.isCharacterJumpFrame=!0===this.canPlayerJump&&!0===this.isJumpPressed),!1===this.isPerformingAction&&!0===this.isCharacterJumpFrame&&!0===this.useClimbSystem&&!0===this.climbContact&&!0===this.heightContact){var i=-1,n=1,r=!1,o=!1,a=0,s=0,l=0,u=parseFloat(this.heightContactPoint.y.toFixed(2)),h=parseFloat(this.transform.position.y.toFixed(2)),c=parseFloat((u-h).toFixed(2));c>=this.maxHeightRanges.stepUpRange.minimumHeight&&c<=this.maxHeightRanges.stepUpRange.maximumHeight?(i=e.ActionAnimationType.StepUp,n=this.maxHeightRanges.stepUpRange.rotationSpeed,r=this.maxHeightRanges.stepUpRange.rotateTowards,o=this.maxHeightRanges.stepUpRange.matchHeight,a=this.maxHeightRanges.stepUpRange.startTime,s=this.maxHeightRanges.stepUpRange.targetTime,l=this.maxHeightRanges.stepUpRange.targetOffset):c>=this.maxHeightRanges.jumpUpRange.minimumHeight&&c<=this.maxHeightRanges.jumpUpRange.maximumHeight?(i=e.ActionAnimationType.JumpUp,n=this.maxHeightRanges.jumpUpRange.rotationSpeed,r=this.maxHeightRanges.jumpUpRange.rotateTowards,o=this.maxHeightRanges.jumpUpRange.matchHeight,a=this.maxHeightRanges.jumpUpRange.startTime,s=this.maxHeightRanges.jumpUpRange.targetTime,l=this.maxHeightRanges.jumpUpRange.targetOffset):c>=this.maxHeightRanges.climbUpRange.minimumHeight&&c<=this.maxHeightRanges.climbUpRange.maximumHeight&&(i=e.ActionAnimationType.ClimbUp,n=this.maxHeightRanges.climbUpRange.rotationSpeed,r=this.maxHeightRanges.climbUpRange.rotateTowards,o=this.maxHeightRanges.climbUpRange.matchHeight,a=this.maxHeightRanges.climbUpRange.startTime,s=this.maxHeightRanges.climbUpRange.targetTime,l=this.maxHeightRanges.climbUpRange.targetOffset),i>=0&&(null!=this.canClimbObstaclePredicate&&!0!==this.canClimbObstaclePredicate(i)||(this.isCharacterJumpFrame=!1,this.isCharacterJumping=!1,this.isCharacterLanding=!1,this.isCharacterRising=!1,this.playActionAnimation(i,!1,!0),this.playerRotationSpeed=n,this.rotatePlayerTowards=r,this.matchTargetHeight=o,this.matchStartTime=a-e.ThirdPersonPlayerController.MIN_TIMER_OFFSET,this.matchTargetTime=s-e.ThirdPersonPlayerController.MIN_TIMER_OFFSET,this.matchTargetOffset=l,this.lastTargetHeight=u,this.lastStartHeight=null,this.lockTargetHeight=!1))}if(!0===this.isCharacterJumpFrame&&this.jumpSpeed>0&&(this.airbornTimeout>0&&(this.characterController.defaultJumpingTimer=this.airbornTimeout+this.deltaTime),this.isCharacterJumping=!0,this.characterController.jump(this.jumpSpeed),this.jumpDelay>0&&(this.delayJumpTimer=this.jumpDelay),this.lastJumpVelocity.set(this.movementVelocity.x,0,this.movementVelocity.z)),this.onBeforeMoveObservable&&this.onBeforeMoveObservable.hasObservers()&&this.onBeforeMoveObservable.notifyObservers(this.transform),null!=this.animationState&&!0===this.rootMotion){var d=this.getDeltaMotionPosition();this.movementVelocity.set(d.x,0,d.z),BABYLON.Vector3.TransformNormalToRef(this.movementVelocity,this.transform.getWorldMatrix(),this.movementVelocity),this.characterController.move(this.movementVelocity)}else this.characterController.move(this.movementVelocity)}}},i.prototype.castPhysicsClimbingVolumeRay=function(){this.climbContact=!1,this.climbContactNode=null,this.climbContactPoint.set(0,0,0),this.climbContactNormal.set(0,0,0),this.climbContactAngle=0,this.climbContactDistance=0,n.Utilities.TransformDirection(this.transform,this.forwardDirection),this.offsetClimbRaycastPosition.set(0,this.rayClimbOffset,0),n.Utilities.GetAbsolutePositionToRef(this.transform,this.startClimbRaycastPosition,this.offsetClimbRaycastPosition),n.Utilities.GetAbsolutePositionToRef(this.transform,this.endClimbRaycastPosition,this.forwardDirection.scale(this.rayClimbLength)),this.endClimbRaycastPosition.y+=this.rayClimbOffset,!0===this.showDebugColliders&&(null==this.climbSensorLine&&(this.climbSensorLine=new n.LinesMeshRenderer(this.transform.name+".ClimbingSensorLine",this.scene)),this.climbSensorLine.drawLine([this.startClimbRaycastPosition,this.endClimbRaycastPosition],BABYLON.Color3.Green()))},i.prototype.castPhysicsHeightCheckVolumeRay=function(){this.heightContact=!1,this.heightContactNode=null,this.heightContactPoint.set(0,0,0),this.heightContactNormal.set(0,0,0),this.heightContactAngle=0,this.heightContactDistance=0,n.Utilities.TransformDirection(this.transform,this.downDirection),!0===this.climbContact?(this.endHeightRaycastPosition.copyFrom(this.climbContactPoint),this.startHeightRaycastPosition.copyFrom(this.climbContactPoint),this.startHeightRaycastPosition.addInPlace(BABYLON.Vector3.UpReadOnly.scale(this.rayHeightLength))):(this.offsetHeightRaycastPosition.set(0,this.rayHeightOffset,this.rayClimbLength),n.Utilities.GetAbsolutePositionToRef(this.transform,this.startHeightRaycastPosition,this.offsetHeightRaycastPosition),this.endHeightRaycastPosition.copyFrom(this.startHeightRaycastPosition),this.endHeightRaycastPosition.addInPlace(this.downDirection.scale(this.rayHeightLength))),!0===this.showDebugColliders&&(null==this.heightSensorLine&&(this.heightSensorLine=new n.LinesMeshRenderer(this.transform.name+".HeightCheckSensorLine",this.scene)),this.heightSensorLine.drawLine([this.startHeightRaycastPosition,this.endHeightRaycastPosition],BABYLON.Color3.Green()))},i.prototype.getCheckedVerticalVelocity=function(){var t=null!=this.characterController?this.characterController.getVerticalVelocity():0;return Math.abs(t)>=e.ThirdPersonPlayerController.MIN_VERTICAL_VELOCITY?t:0},i.prototype.destroyPlayerController=function(){this.animationState=null,this.characterController=null,this.onPreUpdateObservable.clear(),this.onPreUpdateObservable=null,this.onBeforeMoveObservable.clear(),this.onBeforeMoveObservable=null,this.onPostUpdateObservable.clear(),this.onPostUpdateObservable=null},i.prototype.validateAnimationStateParams=function(){null==this.animationStateParams&&(this.animationStateParams={moveDirection:"Direction",inputMagnitude:"Magnitude",horizontalInput:"Horizontal",verticalInput:"Vertical",mouseXInput:"MouseX",mouseYInput:"MouseY",heightInput:"Height",speedInput:"Speed",jumpFrame:"Jumped",jumpState:"Jump",actionState:"Action",fallingState:"FreeFall",slidingState:"Sliding",groundedState:"Grounded"})},i.MIN_VERTICAL_VELOCITY=.01,i.MIN_GROUND_DISTANCE=.15,i.MIN_MOVE_EPSILON=.001,i.MIN_TIMER_OFFSET=0,i.MIN_SLOPE_LIMIT=0,i.PLAYER_HEIGHT="playerHeight",i}(n.ScriptComponent);e.ThirdPersonPlayerController=i,(t=e.ThirdPersonControl||(e.ThirdPersonControl={}))[t.ThirdPersonTurning=0]="ThirdPersonTurning",t[t.ThirdPersonForward=1]="ThirdPersonForward",n.SceneManager.RegisterClass("PROJECT.ThirdPersonPlayerController",i)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.FxParticleSystem");var o=e.call(this,t,i,n,r)||this;return o.m_particleEmitter=null,o.m_particleSystem=null,o}return o(t,e),t.prototype.getParticleEmitter=function(){return this.m_particleEmitter},t.prototype.getParticleSystem=function(){return this.m_particleSystem},t.prototype.awake=function(){var e=n.SceneManager.GetRootUrl(this.scene),t=this.getProperty("classType",0),i=this.getProperty("base64ParticleSystem"),r=this.getProperty("playOnAwake",!1),o=this.getProperty("particleTexture");if(this.m_particleEmitter=this.getAbstractMesh(),null==this.m_particleEmitter&&(this.m_particleEmitter=BABYLON.MeshBuilder.CreateBox(this.transform.name+".Emitter",{size:.25},this.scene),this.m_particleEmitter.parent=this.transform,this.m_particleEmitter.position.set(0,0,0),this.m_particleEmitter.isVisible=!1,this.m_particleEmitter.isPickable=!1,this.m_particleEmitter.material=n.Utilities.GetColliderMaterial(this.scene)),null!=i&&""!==i){var a=window.atob(i);if(null!=a&&""!==a){var s=JSON.parse(a);null!=s&&(null!=s.texture&&null!=o&&(s.texture.name=o.filename,s.texture.url=o.filename),this.m_particleSystem=1===t?BABYLON.GPUParticleSystem.Parse(s,this.scene,e):BABYLON.ParticleSystem.Parse(s,this.scene,e),null!=this.m_particleSystem&&(null!=this.m_particleEmitter&&(this.m_particleSystem.emitter=this.m_particleEmitter),!1===r&&this.m_particleSystem.stop()))}}},t.prototype.destroy=function(){this.m_particleEmitter=null,null!=this.m_particleSystem&&(this.m_particleSystem.dispose(),this.m_particleSystem=null)},t}(n.ScriptComponent);e.FxParticleSystem=t,n.SceneManager.RegisterClass("PROJECT.FxParticleSystem",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.SkyMaterialSystem");var o=e.call(this,t,i,n,r)||this;return o.skyfog=!1,o.skysize=1e3,o.probesize=128,o.reflections=!1,o.reflectlevel=1,o.skytintcolor=new BABYLON.Color3(1,1,1),o.m_skyboxMesh=null,o.m_skyMaterial=null,o.m_reflectProbe=null,o}return o(t,e),t.prototype.getSkyboxMesh=function(){return this.m_skyboxMesh},t.prototype.getSkyMaterial=function(){return this.m_skyMaterial},t.prototype.getReflectionProbe=function(){return this.m_reflectProbe},t.prototype.awake=function(){this.awakeSkyboxMaterial()},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.late=function(){},t.prototype.after=function(){},t.prototype.destroy=function(){this.destroySkyboxMaterial()},t.prototype.awakeSkyboxMaterial=function(){this.skyfog=this.getProperty("applyMeshFog",this.skyfog),this.skysize=this.getProperty("boxSize",this.skysize),this.probesize=this.getProperty("probeSize",this.probesize),this.reflections=this.getProperty("reflections",this.reflections),this.reflectlevel=this.getProperty("reflectLevel",this.reflectlevel);var e=this.getProperty("tintColor");null!=e&&(this.skytintcolor=n.Utilities.ParseColor3(e)),this.m_skyboxMesh=BABYLON.MeshBuilder.CreateBox("Ambient Skybox",{size:this.skysize},this.scene),this.m_skyboxMesh.position.set(0,0,0),this.m_skyboxMesh.infiniteDistance=!0,this.m_skyboxMesh.applyFog=this.skyfog,!0===this.scene.useRightHandedSystem&&(this.m_skyboxMesh.scaling.x*=-1),this.m_skyMaterial=new BABYLON.SkyMaterial(this.transform.name+".SkyMaterial",this.scene),this.m_skyMaterial.backFaceCulling=!1,this.setSkyboxTintColor(this.skytintcolor),this.m_skyMaterial.luminance=this.getProperty("luminance",this.m_skyMaterial.luminance),this.m_skyMaterial.turbidity=this.getProperty("turbidity",this.m_skyMaterial.turbidity),this.m_skyMaterial.rayleigh=this.getProperty("rayleigh",this.m_skyMaterial.rayleigh),this.m_skyMaterial.mieCoefficient=this.getProperty("mieCoefficient",this.m_skyMaterial.mieCoefficient),this.m_skyMaterial.mieDirectionalG=this.getProperty("mieDirectionalG",this.m_skyMaterial.mieDirectionalG),this.m_skyMaterial.distance=this.getProperty("distance",this.m_skyMaterial.distance),this.m_skyMaterial.inclination=this.getProperty("inclination",this.m_skyMaterial.inclination),this.m_skyMaterial.azimuth=this.getProperty("azimuth",this.m_skyMaterial.azimuth);var t=this.getProperty("cameraOffset");null!=t&&(this.m_skyMaterial.cameraOffset=n.Utilities.ParseVector3(t)),this.m_skyMaterial.useSunPosition=this.getProperty("useSunPosition",this.m_skyMaterial.useSunPosition),this.m_skyMaterial.sunPosition=new BABYLON.Vector3(0,50,0),null!=this.scene.metadata&&null!=this.scene.metadata.unity&&this.scene.metadata.unity&&null!=this.scene.metadata.toolkit.sunposition&&(this.m_skyMaterial.sunPosition=n.Utilities.ParseVector3(this.scene.metadata.toolkit.sunposition)),this.m_skyboxMesh.material=this.m_skyMaterial,!0===this.reflections&&(this.m_reflectProbe=new BABYLON.ReflectionProbe("Skybox-ReflectionProbe",this.probesize,this.scene),this.m_reflectProbe.renderList.push(this.m_skyboxMesh),this.scene.customRenderTargets.push(this.m_reflectProbe.cubeTexture),this.scene.environmentTexture=this.m_reflectProbe.cubeTexture,this.scene.environmentIntensity=this.reflectlevel)},t.prototype.destroySkyboxMaterial=function(){null!=this.m_skyboxMesh&&(this.m_skyboxMesh.dispose(),this.m_skyboxMesh=null),null!=this.m_reflectProbe&&(this.m_reflectProbe.dispose(),this.m_reflectProbe=null),null!=this.m_skyMaterial&&(this.m_skyMaterial.dispose(),this.m_skyMaterial=null)},t.prototype.setSkyboxTintColor=function(e){for(var t=[],i=this.m_skyboxMesh.getTotalVertices(),n=0;n<i;++n)t.push(e.r,e.g,e.b,1);this.m_skyboxMesh.setVerticesData("color",t),this.m_skyboxMesh.useVertexColors=!0},t}(n.ScriptComponent);e.SkyMaterialSystem=t,n.SceneManager.RegisterClass("PROJECT.SkyMaterialSystem",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.WaterMaterialSystem");var o=e.call(this,t,i,n,r)||this;return o.waterTag="Water",o.targetSize=new BABYLON.Vector2(128,128),o.renderSize=new BABYLON.Vector2(512,512),o.depthFactor=1,o.reflectSkybox=!0,o.subDivisions=32,o.heightOffset=1,o.windDirection=new BABYLON.Vector2(0,1),o.windForce=6,o.waveSpeed=1,o.waveLength=.4,o.waveHeight=.4,o.bumpHeight=.4,o.waterColor=new BABYLON.Color3(.1,.1,.6),o.colorBlendFactor=.2,o.waterColor2=new BABYLON.Color3(.1,.1,.6),o.colorBlendFactor2=.2,o.disableClipPlane=!1,o.m_waterGeometry=null,o.m_waterMaterial=null,o}return o(t,e),t.prototype.getWaterGeometry=function(){return this.m_waterGeometry},t.prototype.getWaterMaterial=function(){return this.m_waterMaterial},t.prototype.awake=function(){var e=this;this.waterTag=this.getProperty("waterTag",this.waterTag),this.depthFactor=this.getProperty("depthFactor",this.depthFactor),this.subDivisions=this.getProperty("subDivisions",this.subDivisions),this.heightOffset=this.getProperty("heightOffset",this.heightOffset),this.reflectSkybox=this.getProperty("reflectSkybox",this.reflectSkybox),this.windForce=this.getProperty("windForce",this.windForce),this.waveSpeed=this.getProperty("waveSpeed",this.waveSpeed),this.waveLength=this.getProperty("waveLength",this.waveLength),this.waveHeight=this.getProperty("waveHeight",this.waveHeight),this.bumpHeight=this.getProperty("bumpHeight",this.bumpHeight),this.bumpSuperimpose=this.getProperty("bumpSuperimpose",this.bumpSuperimpose),this.bumpAffectsReflection=this.getProperty("bumpAffectsReflection",this.bumpAffectsReflection),this.colorBlendFactor=this.getProperty("colorBlendFactor",this.colorBlendFactor),this.colorBlendFactor2=this.getProperty("colorBlendFactor2",this.colorBlendFactor2),this.disableClipPlane=this.getProperty("disableClipPlane",this.disableClipPlane),this.fresnelSeparate=this.getProperty("fresnelSeparate",this.fresnelSeparate);var t=this.getProperty("waterColor");this.waterColor=n.Utilities.ParseColor3(t);var i=this.getProperty("waterColor2");this.waterColor2=n.Utilities.ParseColor3(i);var r=this.getProperty("windDirection");this.windDirection=n.Utilities.ParseVector2(r);var o=this.getProperty("targetSize");null!=o&&(this.targetSize=n.Utilities.ParseVector2(o));var a=this.getProperty("renderSize");null!=a&&(this.renderSize=n.Utilities.ParseVector2(a));var s=null,l=this.getProperty("bumpTexture");if(null!=l&&(s=n.Utilities.ParseTexture(l,this.scene)),null!=s){if(this.m_waterMaterial=new BABYLON.WaterMaterial(this.transform.name+".Water",this.scene,this.renderSize),this.m_waterMaterial.bumpTexture=s,this.m_waterMaterial.windDirection=this.windDirection,this.m_waterMaterial.windForce=this.windForce,this.m_waterMaterial.waveSpeed=this.waveSpeed,this.m_waterMaterial.waveLength=this.waveLength,this.m_waterMaterial.waveHeight=this.waveHeight,this.m_waterMaterial.bumpHeight=this.bumpHeight,this.m_waterMaterial.bumpSuperimpose=this.bumpSuperimpose,this.m_waterMaterial.bumpAffectsReflection=this.bumpAffectsReflection,this.m_waterMaterial.waterColor=this.waterColor,this.m_waterMaterial.colorBlendFactor=this.colorBlendFactor,this.m_waterMaterial.waterColor2=this.waterColor2,this.m_waterMaterial.colorBlendFactor2=this.colorBlendFactor2,this.m_waterMaterial.disableClipPlane=this.disableClipPlane,this.m_waterMaterial.fresnelSeparate=this.fresnelSeparate,!0===this.reflectSkybox){var u=n.SceneManager.GetDefaultSkybox(this.scene);null!=u&&this.m_waterMaterial.addToRenderList(u)}if(null!=this.waterTag&&""!==this.waterTag){var h=this.scene.getMeshesByTags(this.waterTag);null!=h&&h.length>0&&h.forEach(function(t){e.m_waterMaterial.addToRenderList(t)})}this.m_waterGeometry=BABYLON.MeshBuilder.CreateGround(this.transform.name+".WaterMesh",{width:this.targetSize.x,height:this.targetSize.y,subdivisions:this.subDivisions,updatable:!1},this.scene),this.m_waterGeometry.parent=this.transform,this.m_waterGeometry.position.set(0,this.heightOffset,0),this.depthFactor>0&&(this.m_waterGeometry.scaling.y*=this.depthFactor),this.m_waterGeometry.material=this.m_waterMaterial}else n.SceneManager.LogWarning("No supported water bump texture for: "+this.transform.name)},t.prototype.start=function(){},t.prototype.update=function(){},t.prototype.late=function(){},t.prototype.after=function(){},t.prototype.destroy=function(){},t}(n.ScriptComponent);e.WaterMaterialSystem=t,n.SceneManager.RegisterClass("PROJECT.WaterMaterialSystem",t)}(r||(r={})),function(e){var t=function(t){function i(i,n,r,o){void 0===o&&(o="PROJECT.SnapshotManager");var a=t.call(this,i,n,r,o)||this;return a.autoStart=!1,a.autoUpdate=!0,a.delayTimeout=3,e.SnapshotManager.ResetSnapshotHelper(n),a}return o(i,t),i.IsSnapshotRenderingEnabled=function(){return e.SnapshotManager._HelperEnabled},i.EnableSnapshotRendering=function(){null!=e.SnapshotManager._SnapshotHelper&&(e.SnapshotManager._SnapshotHelper.enableSnapshotRendering(),e.SnapshotManager._HelperEnabled=!0)},i.DisableSnapshotRendering=function(){null!=e.SnapshotManager._SnapshotHelper&&(e.SnapshotManager._SnapshotHelper.disableSnapshotRendering(),e.SnapshotManager._HelperEnabled=!1)},i.ResetSnapshotHelper=function(t){null!=e.SnapshotManager._SnapshotHelper&&(e.SnapshotManager._SnapshotHelper.dispose(),e.SnapshotManager._SnapshotHelper=null),e.SnapshotManager._SnapshotHelper=new BABYLON.SnapshotRenderingHelper(t,{morphTargetsNumMaxInfluences:20}),e.SnapshotManager._HelperEnabled=!1},i.GetSnapshotHelper=function(){return e.SnapshotManager._SnapshotHelper},i.prototype.start=function(){console.warn("*** SnapshotManager Started ***"),null!=e.SnapshotManager._SnapshotHelper&&(e.SnapshotManager._SnapshotHelper.fixMeshes(),console.warn("Snapshot Helper Fixed Meshes.")),this.scene.meshes.forEach(function(e){console.log("Fixup Mesh: "+e.name+" ->: Always Select Mesh: "+e.alwaysSelectAsActiveMesh,e)})},i.prototype.ready=function(){!0===this.autoStart&&(this.delayTimeout>0?n.WindowManager.SetTimeout(1e3*this.delayTimeout,function(){e.SnapshotManager.EnableSnapshotRendering()}):e.SnapshotManager.EnableSnapshotRendering())},i.prototype.update=function(){!0===this.autoUpdate&&null!=e.SnapshotManager._SnapshotHelper&&!0===e.SnapshotManager._HelperEnabled&&this.scene.meshes.forEach(function(e){e.transferToEffect(e.computeWorldMatrix(!0))})},i.prototype.destroy=function(){e.SnapshotManager._HelperEnabled=!1,null!=e.SnapshotManager._SnapshotHelper&&(e.SnapshotManager._SnapshotHelper.dispose(),e.SnapshotManager._SnapshotHelper=null)},i._HelperEnabled=!1,i._SnapshotHelper=null,i}(n.ScriptComponent);e.SnapshotManager=t,n.SceneManager.RegisterClass("PROJECT.SnapshotManager",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){return void 0===n&&(n={}),void 0===r&&(r="PROJECT.SnapshotRenderer"),e.call(this,t,i,n,r)||this}return o(t,e),t.prototype.start=function(){},t}(n.ScriptComponent);e.SnapshotRenderer=t,n.SceneManager.RegisterClass("PROJECT.SnapshotRenderer",t)}(r||(r={})),function(e){var t=function(t){function i(e,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.DefaultMuteButton");var o=t.call(this,e,i,n,r)||this;return o.buttonIdentifier="mute-button",o.buttonClassname="mute-button-active",o.buttonContainer="button-container",o.buttonElement=null,o.muteIconElement=null,o.mutedIconElement=null,o.muteButtonState=!0,o.mutedIconUrl="",o.muteIconUrl="",o.toggleEffects=!0,o.autoPlayList=null,o.audioSources=null,o}return o(i,t),i.IsAudioSystemInitialized=function(){return i.audioSystemInitialized},i.prototype.awake=function(){},i.prototype.start=function(){var e=this;null!=this.autoPlayList&&this.autoPlayList.length>0&&this.autoPlayList.forEach(function(t){var i=n.SceneManager.FindScriptComponent(t,"TOOLKIT.AudioSource");null!=i&&(null==e.audioSources&&(e.audioSources=[]),e.audioSources.push(i))})},i.prototype.ready=function(){this.createMuteButton()},i.prototype.createMuteButton=function(){var e=this,t=window.document.createElement("div");t.className=this.buttonContainer,window.document.body.appendChild(t),this.buttonElement=window.document.createElement("button"),this.buttonElement.id=this.buttonIdentifier,this.buttonElement.className=this.buttonClassname,t.appendChild(this.buttonElement),this.mutedIconElement=window.document.createElement("img"),this.mutedIconElement.id="muted-icon",this.mutedIconElement.src=this.mutedIconUrl,this.mutedIconElement.className="",this.buttonElement.appendChild(this.mutedIconElement),this.muteIconElement=window.document.createElement("img"),this.muteIconElement.id="mute-icon",this.muteIconElement.src=this.muteIconUrl,this.muteIconElement.className="hidden",this.buttonElement.appendChild(this.muteIconElement),this.buttonElement.onclick=function(){e.handleButtonClick()}},i.prototype.handleButtonClick=function(){this.muteButtonState=!this.muteButtonState,this.buttonElement.classList.toggle("mute-button-active"),this.muteIconElement.classList.toggle("hidden"),this.mutedIconElement.classList.toggle("hidden"),!1===e.DefaultMuteButton.audioSystemInitialized?(e.DefaultMuteButton.audioSystemInitialized=!0,null!=this.audioSources&&this.audioSources.length>0&&this.audioSources.forEach(function(e){null!=e&&e.play()})):null!=e.SceneSoundSystem&&(!0===this.muteButtonState?(null!=e.SceneSoundSystem.MUSIC&&e.SceneSoundSystem.MUSIC.muteAllTracks(),null!=e.SceneSoundSystem.SFX&&!0===this.toggleEffects&&e.SceneSoundSystem.SFX.muteAllTracks()):(null!=e.SceneSoundSystem.MUSIC&&e.SceneSoundSystem.MUSIC.unmuteAllTracks(),null!=e.SceneSoundSystem.SFX&&!0===this.toggleEffects&&e.SceneSoundSystem.SFX.unmuteAllTracks()))},i.audioSystemInitialized=!1,i}(n.ScriptComponent);e.DefaultMuteButton=t,n.SceneManager.RegisterClass("PROJECT.DefaultMuteButton",t)}(r||(r={})),function(e){var t=function(t){function i(e,i,n,r){return void 0===n&&(n={}),void 0===r&&(r="PROJECT.SceneSoundSystem"),t.call(this,e,i,n,r)||this}return o(i,t),Object.defineProperty(i,"MUSIC",{get:function(){return i._MUSIC},enumerable:!1,configurable:!0}),Object.defineProperty(i,"SFX",{get:function(){return i._SFX},enumerable:!1,configurable:!0}),i.prototype.start=function(){var t=this.getChildNode("MUSIC");null!=t&&(e.SceneSoundSystem._MUSIC=n.SceneManager.FindScriptComponent(t,"PROJECT.SoundManager"));var i=this.getChildNode("SFX");null!=i&&(e.SceneSoundSystem._SFX=n.SceneManager.FindScriptComponent(i,"PROJECT.SoundManager"))},i._MUSIC=null,i._SFX=null,i}(n.ScriptComponent);e.SceneSoundSystem=t,n.SceneManager.RegisterClass("PROJECT.SceneSoundSystem",t)}(r||(r={})),function(e){var t=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="PROJECT.SoundManager");var o=e.call(this,t,i,n,r)||this;return o.groupName=null,o.cachedVolume=!1,o.volumeProperty="volume",o.m_soundMap=null,o.m_soundList=null,o}return o(t,e),t.prototype.getGroupName=function(){return this.groupName},t.prototype.awake=function(){this.groupName=this.getProperty("groupName",this.transform.name),this.cachedVolume=this.getProperty("cachedVolume",this.cachedVolume),this.volumeProperty=this.getProperty("volumeProperty",this.volumeProperty),this.m_soundMap=new Map,this.m_soundList=[]},t.prototype.start=function(){var e=this.transform.getChildren(null,!0);if(null!=e&&e.length>0)for(var t=0;t<e.length;t++){var i=e[t],r=n.SceneManager.FindScriptComponent(i,"TOOLKIT.AudioSource");if(null!=r){if(!0===this.cachedVolume){var o=window.localStorage.getItem(this.volumeProperty);if(null!=o&&""!==o){var a=parseFloat(o);null!=a&&r.setVolume(a)}}this.m_soundMap.set(i.name,r),this.m_soundList.push(r)}}},t.prototype.update=function(){},t.prototype.destroy=function(){this.m_soundList=null,this.m_soundMap.clear(),this.m_soundMap=null},t.prototype.isPlaying=function(e){var t=this.getAudioSource(e);return null!=t&&t.isPlaying()},t.prototype.isPaused=function(e){var t=this.getAudioSource(e);return null!=t&&t.isPaused()},t.prototype.playTrack=function(e,t,i,n){return s(this,void 0,void 0,function(){var r;return l(this,function(o){return[2,null!=(r=this.getAudioSource(e))&&r.play(t,i,n)]})})},t.prototype.pauseTrack=function(e){var t=this.getAudioSource(e);return null!=t&&t.pause()},t.prototype.pauseAllTracks=function(){if(null!=this.m_soundList&&this.m_soundList.length>0)for(var e=0;e<this.m_soundList.length;e++)null!=this.m_soundList[e]&&this.m_soundList[e].pause()},t.prototype.stopTrack=function(e,t){var i=this.getAudioSource(e);return null!=i&&i.stop(t)},t.prototype.stopAllTracks=function(e){if(null!=this.m_soundList&&this.m_soundList.length>0)for(var t=0;t<this.m_soundList.length;t++)null!=this.m_soundList[t]&&this.m_soundList[t].stop(e)},t.prototype.muteTrack=function(e,t){var i=this.getAudioSource(e);return null!=i&&i.mute(t)},t.prototype.unmuteTrack=function(e,t){var i=this.getAudioSource(e);return null!=i&&i.unmute(t)},t.prototype.muteAllTracks=function(e){if(null!=this.m_soundList&&this.m_soundList.length>0)for(var t=0;t<this.m_soundList.length;t++)null!=this.m_soundList[t]&&this.m_soundList[t].mute(e)},t.prototype.unmuteAllTracks=function(e){if(null!=this.m_soundList&&this.m_soundList.length>0)for(var t=0;t<this.m_soundList.length;t++)null!=this.m_soundList[t]&&this.m_soundList[t].unmute(e)},t.prototype.setGroupVolume=function(e,t){if(null!=this.m_soundList&&this.m_soundList.length>0)for(var i=0;i<this.m_soundList.length;i++)null!=this.m_soundList[i]&&this.m_soundList[i].setVolume(e,t)},t.prototype.getAudioSource=function(e){return this.m_soundMap.get(e)},t}(n.ScriptComponent);e.SoundManager=t,n.SceneManager.RegisterClass("PROJECT.SoundManager",t)}(r||(r={})),function(e){var t=function(){function t(){}return t.IsXboxLiveUserSignedIn=function(t,i){if(void 0===t&&(t=null),void 0===i&&(i=e.PlayerNumber.One),e.WindowManager.IsWindows()){var n=null!=t?e.WindowsPlatform.GetXboxLiveSystemUser(t,i):e.WindowsPlatform.GetXboxLiveUser(i);return null!=n&&1==n.isSignedIn}return!1},t.XboxLiveUserSignIn=function(t,i,n,r){void 0===t&&(t=e.PlayerNumber.One),e.WindowManager.IsWindows()&&e.WindowsPlatform.XboxLiveUserSilentSignIn(t,function(o){o.status===Microsoft.Xbox.Services.System.SignInStatus.userInteractionRequired?e.WindowsPlatform.XboxLiveUserDialogSignIn(t,function(e){i&&i(e)},n,r):i&&i(o)},n,r)},t.XboxLiveUserSilentSignIn=function(t,i,n,r){return void 0===t&&(t=e.PlayerNumber.One),e.WindowManager.IsWindows()?e.WindowsPlatform.GetXboxLiveUser(t).signInSilentlyAsync(null).then(i,n,r):null},t.XboxLiveUserDialogSignIn=function(t,i,n,r){return void 0===t&&(t=e.PlayerNumber.One),e.WindowManager.IsWindows()?e.WindowsPlatform.GetXboxLiveUser(t).signInAsync(null).then(i,n,r):null},t.LoadXboxLiveUserProfile=function(t,i,n,r){return void 0===t&&(t=e.PlayerNumber.One),e.WindowManager.IsWindows()?e.WindowsPlatform.GetXboxLiveUserContext(t).profileService.getUserProfileAsync(e.WindowsPlatform.GetXboxLiveUser(t).xboxUserId).then(i,n,r):null},t.GetXboxLiveUser=function(t){void 0===t&&(t=e.PlayerNumber.One);var i=null;if(e.WindowManager.IsWindows())switch(t){case e.PlayerNumber.One:i=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveUserOne();break;case e.PlayerNumber.Two:i=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveUserTwo();break;case e.PlayerNumber.Three:i=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveUserThree();break;case e.PlayerNumber.Four:i=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveUserFour()}return i},t.GetXboxLiveSystemUser=function(t,i){void 0===i&&(i=e.PlayerNumber.One);var n=null;if(e.WindowManager.IsWindows())switch(i){case e.PlayerNumber.One:n=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveSystemUserOne(t);break;case e.PlayerNumber.Two:n=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveSystemUserTwo(t);break;case e.PlayerNumber.Three:n=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveSystemUserThree(t);break;case e.PlayerNumber.Four:n=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveSystemUserFour(t)}return n},t.GetXboxLiveUserContext=function(t){void 0===t&&(t=e.PlayerNumber.One);var i=null;if(e.WindowManager.IsWindows())switch(t){case e.PlayerNumber.One:i=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveContextOne();break;case e.PlayerNumber.Two:i=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveContextTwo();break;case e.PlayerNumber.Three:i=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveContextThree();break;case e.PlayerNumber.Four:i=window.BabylonToolkit.XboxLive.Plugin.getXboxLiveContextFour()}return i},t.ResetXboxLiveUserContext=function(t){if(void 0===t&&(t=e.PlayerNumber.One),e.WindowManager.IsWindows())switch(t){case e.PlayerNumber.One:window.BabylonToolkit.XboxLive.Plugin.resetXboxLiveUserContextOne();break;case e.PlayerNumber.Two:window.BabylonToolkit.XboxLive.Plugin.resetXboxLiveUserContextTwo();break;case e.PlayerNumber.Three:window.BabylonToolkit.XboxLive.Plugin.resetXboxLiveUserContextThree();break;case e.PlayerNumber.Four:window.BabylonToolkit.XboxLive.Plugin.resetXboxLiveUserContextFour()}},t.GetXboxLiveContextProperty=function(t){return e.WindowManager.IsWindows()?window.BabylonToolkit.XboxLive.Plugin.getXboxLiveContextProperty(t):null},t.SetXboxLiveContextProperty=function(t,i){e.WindowManager.IsWindows()&&window.BabylonToolkit.XboxLive.Plugin.setXboxLiveContextProperty(t,i)},t.ResetXboxLivePropertyContexts=function(){e.WindowManager.IsWindows()&&window.BabylonToolkit.XboxLive.Plugin.resetXboxLivePropertyContexts()},t.SetXboxLiveSignOutHandler=function(t){void 0===t&&(t=null),e.WindowManager.IsWindows()&&(window.BabylonToolkit.XboxLive.Plugin.onusersignout=t)},t}();e.WindowsPlatform=t}(n||(n={})),function(e){var t,i,n,r;(r=e.DragDirection||(e.DragDirection={}))[r.None=0]="None",r[r.Up=1]="Up",r[r.Down=2]="Down",r[r.Right=3]="Right",r[r.Left=4]="Left",(n=e.PinchZoomState||(e.PinchZoomState={}))[n.None=0]="None",n[n.ZoomIn=1]="ZoomIn",n[n.ZoomOut=2]="ZoomOut",(i=e.MouseButtonMode||(e.MouseButtonMode={}))[i.Pan=0]="Pan",i[i.Look=1]="Look",i[i.Move=2]="Move",(t=e.TouchMouseButton||(e.TouchMouseButton={}))[t.Any=-1]="Any",t[t.Left=0]="Left",t[t.Right=1]="Right";var o=function(){function t(){}return t.GetMouseButtonsDown=function(){return e.InputController.mouseButtonsDown},t.GetLeftButtonDown=function(){return e.InputController.leftButtonDown},t.GetMiddleButtonDown=function(){return e.InputController.middleButtonDown},t.GetRightButtonDown=function(){return e.InputController.rightButtonDown},t.GetMouseDownTarget=function(){return e.InputController.mouseDownTarget},t.GetMouseDragTarget=function(){return e.InputController.mouseDragTarget},t.GetPinchZoomState=function(){return e.InputController.pinchZoomState},t.EnableUserInput=function(t,i,n){void 0===n&&(n=null),e.InputController.ConfigureUserInput(t,i,n)},t.ConfigureUserInput=function(t,i,n){void 0===n&&(n=null);var r=null==n||null==n.contextMenu||n.contextMenu,o=null!=n&&null!=n.pointerLock&&n.pointerLock,a=null!=n&&null!=n.preventDefault&&n.preventDefault,s=null!=n&&null!=n.useCapture&&n.useCapture;if(e.InputController.resetUserInput(),!e.InputController.input){document.documentElement.tabIndex=1,document.documentElement.addEventListener("keyup",e.InputController.inputKeyUpHandler,s),document.documentElement.addEventListener("pointerup",e.InputController.inputPointerUpHandler,s),document.documentElement.addEventListener("pointerout",e.InputController.inputPointerUpHandler,s),document.documentElement.addEventListener("pointerleave",e.InputController.inputPointerUpHandler,s),document.documentElement.addEventListener("pointercancel",e.InputController.inputPointerUpHandler,s);var l=document.getElementById("renderingCanvas")||t.getRenderingCanvas();null!=l&&(l.oncontextmenu=!0===r?null:function(e){e.preventDefault(),e.stopPropagation()}),!0===e.UserInputOptions.UseCanvasElement?(l.tabIndex=2,l.addEventListener("focusout",e.InputController.resetKeyMapHandler,s),l.addEventListener("keydown",e.InputController.inputKeyDownHandler,s),l.addEventListener("pointerdown",e.InputController.inputPointerDownHandler,s),l.addEventListener("pointermove",e.InputController.inputPointerMoveHandler,s),l.addEventListener("onwheel"in document?"wheel":"mousewheel",e.InputController.inputPointerWheelHandler,s)):(document.documentElement.addEventListener("focusout",e.InputController.resetKeyMapHandler,s),document.documentElement.addEventListener("keydown",e.InputController.inputKeyDownHandler,s),document.documentElement.addEventListener("pointerdown",e.InputController.inputPointerDownHandler,s),document.documentElement.addEventListener("pointermove",e.InputController.inputPointerMoveHandler,s),document.documentElement.addEventListener("onwheel"in document?"wheel":"mousewheel",e.InputController.inputPointerWheelHandler,s)),e.InputController.preventDefault=a,null==e.InputController.GamepadManager&&(e.InputController.GamepadManager=new BABYLON.GamepadManager,e.InputController.GamepadManager.onGamepadConnectedObservable.add(e.InputController.inputManagerGamepadConnected),e.InputController.GamepadManager.onGamepadDisconnectedObservable.add(e.InputController.inputManagerGamepadDisconnected)),e.InputController.input=!0,document.documentElement.focus(),!0===o&&e.InputController.LockMousePointer(i,!0)}e.InputController._registeredUpdateScenes.has(i)||(e.InputController._registeredUpdateScenes.add(i),i.registerAfterRender(function(){e.InputController.updateUserInput(i)}))},t.SetLeftJoystickBuffer=function(t,i,n){void 0===n&&(n=!0),e.InputController.j_horizontal=t,e.InputController.j_vertical=!0===n?-i:i},t.SetRightJoystickBuffer=function(t,i,n){void 0===n&&(n=!0),e.InputController.j_mousex=t,e.InputController.j_mousey=!0===n?-i:i},t.DisableUserInput=function(t,i){void 0===i&&(i=!1),e.InputController.LockMousePointer(t,!1),e.InputController.resetUserInput()},t.LockMousePointer=function(t,i){!0===i?e.InputController.LockMousePointerObserver=t.onPointerObservable.add(function(i,n){var r;i.type==BABYLON.PointerEventTypes.POINTERDOWN&&(document.pointerLockElement||null===(r=e.SceneManager.GetEngine(t))||void 0===r||r.enterPointerlock())}):e.InputController.IsPointerLockHandled()&&(t.onPointerObservable.remove(e.InputController.LockMousePointerObserver),e.InputController.LockMousePointerObserver=null)},t.IsPointerLocked=function(){return e.InputController.PointerLockedFlag},t.IsPointerLockHandled=function(){return null!=e.InputController.LockMousePointerObserver},t.GetUserInput=function(t,i){void 0===i&&(i=e.PlayerNumber.One);var n=0;if(e.InputController.input)switch(t){case e.UserInputAxis.Vertical:case e.UserInputAxis.Horizontal:n=i===e.PlayerNumber.Four?t===e.UserInputAxis.Horizontal?e.InputController.horizontal4:e.InputController.vertical4:i===e.PlayerNumber.Three?t===e.UserInputAxis.Horizontal?e.InputController.horizontal3:e.InputController.vertical3:i===e.PlayerNumber.Two?t===e.UserInputAxis.Horizontal?e.InputController.horizontal2:e.InputController.vertical2:t===e.UserInputAxis.Horizontal?e.InputController.horizontal:e.InputController.vertical;break;case e.UserInputAxis.MouseX:case e.UserInputAxis.MouseY:n=i===e.PlayerNumber.Four?t===e.UserInputAxis.MouseX?e.InputController.mousex4:e.InputController.mousey4:i===e.PlayerNumber.Three?t===e.UserInputAxis.MouseX?e.InputController.mousex3:e.InputController.mousey3:i===e.PlayerNumber.Two?t===e.UserInputAxis.MouseX?e.InputController.mousex2:e.InputController.mousey2:t===e.UserInputAxis.MouseX?e.InputController.mousex:e.InputController.mousey;break;case e.UserInputAxis.Wheel:i===e.PlayerNumber.One&&(n=e.InputController.wheel)}return n},t.OnKeyboardUp=function(t){e.InputController.input&&e.InputController.keyButtonUp.push(t)},t.OnKeyboardDown=function(t){e.InputController.input&&e.InputController.keyButtonDown.push(t)},t.OnKeyboardPress=function(t,i){e.InputController.input&&e.InputController.keyButtonPress.push({index:t,action:i})},t.GetKeyboardInput=function(t){var i=!1;if(e.InputController.input){var n="k:"+t.toString();if(null!=e.InputController.keymap[n]){var r=e.InputController.keymap[n];i=null!=r.result&&r.result}}return i},t.IsKeyboardButtonHeld=function(t){var i=!1;if(e.InputController.input){var n="k:"+t.toString();if(null!=e.InputController.keymap[n]){var r=e.InputController.keymap[n];null!=r.pressTime&&null!=r.releaseTime&&!0===(null!=r.result&&r.result)&&r.pressTime>0&&0===r.releaseTime&&(i=e.SceneManager.GetTimeMs()-r.pressTime>=e.InputController.TAP_THRESHOLD_MS)}}return i},t.WasKeyboardButtonTapped=function(t,i){void 0===i&&(i=!0);var n=!1;if(e.InputController.input){var r="k:"+t.toString();if(null!=e.InputController.keymap[r]){var o=e.InputController.keymap[r];null!=o.pressTime&&null!=o.releaseTime&&!1===(null!=o.result&&o.result)&&o.pressTime>0&&o.releaseTime>0&&(n=o.releaseTime-o.pressTime<e.InputController.TAP_THRESHOLD_MS)}!0===i&&e.InputController.ResetKeyboardButtonTapped(t)}return n},t.ResetKeyboardButtonTapped=function(t){if(e.InputController.input){var i="k:"+t.toString();null!=e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0})}},t.OnPointerUp=function(t){e.InputController.input&&e.InputController.mouseButtonUp.push(t)},t.OnPointerDown=function(t){e.InputController.input&&e.InputController.mouseButtonDown.push(t)},t.OnPointerPress=function(t,i){e.InputController.input&&e.InputController.mouseButtonPress.push({index:t,action:i})},t.GetPointerInput=function(t){var i=!1;if(e.InputController.input){var n="p:"+t.toString();if(null!=e.InputController.keymap[n]){var r=e.InputController.keymap[n];i=null!=r.result&&r.result}}return i},t.IsPointerButtonHeld=function(t){var i=!1;if(e.InputController.input){var n="p:"+t.toString();if(null!=e.InputController.keymap[n]){var r=e.InputController.keymap[n];null!=r.pressTime&&null!=r.releaseTime&&!0===(null!=r.result&&r.result)&&r.pressTime>0&&0===r.releaseTime&&(i=e.SceneManager.GetTimeMs()-r.pressTime>=e.InputController.TAP_THRESHOLD_MS)}}return i},t.WasPointerButtonTapped=function(t,i){void 0===i&&(i=!0);var n=!1;if(e.InputController.input){var r="p:"+t.toString();if(null!=e.InputController.keymap[r]){var o=e.InputController.keymap[r];null!=o.pressTime&&null!=o.releaseTime&&!1===(null!=o.result&&o.result)&&o.pressTime>0&&o.releaseTime>0&&(n=o.releaseTime-o.pressTime<e.InputController.TAP_THRESHOLD_MS)}!0===i&&e.InputController.ResetPointerButtonTapped(t)}return n},t.ResetPointerButtonTapped=function(t){if(e.InputController.input){var i="p:"+t.toString();null!=e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0})}},t.GetPointerDragDirection=function(t,i,n){return!0===n?0===t&&0===i||(Math.abs(t)>Math.abs(i)?t>0?e.InputController.dragDirection=e.DragDirection.Right:t<0&&(e.InputController.dragDirection=e.DragDirection.Left):i>0?e.InputController.dragDirection=e.DragDirection.Up:i<0&&(e.InputController.dragDirection=e.DragDirection.Down)):e.InputController.dragDirection=e.DragDirection.None,e.InputController.dragDirection},t.ResetPinchZoomTracking=function(){e.InputController.pinchZoomState=0,e.InputController.pinchZoomEvents=[],e.InputController.pinchZoomDistance=null},t.GetMousePosition=function(t,i){void 0===i&&(i=!1);var n=e.InputController.IsPointerLocked(),r=n?e.InputController.virtualClientX:e.InputController.lastClientX||0,o=n?e.InputController.virtualClientY:e.InputController.lastClientY||0,a=t.getEngine().getRenderingCanvas();if(a){var s=a.getBoundingClientRect(),l=r-s.left,u=o-s.top;if(!0===i){var h=s.height-u;e.InputController.LastMousePosition.set(l,h,0)}else e.InputController.LastMousePosition.set(l,u,0);return e.InputController.LastMousePosition}return!0===i?e.InputController.LastMousePosition.set(r,window.innerHeight-o,0):e.InputController.LastMousePosition.set(r,o,0),e.InputController.LastMousePosition},t.IsWheelScrolling=function(){return 0!==e.InputController.scroll},t.OnGamepadButtonUp=function(t,i){if(void 0===i&&(i=e.PlayerNumber.One),e.InputController.input)switch(i){case e.PlayerNumber.One:e.InputController.gamepad1ButtonUp.push(t);break;case e.PlayerNumber.Two:e.InputController.gamepad2ButtonUp.push(t);break;case e.PlayerNumber.Three:e.InputController.gamepad3ButtonUp.push(t);break;case e.PlayerNumber.Four:e.InputController.gamepad4ButtonUp.push(t)}},t.OnGamepadButtonDown=function(t,i){if(void 0===i&&(i=e.PlayerNumber.One),e.InputController.input)switch(i){case e.PlayerNumber.One:e.InputController.gamepad1ButtonDown.push(t);break;case e.PlayerNumber.Two:e.InputController.gamepad2ButtonDown.push(t);break;case e.PlayerNumber.Three:e.InputController.gamepad3ButtonDown.push(t);break;case e.PlayerNumber.Four:e.InputController.gamepad4ButtonDown.push(t)}},t.OnGamepadButtonPress=function(t,i,n){if(void 0===n&&(n=e.PlayerNumber.One),e.InputController.input)switch(n){case e.PlayerNumber.One:e.InputController.gamepad1ButtonPress.push({index:t,action:i});break;case e.PlayerNumber.Two:e.InputController.gamepad2ButtonPress.push({index:t,action:i});break;case e.PlayerNumber.Three:e.InputController.gamepad3ButtonPress.push({index:t,action:i});break;case e.PlayerNumber.Four:e.InputController.gamepad4ButtonPress.push({index:t,action:i})}},t.GetGamepadButtonInput=function(t,i){void 0===i&&(i=e.PlayerNumber.One);var n=!1;if(e.InputController.input){var r=null;switch(i){case e.PlayerNumber.One:r="b1:"+t.toString();break;case e.PlayerNumber.Two:r="b2:"+t.toString();break;case e.PlayerNumber.Three:r="b3:"+t.toString();break;case e.PlayerNumber.Four:r="b4:"+t.toString()}if(null!=r&&null!=e.InputController.keymap[r]){var o=e.InputController.keymap[r];n=null!=o.result&&o.result}}return n},t.IsGamepadButtonHeld=function(t,i){void 0===i&&(i=e.PlayerNumber.One);var n=!1;if(e.InputController.input){var r=null;switch(i){case e.PlayerNumber.One:r="b1:"+t.toString();break;case e.PlayerNumber.Two:r="b2:"+t.toString();break;case e.PlayerNumber.Three:r="b3:"+t.toString();break;case e.PlayerNumber.Four:r="b4:"+t.toString()}if(null!=r&&null!=e.InputController.keymap[r]){var o=e.InputController.keymap[r];null!=o.pressTime&&null!=o.releaseTime&&!0===(null!=o.result&&o.result)&&o.pressTime>0&&0===o.releaseTime&&(n=e.SceneManager.GetTimeMs()-o.pressTime>=e.InputController.TAP_THRESHOLD_MS)}}return n},t.IsGamepadButtonTapped=function(t,i){void 0===i&&(i=e.PlayerNumber.One);var n=!1;if(e.InputController.input){var r=null;switch(i){case e.PlayerNumber.One:r="b1:"+t.toString();break;case e.PlayerNumber.Two:r="b2:"+t.toString();break;case e.PlayerNumber.Three:r="b3:"+t.toString();break;case e.PlayerNumber.Four:r="b4:"+t.toString()}if(null!=r&&null!=e.InputController.keymap[r]){var o=e.InputController.keymap[r];null!=o.pressTime&&null!=o.releaseTime&&!1===(null!=o.result&&o.result)&&o.pressTime>0&&o.releaseTime>0&&(n=o.releaseTime-o.pressTime<e.InputController.TAP_THRESHOLD_MS)}}return n},t.ResetGamepadButtonTapped=function(t,i){if(void 0===i&&(i=e.PlayerNumber.One),e.InputController.input){var n=null;switch(i){case e.PlayerNumber.One:n="b1:"+t.toString();break;case e.PlayerNumber.Two:n="b2:"+t.toString();break;case e.PlayerNumber.Three:n="b3:"+t.toString();break;case e.PlayerNumber.Four:n="b4:"+t.toString()}null!=n&&null!=e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0})}},t.OnGamepadDirectionUp=function(t,i){if(void 0===i&&(i=e.PlayerNumber.One),e.InputController.input)switch(i){case e.PlayerNumber.One:e.InputController.gamepad1DpadUp.push(t);break;case e.PlayerNumber.Two:e.InputController.gamepad2DpadUp.push(t);break;case e.PlayerNumber.Three:e.InputController.gamepad3DpadUp.push(t);break;case e.PlayerNumber.Four:e.InputController.gamepad4DpadUp.push(t)}},t.OnGamepadDirectionDown=function(t,i){if(void 0===i&&(i=e.PlayerNumber.One),e.InputController.input)switch(i){case e.PlayerNumber.One:e.InputController.gamepad1DpadDown.push(t);break;case e.PlayerNumber.Two:e.InputController.gamepad2DpadDown.push(t);break;case e.PlayerNumber.Three:e.InputController.gamepad3DpadDown.push(t);break;case e.PlayerNumber.Four:e.InputController.gamepad4DpadDown.push(t)}},t.OnGamepadDirectionPress=function(t,i,n){if(void 0===n&&(n=e.PlayerNumber.One),e.InputController.input)switch(n){case e.PlayerNumber.One:e.InputController.gamepad1DpadPress.push({index:t,action:i});break;case e.PlayerNumber.Two:e.InputController.gamepad2DpadPress.push({index:t,action:i});break;case e.PlayerNumber.Three:e.InputController.gamepad3DpadPress.push({index:t,action:i});break;case e.PlayerNumber.Four:e.InputController.gamepad4DpadPress.push({index:t,action:i})}},t.GetGamepadDirectionInput=function(t,i){void 0===i&&(i=e.PlayerNumber.One);var n=!1;if(e.InputController.input){var r=null;switch(i){case e.PlayerNumber.One:r="d1:"+t.toString();break;case e.PlayerNumber.Two:r="d2:"+t.toString();break;case e.PlayerNumber.Three:r="d3:"+t.toString();break;case e.PlayerNumber.Four:r="d4:"+t.toString()}if(null!=r&&null!=e.InputController.keymap[r]){var o=e.InputController.keymap[r];n=null!=o.result&&o.result}}return n},t.IsGamepadDirectionHeld=function(t,i){void 0===i&&(i=e.PlayerNumber.One);var n=!1;if(e.InputController.input){var r=null;switch(i){case e.PlayerNumber.One:r="d1:"+t.toString();break;case e.PlayerNumber.Two:r="d2:"+t.toString();break;case e.PlayerNumber.Three:r="d3:"+t.toString();break;case e.PlayerNumber.Four:r="d4:"+t.toString()}if(null!=r&&null!=e.InputController.keymap[r]){var o=e.InputController.keymap[r];null!=o.pressTime&&null!=o.releaseTime&&!0===(null!=o.result&&o.result)&&o.pressTime>0&&0===o.releaseTime&&(n=e.SceneManager.GetTimeMs()-o.pressTime>=e.InputController.TAP_THRESHOLD_MS)}}return n},t.IsGamepadDirectionTapped=function(t,i){void 0===i&&(i=e.PlayerNumber.One);var n=!1;if(e.InputController.input){var r=null;switch(i){case e.PlayerNumber.One:r="d1:"+t.toString();break;case e.PlayerNumber.Two:r="d2:"+t.toString();break;case e.PlayerNumber.Three:r="d3:"+t.toString();break;case e.PlayerNumber.Four:r="d4:"+t.toString()}if(null!=r&&null!=e.InputController.keymap[r]){var o=e.InputController.keymap[r];null!=o.pressTime&&null!=o.releaseTime&&!1===(null!=o.result&&o.result)&&o.pressTime>0&&o.releaseTime>0&&(n=o.releaseTime-o.pressTime<e.InputController.TAP_THRESHOLD_MS)}}return n},t.ResetGamepadDirectionTapped=function(t,i){if(void 0===i&&(i=e.PlayerNumber.One),e.InputController.input){var n=null;switch(i){case e.PlayerNumber.One:n="d1:"+t.toString();break;case e.PlayerNumber.Two:n="d2:"+t.toString();break;case e.PlayerNumber.Three:n="d3:"+t.toString();break;case e.PlayerNumber.Four:n="d4:"+t.toString()}null!=n&&null!=e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0})}},t.OnGamepadTriggerLeft=function(t,i){if(void 0===i&&(i=e.PlayerNumber.One),e.InputController.input)switch(i){case e.PlayerNumber.One:e.InputController.gamepad1LeftTrigger.push(t);break;case e.PlayerNumber.Two:e.InputController.gamepad2LeftTrigger.push(t);break;case e.PlayerNumber.Three:e.InputController.gamepad3LeftTrigger.push(t);break;case e.PlayerNumber.Four:e.InputController.gamepad4LeftTrigger.push(t)}},t.OnGamepadTriggerRight=function(t,i){if(void 0===i&&(i=e.PlayerNumber.One),e.InputController.input)switch(i){case e.PlayerNumber.One:e.InputController.gamepad1RightTrigger.push(t);break;case e.PlayerNumber.Two:e.InputController.gamepad2RightTrigger.push(t);break;case e.PlayerNumber.Three:e.InputController.gamepad3RightTrigger.push(t);break;case e.PlayerNumber.Four:e.InputController.gamepad4RightTrigger.push(t)}},t.GetGamepadTriggerInput=function(t,i){void 0===i&&(i=e.PlayerNumber.One);var n=0;if(e.InputController.input){var r=null;switch(i){case e.PlayerNumber.One:r="t1:"+t.toString();break;case e.PlayerNumber.Two:r="t2:"+t.toString();break;case e.PlayerNumber.Three:r="t3:"+t.toString();break;case e.PlayerNumber.Four:r="t4:"+t.toString()}if(null!=r&&null!=e.InputController.keymap[r]){var o=e.InputController.keymap[r];n=null!=o.result?o.result:0}}return n},t.IsGamepadTriggerHeld=function(t,i){void 0===i&&(i=e.PlayerNumber.One);var n=!1;if(e.InputController.input){var r=null;switch(i){case e.PlayerNumber.One:r="t1:"+t.toString();break;case e.PlayerNumber.Two:r="t2:"+t.toString();break;case e.PlayerNumber.Three:r="t3:"+t.toString();break;case e.PlayerNumber.Four:r="t4:"+t.toString()}if(null!=r&&null!=e.InputController.keymap[r]){var o=e.InputController.keymap[r];null!=o.pressTime&&null!=o.releaseTime&&!0===(null!=o.result&&o.result)&&o.pressTime>0&&0===o.releaseTime&&(n=e.SceneManager.GetTimeMs()-o.pressTime>=e.InputController.TAP_THRESHOLD_MS)}}return n},t.IsGamepadTriggerTapped=function(t,i){void 0===i&&(i=e.PlayerNumber.One);var n=!1;if(e.InputController.input){var r=null;switch(i){case e.PlayerNumber.One:r="t1:"+t.toString();break;case e.PlayerNumber.Two:r="t2:"+t.toString();break;case e.PlayerNumber.Three:r="t3:"+t.toString();break;case e.PlayerNumber.Four:r="t4:"+t.toString()}if(null!=r&&null!=e.InputController.keymap[r]){var o=e.InputController.keymap[r];null!=o.pressTime&&null!=o.releaseTime&&!1===(null!=o.result&&o.result)&&o.pressTime>0&&o.releaseTime>0&&(n=o.releaseTime-o.pressTime<e.InputController.TAP_THRESHOLD_MS)}}return n},t.ResetGamepadTriggerTapped=function(t,i){if(void 0===i&&(i=e.PlayerNumber.One),e.InputController.input){var n=null;switch(i){case e.PlayerNumber.One:n="t1:"+t.toString();break;case e.PlayerNumber.Two:n="t2:"+t.toString();break;case e.PlayerNumber.Three:n="t3:"+t.toString();break;case e.PlayerNumber.Four:n="t4:"+t.toString()}null!=n&&null!=e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0})}},t.GetGamepadType=function(t){void 0===t&&(t=e.PlayerNumber.One);var i=e.GamepadType.None;if(e.InputController.input)switch(t){case e.PlayerNumber.One:i=e.InputController.gamepad1Type;break;case e.PlayerNumber.Two:i=e.InputController.gamepad2Type;break;case e.PlayerNumber.Three:i=e.InputController.gamepad3Type;break;case e.PlayerNumber.Four:i=e.InputController.gamepad4Type}return i},t.GetGamepad=function(t){void 0===t&&(t=e.PlayerNumber.One);var i=null;if(e.InputController.input)switch(t){case e.PlayerNumber.One:i=e.InputController.gamepad1;break;case e.PlayerNumber.Two:i=e.InputController.gamepad2;break;case e.PlayerNumber.Three:i=e.InputController.gamepad3;break;case e.PlayerNumber.Four:i=e.InputController.gamepad4}return i},t.InputKeyDownHandler=function(t,i){if(void 0===i&&(i=null),null==t||!1===e.SceneManager.EnableUserInput)return!1;i&&i.preventDefault();var n="k:"+t.toString(),r=!1;if(null==e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[n]){var o=e.InputController.keymap[n];!1===(r=null!=o.result&&o.result)&&(o.result=!0,o.pressTime=e.SceneManager.GetTimeMs(),o.releaseTime=0)}return null!=e.InputController.keyButtonDown&&e.InputController.keyButtonDown.length>0&&e.InputController.keyButtonDown.forEach(function(e){e(t)}),r||null!=e.InputController.keyButtonPress&&e.InputController.keyButtonPress.length>0&&e.InputController.keyButtonPress.forEach(function(e){e.index===t&&e.action()}),!0},t.InputKeyUpHandler=function(t,i){if(void 0===i&&(i=null),null==t||!1===e.SceneManager.EnableUserInput)return!1;var n="k:"+t.toString();if(null!=e.InputController.keymap[n]){var r=e.InputController.keymap[n];!0===(null!=r.result&&r.result)&&(r.result=!1,r.releaseTime=e.SceneManager.GetTimeMs())}return null!=e.InputController.keyButtonUp&&e.InputController.keyButtonUp.length>0&&e.InputController.keyButtonUp.forEach(function(e){e(t)}),!0},t.tickKeyboardInput=function(t){if(!1!==e.SceneManager.EnableUserInput){var i=e.InputController.GetKeyboardInput(e.UserInputKey.W)||e.InputController.GetKeyboardInput(e.UserInputKey.UpArrow),n=e.InputController.GetKeyboardInput(e.UserInputKey.A),r=e.InputController.GetKeyboardInput(e.UserInputKey.S)||e.InputController.GetKeyboardInput(e.UserInputKey.DownArrow),o=e.InputController.GetKeyboardInput(e.UserInputKey.D),a=e.InputController.GetKeyboardInput(e.UserInputKey.LeftArrow),s=e.InputController.GetKeyboardInput(e.UserInputKey.RightArrow);e.InputController.k_vertical=!0===i?e.Utilities.GetKeyboardInputValue(t,e.InputController.k_vertical,1):!0===r?e.Utilities.GetKeyboardInputValue(t,e.InputController.k_vertical,-1):0,!0===e.UserInputOptions.UseArrowKeyRotation?(e.InputController.k_horizontal=!0===o?e.Utilities.GetKeyboardInputValue(t,e.InputController.k_horizontal,1):!0===n?e.Utilities.GetKeyboardInputValue(t,e.InputController.k_horizontal,-1):0,e.InputController.a_mousex=!0===s?1*e.UserInputOptions.KeyboardArrowSensibility:!0===a?-1*e.UserInputOptions.KeyboardArrowSensibility:0):e.InputController.k_horizontal=!0===o||!0===s?e.Utilities.GetKeyboardInputValue(t,e.InputController.k_horizontal,1):!0===n||!0===a?e.Utilities.GetKeyboardInputValue(t,e.InputController.k_horizontal,-1):0}},t.updateUserInput=function(t){var i=e.InputController.GetMouseButtonsDown();e.InputController.leftButtonDown=!(1&~i),e.InputController.middleButtonDown=!(4&~i),e.InputController.rightButtonDown=!(2&~i),!1!==e.SceneManager.EnableUserInput&&(e.InputController.PointerLockedFlag=t.getEngine().isPointerLock,e.InputController.tickKeyboardInput(t),e.InputController.x_horizontal=0,e.InputController.x_vertical=0,e.InputController.x_mousex=0,e.InputController.x_mousey=0,0!==e.InputController.j_horizontal?e.InputController.x_horizontal=e.InputController.j_horizontal:0!==e.InputController.g_horizontal1?e.InputController.x_horizontal=e.InputController.g_horizontal1:0!==e.InputController.k_horizontal&&(e.InputController.x_horizontal=e.InputController.k_horizontal),0!==e.InputController.j_vertical?e.InputController.x_vertical=e.InputController.j_vertical:0!==e.InputController.g_vertical1?e.InputController.x_vertical=e.InputController.g_vertical1:0!==e.InputController.k_vertical&&(e.InputController.x_vertical=e.InputController.k_vertical),0!==e.InputController.j_mousex?e.InputController.x_mousex=e.InputController.j_mousex:0!==e.InputController.g_mousex1?e.InputController.x_mousex=e.InputController.g_mousex1:0!==e.InputController.a_mousex?e.InputController.x_mousex=e.InputController.a_mousex:0!==e.InputController.k_mousex&&(e.InputController.x_mousex=e.InputController.k_mousex),0!==e.InputController.j_mousey?e.InputController.x_mousey=e.InputController.j_mousey:0!==e.InputController.g_mousey1?e.InputController.x_mousey=e.InputController.g_mousey1:0!==e.InputController.k_mousey&&(e.InputController.x_mousey=e.InputController.k_mousey),e.InputController.horizontal=e.InputController.x_horizontal,e.InputController.vertical=e.InputController.x_vertical,e.InputController.mousex=e.InputController.x_mousex,e.InputController.mousey=e.InputController.x_mousey,e.InputController.scroll=e.InputController.x_scroll,e.InputController.wheel=e.InputController.x_wheel,e.InputController.horizontal2=e.InputController.g_horizontal2,e.InputController.vertical2=e.InputController.g_vertical2,e.InputController.mousex2=e.InputController.g_mousex2,e.InputController.mousey2=e.InputController.g_mousey2,e.InputController.horizontal3=e.InputController.g_horizontal3,e.InputController.vertical3=e.InputController.g_vertical3,e.InputController.mousex3=e.InputController.g_mousex3,e.InputController.mousey3=e.InputController.g_mousey3,e.InputController.horizontal4=e.InputController.g_horizontal4,e.InputController.vertical4=e.InputController.g_vertical4,e.InputController.mousex4=e.InputController.g_mousex4,e.InputController.mousey4=e.InputController.g_mousey4,e.InputController.k_mousex=0,e.InputController.k_mousey=0,e.InputController.x_mousey=0,e.InputController.x_scroll=0)},t.resetUserInput=function(){e.InputController.input=!1,e.InputController.keymap={},e.InputController.scroll=0,e.InputController.wheel=0,e.InputController.mousex=0,e.InputController.mousey=0,e.InputController.vertical=0,e.InputController.horizontal=0,e.InputController.mousex2=0,e.InputController.mousey2=0,e.InputController.vertical2=0,e.InputController.horizontal2=0,e.InputController.mousex3=0,e.InputController.mousey3=0,e.InputController.vertical3=0,e.InputController.horizontal3=0,e.InputController.mousex4=0,e.InputController.mousey4=0,e.InputController.vertical4=0,e.InputController.horizontal4=0,e.InputController.a_mousex=0,e.InputController.x_scroll=0,e.InputController.x_wheel=0,e.InputController.x_mousex=0,e.InputController.x_mousey=0,e.InputController.x_vertical=0,e.InputController.x_horizontal=0,e.InputController.k_mousex=0,e.InputController.k_mousey=0,e.InputController.k_vertical=0,e.InputController.k_horizontal=0,e.InputController.j_mousex=0,e.InputController.j_mousey=0,e.InputController.j_vertical=0,e.InputController.j_horizontal=0,e.InputController.g_mousex1=0,e.InputController.g_mousey1=0,e.InputController.g_vertical1=0,e.InputController.g_horizontal1=0,e.InputController.g_mousex2=0,e.InputController.g_mousey2=0,e.InputController.g_vertical2=0,e.InputController.g_horizontal2=0,e.InputController.g_mousex3=0,e.InputController.g_mousey3=0,e.InputController.g_vertical3=0,e.InputController.g_horizontal3=0,e.InputController.g_mousex4=0,e.InputController.g_mousey4=0,e.InputController.g_vertical4=0,e.InputController.g_horizontal4=0,e.InputController.dragDirection=0,e.InputController.pinchZoomState=0,e.InputController.pinchZoomEvents=[],e.InputController.pinchZoomDistance=null,e.InputController.preventDefault=!1,e.InputController.leftButtonDown=!1,e.InputController.middleButtonDown=!1,e.InputController.rightButtonDown=!1,e.InputController.mouseDownTarget=null,e.InputController.mouseDragTarget=null,e.InputController.mouseButtonsDown=0,e.InputController.mouseButtonUp=[],e.InputController.mouseButtonDown=[],e.InputController.mouseButtonPress=[],e.InputController.keyButtonUp=[],e.InputController.keyButtonDown=[],e.InputController.keyButtonPress=[],e.InputController.gamepad1ButtonUp=[],e.InputController.gamepad1ButtonDown=[],e.InputController.gamepad1ButtonPress=[],e.InputController.gamepad1DpadUp=[],e.InputController.gamepad1DpadDown=[],e.InputController.gamepad1DpadPress=[],e.InputController.gamepad1LeftTrigger=[],e.InputController.gamepad1RightTrigger=[],e.InputController.gamepad2ButtonUp=[],e.InputController.gamepad2ButtonDown=[],e.InputController.gamepad2ButtonPress=[],e.InputController.gamepad2DpadUp=[],e.InputController.gamepad2DpadDown=[],e.InputController.gamepad2DpadPress=[],e.InputController.gamepad2LeftTrigger=[],e.InputController.gamepad2RightTrigger=[],e.InputController.gamepad3ButtonUp=[],e.InputController.gamepad3ButtonDown=[],e.InputController.gamepad3ButtonPress=[],e.InputController.gamepad3DpadUp=[],e.InputController.gamepad3DpadDown=[],e.InputController.gamepad3DpadPress=[],e.InputController.gamepad3LeftTrigger=[],e.InputController.gamepad3RightTrigger=[],e.InputController.gamepad4ButtonUp=[],e.InputController.gamepad4ButtonDown=[],e.InputController.gamepad4ButtonPress=[],e.InputController.gamepad4DpadUp=[],e.InputController.gamepad4DpadDown=[],e.InputController.gamepad4DpadPress=[],e.InputController.gamepad4LeftTrigger=[],e.InputController.gamepad4RightTrigger=[],e.InputController.previousPosition=null,e.InputController.lastClientX=0,e.InputController.lastClientY=0,e.InputController.virtualClientX=0,e.InputController.virtualClientY=0},t.resetKeyMapHandler=function(t){e.InputController.keymap={}},t.getPinchZoomDistance=function(e,t){var i=t.clientX-e.clientX,n=t.clientY-e.clientY;return Math.sqrt(i*i+n*n)},t.cachePinchZoomPointer=function(t){!0===e.InputController.EnablePinchZoomTracking&&e.InputController.pinchZoomEvents.push(t)},t.removePinchZoomPointer=function(t){if(!0===e.InputController.EnablePinchZoomTracking){for(var i=0;i<e.InputController.pinchZoomEvents.length;i++)if(e.InputController.pinchZoomEvents[i].pointerId===t.pointerId){e.InputController.pinchZoomEvents.splice(i,1);break}e.InputController.pinchZoomEvents.length<2&&(e.InputController.pinchZoomDistance=null)}},t.processPinchZoomTracking=function(t){if(!0===e.InputController.EnablePinchZoomTracking){for(var i=0;i<e.InputController.pinchZoomEvents.length;i++)if(e.InputController.pinchZoomEvents[i].pointerId===t.pointerId){e.InputController.pinchZoomEvents[i]=t;break}if(e.InputController.pinchZoomState=e.PinchZoomState.None,2===e.InputController.pinchZoomEvents.length){var n=e.InputController.getPinchZoomDistance(e.InputController.pinchZoomEvents[0],e.InputController.pinchZoomEvents[1]);n!==e.InputController.pinchZoomDistance&&(n>e.InputController.pinchZoomDistance?e.InputController.pinchZoomState=e.PinchZoomState.ZoomIn:n<e.InputController.pinchZoomDistance&&(e.InputController.pinchZoomState=e.PinchZoomState.ZoomOut),e.InputController.pinchZoomDistance=n)}}},t.inputKeyDownHandler=function(t){return e.InputController.InputKeyDownHandler(t.keyCode,t)},t.inputKeyUpHandler=function(t){return e.InputController.InputKeyUpHandler(t.keyCode,t)},t.inputPointerWheelHandler=function(t){if(!1===e.SceneManager.EnableUserInput)return!1;var i=t.deltaY?-t.deltaY:t.wheelDelta/40;return e.InputController.x_scroll=1,e.InputController.x_wheel=Math.abs(i)>e.UserInputOptions.PointerWheelDeadZone?0+i:0,e.InputController.preventDefault&&t.preventDefault(),!0},t.inputPointerDownHandler=function(t){if(e.InputController.mouseDownTarget=t.target,e.InputController.mouseButtonsDown=t.buttons,e.InputController.lastClientX=t.clientX||0,e.InputController.lastClientY=t.clientY||0,e.InputController.virtualClientX=e.InputController.lastClientX,e.InputController.virtualClientY=e.InputController.lastClientY,e.InputController.cachePinchZoomPointer(t),!1===e.SceneManager.EnableUserInput)return!1;e.InputController.previousPosition={x:t.clientX,y:t.clientY};var i="p:"+t.button.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}return null!=e.InputController.mouseButtonDown&&e.InputController.mouseButtonDown.length>0&&e.InputController.mouseButtonDown.forEach(function(e){e(t.button)}),n||null!=e.InputController.mouseButtonPress&&e.InputController.mouseButtonPress.length>0&&e.InputController.mouseButtonPress.forEach(function(e){e.index===t.button&&e.action()}),e.InputController.preventDefault&&t.preventDefault(),!0},t.inputPointerUpHandler=function(t){if(e.InputController.mouseDownTarget=null,e.InputController.mouseDragTarget=null,e.InputController.mouseButtonsDown=t.buttons,e.InputController.lastClientX=t.clientX||0,e.InputController.lastClientY=t.clientY||0,e.InputController.virtualClientX=e.InputController.lastClientX,e.InputController.virtualClientY=e.InputController.lastClientY,e.InputController.removePinchZoomPointer(t),!1===e.SceneManager.EnableUserInput)return!1;e.InputController.previousPosition=null,e.InputController.k_mousex=0,e.InputController.k_mousey=0;var i="p:"+t.button.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}return null!=e.InputController.mouseButtonUp&&e.InputController.mouseButtonUp.length>0&&e.InputController.mouseButtonUp.forEach(function(e){e(t.button)}),e.InputController.preventDefault&&t.preventDefault(),!0},t.inputPointerMoveHandler=function(t){if(e.InputController.mouseDragTarget=t.target,e.InputController.mouseButtonsDown=t.buttons,e.InputController.lastClientX=t.clientX||0,e.InputController.lastClientY=t.clientY||0,e.InputController.IsPointerLocked()){var i=t.movementX||t.mozMovementX||t.webkitMovementX||t.msMovementX||0,n=t.movementY||t.mozMovementY||t.webkitMovementY||t.msMovementY||0;e.InputController.virtualClientX+=i,e.InputController.virtualClientY+=n}else e.InputController.virtualClientX=e.InputController.lastClientX,e.InputController.virtualClientY=e.InputController.lastClientY;if(e.InputController.processPinchZoomTracking(t),!1===e.SceneManager.EnableUserInput)return!1;if(!1===e.SceneManager.VirtualJoystickEnabled){var r=0,o=0;if(e.InputController.IsPointerLocked()?(r=t.movementX||t.mozMovementX||t.webkitMovementX||t.msMovementX||0,o=t.movementY||t.mozMovementY||t.webkitMovementY||t.msMovementY||0,e.InputController.previousPosition=null):null!=e.InputController.previousPosition&&(r=t.clientX-e.InputController.previousPosition.x,o=t.clientY-e.InputController.previousPosition.y,e.InputController.previousPosition={x:t.clientX,y:t.clientY}),!0===e.UserInputOptions.PointerMouseInverted&&(r*=-1,o*=-1),!0===e.InputController.rightHanded&&(r*=-1),!0===e.UserInputOptions.EnableBabylonRotation)e.InputController.k_mousex=r/e.UserInputOptions.BabylonAngularSensibility,e.InputController.k_mousey=o/e.UserInputOptions.BabylonAngularSensibility;else{var a=r*e.UserInputOptions.DefaultAngularSensibility*e.InputController.MOUSE_DAMPENER,s=o*e.UserInputOptions.DefaultAngularSensibility*e.InputController.MOUSE_DAMPENER;Math.abs(r)<=e.UserInputOptions.PointerMouseDeadZone&&(a=0),Math.abs(o)<=e.UserInputOptions.PointerMouseDeadZone&&(s=0),e.InputController.k_mousex+=a,e.InputController.k_mousey+=s,e.InputController.k_mousex=BABYLON.Scalar.Clamp(e.InputController.k_mousex,-1,1),e.InputController.k_mousey=BABYLON.Scalar.Clamp(e.InputController.k_mousey,-1,1)}}return e.InputController.preventDefault&&t.preventDefault(),!0},t.inputOneButtonDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad1){var i="b1:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad1ButtonDown&&e.InputController.gamepad1ButtonDown.length>0&&e.InputController.gamepad1ButtonDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad1ButtonPress&&e.InputController.gamepad1ButtonPress.length>0&&e.InputController.gamepad1ButtonPress.forEach(function(e){e.index===t&&e.action()})}},t.inputOneButtonUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad1){var i="b1:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad1ButtonUp&&e.InputController.gamepad1ButtonUp.length>0&&e.InputController.gamepad1ButtonUp.forEach(function(e){e(t)})}},t.inputOneXboxDPadDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad1){var i="d1:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad1DpadDown&&e.InputController.gamepad1DpadDown.length>0&&e.InputController.gamepad1DpadDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad1DpadPress&&e.InputController.gamepad1DpadPress.length>0&&e.InputController.gamepad1DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputOneShockDPadDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad1){var i="d1:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad1DpadDown&&e.InputController.gamepad1DpadDown.length>0&&e.InputController.gamepad1DpadDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad1DpadPress&&e.InputController.gamepad1DpadPress.length>0&&e.InputController.gamepad1DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputOneXboxDPadUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad1){var i="d1:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad1DpadUp&&e.InputController.gamepad1DpadUp.length>0&&e.InputController.gamepad1DpadUp.forEach(function(e){e(t)})}},t.inputOneShockDPadUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad1){var i="d1:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad1DpadUp&&e.InputController.gamepad1DpadUp.length>0&&e.InputController.gamepad1DpadUp.forEach(function(e){e(t)})}},t.inputOneXboxLeftTriggerHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad1){var i,n="t1:0";t>0?(null==e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[n]&&!1===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!0,i.pressTime=e.SceneManager.GetTimeMs(),i.releaseTime=0)):null!=e.InputController.keymap[n]&&!0===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!1,i.releaseTime=e.SceneManager.GetTimeMs()),null!=e.InputController.gamepad1LeftTrigger&&e.InputController.gamepad1LeftTrigger.length>0&&e.InputController.gamepad1LeftTrigger.forEach(function(e){e(t)})}},t.inputOneXboxRightTriggerHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad1){var i,n="t1:1";t>0?(null==e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[n]&&!1===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!0,i.pressTime=e.SceneManager.GetTimeMs(),i.releaseTime=0)):null!=e.InputController.keymap[n]&&!0===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!1,i.releaseTime=e.SceneManager.GetTimeMs()),null!=e.InputController.gamepad1RightTrigger&&e.InputController.gamepad1RightTrigger.length>0&&e.InputController.gamepad1RightTrigger.forEach(function(e){e(t)})}},t.inputOneLeftStickHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad1){var i=t,n=i.x*e.UserInputOptions.GamepadLStickSensibility,r=i.y*e.UserInputOptions.GamepadLStickSensibility;i.x=Math.abs(n)>e.UserInputOptions.GamepadDeadStickValue?n:0,i.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,i.x=BABYLON.Scalar.Clamp(i.x,-1,1),i.y=BABYLON.Scalar.Clamp(i.y,-1,1),e.InputController.g_horizontal1=e.UserInputOptions.GamepadLStickXInverted?-i.x:i.x,e.InputController.g_vertical1=e.UserInputOptions.GamepadLStickYInverted?i.y:-i.y}},t.inputOneRightStickHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad1){var i=t,n=i.x*e.UserInputOptions.GamepadRStickSensibility,r=i.y*e.UserInputOptions.GamepadRStickSensibility;i.x=Math.abs(n)>e.UserInputOptions.GamepadDeadStickValue?n:0,i.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,i.x=BABYLON.Scalar.Clamp(i.x,-1,1),i.y=BABYLON.Scalar.Clamp(i.y,-1,1),e.InputController.g_mousex1=e.UserInputOptions.GamepadRStickXInverted?-i.x:i.x,e.InputController.g_mousey1=e.UserInputOptions.GamepadRStickYInverted?-i.y:i.y}},t.inputTwoButtonDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad2){var i="b2:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad2ButtonDown&&e.InputController.gamepad2ButtonDown.length>0&&e.InputController.gamepad2ButtonDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad2ButtonPress&&e.InputController.gamepad2ButtonPress.length>0&&e.InputController.gamepad2ButtonPress.forEach(function(e){e.index===t&&e.action()})}},t.inputTwoButtonUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad2){var i="b2:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad2ButtonUp&&e.InputController.gamepad2ButtonUp.length>0&&e.InputController.gamepad2ButtonUp.forEach(function(e){e(t)})}},t.inputTwoXboxDPadDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad2){var i="d2:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad2DpadDown&&e.InputController.gamepad2DpadDown.length>0&&e.InputController.gamepad2DpadDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad2DpadPress&&e.InputController.gamepad2DpadPress.length>0&&e.InputController.gamepad2DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputTwoShockDPadDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad2){var i="d2:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad2DpadDown&&e.InputController.gamepad2DpadDown.length>0&&e.InputController.gamepad2DpadDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad2DpadPress&&e.InputController.gamepad2DpadPress.length>0&&e.InputController.gamepad2DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputTwoXboxDPadUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad2){var i="d2:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad2DpadUp&&e.InputController.gamepad2DpadUp.length>0&&e.InputController.gamepad2DpadUp.forEach(function(e){e(t)})}},t.inputTwoShockDPadUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad2){var i="d2:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad2DpadUp&&e.InputController.gamepad2DpadUp.length>0&&e.InputController.gamepad2DpadUp.forEach(function(e){e(t)})}},t.inputTwoXboxLeftTriggerHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad2){var i,n="t2:0";t>0?(null==e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[n]&&!1===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!0,i.pressTime=e.SceneManager.GetTimeMs(),i.releaseTime=0)):null!=e.InputController.keymap[n]&&!0===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!1,i.releaseTime=e.SceneManager.GetTimeMs()),null!=e.InputController.gamepad2LeftTrigger&&e.InputController.gamepad2LeftTrigger.length>0&&e.InputController.gamepad2LeftTrigger.forEach(function(e){e(t)})}},t.inputTwoXboxRightTriggerHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad2){var i,n="t2:1";t>0?(null==e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[n]&&!1===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!0,i.pressTime=e.SceneManager.GetTimeMs(),i.releaseTime=0)):null!=e.InputController.keymap[n]&&!0===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!1,i.releaseTime=e.SceneManager.GetTimeMs()),null!=e.InputController.gamepad2RightTrigger&&e.InputController.gamepad2RightTrigger.length>0&&e.InputController.gamepad2RightTrigger.forEach(function(e){e(t)})}},t.inputTwoLeftStickHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad2){var i=t,n=i.x*e.UserInputOptions.GamepadLStickSensibility,r=i.y*e.UserInputOptions.GamepadLStickSensibility;i.x=Math.abs(n)>e.UserInputOptions.GamepadDeadStickValue?n:0,i.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,i.x=BABYLON.Scalar.Clamp(i.x,-1,1),i.y=BABYLON.Scalar.Clamp(i.y,-1,1),e.InputController.g_horizontal2=e.UserInputOptions.GamepadLStickXInverted?-i.x:i.x,e.InputController.g_vertical2=e.UserInputOptions.GamepadLStickYInverted?i.y:-i.y}},t.inputTwoRightStickHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad2){var i=t,n=i.x*e.UserInputOptions.GamepadRStickSensibility,r=i.y*e.UserInputOptions.GamepadRStickSensibility;i.x=Math.abs(n)>e.UserInputOptions.GamepadDeadStickValue?n:0,i.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,i.x=BABYLON.Scalar.Clamp(i.x,-1,1),i.y=BABYLON.Scalar.Clamp(i.y,-1,1),e.InputController.g_mousex2=e.UserInputOptions.GamepadRStickXInverted?-i.x:i.x,e.InputController.g_mousey2=e.UserInputOptions.GamepadRStickYInverted?-i.y:i.y}},t.inputThreeButtonDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad3){var i="b3:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad3ButtonDown&&e.InputController.gamepad3ButtonDown.length>0&&e.InputController.gamepad3ButtonDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad3ButtonPress&&e.InputController.gamepad3ButtonPress.length>0&&e.InputController.gamepad3ButtonPress.forEach(function(e){e.index===t&&e.action()})}},t.inputThreeButtonUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad3){var i="b3:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad3ButtonUp&&e.InputController.gamepad3ButtonUp.length>0&&e.InputController.gamepad3ButtonUp.forEach(function(e){e(t)})}},t.inputThreeXboxDPadDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad3){var i="d3:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad3DpadDown&&e.InputController.gamepad3DpadDown.length>0&&e.InputController.gamepad3DpadDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad3DpadPress&&e.InputController.gamepad3DpadPress.length>0&&e.InputController.gamepad3DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputThreeShockDPadDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad3){var i="d3:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad3DpadDown&&e.InputController.gamepad3DpadDown.length>0&&e.InputController.gamepad3DpadDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad3DpadPress&&e.InputController.gamepad3DpadPress.length>0&&e.InputController.gamepad3DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputThreeXboxDPadUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad3){var i="d3:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad3DpadUp&&e.InputController.gamepad3DpadUp.length>0&&e.InputController.gamepad3DpadUp.forEach(function(e){e(t)})}},t.inputThreeShockDPadUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad3){var i="d3:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad3DpadUp&&e.InputController.gamepad3DpadUp.length>0&&e.InputController.gamepad3DpadUp.forEach(function(e){e(t)})}},t.inputThreeXboxLeftTriggerHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad3){var i,n="t3:0";t>0?(null==e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[n]&&!1===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!0,i.pressTime=e.SceneManager.GetTimeMs(),i.releaseTime=0)):null!=e.InputController.keymap[n]&&!0===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!1,i.releaseTime=e.SceneManager.GetTimeMs()),null!=e.InputController.gamepad3LeftTrigger&&e.InputController.gamepad3LeftTrigger.length>0&&e.InputController.gamepad3LeftTrigger.forEach(function(e){e(t)})}},t.inputThreeXboxRightTriggerHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad3){var i,n="t3:1";t>0?(null==e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[n]&&!1===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!0,i.pressTime=e.SceneManager.GetTimeMs(),i.releaseTime=0)):null!=e.InputController.keymap[n]&&!0===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!1,i.releaseTime=e.SceneManager.GetTimeMs()),null!=e.InputController.gamepad3RightTrigger&&e.InputController.gamepad3RightTrigger.length>0&&e.InputController.gamepad3RightTrigger.forEach(function(e){e(t)})}},t.inputThreeLeftStickHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad3){var i=t,n=i.x*e.UserInputOptions.GamepadLStickSensibility,r=i.y*e.UserInputOptions.GamepadLStickSensibility;i.x=Math.abs(n)>e.UserInputOptions.GamepadDeadStickValue?n:0,i.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,i.x=BABYLON.Scalar.Clamp(i.x,-1,1),i.y=BABYLON.Scalar.Clamp(i.y,-1,1),e.InputController.g_horizontal3=e.UserInputOptions.GamepadLStickXInverted?-i.x:i.x,e.InputController.g_vertical3=e.UserInputOptions.GamepadLStickYInverted?i.y:-i.y}},t.inputThreeRightStickHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad3){var i=t,n=i.x*e.UserInputOptions.GamepadRStickSensibility,r=i.y*e.UserInputOptions.GamepadRStickSensibility;i.x=Math.abs(n)>e.UserInputOptions.GamepadDeadStickValue?n:0,i.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,i.x=BABYLON.Scalar.Clamp(i.x,-1,1),i.y=BABYLON.Scalar.Clamp(i.y,-1,1),e.InputController.g_mousex3=e.UserInputOptions.GamepadRStickXInverted?-i.x:i.x,e.InputController.g_mousey3=e.UserInputOptions.GamepadRStickYInverted?-i.y:i.y}},t.inputFourButtonDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad4){var i="b4:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad4ButtonDown&&e.InputController.gamepad4ButtonDown.length>0&&e.InputController.gamepad4ButtonDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad4ButtonPress&&e.InputController.gamepad4ButtonPress.length>0&&e.InputController.gamepad4ButtonPress.forEach(function(e){e.index===t&&e.action()})}},t.inputFourButtonUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad4){var i="b4:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad4ButtonUp&&e.InputController.gamepad4ButtonUp.length>0&&e.InputController.gamepad4ButtonUp.forEach(function(e){e(t)})}},t.inputFourXboxDPadDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad4){var i="d4:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad4DpadDown&&e.InputController.gamepad4DpadDown.length>0&&e.InputController.gamepad4DpadDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad4DpadPress&&e.InputController.gamepad4DpadPress.length>0&&e.InputController.gamepad4DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputFourShockDPadDownHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad4){var i="d4:"+t.toString(),n=!1;if(null==e.InputController.keymap[i]&&(e.InputController.keymap[i]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[i]){var r=e.InputController.keymap[i];!1===(n=null!=r.result&&r.result)&&(r.result=!0,r.pressTime=e.SceneManager.GetTimeMs(),r.releaseTime=0)}null!=e.InputController.gamepad4DpadDown&&e.InputController.gamepad4DpadDown.length>0&&e.InputController.gamepad4DpadDown.forEach(function(e){e(t)}),n||null!=e.InputController.gamepad4DpadPress&&e.InputController.gamepad4DpadPress.length>0&&e.InputController.gamepad4DpadPress.forEach(function(e){e.index===t&&e.action()})}},t.inputFourXboxDPadUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad4){var i="d4:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad4DpadUp&&e.InputController.gamepad4DpadUp.length>0&&e.InputController.gamepad4DpadUp.forEach(function(e){e(t)})}},t.inputFourShockDPadUpHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad4){var i="d4:"+t.toString();if(null!=e.InputController.keymap[i]){var n=e.InputController.keymap[i];!0===(null!=n.result&&n.result)&&(n.result=!1,n.releaseTime=e.SceneManager.GetTimeMs())}null!=e.InputController.gamepad4DpadUp&&e.InputController.gamepad4DpadUp.length>0&&e.InputController.gamepad4DpadUp.forEach(function(e){e(t)})}},t.inputFourXboxLeftTriggerHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad4){var i,n="t4:0";t>0?(null==e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[n]&&!1===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!0,i.pressTime=e.SceneManager.GetTimeMs(),i.releaseTime=0)):null!=e.InputController.keymap[n]&&!0===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!1,i.releaseTime=e.SceneManager.GetTimeMs()),null!=e.InputController.gamepad4LeftTrigger&&e.InputController.gamepad4LeftTrigger.length>0&&e.InputController.gamepad4LeftTrigger.forEach(function(e){e(t)})}},t.inputFourXboxRightTriggerHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad4){var i,n="t4:1";t>0?(null==e.InputController.keymap[n]&&(e.InputController.keymap[n]={result:!1,pressTime:0,releaseTime:0}),null!=e.InputController.keymap[n]&&!1===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!0,i.pressTime=e.SceneManager.GetTimeMs(),i.releaseTime=0)):null!=e.InputController.keymap[n]&&!0===(null!=(i=e.InputController.keymap[n]).result&&i.result)&&(i.result=!1,i.releaseTime=e.SceneManager.GetTimeMs()),null!=e.InputController.gamepad4RightTrigger&&e.InputController.gamepad4RightTrigger.length>0&&e.InputController.gamepad4RightTrigger.forEach(function(e){e(t)})}},t.inputFourLeftStickHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad4){var i=t,n=i.x*e.UserInputOptions.GamepadLStickSensibility,r=i.y*e.UserInputOptions.GamepadLStickSensibility;i.x=Math.abs(n)>e.UserInputOptions.GamepadDeadStickValue?n:0,i.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,i.x=BABYLON.Scalar.Clamp(i.x,-1,1),i.y=BABYLON.Scalar.Clamp(i.y,-1,1),e.InputController.g_horizontal4=e.UserInputOptions.GamepadLStickXInverted?-i.x:i.x,e.InputController.g_vertical4=e.UserInputOptions.GamepadLStickYInverted?i.y:-i.y}},t.inputFourRightStickHandler=function(t){if(!1!==e.SceneManager.EnableUserInput&&null!=e.InputController.gamepad4){var i=t,n=i.x*e.UserInputOptions.GamepadRStickSensibility,r=i.y*e.UserInputOptions.GamepadRStickSensibility;i.x=Math.abs(n)>e.UserInputOptions.GamepadDeadStickValue?n:0,i.y=Math.abs(r)>e.UserInputOptions.GamepadDeadStickValue?r:0,i.x=BABYLON.Scalar.Clamp(i.x,-1,1),i.y=BABYLON.Scalar.Clamp(i.y,-1,1),e.InputController.g_mousex4=e.UserInputOptions.GamepadRStickXInverted?-i.x:i.x,e.InputController.g_mousey4=e.UserInputOptions.GamepadRStickYInverted?-i.y:i.y}},t.inputManagerGamepadConnected=function(t,i){if(null==e.InputController.gamepad1&&0===t.index)if(e.InputController.gamepad1=t,BABYLON.Tools.Log("Gamepad One Connected: "+e.InputController.gamepad1.id),e.InputController.gamepad1 instanceof BABYLON.Xbox360Pad){e.InputController.gamepad1Type=e.GamepadType.Xbox360;var n=e.InputController.gamepad1;n.onbuttonup(e.InputController.inputOneButtonUpHandler),n.onbuttondown(e.InputController.inputOneButtonDownHandler),n.onleftstickchanged(e.InputController.inputOneLeftStickHandler),n.onrightstickchanged(e.InputController.inputOneRightStickHandler),n.ondpadup(e.InputController.inputOneXboxDPadUpHandler),n.ondpaddown(e.InputController.inputOneXboxDPadDownHandler),n.onlefttriggerchanged(e.InputController.inputOneXboxLeftTriggerHandler),n.onrighttriggerchanged(e.InputController.inputOneXboxRightTriggerHandler)}else if(e.InputController.gamepad1 instanceof BABYLON.DualShockPad){e.InputController.gamepad1Type=e.GamepadType.DualShock;var r=e.InputController.gamepad1;r.onbuttonup(e.InputController.inputOneButtonUpHandler),r.onbuttondown(e.InputController.inputOneButtonDownHandler),r.onleftstickchanged(e.InputController.inputOneLeftStickHandler),r.onrightstickchanged(e.InputController.inputOneRightStickHandler),r.ondpadup(e.InputController.inputOneShockDPadUpHandler),r.ondpaddown(e.InputController.inputOneShockDPadDownHandler),r.onlefttriggerchanged(e.InputController.inputOneXboxLeftTriggerHandler),r.onrighttriggerchanged(e.InputController.inputOneXboxRightTriggerHandler)}else{e.InputController.gamepad1Type=e.GamepadType.Generic;var o=e.InputController.gamepad1;o.onbuttonup(e.InputController.inputOneButtonUpHandler),o.onbuttondown(e.InputController.inputOneButtonDownHandler),o.onleftstickchanged(e.InputController.inputOneLeftStickHandler),o.onrightstickchanged(e.InputController.inputOneRightStickHandler)}if(null==e.InputController.gamepad2&&1===t.index)if(e.InputController.gamepad2=t,BABYLON.Tools.Log("Gamepad Two Connected: "+e.InputController.gamepad2.id),e.InputController.gamepad2 instanceof BABYLON.Xbox360Pad){e.InputController.gamepad2Type=e.GamepadType.Xbox360;var a=e.InputController.gamepad2;a.onbuttonup(e.InputController.inputTwoButtonUpHandler),a.onbuttondown(e.InputController.inputTwoButtonDownHandler),a.onleftstickchanged(e.InputController.inputTwoLeftStickHandler),a.onrightstickchanged(e.InputController.inputTwoRightStickHandler),a.ondpadup(e.InputController.inputTwoXboxDPadUpHandler),a.ondpaddown(e.InputController.inputTwoXboxDPadDownHandler),a.onlefttriggerchanged(e.InputController.inputTwoXboxLeftTriggerHandler),a.onrighttriggerchanged(e.InputController.inputTwoXboxRightTriggerHandler)}else if(e.InputController.gamepad2 instanceof BABYLON.DualShockPad){e.InputController.gamepad2Type=e.GamepadType.DualShock;var s=e.InputController.gamepad2;s.onbuttonup(e.InputController.inputOneButtonUpHandler),s.onbuttondown(e.InputController.inputOneButtonDownHandler),s.onleftstickchanged(e.InputController.inputOneLeftStickHandler),s.onrightstickchanged(e.InputController.inputOneRightStickHandler),s.ondpadup(e.InputController.inputOneShockDPadUpHandler),s.ondpaddown(e.InputController.inputOneShockDPadDownHandler),s.onlefttriggerchanged(e.InputController.inputOneXboxLeftTriggerHandler),s.onrighttriggerchanged(e.InputController.inputOneXboxRightTriggerHandler)}else{e.InputController.gamepad2Type=e.GamepadType.Generic;var l=e.InputController.gamepad2;l.onbuttonup(e.InputController.inputTwoButtonUpHandler),l.onbuttondown(e.InputController.inputTwoButtonDownHandler),l.onleftstickchanged(e.InputController.inputTwoLeftStickHandler),l.onrightstickchanged(e.InputController.inputTwoRightStickHandler)}if(null==e.InputController.gamepad3&&2===t.index)if(e.InputController.gamepad3=t,BABYLON.Tools.Log("Gamepad Three Connected: "+e.InputController.gamepad3.id),e.InputController.gamepad3 instanceof BABYLON.Xbox360Pad){e.InputController.gamepad3Type=e.GamepadType.Xbox360;var u=e.InputController.gamepad3;u.onbuttonup(e.InputController.inputThreeButtonUpHandler),u.onbuttondown(e.InputController.inputThreeButtonDownHandler),u.onleftstickchanged(e.InputController.inputThreeLeftStickHandler),u.onrightstickchanged(e.InputController.inputThreeRightStickHandler),u.ondpadup(e.InputController.inputThreeXboxDPadUpHandler),u.ondpaddown(e.InputController.inputThreeXboxDPadDownHandler),u.onlefttriggerchanged(e.InputController.inputThreeXboxLeftTriggerHandler),u.onrighttriggerchanged(e.InputController.inputThreeXboxRightTriggerHandler)}else if(e.InputController.gamepad3 instanceof BABYLON.DualShockPad){var h=e.InputController.gamepad3;h.onbuttonup(e.InputController.inputOneButtonUpHandler),h.onbuttondown(e.InputController.inputOneButtonDownHandler),h.onleftstickchanged(e.InputController.inputOneLeftStickHandler),h.onrightstickchanged(e.InputController.inputOneRightStickHandler),h.ondpadup(e.InputController.inputOneShockDPadUpHandler),h.ondpaddown(e.InputController.inputOneShockDPadDownHandler),h.onlefttriggerchanged(e.InputController.inputOneXboxLeftTriggerHandler),h.onrighttriggerchanged(e.InputController.inputOneXboxRightTriggerHandler)}else{e.InputController.gamepad3Type=e.GamepadType.Generic;var c=e.InputController.gamepad3;c.onbuttonup(e.InputController.inputThreeButtonUpHandler),c.onbuttondown(e.InputController.inputThreeButtonDownHandler),c.onleftstickchanged(e.InputController.inputThreeLeftStickHandler),c.onrightstickchanged(e.InputController.inputThreeRightStickHandler)}if(null==e.InputController.gamepad4&&3===t.index)if(e.InputController.gamepad4=t,BABYLON.Tools.Log("Gamepad Four Connected: "+e.InputController.gamepad4.id),e.InputController.gamepad4 instanceof BABYLON.Xbox360Pad){e.InputController.gamepad4Type=e.GamepadType.Xbox360;var d=e.InputController.gamepad4;d.onbuttonup(e.InputController.inputFourButtonUpHandler),d.onbuttondown(e.InputController.inputFourButtonDownHandler),d.onleftstickchanged(e.InputController.inputFourLeftStickHandler),d.onrightstickchanged(e.InputController.inputFourRightStickHandler),d.ondpadup(e.InputController.inputFourXboxDPadUpHandler),d.ondpaddown(e.InputController.inputFourXboxDPadDownHandler),d.onlefttriggerchanged(e.InputController.inputFourXboxLeftTriggerHandler),d.onrighttriggerchanged(e.InputController.inputFourXboxRightTriggerHandler)}else if(e.InputController.gamepad4 instanceof BABYLON.DualShockPad){var m=e.InputController.gamepad4;m.onbuttonup(e.InputController.inputOneButtonUpHandler),m.onbuttondown(e.InputController.inputOneButtonDownHandler),m.onleftstickchanged(e.InputController.inputOneLeftStickHandler),m.onrightstickchanged(e.InputController.inputOneRightStickHandler),m.ondpadup(e.InputController.inputOneShockDPadUpHandler),m.ondpaddown(e.InputController.inputOneShockDPadDownHandler),m.onlefttriggerchanged(e.InputController.inputOneXboxLeftTriggerHandler),m.onrighttriggerchanged(e.InputController.inputOneXboxRightTriggerHandler)}else{e.InputController.gamepad4Type=e.GamepadType.Generic;var p=e.InputController.gamepad4;p.onbuttonup(e.InputController.inputFourButtonUpHandler),p.onbuttondown(e.InputController.inputFourButtonDownHandler),p.onleftstickchanged(e.InputController.inputFourLeftStickHandler),p.onrightstickchanged(e.InputController.inputFourRightStickHandler)}null!=e.InputController.GamepadConnected&&e.InputController.GamepadConnected(t,i)},t.inputManagerGamepadDisconnected=function(t,i){null!=e.InputController.GamepadDisconnected&&e.InputController.GamepadDisconnected(t,i)},t.MOUSE_DAMPENER=.5,t.TAP_THRESHOLD_MS=200,t.GamepadManager=null,t.GamepadConnected=null,t.GamepadDisconnected=null,t.AllowMobileControls=!0,t.MobileControlsActive=!1,t.EnablePinchZoomTracking=!1,t.LastMousePosition=new BABYLON.Vector3(0,0,0),t.PointerLockedFlag=!1,t.LockMousePointerObserver=null,t._registeredUpdateScenes=new WeakSet,t.input=!1,t.keymap={},t.scroll=0,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_scroll=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.dragDirection=0,t.pinchZoomState=0,t.pinchZoomEvents=[],t.pinchZoomDistance=null,t.mouseDownTarget=null,t.mouseDragTarget=null,t.leftButtonDown=!1,t.middleButtonDown=!1,t.rightButtonDown=!1,t.mouseButtonsDown=0,t.mouseButtonPress=[],t.mouseButtonDown=[],t.mouseButtonUp=[],t.keyButtonPress=[],t.keyButtonDown=[],t.keyButtonUp=[],t.previousPosition=null,t.preventDefault=!1,t.lastClientX=0,t.lastClientY=0,t.virtualClientX=0,t.virtualClientY=0,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}();e.InputController=o;var a=function(){function t(e,t,i,n,r,o){void 0===n&&(n=!0),void 0===r&&(r=-1),void 0===o&&(o=null);var a=this;this.isFixed=!0,this.touchId=null,this.pointerId=null,this.dragStart=null,this.mouseButton=-1,this.maxDistance=48,this.deadZone=2,this.xvalue=0,this.yvalue=0,this.stick=null,this.base=null,this.active=!1,this.enabled=!0,this.updateElements=!0,this.preventDefault=!0,this.stopPropagation=!0,this.baseElementOpacity="1",this.stickElementOpacity="1",this.onHandleDown=null,this.onHandleMove=null,this.onHandleUp=null,this.isFixed=n,this.deadZone=i,this.maxDistance=t,this.mouseButton=r,o&&(this.base=document.getElementById(o)),e&&(this.stick=document.getElementById(e)),this.base&&(this.base.oncontextmenu=function(e){return!1}),this.stick&&(this.stick.oncontextmenu=function(e){return!1}),this.isFixed?this.stick?this.stick.addEventListener("pointerdown",function(e){return a.handleDown(e)}):console.warn("Failed to locate fixed joystick element: "+e):(this.base&&(this.base.style.opacity="0"),this.stick&&(this.stick.style.opacity="0"),document.documentElement.addEventListener("pointerdown",function(e){return a.handleDown(e)})),document.documentElement.addEventListener("pointermove",function(e){return a.handleMove(e)},{passive:!1}),document.documentElement.addEventListener("pointerup",function(e){return a.handleUp(e)})}return t.prototype.dispose=function(){},t.prototype.isActive=function(){return this.active},t.prototype.getValueX=function(){return this.xvalue},t.prototype.getValueY=function(){return this.yvalue},t.prototype.getMouseButton=function(){return this.mouseButton},t.prototype.getBaseElement=function(){return this.base},t.prototype.getStickElement=function(){return this.stick},t.prototype.isFixedJoystick=function(){return this.isFixed},t.prototype.handleDown=function(t){if(this.enabled){var i=!(1&~t.buttons),n=!(2&~t.buttons);(this.mouseButton!==e.TouchMouseButton.Left||i)&&(this.mouseButton!==e.TouchMouseButton.Right||n)&&(this.active=!0,this.pointerId=t.pointerId,this.showBaseElement(t),this.stick&&(this.stick.style.transition="0s"),this.active&&this.preventDefault&&t.preventDefault(),t.changedTouches?(this.dragStart={x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY},this.touchId=t.changedTouches[0].identifier):this.dragStart={x:t.clientX,y:t.clientY},this.onHandleDown&&this.onHandleDown(t),this.stopPropagation&&t.stopPropagation())}},t.prototype.handleMove=function(e){if(this.enabled&&this.active&&e.pointerId===this.pointerId){if(e.changedTouches){for(var t=null,i=0;i<e.changedTouches.length;i++)this.touchId===e.changedTouches[i].identifier&&(t=i,e.clientX=e.changedTouches[i].clientX,e.clientY=e.changedTouches[i].clientY);if(null===t)return}var n=e.clientX-this.dragStart.x,r=e.clientY-this.dragStart.y,o=Math.atan2(r,n),a=Math.min(this.maxDistance,Math.hypot(n,r)),s=a*Math.cos(o),l=a*Math.sin(o);this.stick&&(this.stick.style.transform="translate3d(".concat(s,"px, ").concat(l,"px, 0px)"));var u=a<this.deadZone?0:this.maxDistance/(this.maxDistance-this.deadZone)*(a-this.deadZone),h=u*Math.cos(o),c=u*Math.sin(o),d=parseFloat((h/this.maxDistance).toFixed(4)),m=parseFloat((c/this.maxDistance).toFixed(4));this.xvalue=d,this.yvalue=m,this.onHandleMove&&this.onHandleMove(e),this.stopPropagation&&e.stopPropagation()}},t.prototype.handleUp=function(e){this.enabled&&this.active&&e.pointerId===this.pointerId&&(e.changedTouches&&this.touchId!==e.changedTouches[0].identifier||(this.stick&&(this.stick.style.transition=".2s",this.stick.style.transform="translate3d(0px, 0px, 0px)"),this.xvalue=0,this.yvalue=0,this.touchId=null,this.pointerId=null,this.active=!1,this.hideBaseElement(),this.onHandleUp&&this.onHandleUp(e),this.stopPropagation&&e.stopPropagation()))},t.prototype.showBaseElement=function(e){if(!this.isFixed&&this.updateElements){if(this.base&&this.base.style.opacity!==this.baseElementOpacity){var t=this.base.getBoundingClientRect();this.base.style.left=e.clientX-t.width/2+"px",this.base.style.top=e.clientY-t.height/2+"px",this.base.style.opacity=this.baseElementOpacity}this.stick&&this.stick.style.opacity!==this.stickElementOpacity&&(this.stick.style.opacity=this.stickElementOpacity)}else this.isFixed||this.updateElements||this.hideBaseElement()},t.prototype.hideBaseElement=function(){this.isFixed||(this.base&&"0"!==this.base.style.opacity&&(this.base.style.opacity="0",this.base.style.left="-1000px",this.base.style.top="-1000px"),this.stick&&"0"!==this.stick.style.opacity&&(this.stick.style.opacity="0"))},t}();e.TouchJoystickHandler=a}(n||(n={})),function(e){var t=function(){function t(){}return t.IsWindows=function(){return"undefined"!=typeof Windows&&void 0!==Windows.UI&&void 0!==Windows.System&&void 0!==Windows.Foundation},t.IsCordova=function(){return null!=window.cordova},t.IsWebAssembly=function(){return window.WebAssembly},t.IsOculusBrowser=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/OculusBrowser/i)&&(e=!0),e},t.IsSamsungBrowser=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/SamsungBrowser/i)&&(e=!0),e},t.IsWindowsPhone=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Windows Phone/i)&&(e=!0),e},t.IsBlackBerry=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/BlackBerry/i)&&(e=!0),e},t.IsOperaMini=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Opera Mini/i)&&(e=!0),e},t.IsAndroid=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Android/i)&&(e=!0),e},t.IsWebOS=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/webOS/i)&&(e=!0),e},t.IsIOS=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPhone|iPad|iPod/i)&&(e=!0),e},t.IsIPHONE=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPhone/i)&&(e=!0),e},t.IsIPAD=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPad/i)&&(e=!0),e},t.IsIPOD=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/iPod/i)&&(e=!0),e},t.IsIE11=function(){return void 0!==navigator.maxTouchPoints},t.IsMobile=function(){var e,t,i,n;if("undefined"==typeof navigator||"undefined"==typeof window)return!1;var r=!0===(null===(e=navigator.userAgentData)||void 0===e?void 0:e.mobile),o=null!==(n=null===(i=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(pointer: coarse)"))||void 0===i?void 0:i.matches)&&void 0!==n&&n,a=Math.min(window.innerWidth,window.innerHeight)<=820,s=navigator.userAgent||"",l=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i.test(s);return r||o&&a||l},t.IsHighEndMobile=function(){var e;if(!this.IsMobile())return!1;var t=window.__HEM_CACHE__;if("boolean"==typeof t)return t;var i=0,n=null!==(e=navigator.hardwareConcurrency)&&void 0!==e?e:0;n>=8?i+=3:n>=6?i+=2:n>=4&&(i+=1);var r=navigator.deviceMemory;"number"==typeof r&&(r>=8?i+=3:r>=6?i+=2:r>=4&&(i+=1));var o=window.devicePixelRatio||1;o>=3&&(i+=1);var a=null;try{var s=document.createElement("canvas");if(a=s.getContext("webgl2")||s.getContext("webgl")||s.getContext("experimental-webgl")||null){a.getParameter&&s.getContext("webgl2")&&(i+=2);var l=a.getParameter(a.MAX_TEXTURE_SIZE);l>=8192?i+=2:l>=4096&&(i+=1)}}catch(e){}try{screen.width*o*(screen.height*o)>=25e5&&(i+=1)}catch(e){}var u=i>=6;return window.__HEM_CACHE__=u,u},t.IsHighEndMobileAsync=function(){return s(this,void 0,void 0,function(){var e,t,i,n;return l(this,function(r){for(e=this.IsHighEndMobile(),t=performance.now(),i=0;i<75e4;i++);return(n=performance.now()-t)<18?e=!0:n>45&&(e=!1),[2,e]})})},t.IsDesktop=function(){return!e.WindowManager.IsMobile()},t.IsPlaystation=function(){var e=!1;return null!=navigator&&null!=navigator.userAgent&&navigator.userAgent.match(/Playstation/i)&&(e=!0),e},t.IsXboxConsole=function(){var t=!1;return e.WindowManager.IsWindows()&&void 0!==Windows.System.Profile&&void 0!==Windows.System.Profile.AnalyticsInfo&&void 0!==Windows.System.Profile.AnalyticsInfo.versionInfo&&void 0!==Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamily&&Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamily.match(/Xbox/i)&&(t=!0),t},t.IsXboxLive=function(){return e.WindowManager.IsWindows()&&"undefined"!=typeof Microsoft&&void 0!==Microsoft.Xbox&&void 0!==Microsoft.Xbox.Services},t.IsFrameWindow=function(){return null!=window.parent&&window!==window.parent},t.IsPortraitWindow=function(){return"portrait"===e.WindowManager.GetOrientation()},t.IsLandscapeWindow=function(){return"landscape"===e.WindowManager.GetOrientation()},t.IsStandaloneWindow=function(){return!!window.navigator.standalone||!(!window.matchMedia||!window.matchMedia("(display-mode: standalone)").matches)},t.IsFullscreenWindow=function(){return!!window.navigator.standalone||!(!window.matchMedia||!window.matchMedia("(display-mode: fullscreen)").matches)},t.IsProgressiveWindow=function(){return e.WindowManager.IsStandaloneWindow()||e.WindowManager.IsFullscreenWindow()},t.GetDisplayMode=function(){if(window.navigator.standalone)return"standalone";if(window.matchMedia){if(window.matchMedia("(display-mode: fullscreen)").matches)return"fullscreen";if(window.matchMedia("(display-mode: standalone)").matches)return"standalone";if(window.matchMedia("(display-mode: minimal-ui)").matches)return"minimal-ui"}return"browser"},t.GetOrientation=function(){var e="portrait";if(window.screen&&window.screen.orientation){var t=window.screen.orientation.type;t.includes("portrait")?e="portrait":t.includes("landscape")&&(e="landscape")}else if(window.orientation){var i=window.orientation;0===i||180===i?e="portrait":90!==i&&-90!==i||(e="landscape")}return e},t.SetLocation=function(e,t){void 0===t&&(t=!1),!0===t?window.location.replace(e):window.location.assign(e)},t.AlertMessage=function(t,i){void 0===i&&(i="Babylon Toolkit");var n=null;return e.WindowManager.IsWindows()?n=new Windows.UI.Popups.MessageDialog(t,i).showAsync():window.alert(t),n},t.GetQueryStringParam=function(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var i=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return i?i[2]?decodeURIComponent(i[2].replace(/\+/g," ")):"":null},t.PostWindowMessage=function(e,t,i){void 0===t&&(t="*"),void 0===i&&(i=!1),!0===i?window.postMessage(e,t):window.top?window.top.postMessage(e,t):console.warn("No Valid Top Window")},t.ShowSceneLoader=function(){window.showSceneLoader&&window.showSceneLoader()},t.HideSceneLoader=function(){window.hideSceneLoader&&window.hideSceneLoader()},t.UpdateLoaderStatus=function(e,t,i){window.updateStatus&&window.updateStatus(e,t,i)},t.UpdateLoaderDetails=function(e,t){window.updateDetails&&window.updateDetails(e,t)},t.UpdateLoaderProgress=function(e,t){window.updateProgress&&window.updateProgress(e,t)},t.ShowPageErrorMessage=function(e,t,i){void 0===t&&(t="Error"),void 0===i&&(i=0),window.showErrorMessage&&window.showErrorMessage(e,t,i)},t.SetTimeout=function(e,t){return window.setTimeout(t,e)},t.ClearTimeout=function(e){window.clearTimeout(e)},t.SetInterval=function(e,t){return window.setInterval(t,e)},t.ClearInterval=function(e){window.clearInterval(e)},t.Atob=function(e){return window.atob(e)},t.Btoa=function(e){return window.btoa(e)},t.PopupDebug=function(e){e.debugLayer&&(e.debugLayer.hide(),e.debugLayer.show({enablePopup:!0,globalRoot:null}))},t.ToggleDebug=function(t,i,n){if(void 0===i&&(i=!1),void 0===n&&(n=null),t.debugLayer){var r=window;!0===e.WindowManager.debugLayerVisible?(e.WindowManager.debugLayerVisible=!1,r.METER&&r.METER.show&&r.METER.show(),t.debugLayer.hide()):(e.WindowManager.debugLayerVisible=!0,r.METER&&r.METER.hide&&r.METER.hide(),t.debugLayer.show({embedMode:i,globalRoot:n}))}},t.GetLocalStorageItem=function(e){return null!=window.localStorage?window.localStorage.getItem(e):null},t.SetLocalStorageItem=function(e,t){null!=window.localStorage&&window.localStorage.setItem(e,t)},t.GetSessionStorageItem=function(e){return null!=window.sessionStorage?window.sessionStorage.getItem(e):null},t.SetSessionStorageItem=function(e,t){null!=window.sessionStorage&&window.sessionStorage.setItem(e,t)},t.GetFilenameFromUrl=function(e){return e.substring(e.lastIndexOf("/")+1)},t.GetUrlParameter=function(e){var t=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"),i=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(window.location.search);return null!==i?decodeURIComponent(i[1].replace(/\+/g," ")):null},t.GetVirtualRealityEnabled=function(){var t=e.WindowManager.GetLocalStorageItem("virtualReality");return null!=t&&"true"===t},t.SetVirtualRealityEnabled=function(t){e.WindowManager.SetLocalStorageItem("virtualReality",t.toString().toLowerCase())},t.SetWindowsLaunchMode=function(t){void 0===t&&(t=1),e.WindowManager.IsWindows()&&void 0!==Windows.UI.ViewManagement&&void 0!==Windows.UI.ViewManagement.ApplicationView&&(Windows.UI.ViewManagement.ApplicationView.preferredLaunchWindowingMode=t)},t.GetHardwareScalingLevel=function(){return 1/window.devicePixelRatio},t.QuitWindowsApplication=function(){e.WindowManager.IsWindows()&&window.close()},t.PrintToScreen=function(t,i){if(void 0===i&&(i="white"),e.WindowManager.PrintElement=document.getElementById("print"),null==e.WindowManager.PrintElement){var n=document.createElement("div");n.id="print",n.style.position="absolute",n.style.left="6px",n.style.bottom="3px",n.style.fontSize="12px",n.style.zIndex="9001",n.style.color="#0c0",n.style.pointerEvents="none",document.body.appendChild(n),e.WindowManager.PrintElement=n}null!=e.WindowManager.PrintElement&&e.WindowManager.PrintElement.innerHTML!==t&&(e.WindowManager.PrintElement.style.color!==i&&(e.WindowManager.PrintElement.style.color=i),e.WindowManager.PrintElement.innerHTML=t)},t.debugLayerVisible=!1,t.PrintElement=null,t}();e.WindowManager=t}(n||(n={})),n.WindowManager.IsWindows()&&void 0!==Windows.UI.ViewManagement&&void 0!==Windows.UI.ViewManagement.ApplicationViewBoundsMode&&void 0!==Windows.UI.ViewManagement.ApplicationViewBoundsMode.useCoreWindow&&Windows.UI.ViewManagement.ApplicationView.getForCurrentView().setDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.useCoreWindow),n.WindowManager.IsXboxConsole()&&navigator.gamepadInputEmulation&&(navigator.gamepadInputEmulation="gamepad"),function(e){var t=function(t){function i(i,n,r,o){void 0===r&&(r={}),void 0===o&&(o="TOOLKIT.AnimationState");var a=t.call(this,i,n,r,o)||this;return a._looptime=!1,a._loopblend=!1,a._frametime=0,a._layercount=0,a._updatemode=0,a._hasrootmotion=!1,a._animationplaying=!1,a._initialtargetblending=!1,a._hastransformhierarchy=!1,a._leftfeetbottomheight=0,a._rightfeetbottomheight=0,a._runtimecontroller=null,a._executed=!1,a._awakened=!1,a._initialized=!1,a._checkers=new e.TransitionCheck,a._source="",a._machine=null,a._animationmode=0,a._animationrig=null,a._deltaPosition=new BABYLON.Vector3(0,0,0),a._deltaRotation=new BABYLON.Quaternion(0,0,0,0),a._angularVelocity=new BABYLON.Vector3(0,0,0),a._rootMotionSpeed=0,a._lastMotionSpeed=0,a._loopMotionSpeed=0,a._lastRotateSpeed=0,a._loopRotateSpeed=0,a._lastMotionRotation=new BABYLON.Quaternion(0,0,0,0),a._lastMotionPosition=new BABYLON.Vector3(0,0,0),a._positionWeight=!1,a._rootBoneWeight=!1,a._rotationWeight=!1,a._rootQuatWeight=!1,a._rootBoneTransform=null,a._positionHolder=new BABYLON.Vector3(0,0,0),a._rootBoneHolder=new BABYLON.Vector3(0,0,0),a._rotationHolder=new BABYLON.Quaternion(0,0,0,0),a._rootQuatHolder=new BABYLON.Quaternion(0,0,0,0),a._rootMotionMatrix=BABYLON.Matrix.Zero(),a._rootMotionScaling=new BABYLON.Vector3(0,0,0),a._rootMotionRotation=new BABYLON.Quaternion(0,0,0,0),a._rootMotionPosition=new BABYLON.Vector3(0,0,0),a._dirtyMotionMatrix=null,a._dirtyBlenderMatrix=null,a._targetPosition=new BABYLON.Vector3(0,0,0),a._targetRotation=new BABYLON.Quaternion(0,0,0,0),a._targetScaling=new BABYLON.Vector3(1,1,1),a._updateMatrix=BABYLON.Matrix.Zero(),a._blenderMatrix=BABYLON.Matrix.Zero(),a._blendWeights=new e.BlendingWeights,a._emptyScaling=new BABYLON.Vector3(1,1,1),a._emptyPosition=new BABYLON.Vector3(0,0,0),a._emptyRotation=new BABYLON.Quaternion(0,0,0,0),a._ikFrameEanbled=!1,a._data=new Map,a._anims=new Map,a._clips=null,a._numbers=new Map,a._booleans=new Map,a._triggers=new Map,a._parameters=new Map,a._smoothTargets=new Map,a.delayStart=0,a.speedRatio=1,a.delayUpdateUntilReady=!0,a.enableAnimations=!0,a.applyRootMotion=!1,a.onAnimationAwakeObservable=new BABYLON.Observable,a.onAnimationInitObservable=new BABYLON.Observable,a.onAnimationIKObservable=new BABYLON.Observable,a.onAnimationEndObservable=new BABYLON.Observable,a.onAnimationLoopObservable=new BABYLON.Observable,a.onAnimationEventObservable=new BABYLON.Observable,a.onAnimationUpdateObservable=new BABYLON.Observable,a.onAnimationTransitionObservable=new BABYLON.Observable,a.m_zeroVector=new BABYLON.Vector3(0,0,0),a.m_defaultGroup=null,a.m_animationTargets=null,a.m_rotationIdentity=new BABYLON.Quaternion(0,0,0,0),a.m_timelineScrubbing=!1,a.m_vertexAnimationMode=!1,a.m_vertexAnimationRenderers=null,a.m_vertexAnimationController=null,a.m_vertexAnimationDefaultClip=null,a.sourceAnimationGroups=null,a}return o(i,t),i.prototype.awakened=function(){return this._awakened},i.prototype.initialized=function(){return this._initialized},i.prototype.hasRootMotion=function(){return this._hasrootmotion},i.prototype.isFirstFrame=function(){return 0===this._frametime},i.prototype.isLastFrame=function(){return this._frametime>=.985},i.prototype.ikFrameEnabled=function(){return this._ikFrameEanbled},i.prototype.getAnimationTime=function(){return this._frametime},i.prototype.getFrameLoopTime=function(){return this._looptime},i.prototype.getFrameLoopBlend=function(){return this._loopblend},i.prototype.getAnimationPlaying=function(){return this._animationplaying},i.prototype.getRuntimeController=function(){return this._runtimecontroller},i.prototype.getRootBoneTransform=function(){return this._rootBoneTransform},i.prototype.getDeltaRootMotionAngle=function(){return this._angularVelocity.y},i.prototype.getDeltaRootMotionSpeed=function(){return this._rootMotionSpeed},i.prototype.getDeltaRootMotionPosition=function(){return this._deltaPosition},i.prototype.getDeltaRootMotionRotation=function(){return this._deltaRotation},i.prototype.getFixedRootMotionPosition=function(){return null!=this._dirtyMotionMatrix?this._rootMotionPosition:null},i.prototype.getFixedRootMotionRotation=function(){return null!=this._dirtyMotionMatrix?this._rootMotionRotation:null},i.prototype.getVertexAnimationController=function(){return this.m_vertexAnimationController},i.prototype.isVertexAnimationModeEnabled=function(){return this.m_vertexAnimationMode},i.prototype.getVertexAnimationMaterial=function(t,i){if(void 0===t&&(t=0),void 0===i&&(i=0),!this.m_vertexAnimationRenderers||0===this.m_vertexAnimationRenderers.length)return null;var n=Math.max(0,Math.min(t,this.m_vertexAnimationRenderers.length-1)),r=this.m_vertexAnimationRenderers[n];if(!r)return null;var o=r.material;if(o instanceof e.VertexAnimationMaterial)return o;if(o instanceof BABYLON.MultiMaterial){var a=o.subMaterials,s=Math.max(0,Math.min(i,a.length-1));return a[s]instanceof e.VertexAnimationMaterial?a[s]:null}return null},i.prototype.awake=function(){this.awakeStateMachine()},i.prototype.update=function(){this.updateSmoothParameters(this.getDeltaSeconds()),this.updateStateMachine()},i.prototype.destroy=function(){this.destroyStateMachine()},i.prototype.playDefault=function(t,i,n){void 0===t&&(t=.1),void 0===i&&(i=0),void 0===n&&(n=null);var r=!1;if(!0===this._initialized)if(!0===this.m_vertexAnimationMode)if(null!=this.m_vertexAnimationController)if(null!=this._machine&&null!=this._machine.layers&&this._machine.layers.length>0){var o=this._machine.layers[0];this.playCurrentAnimationState(o,o.entry,t),r=!0}else BABYLON.Tools.Warn("No animation state layers on "+this.transform.name);else BABYLON.Tools.Warn("Vertex animation controller not initialized for "+this.transform.name);else if(!0===this._initialized)if(null!=this._machine&&null!=this._machine.layers&&this._machine.layers.length>i){var a=null!=(o=this._machine.layers[i]).animationStateMachine&&o.animationStateMachine.rate||e.AnimationState.FPS,s=t>0?e.Utilities.ComputeBlendingSpeed(n||a,t):0;this.playCurrentAnimationState(o,o.entry,s),r=!0}else BABYLON.Tools.Warn("No animation state layers on "+this.transform.name);else BABYLON.Tools.Warn("Animation state machine not initialized for "+this.transform.name);else BABYLON.Tools.Warn("Animation state machine not initialized for "+this.transform.name);return r},i.prototype.playAnimation=function(t,i,n,r){void 0===i&&(i=.1),void 0===n&&(n=0),void 0===r&&(r=null);var o=!1;if(!0===this._initialized)if(!0===this.m_vertexAnimationMode)if(null!=this.m_vertexAnimationController)if(null!=this._machine&&null!=this._machine.layers&&this._machine.layers.length>0){var a=this._machine.layers[0];this.playCurrentAnimationState(a,t,i),o=!0}else BABYLON.Tools.Warn("No animation state layers on "+this.transform.name);else BABYLON.Tools.Warn("Vertex animation controller not initialized for "+this.transform.name);else if(null!=this._machine&&null!=this._machine.layers&&this._machine.layers.length>n){var s=null!=(a=this._machine.layers[n]).animationStateMachine&&a.animationStateMachine.rate||e.AnimationState.FPS,l=i>0?e.Utilities.ComputeBlendingSpeed(r||s,i):0;this.playCurrentAnimationState(a,t,l),o=!0}else BABYLON.Tools.Warn("No animation state layers on "+this.transform.name);else BABYLON.Tools.Warn("Animation state machine not initialized for "+this.transform.name);return o},i.prototype.stopAnimation=function(e){void 0===e&&(e=0);var t=!1;if(!0===this._initialized)if(!0===this.m_vertexAnimationMode)if(null!=this.m_vertexAnimationController)if(null!=this._machine&&null!=this._machine.layers&&this._machine.layers.length>0){var i=this._machine.layers[0];this.stopCurrentAnimationState(i),t=!0}else BABYLON.Tools.Warn("No animation state layers on "+this.transform.name);else BABYLON.Tools.Warn("Vertex animation controller not initialized for "+this.transform.name);else null!=this._machine&&null!=this._machine.layers&&this._machine.layers.length>e?(i=this._machine.layers[e],this.stopCurrentAnimationState(i),t=!0):BABYLON.Tools.Warn("No animation state layers on "+this.transform.name);else BABYLON.Tools.Warn("Animation state machine not initialized for "+this.transform.name);return t},i.prototype.killAnimations=function(){var e=this,t=!1;if(!0===this._initialized)if(!0===this.m_vertexAnimationMode)if(null!=this.m_vertexAnimationController)if(null!=this._machine&&null!=this._machine.layers&&this._machine.layers.length>0){var i=this._machine.layers[0];this.stopCurrentAnimationState(i),t=!0}else BABYLON.Tools.Warn("No animation state layers on "+this.transform.name);else BABYLON.Tools.Warn("Vertex animation controller not initialized for "+this.transform.name);else null!=this._machine&&null!=this._machine.layers?this._machine.layers.forEach(function(i){e.stopCurrentAnimationState(i),t=!0}):BABYLON.Tools.Warn("No animation state layers on "+this.transform.name);else BABYLON.Tools.Warn("Animation state machine not initialized for "+this.transform.name);return t},i.prototype.setTimelineScrubbing=function(e){this.m_timelineScrubbing=e,!0===this.m_vertexAnimationMode&&null!=this.m_vertexAnimationController&&!1===e&&this.m_vertexAnimationController.currentClip&&this.m_vertexAnimationController.resume()},i.prototype.getIsTimelineScrubbing=function(){return this.m_timelineScrubbing},i.prototype.setAnimationTime=function(t){if(!0===this.m_vertexAnimationMode&&null!=this.m_vertexAnimationController){if(this.m_vertexAnimationController.setCurrentTime(t),null!=this._machine&&null!=this._machine.layers&&this._machine.layers.length>0){var i=this._machine.layers[0],n=this.m_vertexAnimationController.currentClip,r=null!=n?n.duration:0,o=r>0?Math.max(0,Math.min(1,t/r)):0;i.animationNormal=o,i.animationTime=o*e.AnimationState.TIME}return!0}return!1},i.prototype.setAnimationSpeed=function(e){return!0===this.m_vertexAnimationMode&&null!=this.m_vertexAnimationController&&(this.m_vertexAnimationController.setSpeed(e),!0)},i.prototype.setAnimationLoop=function(e){return!0===this.m_vertexAnimationMode&&null!=this.m_vertexAnimationController&&(this.m_vertexAnimationController.setLoop(e),!0)},i.prototype.hasBool=function(e){return null!=this._booleans.get(e)},i.prototype.getBool=function(e){return this._booleans.get(e)||!1},i.prototype.setBool=function(e,t){this._booleans.set(e,t)},i.prototype.hasFloat=function(e){return null!=this._numbers.get(e)},i.prototype.getFloat=function(e){return this._numbers.get(e)||0},i.prototype.setFloat=function(e,t){this._numbers.set(e,t)},i.prototype.hasInteger=function(e){return null!=this._numbers.get(e)},i.prototype.getInteger=function(e){return this._numbers.get(e)||0},i.prototype.setInteger=function(e,t){this._numbers.set(e,t)},i.prototype.hasTrigger=function(e){return null!=this._triggers.get(e)},i.prototype.getTrigger=function(e){return this._triggers.get(e)||!1},i.prototype.setTrigger=function(e){this._triggers.set(e,!0)},i.prototype.resetTrigger=function(e){this._triggers.set(e,!1)},i.prototype.setSmoothFloat=function(e,t,i,n){if(void 0===i&&(i=.1),!(i>0))return this._smoothTargets&&this._smoothTargets.delete(e),void this.setFloat(e,t);var r=this._smoothTargets.get(e);null==r?(r={target:t,dampTime:i,velocity:new BABYLON.Vector2(0,0)},this._smoothTargets.set(e,r)):(r.target=t,r.dampTime=i)},i.prototype.setSmoothInteger=function(e,t,i,n){void 0===i&&(i=.1),this.setSmoothFloat(e,t,i,n)},i.prototype.updateSmoothParameters=function(t){var i=this;if(null!=this._smoothTargets&&0!==this._smoothTargets.size&&t>0){var n=1e-4,r=[];this._smoothTargets.forEach(function(o,a){var s=i.getFloat(a);if(Math.abs(s-o.target)<=n&&Math.abs(o.velocity.x)<=n)return i.setFloat(a,o.target),void r.push(a);var l=e.Utilities.SmoothDamp(s,o.target,o.dampTime,Number.POSITIVE_INFINITY,t,o.velocity);i.setFloat(a,l)});for(var o=0;o<r.length;o++)this._smoothTargets.delete(r[o])}},i.prototype.getMachineState=function(e){return this._data.get(e)},i.prototype.setMachineState=function(e,t){this._data.set(e,t)},i.prototype.getCurrentState=function(e){return null!=this._machine.layers&&this._machine.layers.length>e?this._machine.layers[e].animationStateMachine:null},i.prototype.getDefaultClips=function(){return this._clips},i.prototype.getDefaultSource=function(){return this._source},i.prototype.setLayerWeight=function(e,t){},i.prototype.fixAnimationGroup=function(e){var t=null;if(null!=this._clips&&this._clips.length>0)for(var i=0;i<this._clips.length;i++){var n=this._clips[i];if(null!=n.clip){var r=("."+n.clip).toLowerCase();if(e.name.toLowerCase().endsWith(r)){null==e.metadata&&(e.metadata={}),null==e.metadata.toolkit&&(e.metadata.toolkit=n),e.metadata.toolkit.source=this._source,t=n;break}}}return t},i.prototype.getAnimationGroup=function(e){return this._anims.get(e)},i.prototype.getAnimationGroups=function(){return this.sourceAnimationGroups},i.prototype.setAnimationGroups=function(e){!0!==this.m_vertexAnimationMode&&(null==this.transform.metadata&&(this.transform.metadata={}),null==this.transform.metadata.toolkit&&(this.transform.metadata.toolkit={}),this.transform.metadata.toolkit.sourceAnimationGroups=e,this.setupSourceAnimationGroups())},i.prototype.updateAnimationGroups=function(t){var i=this;!0!==this.m_vertexAnimationMode&&null!=t&&t.length>0&&(this._anims=new Map,this.m_animationTargets=[],this.m_defaultGroup=null,this.sourceAnimationGroups=null,t.forEach(function(t){var n=!1,r=t;if(null!=r&&null!=r.metadata&&null!=r.metadata.toolkit&&null!=r.metadata.toolkit.source&&""!==r.metadata.toolkit.source&&r.metadata.toolkit.source===i._source&&(n=!0),!0===n&&null!=r&&null!=r.metadata&&null!=r.metadata.toolkit&&null!=r.metadata.toolkit.clip&&""!==r.metadata.toolkit.clip){try{t.stop()}catch(e){}null==i.sourceAnimationGroups&&(i.sourceAnimationGroups=[]),i.sourceAnimationGroups.push(t),i._anims.set(r.metadata.toolkit.clip,t),null==i.m_defaultGroup&&(i.m_defaultGroup=t),null!=t.targetedAnimations&&t.targetedAnimations.length>0&&t.targetedAnimations.forEach(function(t){for(var n=-1,r=0;r<i.m_animationTargets.length;r++)if(i.m_animationTargets[r].target===t.target){n=r;break}if(n<0)if(i.m_animationTargets.push(t),null==t.target.metadata&&(t.target.metadata={}),t.target instanceof BABYLON.TransformNode){e.Utilities.ValidateTransformQuaternion(t.target);for(var o=[],a=0;a<i._layercount;a++){var s=new e.AnimationMixer;s.positionBuffer=null,s.rotationBuffer=null,s.scalingBuffer=null,s.originalMatrix=null,s.blendingFactor=0,s.blendingSpeed=0,s.rootPosition=null,s.rootRotation=null,o.push(s)}t.target.metadata.mixer=o}else if(t.target instanceof BABYLON.MorphTarget){var l=[];for(a=0;a<i._layercount;a++){var u=new e.AnimationMixer;u.influenceBuffer=null,l.push(u)}t.target.metadata.mixer=l}})}}))},i.prototype.setupSourceAnimationGroups=function(){var e=this;if(!0!==this.m_vertexAnimationMode){var t=null!=this.transform.metadata&&null!=this.transform.metadata.toolkit&&null!=this.transform.metadata.toolkit.sourceAnimationGroups?this.transform.metadata.toolkit.sourceAnimationGroups:null;null!=t&&(this.updateAnimationGroups(t),null!=this.sourceAnimationGroups&&null!=this._machine&&null!=this._machine.states&&this._machine.states.length>0&&this._machine.states.forEach(function(t){null!=t&&null!=t.name&&(null!=t.ccurves&&t.ccurves.length>0&&t.ccurves.forEach(function(e){if(null!=e.animation){var i=BABYLON.Animation.Parse(e.animation);null!=i&&(null==t.tcurves&&(t.tcurves=[]),t.tcurves.push(i))}}),e.setupTreeBranches(t.blendtree),e.setMachineState(t.name,t))}))}},i.prototype.awakeStateMachine=function(){var t=this;e.Utilities.ValidateTransformQuaternion(this.transform),this.m_animationTargets=[],this.m_defaultGroup=null,this.m_rotationIdentity=BABYLON.Quaternion.Identity(),this._source=null!=this.transform.metadata&&null!=this.transform.metadata.toolkit&&null!=this.transform.metadata.toolkit.animator&&""!==this.transform.metadata.toolkit.animator?this.transform.metadata.toolkit.animator:null,this._clips=this.getProperty("clips",this._clips),this._machine=this.getProperty("machine",this._machine),this._updatemode=this.getProperty("updatemode",this._updatemode),this._animationrig=this.getProperty("animationrig",this._animationrig),this._animationmode=this.getProperty("animationmode",this._animationmode),this._hasrootmotion=this.getProperty("hasrootmotion",this._hasrootmotion),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),null!=this._machine&&(null!=this._machine.owner&&null!=this._machine.owner&&""!==this._machine.owner&&"*"!==this._machine.owner||(this._machine.owner=null!=this.transform.parent?this.transform.parent.name:this.transform.name),null!=this._machine.speed&&(this.speedRatio=this._machine.speed),null!=this._machine.parameters&&this._machine.parameters.length>0&&this._machine.parameters.forEach(function(i){var n=i.name,r=i.type,o=(i.curve,i.defaultFloat),a=i.defaultBool,s=i.defaultInt;t._parameters.set(n,r),r===e.AnimatorParameterType.Bool?t.setBool(n,a):r===e.AnimatorParameterType.Float?t.setFloat(n,o):r===e.AnimatorParameterType.Int?t.setInteger(n,s):r===e.AnimatorParameterType.Trigger&&t.resetTrigger(n)}),null!=this._machine.layers&&this._machine.layers.length>0&&(this._layercount=this._machine.layers.length,this._machine.layers.sort(function(e,t){return e.index<t.index?-1:e.index>t.index?1:0}),this._machine.layers.forEach(function(e){if(null==e.owner||null==e.owner||""===e.owner||e.owner,e.animationMaskMap=new Map,null!=e.avatarMask&&null!=e.avatarMask.transformPaths&&e.avatarMask.transformPaths.length>0)for(var t=0;t<e.avatarMask.transformPaths.length;t++)e.animationMaskMap.set(e.avatarMask.transformPaths[t],t)})));var i=this.getProperty("vertexcontroller",null),n=this.getProperty("lazyloadtextures",!1),r=this.getProperty("clips",null);if(null!=i&&null!=r){var o=[];if(r.forEach(function(e){var i,n;null==t.m_vertexAnimationDefaultClip&&null!=e.clip&&(t.m_vertexAnimationDefaultClip=e.clip);var r=null!==(n=null===(i=null==e?void 0:e.settings)||void 0===i?void 0:i.vertexrenderers)&&void 0!==n?n:null;null!=r&&r.forEach(function(e){return o.push(e)})}),o.length>0){this.m_vertexAnimationMode=!0,this.m_vertexAnimationRenderers=[];var a=e.SceneManager.GetRootUrl(this.scene),s={};o.forEach(function(r){if(r&&r.vertexguid&&!s[r.vertexguid]){s[r.vertexguid]=!0;var l=t.scene.getNodeById(r.vertexguid);if(null!=l){var u=l.material,h=!1;if(!(l instanceof BABYLON.InstancedMesh)){var c=function(t){if(t instanceof e.VertexAnimationMaterial){var n=t.getPlugin();n&&n.controller&&n.controller.guid!==i&&(h=!0)}};u instanceof BABYLON.MultiMaterial?u.subMaterials.forEach(c):c(u)}if(h)if(u instanceof BABYLON.MultiMaterial){var d=new BABYLON.MultiMaterial(u.name+"_"+i,t.scene);u.subMaterials.forEach(function(t){d.subMaterials.push(t instanceof e.VertexAnimationMaterial?t.cloneForInstance(t.name+"_"+i):t)}),l.material=d}else u instanceof e.VertexAnimationMaterial&&(l.material=u.cloneForInstance(u.name+"_"+i));var m=[];if(l.material instanceof BABYLON.MultiMaterial?l.material.subMaterials.forEach(function(t){t instanceof e.VertexAnimationMaterial&&m.push(t)}):l.material instanceof e.VertexAnimationMaterial&&m.push(l.material),m.length>0){t.m_vertexAnimationRenderers.push(l);var p=l instanceof BABYLON.InstancedMesh?l.sourceMesh:l;p&&!p.__vatPackedInstancedBuffersRegistered&&(p.__vatPackedInstancedBuffersRegistered=!0,p.registerInstancedBuffer("g_vatAnim0",4),p.registerInstancedBuffer("g_vatAnim1",4));var f=l.instancedBuffers;f&&(f.g_vatAnim0=new BABYLON.Vector4(0,0,0,1),f.g_vatAnim1=new BABYLON.Vector4(0,0,0,0)),m.forEach(function(s){var u=s.getPlugin();if(u instanceof e.VertexAnimationMaterialPlugin){var h=u.setupAnimations(o,i,a,n);null!=h&&(h.setInstanceMesh(r.vertexguid,l),null==t.m_vertexAnimationController&&(t.m_vertexAnimationController=h))}})}else console.error("### No VertexAnimationMaterial found on mesh GUID: "+r.vertexguid+" --\x3e For: "+t.transform.name,l)}else console.error("### Failed To Setup Vertex Animation Renderer For GUID: "+r.vertexguid+" --\x3e For: "+t.transform.name)}}),null!=this._machine&&null!=this._machine.states&&this._machine.states.length>0&&this._machine.states.forEach(function(e){null!=e&&null!=e.name&&(null!=e.ccurves&&e.ccurves.length>0&&e.ccurves.forEach(function(t){if(null!=t.animation){var i=BABYLON.Animation.Parse(t.animation);null!=i&&(null==e.tcurves&&(e.tcurves=[]),e.tcurves.push(i))}}),t.setMachineState(e.name,e))})}else this.m_vertexAnimationMode=!1,this.m_vertexAnimationRenderers=null}else this.m_vertexAnimationMode=!1,this.m_vertexAnimationRenderers=null;this._awakened=!0,this.onAnimationAwakeObservable&&this.onAnimationAwakeObservable.hasObservers()&&this.onAnimationAwakeObservable.notifyObservers(this.transform)},i.prototype.updateStateMachine=function(e){var t=this;if(void 0===e&&(e=null),!1===this.delayUpdateUntilReady||!0===this.delayUpdateUntilReady&&this.isReady())if(!0===this.m_vertexAnimationMode){if(!1===this._executed){if(this._executed=!0,null!=this._machine.layers&&this._machine.layers.length>0){var i=this._machine.layers[0];this.playCurrentAnimationState(i,i.entry,0)}this._initialized=!0,this.onAnimationInitObservable&&this.onAnimationInitObservable.hasObservers()&&this.onAnimationInitObservable.notifyObservers(this.transform)}if(!0===this.enableAnimations){var n=e||this.getDeltaSeconds();this.updateAnimationState(n),this.onAnimationUpdateObservable&&this.onAnimationUpdateObservable.hasObservers()&&this.onAnimationUpdateObservable.notifyObservers(this.transform)}}else null==this.sourceAnimationGroups&&this.setupSourceAnimationGroups(),null!=this.sourceAnimationGroups&&(!1===this._executed&&(this._executed=!0,null!=this._machine.layers&&this._machine.layers.length>0&&this._machine.layers.forEach(function(e){t.playCurrentAnimationState(e,e.entry,0)}),this._initialized=!0,this.onAnimationInitObservable&&this.onAnimationInitObservable.hasObservers()&&this.onAnimationInitObservable.notifyObservers(this.transform)),!0===this.enableAnimations)&&(n=e||this.getDeltaSeconds(),this.updateAnimationState(n),this.updateAnimationTargets(n),this.onAnimationUpdateObservable&&this.onAnimationUpdateObservable.hasObservers()&&this.onAnimationUpdateObservable.notifyObservers(this.transform))},i.prototype.destroyStateMachine=function(){this._data=null,this._clips=null,this._anims=null,this._numbers=null,this._booleans=null,this._triggers=null,this._parameters=null,this._smoothTargets=null,this._checkers=null,this._machine=null,this.sourceAnimationGroups=null,this.onAnimationAwakeObservable.clear(),this.onAnimationAwakeObservable=null,this.onAnimationInitObservable.clear(),this.onAnimationInitObservable=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,this.onAnimationTransitionObservable.clear(),this.onAnimationTransitionObservable=null},i.prototype.updateAnimationState=function(e){var t=this;if(null!=this._machine.layers&&this._machine.layers.length>0)if(!0===this.m_vertexAnimationMode){var i=this._machine.layers[0];this.checkStateMachine(i,e),this.updateVertexAnimationLayer(i,e)}else this._machine.layers.forEach(function(i){t.checkStateMachine(i,e)})},i.prototype.updateVertexAnimationLayer=function(t,i){if(null!=this.m_vertexAnimationController&&null!=t&&null!=t.animationStateMachine){var n=t.animationStateMachine,r=n.blendtree;if(null!=r&&null!=r.children&&0!==r.children.length){var o="number"==typeof n.speed?n.speed:1,a=Math.abs(o)*Math.abs(this.speedRatio||1),s=null,l=null,u=1,h=0,c=0,d=!1;if(r.blendType===e.BlendTreeType.Clip){var m=r.children[0];if(null==m||!m.motion)return;var p=this.m_vertexAnimationController.getClip(m.motion);if(null==p||p.duration<=0)return;s=m.motion,h=p.duration,d=!!p.loop}else{var f=[];if(this.parseTreeBranches(t,r,1,f),0===f.length)return;this.sortWeightedBlendingList(f);var g=f[0],y=f.length>1?f[1]:null,v=g.weight||0,S=v+(y&&y.weight||0);u=S>0?v/S:1;var _=this.m_vertexAnimationController.getClip(g.motion);if(null==_||_.duration<=0)return;if(s=g.motion,h=_.duration,d=!!_.loop,null!=y){var b=this.m_vertexAnimationController.getClip(y.motion);null!=b&&b.duration>0&&(l=y.motion,c=b.duration)}}if(!(null==s||h<=0)){var B=e.AnimationState.TIME/h,C=B;if(null!=l&&c>0){var A=e.AnimationState.TIME/c;C=BABYLON.Scalar.Lerp(A,B,u)}var T=this.m_vertexAnimationController.loopOverride,M=null!==T?T:d;if(t.animationTime+=i*C*a,M){for(;t.animationTime>=e.AnimationState.TIME;)t.animationTime-=e.AnimationState.TIME,this.onAnimationLoopObservable&&this.onAnimationLoopObservable.hasObservers()&&this.onAnimationLoopObservable.notifyObservers(t.index);t.animationTime<0&&(t.animationTime+=e.AnimationState.TIME)}else t.animationTime>e.AnimationState.TIME&&(t.animationTime=e.AnimationState.TIME),t.animationTime<0&&(t.animationTime=0);t.animationNormal=e.AnimationState.TIME>0?t.animationTime/e.AnimationState.TIME:0;var L=o<0!=(this.speedRatio||1)<0?1-t.animationNormal:t.animationNormal,P=L*h,w=null!=l&&c>0?L*c:0;if(!0===t.vatTransitionActive&&t.vatTransitionDuration>0){t.vatTransitionElapsed=(t.vatTransitionElapsed||0)+i;var x=t.vatTransitionElapsed/t.vatTransitionDuration;x>=1&&(x=1,t.vatTransitionActive=!1,t.vatTransitionElapsed=0,t.vatTransitionDuration=0,t.vatSourceClipName=null,t.vatSourceTimeSec=0),this.m_vertexAnimationController.driveBlend(s,P,x<1&&t.vatSourceClipName||null,x<1&&t.vatSourceTimeSec||0,x)}else this.m_vertexAnimationController.driveBlend(s,P,l,w,u)}}}},i.prototype.updateAnimationTargets=function(t){var i=this;!0!==this.m_vertexAnimationMode&&(this._looptime=!1,this._loopblend=!1,this._ikFrameEanbled=!1,this._animationplaying=!1,null!=this._machine.layers&&this._machine.layers.length>0&&this._machine.layers.forEach(function(n){if(0===n.index&&(i._frametime=n.animationTime),null!=n.animationStateMachine&&null!=n.animationStateMachine.blendtree){!0===n.animationStateMachine.iKOnFeet&&(i._ikFrameEanbled=!0),!0===n.iKPass&&i.onAnimationIKObservable&&i.onAnimationIKObservable.hasObservers()&&i.onAnimationIKObservable.notifyObservers(n.index);var r=n.animationStateMachine;if(r.type===e.MotionType.Clip&&-1!==r.played&&(r.played+=t),null!=r.blendtree.children&&r.blendtree.children.length>0){var o=r.blendtree.children[0];if(null!=o)if(r.blendtree.blendType==e.BlendTreeType.Clip){var a=o.track;if(null!=a){var s=a.metadata.toolkit.length,l=s>0?e.AnimationState.TIME/s:0;n.animationTime+=t*l*Math.abs(r.speed)*Math.abs(i.speedRatio),n.animationTime>e.AnimationState.TIME&&(n.animationTime=e.AnimationState.TIME);var u=n.animationTime>0?BABYLON.Scalar.Clamp(n.animationTime/e.AnimationState.TIME,0,1):0,h=r.speed<0!=i.speedRatio<0;n.animationNormal=h?1-u:u;var c=n.animationNormal>=.99?1:n.animationNormal,d=(parseFloat(c.toFixed(3)),s*n.animationNormal),m=0,p=0,f=0,g=!1,y=!1,v=0,S=!0,_=!0,b=!0,B=a;if(null!=B.metadata&&null!=B.metadata.toolkit&&(null!=B.metadata.toolkit.averagespeed&&(p=null!=B.metadata.toolkit.averagespeed.x?B.metadata.toolkit.averagespeed.x:0,f=null!=B.metadata.toolkit.averagespeed.z?B.metadata.toolkit.averagespeed.z:0),null!=B.metadata.toolkit.settings&&(m=null!=B.metadata.toolkit.settings.level?B.metadata.toolkit.settings.level:0,g=null!=B.metadata.toolkit.settings.looptime&&B.metadata.toolkit.settings.looptime,y=null!=B.metadata.toolkit.settings.loopblend&&B.metadata.toolkit.settings.loopblend,v=null!=B.metadata.toolkit.settings.orientationoffsety?B.metadata.toolkit.settings.orientationoffsety:0,S=null==B.metadata.toolkit.settings.loopblendorientation||B.metadata.toolkit.settings.loopblendorientation,_=null==B.metadata.toolkit.settings.loopblendpositiony||B.metadata.toolkit.settings.loopblendpositiony,b=null==B.metadata.toolkit.settings.loopblendpositionxz||B.metadata.toolkit.settings.loopblendpositionxz)),0===n.index&&(i._looptime=g,i._loopblend=y),v=BABYLON.Tools.ToRadians(v),p=Math.abs(p),f=Math.abs(f),m*=-1,n.animationTime>=e.AnimationState.TIME&&(n.animationFirstRun=!1,n.animationLoopFrame=!0,!0===g?(n.animationLoopCount++,i.onAnimationLoopObservable&&i.onAnimationLoopObservable.hasObservers()&&i.onAnimationLoopObservable.notifyObservers(n.index)):!1===n.animationEndFrame&&(n.animationEndFrame=!0,i.onAnimationEndObservable&&i.onAnimationEndObservable.hasObservers()&&i.onAnimationEndObservable.notifyObservers(n.index))),!0!==n.animationFirstRun&&!0!==g||(i._animationplaying=!0,a.targetedAnimations.forEach(function(t){if(t.target instanceof BABYLON.TransformNode){var r=t.target;if(0===n.index||null==n.avatarMask||i.filterTargetAvatarMask(n,r)){var o=null!=r.metadata&&null!=r.metadata.toolkit&&null!=r.metadata.toolkit.rootbone&&r.metadata.toolkit.rootbone;if(!0===o&&null==i._rootBoneTransform&&(i._rootBoneTransform=r),null!=r.metadata&&null!=r.metadata.mixer){var a=r.metadata.mixer[n.index];if(null!=a)if("position"===t.animation.targetProperty)i._targetPosition=e.Utilities.SampleAnimationVector3(t.animation,d,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE,!0),!0===o&&null!=i._rootBoneTransform?(i._positionWeight=!0,i._positionHolder.set(0,0,0),i._rootBoneWeight=!1,i._rootBoneHolder.set(0,0,0),!0===i.applyRootMotion?!0===_&&!0===b?(i._positionWeight=!0,i._positionHolder.set(i._targetPosition.x,i._targetPosition.y+m,i._targetPosition.z)):!1===_&&!1===b?(i._rootBoneWeight=!0,i._rootBoneHolder.set(i._targetPosition.x,i._targetPosition.y+m,i._targetPosition.z)):!0===_&&!1===b?(i._positionWeight=!0,i._positionHolder.set(i.m_zeroVector.x,i._targetPosition.y+m,i.m_zeroVector.z),i._rootBoneWeight=!0,i._rootBoneHolder.set(i._targetPosition.x,i.m_zeroVector.y,i._targetPosition.z)):!0===b&&!1===_&&(i._positionWeight=!0,i._positionHolder.set(i._targetPosition.x,i.m_zeroVector.y,i._targetPosition.z),i._rootBoneWeight=!0,i._rootBoneHolder.set(i.m_zeroVector.x,i._targetPosition.y+m,i.m_zeroVector.z)):(i._positionWeight=!0,i._positionHolder.set(i._targetPosition.x,i._targetPosition.y,i._targetPosition.z)),!0===i._positionWeight&&(null==a.positionBuffer&&(a.positionBuffer=new BABYLON.Vector3(0,0,0)),e.Utilities.BlendVector3Value(a.positionBuffer,i._positionHolder,1)),!0===i._rootBoneWeight&&(null==a.rootPosition&&(a.rootPosition=new BABYLON.Vector3(0,0,0)),e.Utilities.BlendVector3Value(a.rootPosition,i._rootBoneHolder,1))):(null==a.positionBuffer&&(a.positionBuffer=new BABYLON.Vector3(0,0,0)),e.Utilities.BlendVector3Value(a.positionBuffer,i._targetPosition,1));else if("rotationQuaternion"===t.animation.targetProperty)if(i._targetRotation=e.Utilities.SampleAnimationQuaternion(t.animation,d,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE,!0),!0===o&&null!=i._rootBoneTransform){i._rotationWeight=!1,i._rotationHolder.copyFrom(i.m_rotationIdentity),i._rootQuatWeight=!1,i._rootQuatHolder.copyFrom(i.m_rotationIdentity);var s=i._targetRotation.toEulerAngles(),l=s.y;!0===i.applyRootMotion?!0===S?(i._rotationWeight=!0,BABYLON.Quaternion.FromEulerAnglesToRef(s.x,l+v,s.z,i._rotationHolder)):(i._rotationWeight=!0,BABYLON.Quaternion.FromEulerAnglesToRef(s.x,i.m_zeroVector.y,s.z,i._rotationHolder),i._rootQuatWeight=!0,BABYLON.Quaternion.FromEulerAnglesToRef(i.m_zeroVector.x,l+v,i.m_zeroVector.z,i._rootQuatHolder)):(i._rotationWeight=!0,BABYLON.Quaternion.FromEulerAnglesToRef(s.x,l+v,s.z,i._rotationHolder)),!0===i._rotationWeight&&(null==a.rotationBuffer&&(a.rotationBuffer=new BABYLON.Quaternion(0,0,0,0)),e.Utilities.BlendQuaternionValue(a.rotationBuffer,i._rotationHolder,1)),!0===i._rootQuatWeight&&(null==a.rootRotation&&(a.rootRotation=new BABYLON.Quaternion(0,0,0,0)),e.Utilities.BlendQuaternionValue(a.rootRotation,i._rootQuatHolder,1))}else null==a.rotationBuffer&&(a.rotationBuffer=new BABYLON.Quaternion(0,0,0,0)),e.Utilities.BlendQuaternionValue(a.rotationBuffer,i._targetRotation,1);else"scaling"===t.animation.targetProperty&&(i._targetScaling=e.Utilities.SampleAnimationVector3(t.animation,d,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE,!0),null==a.scalingBuffer&&(a.scalingBuffer=new BABYLON.Vector3(1,1,1)),e.Utilities.BlendVector3Value(a.scalingBuffer,i._targetScaling,1))}}}else if(t.target instanceof BABYLON.MorphTarget){var u=t.target;if(null!=u.metadata&&null!=u.metadata.mixer){var h=u.metadata.mixer[n.index];if("influence"===t.animation.targetProperty){var c=e.Utilities.SampleAnimationFloat(t.animation,d,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE,!0);null==h.influenceBuffer&&(h.influenceBuffer=0),h.influenceBuffer=e.Utilities.BlendFloatValue(h.influenceBuffer,c,1)}}}})),1==i._animationplaying&&(null!=n.animationStateMachine.tcurves&&n.animationStateMachine.tcurves.length>0&&n.animationStateMachine.tcurves.forEach(function(t){if(null!=t.targetProperty&&""!==t.targetProperty){var r=e.Utilities.SampleAnimationFloat(t,n.animationNormal,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE,!0);i.setFloat(t.targetProperty,r)}}),null!=n.animationStateMachine.events&&n.animationStateMachine.events.length>0)){for(var C=void 0!==n._prevAnimationNormal?n._prevAnimationNormal:n.animationNormal,A=n.animationNormal,T=r.speed<0!=i.speedRatio<0?-1:1,M=function(e,t,i,n){return 1===n?e<=t?e<i&&i<=t:e<i&&i<=1||0<=i&&i<=t:e>=t?t<=i&&i<e:0<=i&&i<e||t<=i&&i<=1},L=0,P=n.animationStateMachine.events;L<P.length;L++)if(M(C,A,(W=P[L]).time,T)){var w=W.function+"_"+W.time;null==n.animationLoopEvents&&(n.animationLoopEvents={}),n.animationLoopEvents[w]||(n.animationLoopEvents[w]=!0,i.onAnimationEventObservable&&i.onAnimationEventObservable.hasObservers()&&i.onAnimationEventObservable.notifyObservers(W))}n._prevAnimationNormal=A}!0===n.animationLoopFrame&&(n.animationTime=0,n.animationNormal=0,n.animationLoopFrame=!1,n.animationLoopEvents=null)}}else{i._animationplaying=!0,i._blendWeights.primary=null,i._blendWeights.secondary=null;var x=[],O=r.blendtree;i.parseTreeBranches(n,O,1,x),l=i.computeWeightedFrameRatio(x),n.animationTime+=t*l*Math.abs(r.speed)*Math.abs(i.speedRatio),n.animationTime>e.AnimationState.TIME&&(n.animationTime=e.AnimationState.TIME),u=n.animationTime>0?BABYLON.Scalar.Clamp(n.animationTime/e.AnimationState.TIME,0,1):0,h=r.speed<0!=i.speedRatio<0,n.animationNormal=h?1-u:u,c=n.animationNormal>=.99?1:n.animationNormal,parseFloat(c.toFixed(3));var R=n.animationNormal;n.animationTime>=e.AnimationState.TIME&&(n.animationFirstRun=!1,n.animationLoopFrame=!0,n.animationLoopCount++);var I=null!=x&&x.length>0&&null!=x[0].track?x[0].track:null;if(null!=I)for(var N=I.targetedAnimations.length,k=0;k<N;k++){var F=I.targetedAnimations[k];if(F.target instanceof BABYLON.TransformNode){var D=F.target;if(0===n.index||null==n.avatarMask||i.filterTargetAvatarMask(n,D)){var E=null!=D.metadata&&null!=D.metadata.toolkit&&null!=D.metadata.toolkit.rootbone&&D.metadata.toolkit.rootbone;if(!0===E&&null==i._rootBoneTransform&&(i._rootBoneTransform=D),null!=D.metadata&&null!=D.metadata.mixer){i._initialtargetblending=!0;var V=D.metadata.mixer[n.index];i.updateBlendableTargets(t,n,O,F,k,V,R,E,D)}}}}if(null!=n.animationStateMachine.tcurves&&n.animationStateMachine.tcurves.length>0&&n.animationStateMachine.tcurves.forEach(function(t){if(null!=t.targetProperty&&""!==t.targetProperty){var r=e.Utilities.SampleAnimationFloat(t,n.animationNormal,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE,!0);i.setFloat(t.targetProperty,r)}}),null!=n.animationStateMachine.events&&n.animationStateMachine.events.length>0){A=R,C=void 0!==n._prevBlendingNormal?n._prevBlendingNormal:A,T=r.speed<0!=i.speedRatio<0?-1:1,M=function(e,t,i,n){return 1===n?e<=t?e<i&&i<=t:e<i&&i<=1||0<=i&&i<=t:e>=t?t<=i&&i<e:0<=i&&i<e||t<=i&&i<=1};for(var Y=0,U=n.animationStateMachine.events;Y<U.length;Y++){var W;M(C,A,(W=U[Y]).time,T)&&(w=W.function+"_"+W.time,null==n.animationLoopEvents&&(n.animationLoopEvents={}),n.animationLoopEvents[w]||(n.animationLoopEvents[w]=!0,i.onAnimationEventObservable&&i.onAnimationEventObservable.hasObservers()&&i.onAnimationEventObservable.notifyObservers(W)))}n._prevBlendingNormal=A}!0===n.animationLoopFrame&&(n.animationTime=0,n.animationNormal=0,n.animationLoopFrame=!1,n.animationLoopEvents=null)}}}}),this.finalizeAnimationTargets(t))},i.prototype.updateBlendableTargets=function(t,i,n,r,o,a,s,l,u){if(!0!==this.m_vertexAnimationMode&&null!=a&&null!=n.children&&n.children.length>0)for(var h=0;h<n.children.length;h++){var c=n.children[h];if(c.weight>0)if(c.type===e.MotionType.Clip){if(null!=c.track){var d=0,m=0,p=0,f=!1,g=0,y=!0,v=!0,S=!0,_=c.track;null!=_.metadata&&null!=_.metadata.toolkit&&(null!=_.metadata.toolkit.averagespeed&&(m=null!=_.metadata.toolkit.averagespeed.x?_.metadata.toolkit.averagespeed.x:0,p=null!=_.metadata.toolkit.averagespeed.z?_.metadata.toolkit.averagespeed.z:0),null!=_.metadata.toolkit.settings&&(d=null!=_.metadata.toolkit.settings.level?_.metadata.toolkit.settings.level:0,f=null!=_.metadata.toolkit.settings.loopblend&&_.metadata.toolkit.settings.loopblend,g=null!=_.metadata.toolkit.settings.orientationoffsety?_.metadata.toolkit.settings.orientationoffsety:0,y=null==_.metadata.toolkit.settings.loopblendorientation||_.metadata.toolkit.settings.loopblendorientation,v=null==_.metadata.toolkit.settings.loopblendpositiony||_.metadata.toolkit.settings.loopblendpositiony,S=null==_.metadata.toolkit.settings.loopblendpositionxz||_.metadata.toolkit.settings.loopblendpositionxz)),0===i.index&&(this._looptime=!0,this._loopblend=f),g=BABYLON.Tools.ToRadians(g),m=Math.abs(m),p=Math.abs(p),d*=-1;var b=c.track.targetedAnimations[o],B=!0===this._initialtargetblending?1:parseFloat(c.weight.toFixed(2));if(this._initialtargetblending=!1,b.target===r.target&&b.animation.targetProperty===r.animation.targetProperty){var C=s;c.timescale<0&&(C=1-C);var A=c.track.metadata.toolkit.length*C;if("position"===r.animation.targetProperty)this._targetPosition=e.Utilities.SampleAnimationVector3(b.animation,A,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE,!0),!0===l&&null!=this._rootBoneTransform?(this._positionWeight=!0,this._positionHolder.set(0,0,0),this._rootBoneWeight=!1,this._rootBoneHolder.set(0,0,0),!0===this.applyRootMotion?!0===v&&!0===S?(this._positionWeight=!0,this._positionHolder.set(this._targetPosition.x,this._targetPosition.y+d,this._targetPosition.z)):!1===v&&!1===S?(this._rootBoneWeight=!0,this._rootBoneHolder.set(this._targetPosition.x,this._targetPosition.y+d,this._targetPosition.z)):!0===v&&!1===S?(this._positionWeight=!0,this._positionHolder.set(this.m_zeroVector.x,this._targetPosition.y+d,this.m_zeroVector.z),this._rootBoneWeight=!0,this._rootBoneHolder.set(this._targetPosition.x,this.m_zeroVector.y,this._targetPosition.z)):!0===S&&!1===v&&(this._positionWeight=!0,this._positionHolder.set(this._targetPosition.x,this.m_zeroVector.y,this._targetPosition.z),this._rootBoneWeight=!0,this._rootBoneHolder.set(this.m_zeroVector.x,this._targetPosition.y+d,this.m_zeroVector.z)):(this._positionWeight=!0,this._positionHolder.set(this._targetPosition.x,this._targetPosition.y,this._targetPosition.z)),!0===this._positionWeight&&(null==a.positionBuffer&&(a.positionBuffer=new BABYLON.Vector3(0,0,0)),e.Utilities.BlendVector3Value(a.positionBuffer,this._positionHolder,B)),!0===this._rootBoneWeight&&(null==a.rootPosition&&(a.rootPosition=new BABYLON.Vector3(0,0,0)),e.Utilities.BlendVector3Value(a.rootPosition,this._rootBoneHolder,B))):(null==a.positionBuffer&&(a.positionBuffer=new BABYLON.Vector3(0,0,0)),e.Utilities.BlendVector3Value(a.positionBuffer,this._targetPosition,B));else if("rotationQuaternion"===r.animation.targetProperty)if(this._targetRotation=e.Utilities.SampleAnimationQuaternion(b.animation,A,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE,!0),!0===l&&null!=this._rootBoneTransform){this._rotationWeight=!1,this._rotationHolder.copyFrom(this.m_rotationIdentity),this._rootQuatWeight=!1,this._rootQuatHolder.copyFrom(this.m_rotationIdentity);var T=this._targetRotation.toEulerAngles(),M=T.y;!0===this.applyRootMotion?!0===y?(this._rotationWeight=!0,BABYLON.Quaternion.FromEulerAnglesToRef(T.x,M+g,T.z,this._rotationHolder)):(this._rotationWeight=!0,BABYLON.Quaternion.FromEulerAnglesToRef(T.x,this.m_zeroVector.y,T.z,this._rotationHolder),this._rootQuatWeight=!0,BABYLON.Quaternion.FromEulerAnglesToRef(this.m_zeroVector.x,M+g,this.m_zeroVector.z,this._rootQuatHolder)):(this._rotationWeight=!0,BABYLON.Quaternion.FromEulerAnglesToRef(T.x,M+g,T.z,this._rotationHolder)),!0===this._rotationWeight&&(null==a.rotationBuffer&&(a.rotationBuffer=new BABYLON.Quaternion(0,0,0,0)),e.Utilities.BlendQuaternionValue(a.rotationBuffer,this._rotationHolder,B)),!0===this._rootQuatWeight&&(null==a.rootRotation&&(a.rootRotation=new BABYLON.Quaternion(0,0,0,0)),e.Utilities.BlendQuaternionValue(a.rootRotation,this._rootQuatHolder,B))}else null==a.rotationBuffer&&(a.rotationBuffer=new BABYLON.Quaternion(0,0,0,0)),e.Utilities.BlendQuaternionValue(a.rotationBuffer,this._targetRotation,B);else"scaling"===r.animation.targetProperty&&(this._targetScaling=e.Utilities.SampleAnimationVector3(b.animation,A,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE,!0),null==a.scalingBuffer&&(a.scalingBuffer=new BABYLON.Vector3(1,1,1)),e.Utilities.BlendVector3Value(a.scalingBuffer,this._targetScaling,B))}}}else c.type===e.MotionType.Tree&&this.updateBlendableTargets(t,i,c.subtree,r,o,a,s,l,u)}},i.prototype.finalizeAnimationTargets=function(t){var i=this;if(!0!==this.m_vertexAnimationMode&&(this._deltaPosition.set(0,0,0),this._deltaRotation.set(0,0,0,0),this._angularVelocity.set(0,0,0),this._rootMotionSpeed=0,this._rootMotionMatrix.reset(),this._dirtyMotionMatrix=null,this._rootMotionPosition.set(0,0,0),this._rootMotionRotation.set(0,0,0,0),null!=this.m_animationTargets&&this.m_animationTargets.length>0&&this.m_animationTargets.forEach(function(t){var n=t.target;null!=n.metadata&&null!=n.metadata.mixer&&null!=i._machine.layers&&i._machine.layers.length>0&&(i._blenderMatrix.reset(),i._dirtyBlenderMatrix=null,i._machine.layers.forEach(function(t){var r=n.metadata.mixer[t.index];if(null!=r)if(n instanceof BABYLON.TransformNode){if(null==r.positionBuffer&&null==r.rotationBuffer&&null==r.scalingBuffer||(BABYLON.Matrix.ComposeToRef(r.scalingBuffer||n.scaling,r.rotationBuffer||n.rotationQuaternion,r.positionBuffer||n.position,i._updateMatrix),r.blendingSpeed>0&&(r.blendingFactor<=1&&null==r.originalMatrix&&(r.originalMatrix=BABYLON.Matrix.Compose(n.scaling,n.rotationQuaternion,n.position)),r.blendingFactor<=1&&null!=r.originalMatrix&&(e.Utilities.FastMatrixSlerp(r.originalMatrix,i._updateMatrix,r.blendingFactor,i._updateMatrix),r.blendingFactor+=r.blendingSpeed)),e.Utilities.FastMatrixSlerp(i._blenderMatrix,i._updateMatrix,t.defaultWeight,i._blenderMatrix),i._dirtyBlenderMatrix=!0,r.positionBuffer=null,r.rotationBuffer=null,r.scalingBuffer=null),i._emptyPosition.set(0,0,0),i._emptyRotation.set(0,0,0,0),i._emptyScaling.set(1,1,1),null!=r.rootPosition||null!=r.rootRotation){var o=i._emptyPosition,a=r.rootRotation?r.rootRotation.clone():i._emptyRotation,s=r.rootPosition?r.rootPosition.clone():i._emptyPosition;BABYLON.Matrix.ComposeToRef(o,a,s,i._updateMatrix),e.Utilities.FastMatrixSlerp(i._rootMotionMatrix,i._updateMatrix,t.defaultWeight,i._rootMotionMatrix),i._dirtyMotionMatrix=!0,r.rootPosition=null,r.rootRotation=null}}else n instanceof BABYLON.MorphTarget&&null!=r.influenceBuffer&&(n.influence=BABYLON.Scalar.Lerp(n.influence,r.influenceBuffer,t.defaultWeight),r.influenceBuffer=null)}),null!=i._dirtyBlenderMatrix&&i._blenderMatrix.decompose(n.scaling,n.rotationQuaternion,n.position))}),!0===this.applyRootMotion&&null!=this._dirtyMotionMatrix)){if(this._rootMotionMatrix.decompose(this._rootMotionScaling,this._rootMotionRotation,this._rootMotionPosition),!0===this.isFirstFrame())this._deltaPosition.copyFrom(this._rootMotionPosition),this._deltaRotation.copyFrom(this._rootMotionRotation);else if(!0===this.isLastFrame()){if(this._rootMotionPosition.subtractToRef(this._lastMotionPosition,this._deltaPosition),e.Utilities.QuaternionDiffToRef(this._rootMotionRotation,this._lastMotionRotation,this._deltaRotation),!0===this._looptime&&!0===this._loopblend){var n=this._loopMotionSpeed+this._lastMotionSpeed;0!==n&&(n/=2),this._deltaPosition.normalize(),this._deltaPosition.scaleInPlace(n*t);var r=this._loopRotateSpeed+this._lastRotateSpeed;0!==r&&(r/=2),this._deltaRotation.toEulerAnglesToRef(this._angularVelocity),BABYLON.Quaternion.FromEulerAnglesToRef(this._angularVelocity.x,r,this._angularVelocity.z,this._deltaRotation)}}else this._rootMotionPosition.subtractToRef(this._lastMotionPosition,this._deltaPosition),e.Utilities.QuaternionDiffToRef(this._rootMotionRotation,this._lastMotionRotation,this._deltaRotation);var o=this._deltaPosition.length();this._rootMotionSpeed=o>0?o/t:o,this._deltaRotation.toEulerAnglesToRef(this._angularVelocity),this._lastMotionPosition.copyFrom(this._rootMotionPosition),this._lastMotionRotation.copyFrom(this._rootMotionRotation),this._lastMotionSpeed=this._rootMotionSpeed,this._lastRotateSpeed=this._angularVelocity.y,0===this._frametime&&(this._loopMotionSpeed=this._rootMotionSpeed,this._loopRotateSpeed=this._angularVelocity.y)}},i.prototype.checkStateMachine=function(e,t){var i=this;if(this._checkers.result=null,this._checkers.offest=0,this._checkers.blending=0,this._checkers.duration=0,this._checkers.triggered=[],null!=e.animationStateMachine&&(e.animationStateMachine.time+=t,this.checkStateTransitions(e,e.animationStateMachine.transitions),null==this._checkers.result&&null!=this._machine.transitions&&this.checkStateTransitions(e,this._machine.transitions)),null!=this._checkers.triggered&&this._checkers.triggered.length>0&&(this._checkers.triggered.forEach(function(e){i.resetTrigger(e)}),this._checkers.triggered=null),null!=this._checkers.result){this.onAnimationTransitionObservable&&this.onAnimationTransitionObservable.hasObservers()&&this.onAnimationTransitionObservable.notifyObservers(this.transform);var n=!0===this.m_vertexAnimationMode?this._checkers.duration:this._checkers.blending;this.playCurrentAnimationState(e,this._checkers.result,n,this._checkers.offest)}},i.prototype.checkStateTransitions=function(t,i){var n=this,r=t.animationStateMachine.rate,o=t.animationStateMachine.length;if(null!=i&&i.length>0){var a=0,s=-1;for(a=0;a<i.length;a++)if(!0===i[a].solo&&!1===i[a].mute){s=a;break}var l=function(){var l=i[a];if(l.layerIndex!==t.index)return"continue";if(!0===l.mute)return"continue";if(s>=0&&s!==a)return"continue";var h=!1,c=0,d=!0;if(l.exitTime>0&&(c=o*l.exitTime/u.speedRatio,d=!0!==l.hasExitTime||t.animationStateMachine.time>=c),!0===l.hasExitTime&&l.intSource==e.InterruptionSource.None&&!1===d)return"continue";if(null!=l.conditions&&l.conditions.length>0){var m=0,p=l.conditions.length;l.conditions.forEach(function(t){var i=n._parameters.get(t.parameter);if(null!=i)if(i==e.AnimatorParameterType.Float||i==e.AnimatorParameterType.Int){var r=parseFloat(n.getFloat(t.parameter).toFixed(2));(t.mode===e.ConditionMode.Greater&&r>t.threshold||t.mode===e.ConditionMode.Less&&r<t.threshold||t.mode===e.ConditionMode.Equals&&r===t.threshold||t.mode===e.ConditionMode.NotEqual&&r!==t.threshold)&&m++}else if(i==e.AnimatorParameterType.Bool){var o=n.getBool(t.parameter);(t.mode===e.ConditionMode.If&&!0===o||t.mode===e.ConditionMode.IfNot&&!1===o)&&m++}else if(i==e.AnimatorParameterType.Trigger&&!0===n.getTrigger(t.parameter)){m++;for(var a=-1,s=0;s<n._checkers.triggered.length;s++)if(n._checkers.triggered[s]===t.parameter){a=s;break}a<0&&n._checkers.triggered.push(t.parameter)}}),h=!0===l.hasExitTime?!0===d&&m===p:m===p}else h=!0===l.hasExitTime&&!0===d;if(!0===h){!0===l.hasExitTime&&!0===d&&u.onAnimationEndObservable&&u.onAnimationEndObservable.hasObservers()&&u.onAnimationEndObservable.notifyObservers(t.index);var f=r>0?r:e.AnimationState.FPS,g=!1===l.isExit?l.destination:e.AnimationState.EXIT,y=!0===l.fixedDuration?l.duration:BABYLON.Scalar.Denormalize(l.duration,0,o),v=e.Utilities.ComputeBlendingSpeed(f,y),S=l.offset;return u._checkers.result=g,u._checkers.offest=S,u._checkers.blending=v,u._checkers.duration=y,"break"}},u=this;for(a=0;a<i.length&&"break"!==l();a++);}},i.prototype.playCurrentAnimationState=function(t,i,n,r){if(void 0===r&&(r=0),null!=t&&null!=i&&""!==i&&i!==e.AnimationState.EXIT&&(null==t.animationStateMachine||t.animationStateMachine.name!==i)){null!=this.m_animationTargets&&this.m_animationTargets.length>0&&this.m_animationTargets.forEach(function(e){var i=e.target;if(null!=i.metadata&&null!=i.metadata.mixer){var r=i.metadata.mixer[t.index];null!=r&&(r.originalMatrix=null,r.blendingFactor=0,r.blendingSpeed=n)}});var o=this.getMachineState(i);if(null!=o&&o.layerIndex===t.index&&(o.time=0,o.played=0,o.interrupted=!1,t.animationTime=BABYLON.Scalar.Clamp(r),t.animationNormal=0,t.animationFirstRun=!0,t.animationEndFrame=!1,t.animationLoopFrame=!1,t.animationLoopCount=0,t.animationLoopEvents=null,t.animationStateMachine=o,this._deltaPosition.set(0,0,0),this._deltaRotation.set(0,0,0,0),this._angularVelocity.set(0,0,0),this._rootMotionSpeed=0,this._rootMotionMatrix.reset(),this._dirtyMotionMatrix=null,this._rootMotionPosition.set(0,0,0),this._rootMotionRotation.set(0,0,0,0),this._lastMotionPosition.set(0,0,0),this._lastMotionRotation.set(0,0,0,0),!0===this.m_vertexAnimationMode&&null!=this.m_vertexAnimationController)){var a=this.m_vertexAnimationController.currentClip;n>0&&null!=a?(t.vatTransitionActive=!0,t.vatTransitionElapsed=0,t.vatTransitionDuration=n,t.vatSourceClipName=a.name,t.vatSourceTimeSec=this.m_vertexAnimationController.currentTime):(t.vatTransitionActive=!1,t.vatTransitionElapsed=0,t.vatTransitionDuration=0,t.vatSourceClipName=null,t.vatSourceTimeSec=0)}}},i.prototype.stopCurrentAnimationState=function(e){null!=e&&(null!=this.m_animationTargets&&this.m_animationTargets.length>0&&this.m_animationTargets.forEach(function(t){var i=t.target;if(null!=i.metadata&&null!=i.metadata.mixer){var n=i.metadata.mixer[e.index];null!=n&&(n.originalMatrix=null,n.blendingFactor=0,n.blendingSpeed=0)}}),e.animationTime=0,e.animationNormal=0,e.animationFirstRun=!0,e.animationEndFrame=!1,e.animationLoopFrame=!1,e.animationLoopCount=0,e.animationLoopEvents=null,e.animationStateMachine=null,this._deltaPosition.set(0,0,0),this._deltaRotation.set(0,0,0,0),this._angularVelocity.set(0,0,0),this._rootMotionSpeed=0,this._rootMotionMatrix.reset(),this._dirtyMotionMatrix=null,this._rootMotionPosition.set(0,0,0),this._rootMotionRotation.set(0,0,0,0),this._lastMotionPosition.set(0,0,0),this._lastMotionRotation.set(0,0,0,0),!0===this.m_vertexAnimationMode&&null!=this.m_vertexAnimationController&&(this.m_vertexAnimationController.stop(),e.vatTransitionActive=!1,e.vatTransitionElapsed=0,e.vatTransitionDuration=0,e.vatSourceClipName=null,e.vatSourceTimeSec=0))},i.prototype.checkAvatarTransformPath=function(e,t){var i=!1;if(null!=e.animationMaskMap){var n=e.animationMaskMap.get(t);null!=n&&n>=0&&(i=!0)}return i},i.prototype.filterTargetAvatarMask=function(e,t){var i=!1;if(null!=t.metadata&&null!=t.metadata.toolkit&&null!=t.metadata.toolkit.bone&&""!==t.metadata.toolkit.bone){var n=t.metadata.toolkit.bone;i=this.checkAvatarTransformPath(e,n)}return i},i.prototype.sortWeightedBlendingList=function(e){null!=e&&e.length>0&&e.sort(function(e,t){return e.weight<t.weight?1:e.weight>t.weight?-1:0})},i.prototype.computeWeightedFrameRatio=function(e){var t=1;if(null!=e&&e.length>0)if(this.sortWeightedBlendingList(e),this._blendWeights.primary=e[0],this._blendWeights.primary.weight<1&&e.length>1&&(this._blendWeights.secondary=e[1]),null!=this._blendWeights.primary&&null!=this._blendWeights.secondary){var i=BABYLON.Scalar.Clamp(this._blendWeights.primary.weight);t=BABYLON.Scalar.Lerp(this._blendWeights.secondary.ratio,this._blendWeights.primary.ratio,i)}else null!=this._blendWeights.primary&&null==this._blendWeights.secondary&&(t=this._blendWeights.primary.ratio);return t},i.prototype.getFirstMotion=function(t){var i;if(!(null===(i=null==t?void 0:t.children)||void 0===i?void 0:i.length))return null;for(var n=0,r=t.children;n<r.length;n++){var o=r[n];if(o.type===e.MotionType.Clip)return o.motion;if(o.type===e.MotionType.Tree){var a=this.getFirstMotion(o.subtree);if(null!=a)return a}}return null},i.prototype.getLastMotion=function(t){var i;if(!(null===(i=null==t?void 0:t.children)||void 0===i?void 0:i.length))return null;for(var n=t.children.length-1;n>=0;n--){var r=t.children[n];if(r.type===e.MotionType.Clip)return r.motion;if(r.type===e.MotionType.Tree){var o=this.getLastMotion(r.subtree);if(null!=o)return o}}return null},i.prototype.setupTreeBranches=function(t){var i=this;null!=t&&null!=t.children&&t.children.length>0&&t.children.forEach(function(t){if(t.type===e.MotionType.Tree)i.setupTreeBranches(t.subtree);else if(t.type===e.MotionType.Clip&&null!=t.motion&&""!==t.motion&&(t.weight=0,t.ratio=0,t.track=i.getAnimationGroup(t.motion),null!=t.track)){var n=t.track.metadata.toolkit.length;t.ratio=e.AnimationState.TIME/n}})},i.prototype.parseTreeBranches=function(t,i,n,r){if(null!=i)switch(i.valueParameterX=null!=i.blendParameterX?parseFloat(this.getFloat(i.blendParameterX).toFixed(2)):0,i.valueParameterY=null!=i.blendParameterY?parseFloat(this.getFloat(i.blendParameterY).toFixed(2)):0,i.blendType){case e.BlendTreeType.Simple1D:this.parse1DSimpleTreeBranches(t,i,n,r);break;case e.BlendTreeType.SimpleDirectional2D:this.parse2DSimpleDirectionalTreeBranches(t,i,n,r);break;case e.BlendTreeType.FreeformDirectional2D:this.parse2DFreeformDirectionalTreeBranches(t,i,n,r);break;case e.BlendTreeType.FreeformCartesian2D:this.parse2DFreeformCartesianTreeBranches(t,i,n,r)}},i.prototype.parse1DSimpleTreeBranches=function(t,i,n,r){var o=this;if(null!=i&&null!=i.children&&i.children.length>0){var a=[];i.children.forEach(function(e){e.weight=0;var t={source:e,motion:e.motion,posX:e.threshold,posY:e.threshold,weight:e.weight};a.push(t)}),e.BlendTreeSystem.Calculate1DSimpleBlendTree(i.valueParameterX,a),a.forEach(function(e){null!=e.source&&(e.source.weight=e.weight)}),i.children.forEach(function(i){i.weight*=n,i.type===e.MotionType.Clip&&i.weight>0&&r.push(i),i.type===e.MotionType.Tree&&o.parseTreeBranches(t,i.subtree,i.weight,r)})}},i.prototype.parse2DSimpleDirectionalTreeBranches=function(t,i,n,r){var o=this;if(null!=i&&null!=i.children&&i.children.length>0){var a=[];i.children.forEach(function(e){e.weight=0;var t={source:e,motion:e.motion,posX:e.positionX,posY:e.positionY,weight:e.weight};a.push(t)}),e.BlendTreeSystem.Calculate2DFreeformDirectional(i.valueParameterX,i.valueParameterY,a),a.forEach(function(e){null!=e.source&&(e.source.weight=e.weight)}),i.children.forEach(function(i){i.weight*=n,i.type===e.MotionType.Clip&&i.weight>0&&r.push(i),i.type===e.MotionType.Tree&&o.parseTreeBranches(t,i.subtree,i.weight,r)})}},i.prototype.parse2DFreeformDirectionalTreeBranches=function(t,i,n,r){var o=this;if(null!=i&&null!=i.children&&i.children.length>0){var a=[];i.children.forEach(function(e){e.weight=0;var t={source:e,motion:e.motion,posX:e.positionX,posY:e.positionY,weight:e.weight};a.push(t)}),e.BlendTreeSystem.Calculate2DFreeformDirectional(i.valueParameterX,i.valueParameterY,a),a.forEach(function(e){null!=e.source&&(e.source.weight=e.weight)}),i.children.forEach(function(i){i.weight*=n,i.type===e.MotionType.Clip&&i.weight>0&&r.push(i),i.type===e.MotionType.Tree&&o.parseTreeBranches(t,i.subtree,i.weight,r)})}},i.prototype.parse2DFreeformCartesianTreeBranches=function(t,i,n,r){var o=this;if(null!=i&&null!=i.children&&i.children.length>0){var a=[];i.children.forEach(function(e){e.weight=0;var t={source:e,motion:e.motion,posX:e.positionX,posY:e.positionY,weight:e.weight};a.push(t)}),e.BlendTreeSystem.Calculate2DFreeformCartesian(i.valueParameterX,i.valueParameterY,a),a.forEach(function(e){null!=e.source&&(e.source.weight=e.weight)}),i.children.forEach(function(i){i.weight*=n,i.type===e.MotionType.Clip&&i.weight>0&&r.push(i),i.type===e.MotionType.Tree&&o.parseTreeBranches(t,i.subtree,i.weight,r)})}},i.FPS=30,i.EXIT="[EXIT]",i.TIME=1,i}(e.ScriptComponent);e.AnimationState=t;e.BlendTreeValue=function(e){this.source=e.source,this.motion=e.motion,this.posX=e.posX||0,this.posY=e.posY||0,this.weight=e.weight||0};var i=function(){function e(){}return e.ClampValue=function(e,t,i){return e<=t?t:e>=i?i: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,i,n,r){return t+(n-t)/(i-e)*(r-e)},e.GetRightNeighbourIndex=function(e,t){t.sort(function(e,t){return e.posX-t.posX});for(var i=0;i<t.length;++i)if(t[i].posX>e)return i;return-1},e}();e.BlendTreeUtils=i;var n=function(){function t(){}return t.Calculate1DSimpleBlendTree=function(t,i){var n=i[0],r=i[i.length-1];if(t<=n.posX)n.weight=1;else if(t>=r.posX)r.weight=1;else{var o=e.BlendTreeUtils.GetRightNeighbourIndex(t,i),a=i[o-1],s=i[o],l=e.BlendTreeUtils.GetLinearInterpolation(a.posX,1,s.posX,0,t);a.weight=l,s.weight=1-a.weight}},t.Calculate2DFreeformDirectional=function(t,i,n){e.BlendTreeSystem.TempVector2_IP.set(t,i),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 r=0,o=e.BlendTreeSystem.TempVector2_IP.length(),a=0;a<n.length;++a){var s=n[a];e.BlendTreeSystem.TempVector2_POSI.set(s.posX,s.posY);for(var l=e.BlendTreeSystem.TempVector2_POSI.length(),u=o-l,h=e.BlendTreeUtils.GetSignedAngle(e.BlendTreeSystem.TempVector2_POSI,e.BlendTreeSystem.TempVector2_IP),c=1,d=0;d<n.length;++d)if(d!==a){e.BlendTreeSystem.TempVector2_POSJ.set(n[d].posX,n[d].posY);var m=e.BlendTreeSystem.TempVector2_POSJ.length(),p=(l+m)/2,f=u/p,g=(m-l)/p,y=e.BlendTreeUtils.GetSignedAngle(e.BlendTreeSystem.TempVector2_POSI,e.BlendTreeSystem.TempVector2_POSJ);e.BlendTreeSystem.TempVector2_POSIP.set(f,2*h),e.BlendTreeSystem.TempVector2_POSIJ.set(g,2*y);var v=e.BlendTreeSystem.TempVector2_POSIJ.lengthSquared(),S=BABYLON.Vector2.Dot(e.BlendTreeSystem.TempVector2_POSIP,e.BlendTreeSystem.TempVector2_POSIJ)/v;S=1-S,S=e.BlendTreeUtils.ClampValue(S,0,1),c=Math.min(S,c)}s.weight=c,r+=c}for(var _=0,b=n;_<b.length;_++)(s=b[_]).weight/=r},t.Calculate2DFreeformCartesian=function(t,i,n){e.BlendTreeSystem.TempVector2_IP.set(t,i),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 r=0,o=0;o<n.length;++o){var a=n[o];e.BlendTreeSystem.TempVector2_POSI.set(a.posX,a.posY),e.BlendTreeSystem.TempVector2_IP.subtractToRef(e.BlendTreeSystem.TempVector2_POSI,e.BlendTreeSystem.TempVector2_POSIP);for(var s=1,l=0;l<n.length;++l)if(l!==o){e.BlendTreeSystem.TempVector2_POSJ.set(n[l].posX,n[l].posY),e.BlendTreeSystem.TempVector2_POSJ.subtractToRef(e.BlendTreeSystem.TempVector2_POSI,e.BlendTreeSystem.TempVector2_POSIJ);var u=e.BlendTreeSystem.TempVector2_POSIJ.lengthSquared(),h=BABYLON.Vector2.Dot(e.BlendTreeSystem.TempVector2_POSIP,e.BlendTreeSystem.TempVector2_POSIJ)/u;h=1-h,h=e.BlendTreeUtils.ClampValue(h,0,1),s=Math.min(s,h)}a.weight=s,r+=s}for(var c=0,d=n;c<d.length;c++)(a=d[c]).weight/=r},t.TempVector2_IP=new BABYLON.Vector2(0,0),t.TempVector2_POSI=new BABYLON.Vector2(0,0),t.TempVector2_POSJ=new BABYLON.Vector2(0,0),t.TempVector2_POSIP=new BABYLON.Vector2(0,0),t.TempVector2_POSIJ=new BABYLON.Vector2(0,0),t}();e.BlendTreeSystem=n;e.MachineState=function(){};e.TransitionCheck=function(){};e.AnimationMixer=function(){};var r,a,s,l,u,h;e.BlendingWeights=function(){},(h=e.MotionType||(e.MotionType={}))[h.Clip=0]="Clip",h[h.Tree=1]="Tree",(u=e.ConditionMode||(e.ConditionMode={}))[u.If=1]="If",u[u.IfNot=2]="IfNot",u[u.Greater=3]="Greater",u[u.Less=4]="Less",u[u.Equals=6]="Equals",u[u.NotEqual=7]="NotEqual",(l=e.InterruptionSource||(e.InterruptionSource={}))[l.None=0]="None",l[l.Source=1]="Source",l[l.Destination=2]="Destination",l[l.SourceThenDestination=3]="SourceThenDestination",l[l.DestinationThenSource=4]="DestinationThenSource",(s=e.BlendTreeType||(e.BlendTreeType={}))[s.Simple1D=0]="Simple1D",s[s.SimpleDirectional2D=1]="SimpleDirectional2D",s[s.FreeformDirectional2D=2]="FreeformDirectional2D",s[s.FreeformCartesian2D=3]="FreeformCartesian2D",s[s.Direct=4]="Direct",s[s.Clip=5]="Clip",(a=e.BlendTreePosition||(e.BlendTreePosition={}))[a.Lower=0]="Lower",a[a.Upper=1]="Upper",(r=e.AnimatorParameterType||(e.AnimatorParameterType={}))[r.Float=1]="Float",r[r.Int=3]="Int",r[r.Bool=4]="Bool",r[r.Trigger=9]="Trigger",e.SceneManager.RegisterClass("TOOLKIT.AnimationState",t)}(n||(n={})),function(e){var t=function(t){function i(e,i,n,r){void 0===n&&(n={}),void 0===r&&(r="TOOLKIT.AudioSource");var o=t.call(this,e,i,n,r)||this;return o._audio=null,o._name=null,o._loop=!1,o._mute=!1,o._pitch=1,o._volume=1,o._preload=!1,o._playonawake=!0,o._spatialblend=0,o._preloaderUrl=null,o._lastmutedvolume=null,o._priority=128,o._panstereo=0,o._mindistance=1,o._maxdistance=200,o._reverbzonemix=1,o._bypasseffects=!1,o._bypassreverbzones=!1,o._bypasslistenereffects=!1,o._initializedReadyInstance=!1,o._isAudioPlaying=!1,o._isAudioPaused=!1,o._isAudioSpatial=!1,o.onReadyObservable=new BABYLON.Observable,o}return o(i,t),i.prototype.getSoundClip=function(){return this._audio},i.prototype.awake=function(){this.awakeAudioSource()},i.prototype.start=function(){this.startAudioSource()},i.prototype.after=function(){this.updateAudioSource()},i.prototype.destroy=function(){this.destroyAudioSource()},i.prototype.awakeAudioSource=function(){return s(this,void 0,void 0,function(){var t,i,n;return l(this,function(r){switch(r.label){case 0:return this._name=this.getProperty("name",this._name),this._loop=this.getProperty("loop",this._loop),this._mute=this.getProperty("mute",this._mute),this._pitch=this.getProperty("pitch",this._pitch),this._volume=this.getProperty("volume",this._volume),this._preload=this.getProperty("preload",this._preload),this._priority=this.getProperty("priority",this._priority),this._panstereo=this.getProperty("panstereo",this._panstereo),this._playonawake=this.getProperty("playonawake",this._playonawake),this._mindistance=this.getProperty("mindistance",this._mindistance),this._maxdistance=this.getProperty("maxdistance",this._maxdistance),this._spatialblend=this.getProperty("spatialblend",this._spatialblend),this._reverbzonemix=this.getProperty("reverbzonemix",this._reverbzonemix),this._bypasseffects=this.getProperty("bypasseffects",this._bypasseffects),this._bypassreverbzones=this.getProperty("bypassreverbzones",this._bypassreverbzones),this._bypasslistenereffects=this.getProperty("bypasslistenereffects",this._bypasslistenereffects),null!=this._name&&""!==this._name||(this._name="Unknown"),null==(t=this.getProperty("file"))||""===t?[3,4]:(i=e.SceneManager.GetRootUrl(this.scene),null==(n=i+t)||""===n?[3,4]:!0!==this._preload?[3,1]:(this._preloaderUrl=n,[3,4]));case 1:return this.isLegacy()?(this.setLegacyDataSource(n),[3,4]):[3,2];case 2:return[4,this.setAudioDataSource(n)];case 3:r.sent(),r.label=4;case 4:return[2]}})})},i.prototype.startAudioSource=function(){this._volume>=e.AudioSource.MAX_VOLUME&&(this._volume=e.AudioSource.DEFAULT_LEVEL)},i.prototype.updateAudioSource=function(){return s(this,void 0,void 0,function(){return l(this,function(e){return!0===this._isAudioSpatial&&(this._audio,BABYLON.StaticSound),[2]})})},i.prototype.destroyAudioSource=function(){this.onReadyObservable.clear(),this.onReadyObservable=null,null!=this._audio&&(this._audio.dispose(),this._audio=null)},i.prototype.isLegacy=function(){return!!BABYLON.Engine.audioEngine},i.prototype.isReady=function(){return null!=this._audio},i.prototype.isPlaying=function(){return this._isAudioPlaying},i.prototype.isPaused=function(){return this._isAudioPaused},i.prototype.play=function(t,i,n){return s(this,void 0,void 0,function(){return l(this,function(r){switch(r.label){case 0:return[4,e.AudioSource.UnlockAudioEngine()];case 1:return r.sent(),this.internalPlay(t,i,n),[2,!0]}})})},i.prototype.internalPlay=function(e,t,i){var n=this;null!=this._audio&&(!0===this._initializedReadyInstance?(this._audio instanceof BABYLON.StaticSound?this._audio.play({waitTime:e,startOffset:t,duration:i}):this._audio instanceof BABYLON.Sound&&this._audio.play(e,t,i),this._isAudioPlaying=!0,this._isAudioPaused=!1):this.onReadyObservable.addOnce(function(){n._audio instanceof BABYLON.StaticSound?n._audio.play({waitTime:e,startOffset:t,duration:i}):n._audio instanceof BABYLON.Sound&&n._audio.play(e,t,i),n._isAudioPlaying=!0,n._isAudioPaused=!1}))},i.prototype.pause=function(){var e=!1;return null!=this._audio&&(this._audio.pause(),this._isAudioPlaying=!1,this._isAudioPaused=!0,e=!0),e},i.prototype.stop=function(e){var t=!1;return null!=this._audio&&(this._audio instanceof BABYLON.StaticSound?this._audio.stop({waitTime:e}):this._audio instanceof BABYLON.Sound&&this._audio.stop(e),this._isAudioPlaying=!1,this._isAudioPaused=!1,t=!0),t},i.prototype.mute=function(t){var i=this,n=!1;return null!=this._audio&&(this._audio instanceof BABYLON.StaticSound?null!=t&&t>0?e.WindowManager.SetTimeout(t/1e3,function(){i._lastmutedvolume=i._audio.volume,i._audio.volume=0}):(this._lastmutedvolume=this._audio.volume,this._audio.volume=0):this._audio instanceof BABYLON.Sound&&(this._lastmutedvolume=this._audio.getVolume(),this._audio.setVolume(0,t)),n=!0),n},i.prototype.unmute=function(t){var i=this,n=!1;return null!=this._audio&&(this._audio instanceof BABYLON.StaticSound?null!=t&&t>0?e.WindowManager.SetTimeout(t/1e3,function(){null!=i._lastmutedvolume&&(i._audio.volume=i._lastmutedvolume,i._lastmutedvolume=null)}):null!=this._lastmutedvolume&&(this._audio.volume=this._lastmutedvolume,this._lastmutedvolume=null):this._audio instanceof BABYLON.Sound&&null!=this._lastmutedvolume&&(this._audio.setVolume(this._lastmutedvolume,t),this._lastmutedvolume=null),n=!0),n},i.prototype.getPitch=function(){return null==this._audio?0:this._audio instanceof BABYLON.StaticSound?this._audio.playbackRate:this._audio instanceof BABYLON.Sound?this._audio.getPlaybackRate():void 0},i.prototype.setPitch=function(e){null!=this._audio&&(this._audio instanceof BABYLON.StaticSound?this._audio.playbackRate=e:this._audio instanceof BABYLON.Sound&&this._audio.setPlaybackRate(e))},i.prototype.getVolume=function(){var e=0;return null!=this._audio?this._audio instanceof BABYLON.StaticSound?e=this._audio.volume:this._audio instanceof BABYLON.Sound&&(e=this._audio.getVolume()):e=this._volume,e},i.prototype.setVolume=function(t,i){var n=this;return this._volume=t,null!=this._audio&&(this._audio instanceof BABYLON.StaticSound?null!=i&&i>0?e.WindowManager.SetTimeout(i/1e3,function(){n._audio.volume=n._volume}):this._audio.volume=this._volume:this._audio instanceof BABYLON.Sound&&this._audio.setVolume(this._volume,i)),!0},i.prototype.setPosition=function(e){this._audio instanceof BABYLON.StaticSound?null!=this._audio.spatial&&(this._audio.spatial.position=e):this._audio instanceof BABYLON.Sound&&this._audio.setPosition(e)},i.prototype.getPlaybackSpeed=function(){return null==this._audio?0:this._audio instanceof BABYLON.StaticSound?this._audio.playbackRate:this._audio instanceof BABYLON.Sound?this._audio.getPlaybackRate():void 0},i.prototype.setPlaybackSpeed=function(e){null!=this._audio&&(this._audio instanceof BABYLON.StaticSound?this._audio.playbackRate=e:this._audio instanceof BABYLON.Sound&&this._audio.setPlaybackRate(e))},i.prototype.setRolloffMode=function(e){null!=this._audio&&(this._audio instanceof BABYLON.StaticSound&&("linear"===e||"inverse"===e||"exponential"===e)?null!=this._audio.spatial&&(this._audio.spatial.distanceModel=e):(this._audio,BABYLON.Sound))},i.prototype.setMinDistance=function(e){null!=this._audio&&(this._audio instanceof BABYLON.StaticSound?null!=this._audio.spatial&&(this._audio.spatial.minDistance=Math.max(1,e)):this._audio instanceof BABYLON.Sound&&(this._audio.refDistance=e))},i.prototype.setMaxDistance=function(e){null!=this._audio&&(this._audio instanceof BABYLON.StaticSound?null!=this._audio.spatial&&(this._audio.spatial.maxDistance=e):this._audio instanceof BABYLON.Sound&&(this._audio.maxDistance=e))},i.prototype.setSpatialBlend=function(e){null!=this._audio&&(this._audio instanceof BABYLON.StaticSound||(this._audio,BABYLON.Sound))},i.prototype.hasSpatialSound=function(){var e=!1;return null!=this._audio&&(this._audio instanceof BABYLON.StaticSound?e=null!=this._audio.spatial:this._audio instanceof BABYLON.Sound&&(e=this._audio.spatialSound)),e},i.prototype.getSpatialSound=function(){var e=null;return null!=this._audio&&this._audio instanceof BABYLON.StaticSound&&(e=this._audio.spatial),e},i.prototype.attachToSpatialNode=function(e){null!=this._audio&&(this._audio instanceof BABYLON.StaticSound?null!=this._audio.spatial&&this._audio.spatial.attach(e,!0,BABYLON.SpatialAudioAttachmentType.PositionAndRotation):this._audio instanceof BABYLON.Sound&&this._audio.attachToMesh(e),this._isAudioSpatial=!0)},i.prototype.getCurrentTrackTime=function(){var e=0;return null!=this._audio&&(e=this._audio.currentTime),e},i.prototype.setAudioDataSource=function(t){return s(this,void 0,void 0,function(){var i,n,r;return l(this,function(o){switch(o.label){case 0:return null!=this._audio&&(this._audio.dispose(),this._audio=null),i=this._spatialblend>=.1,this._initializedReadyInstance=!1,this._lastmutedvolume=this._volume,n={loop:this._loop,volume:!0===this._mute?0:this._volume,autoplay:!1,autoUpdate:!0,playbackRate:this._pitch,spatialEnabled:i,spatialAutoUpdate:!0,spatialPosition:new BABYLON.Vector3(0,0,0),spatialRotationQuaternion:new BABYLON.Quaternion(0,0,0,1),spatialPanningModel:"equalpower",spatialDistanceModel:"linear",spatialMinDistance:this._mindistance,spatialMaxDistance:this._maxdistance,spatialRolloffFactor:e.AudioSource.DEFAULT_ROLLOFF,spatialConeInnerAngle:360,spatialConeOuterAngle:360},r=this,[4,e.AudioSource.CreateStaticSound(this._name,t,n)];case 1:return r._audio=o.sent(),null!=this._audio&&(this._initializedReadyInstance=!0,!0===i&&null!=this._audio.spatial&&(this._audio.spatial.position=new BABYLON.Vector3(0,0,0),this._audio.spatial.rotationQuaternion=new BABYLON.Quaternion(0,0,0,1),this._audio.spatial.panningModel="equalpower",this._audio.spatial.distanceModel="linear",this._audio.spatial.minDistance=this._mindistance,this._audio.spatial.maxDistance=this._maxdistance,this._audio.spatial.rolloffFactor=e.AudioSource.DEFAULT_ROLLOFF,this._audio.spatial.coneInnerAngle=360,this._audio.spatial.coneOuterAngle=360,this._audio.spatial.attach(this.transform,!0,BABYLON.SpatialAudioAttachmentType.PositionAndRotation),this._isAudioSpatial=!0),this.onReadyObservable&&this.onReadyObservable.hasObservers()&&this.onReadyObservable.notifyObservers(this._audio),!0===this._playonawake&&this.play()),[2]}})})},i.prototype.setLegacyDataSource=function(t){var i=this;null!=this._audio&&(this._audio.dispose(),this._audio=null);var n=this._spatialblend>=.1,r=null!=this.transform.metadata&&null!=this.transform.metadata.vtt&&!0===this.transform.metadata.vtt;this._initializedReadyInstance=!1,this._audio=new BABYLON.Sound(this._name,t,this.scene,function(){i._lastmutedvolume=i._volume,i._audio.setVolume(!0===i._mute?0:i._volume),i._audio.setPlaybackRate(i._pitch),i._audio.setPosition(i.transform.absolutePosition.clone()),i._initializedReadyInstance=!0,!0===n&&i._audio instanceof BABYLON.Sound&&(i._isAudioSpatial=!0,i._audio.attachToMesh(i.transform)),i.onReadyObservable&&i.onReadyObservable.hasObservers()&&i.onReadyObservable.notifyObservers(i._audio),!0===i._playonawake&&i.play()},{loop:this._loop,autoplay:!1,refDistance:this._mindistance,maxDistance:this._maxdistance,rolloffFactor:e.AudioSource.DEFAULT_ROLLOFF,spatialSound:n,distanceModel:"linear",streaming:r})},i.prototype.addPreloaderTasks=function(e){var t=this;!0===this._preload&&(e.addBinaryFileTask(this.transform.name+".AudioTask",this._preloaderUrl).onSuccess=function(e){return s(t,void 0,void 0,function(){return l(this,function(t){switch(t.label){case 0:return this.isLegacy()?(this.setLegacyDataSource(e.data),[3,3]):[3,1];case 1:return[4,this.setAudioDataSource(e.data)];case 2:t.sent(),t.label=3;case 3:return[2]}})})})},i.IsLegacyEngine=function(){return!!BABYLON.Engine.audioEngine},i.GetAudioOptions=function(){return e.AudioSource.AUDIO_ENGINE_V2_OPTIONS},i.SetAudioOptions=function(t){e.AudioSource.AUDIO_ENGINE_V2_OPTIONS=t},i.GetAudioEngine=function(){return s(this,void 0,void 0,function(){var t;return l(this,function(i){switch(i.label){case 0:return null!=e.AudioSource.AUDIO_ENGINE_V2?[3,2]:(t=e.AudioSource,[4,BABYLON.CreateAudioEngineAsync(e.AudioSource.AUDIO_ENGINE_V2_OPTIONS||{listenerAutoUpdate:!0,listenerEnabled:!0,resumeOnInteraction:!0,resumeOnPause:!0})]);case 1:t.AUDIO_ENGINE_V2=i.sent(),i.label=2;case 2:return[2,e.AudioSource.AUDIO_ENGINE_V2]}})})},i.UnlockLegacyAudio=function(){null==BABYLON.Engine.audioEngine||BABYLON.Engine.audioEngine.unlocked||BABYLON.Engine.audioEngine.unlock()},i.UnlockAudioEngine=function(){return s(this,void 0,void 0,function(){var t;return l(this,function(i){switch(i.label){case 0:return[4,e.AudioSource.GetAudioEngine()];case 1:return null==(t=i.sent())?[3,3]:[4,t.unlockAsync()];case 2:i.sent(),i.label=3;case 3:return[2]}})})},i.AttachSpatialCamera=function(t){return s(this,void 0,void 0,function(){var i;return l(this,function(n){switch(n.label){case 0:return null==t?(console.warn("TOOLKIT.AudioSource.AttachSpatialCamera: No node provided to attach spatial audio listener to."),[2]):[4,e.AudioSource.GetAudioEngine()];case 1:return null!=(i=n.sent())&&null!=i.listener&&i.listener.attach(t,!0,BABYLON.SpatialAudioAttachmentType.PositionAndRotation),[2]}})})},i.DetachSpatialCamera=function(){return s(this,void 0,void 0,function(){var t;return l(this,function(i){switch(i.label){case 0:return[4,e.AudioSource.GetAudioEngine()];case 1:return null!=(t=i.sent())&&null!=t.listener&&t.listener.detach(),[2]}})})},i.CreateSoundBuffer=function(t,i){return s(this,void 0,void 0,function(){var n,r;return l(this,function(o){switch(o.label){case 0:return n=null,[4,e.AudioSource.GetAudioEngine()];case 1:return null==(r=o.sent())?[3,3]:[4,r.createSoundBufferAsync(t,i)];case 2:n=o.sent(),o.label=3;case 3:return[2,n]}})})},i.CreateStaticSound=function(t,i,n){return s(this,void 0,void 0,function(){var r,o;return l(this,function(a){switch(a.label){case 0:return r=null,[4,e.AudioSource.GetAudioEngine()];case 1:return null==(o=a.sent())?[3,3]:[4,o.createSoundAsync(t,i,n)];case 2:r=a.sent(),a.label=3;case 3:return[2,r]}})})},i.CreateStreamingSound=function(t,i,n){return s(this,void 0,void 0,function(){var r,o;return l(this,function(a){switch(a.label){case 0:return r=null,[4,e.AudioSource.GetAudioEngine()];case 1:return null==(o=a.sent())?[3,3]:[4,o.createStreamingSoundAsync(t,i,n)];case 2:r=a.sent(),a.label=3;case 3:return[2,r]}})})},i.MAX_VOLUME=1,i.DEFAULT_LEVEL=1,i.DEFAULT_ROLLOFF=1,i.AUDIO_ENGINE_V2=null,i.AUDIO_ENGINE_V2_OPTIONS={listenerAutoUpdate:!0,listenerEnabled:!0,resumeOnInteraction:!0,resumeOnPause:!0},i}(e.ScriptComponent);e.AudioSource=t,e.SceneManager.RegisterClass("TOOLKIT.AudioSource",t)}(n||(n={})),function(e){var t=function(){function e(){}return e.CreatePostProcess=function(e,t,i){var n=i||{},r=n.red||[1,0,0],o=n.green||[0,1,0],a=n.blue||[0,0,1],s=new BABYLON.PostProcess("channelMixer","\n precision highp float;\n varying vec2 vUV;\n uniform sampler2D textureSampler;\n uniform vec3 redMix;\n uniform vec3 greenMix;\n uniform vec3 blueMix;\n\n void main(void) {\n vec4 sceneColor = texture2D(textureSampler, vUV);\n vec3 rgb = sceneColor.rgb;\n float newR = dot(rgb, redMix);\n float newG = dot(rgb, greenMix);\n float newB = dot(rgb, blueMix);\n gl_FragColor = vec4(newR, newG, newB, sceneColor.a);\n }\n ",["redMix","greenMix","blueMix"],[],1,t,BABYLON.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1);return s.onApply=function(e){e.setFloat3("redMix",r[0]||1,r[1]||0,r[2]||0),e.setFloat3("greenMix",o[0]||0,o[1]||1,o[2]||0),e.setFloat3("blueMix",a[0]||0,a[1]||0,a[2]||1)},s},e}();e.ChannelMixerPlugin=t}(n||(n={})),function(e){var t=function(t){function i(e,i,n,r){void 0===n&&(n={}),void 0===r&&(r="TOOLKIT.CharacterController");var o=t.call(this,e,i,n,r)||this;return o._avatarRadius=.28,o._avatarHeight=1.8,o._centerOffset=new BABYLON.Vector3(0,.94,0),o._slopeLimit=45,o._skinWidth=.025,o._stepHeight=.25,o._minMoveDistance=.001,o._verticalVelocity=0,o._currentSlopeAngle=0,o._collisionEvents=!0,o._targetRotation=new BABYLON.Quaternion(0,0,0,1),o._targetVelocity=new BABYLON.Vector3,o._currentVelocity=new BABYLON.Vector3(0,0,0),o._inputVelocity=new BABYLON.Vector3(0,0,0),o._stepUpVelocity=0,o._gravityFactor=3,o._minJumpTimer=0,o._isGrounded=!1,o._groundContacts=new Map,o._groundContactInfo=null,o._groundedEnterTimer=0,o._groundedExitTimer=0,o._raycastResult=new BABYLON.PhysicsRaycastResult,o._rayOrigin=new BABYLON.Vector3,o._rayTarget=new BABYLON.Vector3,o._previousGroundHeight=0,o._stepDetectionDistance=.5,o.m_moveDeltaX=0,o.m_moveDeltaY=0,o.m_moveDeltaZ=0,o.m_havokplugin=null,o.onUpdatePositionObservable=new BABYLON.Observable,o.onUpdateVelocityObservable=new BABYLON.Observable,o.enableUpdate=!0,o.enableGravity=!1,o.enableStepOffset=!1,o.useMultiRaycast=!1,o.multiRaycastCount=5,o.groundCheckDistance=.25,o.stepUpVelocityFactor=.5,o.defaultJumpingTimer=.5,o.onlyApplyGravityWhenNotGrounded=!1,o.downwardVelocityClamp=-2,o.contactHysteresisTime=.15,o.groundedEnterTime=.03,o.groundedExitTime=.1,o}return o(i,t),i.prototype.getAvatarRadius=function(){return this._avatarRadius},i.prototype.getAvatarHeight=function(){return this._avatarHeight},i.prototype.getCenterOffset=function(){return this._centerOffset},i.prototype.getSkinWidth=function(){return this._skinWidth},i.prototype.getStepHeight=function(){return this._stepHeight},i.prototype.getGravityFactor=function(){return this._gravityFactor},i.prototype.setGravityFactor=function(e){this._gravityFactor=e},i.prototype.getInputVelocity=function(){return this._inputVelocity},i.prototype.setInputVelocity=function(e){this._inputVelocity.copyFrom(e)},i.prototype.getStepUpVelocity=function(){return this._stepUpVelocity},i.prototype.getCurrentSlopeAngle=function(){return this._currentSlopeAngle},i.prototype.getVerticalVelocity=function(){return!0===this.isGrounded()?0:this._currentVelocity.y},i.prototype.getMinMoveDistance=function(){return this._minMoveDistance},i.prototype.setMinMoveDistance=function(e){this._minMoveDistance=e},i.prototype.getGroundContactInfo=function(){return this._groundContactInfo},i.prototype.getMinJumpTimer=function(){return this._minJumpTimer},i.prototype.getSlopeLimit=function(){return this._slopeLimit},i.prototype.setSlopeLimit=function(e){this._slopeLimit=e},i.prototype.isGrounded=function(){return this._isGrounded},i.prototype.canJump=function(){return!0===this.isGrounded()},i.prototype.awake=function(){var t=this;this._avatarRadius=this.getProperty("avatarRadius",this._avatarRadius),this._avatarHeight=this.getProperty("avatarHeight",this._avatarHeight),this._slopeLimit=this.getProperty("slopeLimit",this._slopeLimit),this._skinWidth=this.getProperty("skinWidth",this._skinWidth),this._stepHeight=this.getProperty("stepOffset",this._stepHeight),this._minMoveDistance=this.getProperty("minMoveDistance",this._minMoveDistance),this._collisionEvents=this.getProperty("collisionEvents",this._collisionEvents),this.contactHysteresisTime=this.getProperty("contactHysteresisTime",this.contactHysteresisTime),this.groundedEnterTime=this.getProperty("groundedEnterTime",this.groundedEnterTime),this.groundedExitTime=this.getProperty("groundedExitTime",this.groundedExitTime);var i=this.getProperty("centerOffset");null!=i&&(this._centerOffset=e.Utilities.ParseVector3(i)),this.enableStepOffset=this.getProperty("enableStepOffset",this.enableStepOffset),this.createPhysicsBodyAndShape(e.CharacterController.DEFAULT_CHARACTER_MASS,e.Utilities.GetLayerMask(31),-1),this.enableCollisionEvents();var n=function(e){t.registerGroundContact(e)};this.onCollisionEnterObservable.add(n),this.onCollisionStayObservable.add(n),this.onCollisionExitObservable.add(function(e){})},i.prototype.update=function(){if(!1!==this.enableUpdate){var e=this.getDeltaSeconds();this._minJumpTimer>0&&(this._minJumpTimer-=e,this._minJumpTimer<0&&(this._minJumpTimer=0))}},i.prototype.fixed=function(){if(!1!==this.enableUpdate&&null!=this.transform){if(null!=this.transform.physicsBody?this.transform.physicsBody.getLinearVelocityToRef(this._currentVelocity):this._currentVelocity.set(0,0,0),this.m_moveDeltaX=this._targetVelocity.x,this.m_moveDeltaY=this._targetVelocity.y,this.m_moveDeltaZ=this._targetVelocity.z,Math.abs(this.m_moveDeltaX)<this._minMoveDistance&&(this.m_moveDeltaX>0?this.m_moveDeltaX=this._minMoveDistance:this.m_moveDeltaX<0&&(this.m_moveDeltaX=-this._minMoveDistance)),Math.abs(this.m_moveDeltaZ)<this._minMoveDistance&&(this.m_moveDeltaZ>0?this.m_moveDeltaZ=this._minMoveDistance:this.m_moveDeltaZ<0&&(this.m_moveDeltaZ=-this._minMoveDistance)),this.updateGroundedState(),this.onUpdateVelocityObservable&&this.onUpdateVelocityObservable.hasObservers()&&this.onUpdateVelocityObservable.notifyObservers(this.transform),this._inputVelocity.set(this.m_moveDeltaX,this.m_moveDeltaY+this._verticalVelocity,this.m_moveDeltaZ),null!=this.transform.physicsBody)try{(!1===this.enableGravity||!0===this.onlyApplyGravityWhenNotGrounded&&!0===this._isGrounded)&&(this._inputVelocity.y=0),this.transform.physicsBody.setLinearVelocity(this._inputVelocity)}catch(e){console.warn("Failed to set linear velocity on physics body: ",e)}else console.warn("No physics body attached to character controller transform: "+this.transform.name);this.onUpdatePositionObservable&&this.onUpdatePositionObservable.hasObservers()&&this.onUpdatePositionObservable.notifyObservers(this.transform)}},i.prototype.set=function(e,t,i,n,r,o,a){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),!1!==this.enableUpdate&&null!=this.transform&&(null!=this.transform.position&&null!=e&&null!=t&&null!=i&&this.transform.position.set(e,t,i),null!=this.transform.rotationQuaternion&&null!=n&&null!=r&&null!=o&&null!=a&&this.transform.rotationQuaternion.set(n,r,o,a))},i.prototype.move=function(e,t){void 0===t&&(t=!0),!1!==this.enableUpdate&&null!=e&&this._targetVelocity.copyFrom(e)},i.prototype.jump=function(e){var t;if(!1!==this.enableUpdate&&this.canJump()&&(this._isGrounded=!1,this._groundContactInfo=null,this._minJumpTimer=this.defaultJumpingTimer,this._verticalVelocity=e,null===(t=this.transform)||void 0===t?void 0:t.physicsBody)){var i=new BABYLON.Vector3;this.transform.physicsBody.getLinearVelocityToRef(i),i.y=e,this.transform.physicsBody.setLinearVelocity(i)}},i.prototype.turn=function(e){!1!==this.enableUpdate&&null!=this.transform&&this.transform.addRotation(0,e,0)},i.prototype.rotate=function(e,t,i,n){!1!==this.enableUpdate&&null!=this.transform&&null!=this.transform.rotationQuaternion&&(this._targetRotation.set(e,t,i,n),this.transform.rotationQuaternion.copyFrom(this._targetRotation))},i.prototype.setRigidBodyMass=function(e){if(null!=this.transform&&null!=this.transform.physicsBody){var t=this.transform.physicsBody.getMassProperties();t.mass=e>=1e-7?e:1e-7,this.transform.physicsBody.setMassProperties(t)}},i.prototype.setCollisionState=function(e){null!=this.transform&&null!=this.transform.physicsBody&&null!=this.transform.physicsBody.shape&&(this.transform.physicsBody.shape.isTrigger=!e)},i.prototype.setCollisionFilters=function(e,t){if(null!=this.transform&&null!=this.transform.physicsBody&&null!=this.transform.physicsBody.shape){var i=this.transform.physicsBody.shape,n=function(i){i&&(i.filterCollideMask=t,i.filterMembershipMask=e)};n(i),Array.isArray(i.children)&&i.children.forEach(function(e){return n(e)})}},i.prototype.registerGroundContact=function(e){e&&this.isContactAtFeet(e)&&this._groundContacts.set(e,0)},i.prototype.updateGroundContactAges=function(e){var t=this;if(0===this._groundContacts.size)return 0;var i=1e3*Math.max(0,this.contactHysteresisTime),n=0;return this._groundContacts.forEach(function(r,o){var a=r+e;a>i?t._groundContacts.delete(o):(t._groundContacts.set(o,a),n++)}),n},i.prototype.isContactAtFeet=function(e){return!(!e||!this.transform)},i.prototype.isValidGroundNormal=function(e){var t=new BABYLON.Vector3(0,1,0),i=BABYLON.Vector3.Dot(e,t);return this._currentSlopeAngle=Math.acos(i)*(180/Math.PI),i>=Math.cos(this._slopeLimit*Math.PI/180)},i.prototype.performSingleRayGroundCheck=function(t){return this._rayOrigin.copyFrom(this.transform.position),this._rayOrigin.y+=.1*this._centerOffset.y,this._rayTarget.copyFrom(this._rayOrigin),this._rayTarget.y-=this.groundCheckDistance,this._raycastResult.reset(),e.RigidbodyPhysics.RaycastToRef(this._rayOrigin,this._rayTarget,this._raycastResult),this._raycastResult.hasHit&&(t.hasGround=!0,t.groundNormal.copyFrom(this._raycastResult.hitNormalWorld),t.groundHeight=this._raycastResult.hitPointWorld.y,t.groundBody=this._raycastResult.body),t},i.prototype.performMultiRayGroundCheck=function(t){for(var i=[],n=this.transform.position.y+.1*this._centerOffset.y,r=0;r<this.multiRaycastCount;r++){var o=r/this.multiRaycastCount*Math.PI*2,a=.7*this._avatarRadius;if(this._rayOrigin.set(this.transform.position.x+Math.cos(o)*a,n,this.transform.position.z+Math.sin(o)*a),this._rayTarget.copyFrom(this._rayOrigin),this._rayTarget.y-=this.groundCheckDistance,this._raycastResult.reset(),e.RigidbodyPhysics.RaycastToRef(this._rayOrigin,this._rayTarget,this._raycastResult),this._raycastResult.hasHit){var s=this._rayOrigin.y-this._raycastResult.hitPointWorld.y;i.push({normal:this._raycastResult.hitNormalWorld.clone(),height:this._raycastResult.hitPointWorld.y,distance:s,body:this._raycastResult.body})}}if(i.length>0){var l=i[0];for(r=1;r<i.length;r++)i[r].distance<l.distance&&(l=i[r]);var u=new BABYLON.Vector3;i.forEach(function(e){return u.addInPlace(e.normal)}),u.scaleInPlace(1/i.length),u.normalize(),t.hasGround=!0,t.groundNormal.copyFrom(u),t.groundHeight=l.height,t.groundBody=l.body}return t},i.prototype.performGroundRaycast=function(){var e={hasGround:!1,groundNormal:new BABYLON.Vector3(0,1,0),groundHeight:0,groundBody:null};return this.useMultiRaycast?this.performMultiRayGroundCheck(e):this.performSingleRayGroundCheck(e)},i.prototype.detectAndHandleStepOffset=function(t){if(Math.sqrt(this.m_moveDeltaX*this.m_moveDeltaX+this.m_moveDeltaZ*this.m_moveDeltaZ)<.01)return 0;var i=new BABYLON.Vector3(this.m_moveDeltaX,0,this.m_moveDeltaZ).normalize(),n=t;if(this._rayOrigin.copyFrom(this.transform.position),this._rayOrigin.y=n+.05,this._rayTarget.copyFrom(this._rayOrigin),this._rayTarget.addInPlace(i.scale(this._stepDetectionDistance)),this._raycastResult.reset(),e.RigidbodyPhysics.RaycastToRef(this._rayOrigin,this._rayTarget,this._raycastResult),!this._raycastResult.hasHit)return 0;var r=BABYLON.Vector3.Distance(this._rayOrigin,this._raycastResult.hitPointWorld);if(this._rayOrigin.copyFrom(this.transform.position),this._rayOrigin.y=n+this._stepHeight+.05,this._rayOrigin.addInPlace(i.scale(r+.1)),this._rayTarget.copyFrom(this._rayOrigin),this._rayTarget.y=n-.05,this._raycastResult.reset(),e.RigidbodyPhysics.RaycastToRef(this._rayOrigin,this._rayTarget,this._raycastResult),!this._raycastResult.hasHit)return 0;var o=this._raycastResult.hitPointWorld.y-n;return o>.01&&o<=this._stepHeight?Math.sqrt(2*Math.abs(this.scene.gravity.y)*o*this._gravityFactor)*this.stepUpVelocityFactor:0},i.prototype.updateGroundedState=function(){if(this._minJumpTimer>0){this._isGrounded=!1,this._groundContactInfo=null;var t=this.getDeltaSeconds();return this._verticalVelocity-=Math.abs(this.scene.gravity.y)*this._gravityFactor*t,void(Math.abs(this._verticalVelocity)>e.CharacterController.TERMINAL_VELOCITY&&(this._verticalVelocity=-e.CharacterController.TERMINAL_VELOCITY))}var i=this.getDeltaSeconds(),n=1e3*i,r=Math.max(0,this.groundedEnterTime),o=Math.max(0,this.groundedExitTime),a=this.updateGroundContactAges(n)>0,s=null;if(this._currentSlopeAngle=0,a){var l=this.performGroundRaycast();l.hasGround&&this.isValidGroundNormal(l.groundNormal)?s=l:a=!1}if(a?(this._groundedExitTimer=0,this._groundedEnterTimer=Math.min(this._groundedEnterTimer+i,r),!this._isGrounded&&this._groundedEnterTimer>=r?this._isGrounded=!0:this._isGrounded&&(this._groundedEnterTimer=r)):(this._groundedEnterTimer=0,this._groundedExitTimer=Math.min(this._groundedExitTimer+i,o),this._isGrounded&&this._groundedExitTimer>=o&&(this._isGrounded=!1)),s&&this._isGrounded?(this._groundContactInfo=s,this._previousGroundHeight=s.groundHeight):s||(this._groundContactInfo=null),!0===this._isGrounded&&!0===this.enableStepOffset){var u=this._groundContactInfo?this._groundContactInfo.groundHeight:this.transform.position.y;this._stepUpVelocity=this.detectAndHandleStepOffset(u),this._stepUpVelocity>0&&(this._verticalVelocity=Math.max(this._verticalVelocity,this._stepUpVelocity))}else this._stepUpVelocity=0;!0===this._isGrounded&&this._verticalVelocity<0?this._verticalVelocity=Math.max(this._verticalVelocity,this.downwardVelocityClamp):(this._verticalVelocity-=Math.abs(this.scene.gravity.y)*this._gravityFactor*i,Math.abs(this._verticalVelocity)>e.CharacterController.TERMINAL_VELOCITY&&(this._verticalVelocity=-e.CharacterController.TERMINAL_VELOCITY))},i.prototype.createPhysicsBodyAndShape=function(t,i,n){var r=this.transform;e.Utilities.ReparentColliders()||r.setParent(null,!0,!0);var o=this._avatarRadius*parseFloat(r.scaling.x.toFixed(4)),a=this._avatarHeight*parseFloat(r.scaling.y.toFixed(4)),s=this.createPhysicsShapeCapsule(o,a);s.filterCollideMask=this.getProperty("filterCollideMask")||4294967295,s.filterMembershipMask=this.getProperty("filterMembershipMask")||i;var l=new BABYLON.Quaternion(0,0,0,1),u=this._centerOffset.x*parseFloat(r.scaling.x.toFixed(4)),h=this._centerOffset.y*parseFloat(r.scaling.y.toFixed(4)),c=this._centerOffset.z*parseFloat(r.scaling.z.toFixed(4)),d=new BABYLON.Vector3(u,h,c),m=new BABYLON.PhysicsShapeContainer(this.scene);m.filterCollideMask=s.filterCollideMask,m.filterMembershipMask=s.filterMembershipMask,m.material={friction:0,staticFriction:0,restitution:0,frictionCombine:0,restitutionCombine:0},m.addChild(s,d,l,new BABYLON.Vector3(1,1,1));var p=new BABYLON.PhysicsBody(r,BABYLON.PhysicsMotionType.DYNAMIC,!1,this.scene);if(p.shape=m,p.setMassProperties({mass:t,centerOfMass:new BABYLON.Vector3(0,0,0),inertia:new BABYLON.Vector3(0,0,0)}),p.setGravityFactor(0),p.setLinearDamping(0),p.setAngularDamping(0),p.disablePreStep=!1,!0===this._collisionEvents&&(p.setCollisionCallbackEnabled(!0),p.setCollisionEndedCallbackEnabled(!0)),e.Utilities.ShowDebugColliders()&&console.log("Setup character controller physics collider for: "+r.name,r),!e.Utilities.ShowDebugColliders()){var f=r;null!=f.material&&"CenterBox-Material"===f.material.name&&(f.isVisible=!1)}e.Utilities.ShowDebugColliders()&&(null==e.RigidbodyPhysics.DebugPhysicsViewer&&(e.RigidbodyPhysics.DebugPhysicsViewer=new BABYLON.Debug.PhysicsViewer),null!=e.RigidbodyPhysics.DebugPhysicsViewer&&e.RigidbodyPhysics.DebugPhysicsViewer.showBody(p))},i.prototype.createPhysicsShapeCapsule=function(e,t){var i=-.5*(t-.5),n=.5*(t-.5);return new BABYLON.PhysicsShapeCapsule(new BABYLON.Vector3(0,i,0),new BABYLON.Vector3(0,n,0),e,this.scene)},i.TERMINAL_VELOCITY=55,i.DEFAULT_CHARACTER_MASS=85,i}(e.ScriptComponent);e.CharacterController=t;var i=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="TOOLKIT.SimpleCharacterController");var o=e.call(this,t,i,n,r)||this;return o._eulerAngles=new BABYLON.Vector3(0,0,0),o}return o(t,e),t.prototype.start=function(){},t.prototype.set=function(e,t,i,n,r,o,a,s){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=!0),null!=this.transform&&(null!=this.transform.position&&null!=e&&null!=t&&null!=i&&this.transform.position.set(e,t,i),null!=this.transform.rotationQuaternion&&null!=n&&null!=r&&null!=o&&null!=a&&this.transform.rotationQuaternion.set(n,r,o,a))},t.prototype.move=function(e,t){void 0===t&&(t=!0),null!=e&&null!=this.transform&&this.transform instanceof BABYLON.AbstractMesh&&this.transform.moveWithCollisions(e)},t.prototype.jump=function(e){},t.prototype.turn=function(e){null!=this.transform&&this.transform.addRotation(0,e,0)},t.prototype.rotate=function(e,t,i,n){null!=this.transform&&null!=this.transform.rotationQuaternion&&this.transform.rotationQuaternion.set(e,t,i,n)},t}(e.ScriptComponent);e.SimpleCharacterController=i;var n=function(e){function t(t,i,n,r){void 0===n&&(n={}),void 0===r&&(r="TOOLKIT.RecastCharacterController");var o=e.call(this,t,i,n,r)||this;return o._eulerAngles=new BABYLON.Vector3(0,0,0),o._teleportVector=new BABYLON.Vector3(0,0,0),o._navigationAgent=null,o}return o(t,e),t.prototype.getNavigationAgent=function(){return this._navigationAgent},t.prototype.setNavigationAgent=function(e){this._navigationAgent=e},t.prototype.setDestinationPoint=function(e,t){void 0===t&&(t=!0),null!=this._navigationAgent&&this._navigationAgent.setDestination(e,t)},t.prototype.start=function(){this._navigationAgent=this.getComponent("TOOLKIT.NavigationAgent")},t.prototype.set=function(e,t,i,n,r,o,a,s){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=!0),null!=this.transform&&null!=this._navigationAgent&&(null!=this.transform.position&&null!=e&&null!=t&&null!=i&&(this._teleportVector.set(e,t,i),this._navigationAgent.teleport(this._teleportVector,s)),null!=this.transform.rotationQuaternion&&null!=n&&null!=r&&null!=o&&null!=a&&this.transform.rotationQuaternion.set(n,r,o,a))},t.prototype.move=function(e,t){void 0===t&&(t=!0),null!=e&&null!=this._navigationAgent&&this._navigationAgent.move(e,t)},t.prototype.jump=function(e){console.warn("Jump is not supported by the navigation mesh character controller.")},t.prototype.turn=function(e){null!=this.transform&&this.transform.addRotation(0,e,0)},t.prototype.rotate=function(e,t,i,n){null!=this.transform&&null!=this.transform.rotationQuaternion&&null!=this._navigationAgent&&this.transform.rotationQuaternion.set(e,t,i,n)},t}(e.ScriptComponent);e.RecastCharacterController=n,e.SceneManager.RegisterClass("TOOLKIT.CharacterController",t),e.SceneManager.RegisterClass("TOOLKIT.SimpleCharacterController",i),e.SceneManager.RegisterClass("TOOLKIT.RecastCharacterController",n)}(n||(n={})),function(e){var t=function(){function e(){}return e.CreatePostProcess=function(e,t,i){var n=i||{},r=Array.isArray(n.color)?n.color:n.color?[n.color.r||1,n.color.g||1,n.color.b||1,null!=n.color.a?n.color.a:1]:[1,1,1,1],o=new BABYLON.PostProcess("colorFilter","\n precision highp float;\n varying vec2 vUV;\n uniform sampler2D textureSampler;\n uniform vec4 filterColor;\n\n void main(void) {\n vec4 sceneColor = texture2D(textureSampler, vUV);\n gl_FragColor = sceneColor * filterColor;\n }\n ",["filterColor"],[],1,t,BABYLON.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1);return o.onApply=function(e){e.setFloat4("filterColor",r[0]||1,r[1]||1,r[2]||1,null!=r[3]?r[3]:1)},o},e}();e.ColorFilterPlugin=t}(n||(n={})),function(e){var t=function(){function e(){}return e.CreateColoredBloom=function(e,t,i){var n=i||{},r=null!=n.threshold?n.threshold:1,o=Array.isArray(n.color)?n.color:n.color?[n.color.r||1,n.color.g||1,n.color.b||1]:[1,1,1],a=null!=n.weight?n.weight:1,s=null!=n.kernel?n.kernel:4,l=null!=n.downsampleRatio?n.downsampleRatio:null!=n.ratio?n.ratio:.5,u=null!=n.passes?Math.max(1,Math.floor(n.passes)):1,h=null!=n.saturation?n.saturation:1,c=new BABYLON.PostProcess("coloredBloom_prefilter","\n precision highp float;\n varying vec2 vUV;\n uniform sampler2D textureSampler;\n uniform float threshold;\n uniform vec3 tint;\n\n void main(void) {\n vec4 color = texture2D(textureSampler, vUV);\n float lum = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));\n float mask = smoothstep(threshold * 0.95, threshold * 1.05, lum);\n vec3 bloom = color.rgb * mask * tint;\n gl_FragColor = vec4(bloom, 1.0);\n }\n ",["threshold","tint"],[],l,t,BABYLON.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1);c.onApply=function(e){e.setFloat("threshold",r),e.setFloat3("tint",o[0]||1,o[1]||1,o[2]||1)};for(var d=[],m=0;m<u;m++){var p=new BABYLON.BlurPostProcess("coloredBloom_blurH_"+m,new BABYLON.Vector2(1,0),s,l,null,BABYLON.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1),f=new BABYLON.BlurPostProcess("coloredBloom_blurV_"+m,new BABYLON.Vector2(0,1),s,l,null,BABYLON.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1);d.push({h:p,v:f})}var g=new BABYLON.PostProcess("coloredBloom_composite","\n precision highp float;\n varying vec2 vUV;\n uniform sampler2D textureSampler;\n uniform sampler2D bloomSampler;\n uniform float weight;\n uniform float saturation;\n\n vec3 desaturate(in vec3 c) {\n float l = dot(c, vec3(0.2126, 0.7152, 0.0722));\n return vec3(l);\n }\n\n void main(void) {\n vec4 scene = texture2D(textureSampler, vUV);\n vec3 bloom = texture2D(bloomSampler, vUV).rgb;\n // apply saturation control to bloom\n bloom = mix(desaturate(bloom), bloom, saturation);\n gl_FragColor = vec4(scene.rgb + bloom * weight, scene.a);\n }\n ",["weight","saturation"],["bloomSampler"],1,t,BABYLON.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1);return g.onApply=function(e){e.setFloat("weight",a),e.setFloat("saturation",h)},{prefilter:c,blurPasses:d,composite:g,passes:u,saturation:h,dispose:function(){try{this.prefilter.dispose()}catch(e){}try{this.blurPasses.forEach(function(e){try{e.h.dispose()}catch(e){}try{e.v.dispose()}catch(e){}})}catch(e){}try{this.composite.dispose()}catch(e){}}}},e}();e.ColoredBloomPlugin=t}(n||(n={})),function(e){e.btVehicleTuning=function(){this.suspensionStiffness=25,this.suspensionCompression=4.5,this.suspensionDamping=6.5,this.maxSuspensionTravelCm=10,this.frictionSlip=10,this.maxSuspensionForce=15e3};var t=function(){this.hitPointInWorld=new BABYLON.Vector3,this.hitNormalInWorld=new BABYLON.Vector3,this.distFraction=0,this.hitBody=null,this.filterCollideMask=0,this.filterMembershipMask=0};e.btVehicleRaycasterResult=t;var i=function(){function t(e){this._raycastResult=new BABYLON.PhysicsRaycastResult,this._query=e||void 0}return t.prototype.castRay=function(t,i,n){if(this._raycastResult.reset(),n.hitBody=null,n.filterCollideMask=0,n.filterMembershipMask=0,e.RigidbodyPhysics.RaycastToRef(t,i,this._raycastResult,this._query),this._raycastResult.hasHit){var r=this._raycastResult.body;if(r){n.hitPointInWorld.copyFrom(this._raycastResult.hitPointWorld),n.hitNormalInWorld.copyFrom(this._raycastResult.hitNormalWorld),n.hitNormalInWorld.normalize();var o=n.hitPointInWorld.x-t.x,a=n.hitPointInWorld.y-t.y,s=n.hitPointInWorld.z-t.z,l=Math.sqrt(o*o+a*a+s*s),u=i.x-t.x,h=i.y-t.y,c=i.z-t.z,d=Math.sqrt(u*u+h*h+c*c);n.distFraction=d>1e-8?l/d:0,n.hitBody=r;var m=this._raycastResult.shape||r.shape;return m&&(n.filterCollideMask=0|m.filterCollideMask,n.filterMembershipMask=0|m.filterMembershipMask),r}}return null},t}();e.btDefaultVehicleRaycaster=i;var n=function(){this.contactNormalWS=new BABYLON.Vector3(0,1,0),this.contactPointWS=new BABYLON.Vector3,this.suspensionLength=0,this.hardPointWS=new BABYLON.Vector3,this.wheelDirectionWS=new BABYLON.Vector3(0,-1,0),this.wheelAxleWS=new BABYLON.Vector3(1,0,0),this.isInContact=!1,this.groundObject=null};e.btWheelRaycastInfo=n;var r=function(){function e(e){this.raycastInfo=new n,this.worldTransformPosition=new BABYLON.Vector3,this.worldTransformRotation=new BABYLON.Quaternion,this.steering=0,this.rotation=0,this.deltaRotation=0,this.rollInfluence=.1,this.engineForce=0,this.brake=0,this.clippedInvContactDotSuspension=1,this.suspensionRelativeVelocity=0,this.suspensionForce=0,this.skidInfo=1,this.clientInfo=null,this.steeringAngle=0,this.rotationBoost=0,this.defaultFriction=0,this.invertWheelDirection=!1,this.maxVisualTravelRange=0,this.contactCollideMask=0,this.contactMembershipMask=0,this._prevContactNormalWS=new BABYLON.Vector3(0,1,0),this._prevSuspensionLength=-1,this._prevSuspensionForce=-1,this._hasPrevSuspState=!1,this._rayHistoryLengths=[],this._rayHistoryNormalsX=[],this._rayHistoryNormalsY=[],this._rayHistoryNormalsZ=[],this._rayHistoryIndex=0,this._rayHistoryCount=0,this._smoothedSuspensionLength=-1,this._smoothedContactNormal=new BABYLON.Vector3(0,1,0),this._smoothedContactNormalValid=!1,this._contactLossFrames=0,this.transform=null,this.spinner=null,this.chassisConnectionPointCS=e.chassisConnectionCS.clone(),this.wheelDirectionCS=e.wheelDirectionCS.clone(),this.wheelAxleCS=e.wheelAxleCS.clone(),this.suspensionRestLength=e.suspensionRestLength,this.maxSuspensionTravelCm=e.maxSuspensionTravelCm,this.wheelRadius=e.wheelRadius,this.suspensionStiffness=e.suspensionStiffness,this.dampingCompression=e.dampingCompression,this.dampingRelaxation=e.dampingRelaxation,this.frictionSlip=e.frictionSlip,this.maxSuspensionForce=e.maxSuspensionForce,this.isFrontWheel=e.isFrontWheel}return e.prototype.getSuspensionRestLength=function(){return this.suspensionRestLength},e}();e.btWheelInfo=r;var o=function(){function i(e,i,n){this._wheelInfo=[],this._indexRightAxis=0,this._indexUpAxis=1,this._indexForwardAxis=2,this._currentVehicleSpeedKmHour=0,this.enableMultiRaycast=!0,this.minimumWheelContacts=4,this.trackConnectionAccel=6,this.smoothFlyingImpulse=8,this.arcadeSteeringAssist=1,this.smoothedGradientSpeed=.5,this.maximumYawRateLow=60,this.maximumYawRateHigh=30,this.angularDamping=new BABYLON.Vector3(.5,1,.5),this.wheelSkidFadeInSpeed=18,this.wheelSkidFadeOutSpeed=6,this.minContactDotSuspension=.1,this.suspensionForceSmoothing=0,this.suspensionDampingOverdrive=1,this.raycastSmoothingEnabled=!0,this.raycastHistoryBufferSize=12,this.raycastLengthCompressionAlpha=.5,this.raycastLengthRelaxationAlpha=.2,this.raycastNormalSmoothingAlpha=.15,this.raycastOutlierRejectionEnabled=!0,this.raycastOutlierThresholdMeters=.03,this.raycastMaxLengthChangePerSecond=3.5,this.raycastContactLossGraceFrames=3,this.raycastDebugLogEnabled=!1,this.raycastDebugLogIntervalFrames=30,this.raycastDebugLogSpikeThresholdMeters=.04,this.raycastDebugLogWheelMask=65535,this._raycastDebugFrameCounter=0,this._raycastMedianScratch=[],this.sideToSideStabilityEnabled=!0,this.sideToSideStabilityStartKmh=80,this.sideToSideStabilityFullKmh=180,this.stabilizationDebug=!1,this.stabilizationDebugInterval=.25,this.downforceCoefficient=.8,this.constantDownforce=.1,this.stabilizationNormalSmoothing=.85,this.airborneGroundNormalHoldTime=.35,this.groundedAutoLevelEnabled=!0,this.groundedAutoLevelStrength=20,this.groundedAutoLevelDeadzoneDeg=3,this.groundedAutoLevelSettleDeg=1,this.groundedAutoLevelSettleScale=.55,this.groundedAutoLevelHysteresisDeg=.25,this.groundedAutoLevelStartKmh=20,this.groundedAutoLevelFullKmh=100,this.groundedAutoLevelMaxRate=9,this.groundedAutoLevelPartialContactBoost=1.6,this.groundedAutoLevelSlideScale=.35,this.groundedAutoLevelTrackNormalMinDot=.45,this.airborneTrackConnectionStartKmh=80,this.airborneTrackConnectionFullKmh=180,this.airborneTrackConnectionMaxAccel=12,this.airborneRiseDamping=6,this.airborneMaxRiseSpeed=0,this._groundedAutoLevelWasActive=!1,this._stabilizationGroundNormal=new BABYLON.Vector3(0,1,0),this._stabilizationHasGroundNormal=!1,this._stabilizationAirborneTime=0,this.isArcadeBurnoutModeActive=!1,this.isArcadeDonutModeActive=!1,this.isArcadeFootBrakeActive=!1,this.isArcadeHandBrakeActive=!1,this.isArcadeWheelSkidActive=!1,this.isArcadeYawAssistActive=!1,this.burnoutFrictionFloor=1,this.frictionRestoreSpeed=8,this.arcadeBurnoutWheelSpinGain=1,this.arcadeDonutWheelSpinGain=1,this.arcadeBurnoutDirectionChangeSpeedKmh=24.1401,this.arcadeBurnoutDirectionChangeGripScale=.2,this.arcadeWheelSpinBuildSpeed=12,this.arcadeWheelSpinRecoverySpeed=10,this.arcadeWheelSpinAirDamping=.985,this.arcadeWheelSpinMaxAngularVelocity=160,this.arcadeStationaryBurnoutWheelSpinGain=3.25,this.arcadeStationaryBurnoutMinAngularVelocity=65,this.arcadeHandbrakeYawCapMultiplier=1.85,this.arcadeBurnoutYawCapMultiplier=1.25,this.arcadeDonutYawCapMultiplier=2,this.arcadeSkidFadeInSpeed=18,this.arcadeSkidFadeOutSpeed=6,this.wheelAtRestSpeedThresholdKmh=1,this.arcadeHandbrakeAssistEnabled=!0,this.currentSteeringInput=0,this.arcadeDonutDirectYawEnabled=!0,this.arcadeDonutDirectYawDegPerSec=60,this.arcadeDonutDirectYawDurationMs=0,this.arcadeDonutDirectYawFadeMs=120,this._arcadeDonutHoldElapsedSec=0,this._arcadeDonutDirectionSign=0,this._forwardWS=[],this._axle=[],this._forwardImpulse=[],this._sideImpulse=[],this._arcadeSkidInfo=[],this._arcadePreviousWheelSpin=[],this.sideFrictionStiffness=1,this.arcadeSideSlipSaturationEnabled=!0,this.arcadeSideSlipPeakDeg=8,this.arcadeSideSlipFalloffDeg=45,this.arcadeSideSlipFalloffFactor=.4,this.arcadeSideSlipMinSpeedMps=1.5,this._chassisMass=0,this._chassisInvMass=0,this._chassisTransform=BABYLON.Matrix.Identity(),this._rayResults=new t,this._sv1=new BABYLON.Vector3,this._sv2=new BABYLON.Vector3,this._sv3=new BABYLON.Vector3,this._sv4=new BABYLON.Vector3,this._sv5=new BABYLON.Vector3,this._sv6=new BABYLON.Vector3,this._sv7=new BABYLON.Vector3,this._sv8=new BABYLON.Vector3,this._sv9=new BABYLON.Vector3,this._sv10=new BABYLON.Vector3,this._sq1=new BABYLON.Quaternion,this._sq2=new BABYLON.Quaternion,this._sm1=BABYLON.Matrix.Identity(),this._sm2=BABYLON.Matrix.Identity(),this._sm3=BABYLON.Matrix.Identity(),this._sm4=BABYLON.Matrix.Identity(),this._vapLinVel=new BABYLON.Vector3,this._vapAngVel=new BABYLON.Vector3,this._vapRelPos=new BABYLON.Vector3,this._vapCenter=new BABYLON.Vector3,this._vapCross=new BABYLON.Vector3,this._rsbVel1=new BABYLON.Vector3,this._crfVel1=new BABYLON.Vector3,this._basisCols=[new BABYLON.Vector3,new BABYLON.Vector3,new BABYLON.Vector3],this._stb1=new BABYLON.Vector3,this._stb2=new BABYLON.Vector3,this._stb3=new BABYLON.Vector3,this._stb4=new BABYLON.Vector3,this._stb5=new BABYLON.Vector3,this._chassisBody=i,this._vehicleRaycaster=n,this._currentVehicleSpeedKmHour=0,this.cacheMassProperties()}return i.prototype.addWheel=function(e,t,i,n,o,a,s){var l=new r({chassisConnectionCS:e,wheelDirectionCS:t,wheelAxleCS:i,suspensionRestLength:n,maxSuspensionTravelCm:a.maxSuspensionTravelCm,wheelRadius:o,suspensionStiffness:a.suspensionStiffness,dampingCompression:a.suspensionCompression,dampingRelaxation:a.suspensionDamping,frictionSlip:a.frictionSlip,maxSuspensionForce:a.maxSuspensionForce,isFrontWheel:s});return this._wheelInfo.push(l),this._forwardWS.push(new BABYLON.Vector3),this._axle.push(new BABYLON.Vector3),this._forwardImpulse.push(0),this._sideImpulse.push(0),this._arcadeSkidInfo.push(1),this._arcadePreviousWheelSpin.push(0),this.updateWheelTransformsWS(l,!1),this.updateWheelTransform(this._wheelInfo.length-1,!1),l},i.prototype.getNumWheels=function(){return this._wheelInfo.length},i.prototype.getWheelInfo=function(e){return this._wheelInfo[e]},i.prototype.setSteeringValue=function(e,t){this._wheelInfo[t].steering=e},i.prototype.getSteeringValue=function(e){return this._wheelInfo[e].steering},i.prototype.applyEngineForce=function(e,t){this._wheelInfo[t].engineForce=e},i.prototype.setBrake=function(e,t){this._wheelInfo[t].brake=e},i.prototype.getCurrentSpeedKmHour=function(){return this._currentVehicleSpeedKmHour},i.prototype.getRigidBody=function(){return this._chassisBody},i.prototype.getRightAxis=function(){return this._indexRightAxis},i.prototype.getUpAxis=function(){return this._indexUpAxis},i.prototype.getForwardAxis=function(){return this._indexForwardAxis},i.prototype.setCoordinateSystem=function(e,t,i){this._indexRightAxis=e,this._indexUpAxis=t,this._indexForwardAxis=i},i.prototype.getForwardVector=function(){var e=this._chassisTransform.m,t=this._indexForwardAxis;return new BABYLON.Vector3(e[4*t],e[4*t+1],e[4*t+2])},i.prototype.getForwardVectorToRef=function(e){var t=this._chassisTransform.m,i=this._indexForwardAxis;e.set(t[4*i],t[4*i+1],t[4*i+2])},i.prototype.cacheMassProperties=function(){var e=this._chassisBody.getMassProperties();this._chassisMass=e.mass,this._chassisInvMass=this._chassisMass>0?1/this._chassisMass:0},i.prototype.setIsArcadeBurnoutActive=function(e){this.isArcadeBurnoutModeActive=e},i.prototype.getIsArcadeBurnoutActive=function(){return this.isArcadeBurnoutModeActive},i.prototype.setIsArcadeDonutActive=function(e){!0!==e&&(this._arcadeDonutDirectionSign=0),this.isArcadeDonutModeActive=e},i.prototype.getIsArcadeDonutActive=function(){return this.isArcadeDonutModeActive},i.prototype.setIsArcadeFootBrakeActive=function(e){this.isArcadeFootBrakeActive=e},i.prototype.getIsArcadeFootBrakeActive=function(){return this.isArcadeFootBrakeActive},i.prototype.setIsArcadeHandBrakeActive=function(e){this.isArcadeHandBrakeActive=e},i.prototype.getIsArcadeHandBrakeActive=function(){return this.isArcadeHandBrakeActive},i.prototype.setIsArcadeWheelSkidActive=function(e){this.isArcadeWheelSkidActive=e},i.prototype.getIsArcadeWheelSkidActive=function(){return this.isArcadeWheelSkidActive},i.prototype.setWheelContactFilters=function(e,t,i){e.contactCollideMask=0|t,e.contactMembershipMask=0|i},i.prototype.resetSuspension=function(){for(var e=0;e<this._wheelInfo.length;e++){var t=this._wheelInfo[e];t.raycastInfo.suspensionLength=t.getSuspensionRestLength(),t.suspensionRelativeVelocity=0,t.raycastInfo.contactNormalWS.copyFrom(t.raycastInfo.wheelDirectionWS).scaleInPlace(-1),t.clippedInvContactDotSuspension=1,t._rayHistoryCount=0,t._rayHistoryIndex=0,t._smoothedSuspensionLength=-1,t._smoothedContactNormalValid=!1,t._prevSuspensionLength=-1,t._contactLossFrames=0,this.setWheelContactFilters(t,0,0)}this._stabilizationGroundNormal.set(0,1,0),this._stabilizationHasGroundNormal=!1,this._stabilizationAirborneTime=0,this._groundedAutoLevelWasActive=!1},i.prototype.getChassisWorldTransform=function(){var e=this._chassisBody.transformNode.getWorldMatrix();return this._chassisTransform.copyFrom(e),this._chassisTransform},i.prototype.updateWheelTransformsWS=function(e,t,i){void 0===i&&(i=1),e.raycastInfo.isInContact=!1;var n=this._chassisTransform;1!==i?(e.chassisConnectionPointCS.scaleToRef(i,this._sv1),BABYLON.Vector3.TransformCoordinatesToRef(this._sv1,n,e.raycastInfo.hardPointWS)):BABYLON.Vector3.TransformCoordinatesToRef(e.chassisConnectionPointCS,n,e.raycastInfo.hardPointWS),BABYLON.Vector3.TransformNormalToRef(e.wheelDirectionCS,n,e.raycastInfo.wheelDirectionWS),BABYLON.Vector3.TransformNormalToRef(e.wheelAxleCS,n,e.raycastInfo.wheelAxleWS)},i.prototype.updateWheelTransform=function(e,t){void 0===t&&(t=!0);var i=this._wheelInfo[e];this.updateWheelTransformsWS(i,t);var n=this._sv1;i.raycastInfo.wheelDirectionWS.negateToRef(n);var r=this._sv2;r.copyFrom(i.raycastInfo.wheelAxleWS);var o=this._sv3;BABYLON.Vector3.CrossToRef(n,r,o),o.normalize(),BABYLON.Quaternion.RotationAxisToRef(n,i.steering,this._sq1),BABYLON.Matrix.FromQuaternionToRef(this._sq1,this._sm2),BABYLON.Quaternion.RotationAxisToRef(r,-i.rotation,this._sq2),BABYLON.Matrix.FromQuaternionToRef(this._sq2,this._sm3),this._basisCols[this._indexRightAxis].copyFrom(r),this._basisCols[this._indexUpAxis].copyFrom(n),this._basisCols[this._indexForwardAxis].copyFrom(o);var a=this._basisCols[0],s=this._basisCols[1],l=this._basisCols[2];BABYLON.Matrix.FromValuesToRef(a.x,a.y,a.z,0,s.x,s.y,s.z,0,l.x,l.y,l.z,0,0,0,0,1,this._sm1),this._sm1.multiplyToRef(this._sm3,this._sm4),this._sm4.multiplyToRef(this._sm2,this._sm1),i.raycastInfo.wheelDirectionWS.scaleToRef(i.raycastInfo.suspensionLength,this._sv4),this._sv4.addInPlace(i.raycastInfo.hardPointWS),i.worldTransformPosition.copyFrom(this._sv4),this._sm1.setTranslationFromFloats(this._sv4.x,this._sv4.y,this._sv4.z),BABYLON.Quaternion.FromRotationMatrixToRef(this._sm1,i.worldTransformRotation)},i.prototype.rayCast=function(e,t){void 0===t&&(t=1),this.updateWheelTransformsWS(e,!1,t),this.setWheelContactFilters(e,0,0);var i=-1,n=e.getSuspensionRestLength()+e.wheelRadius;e.raycastInfo.wheelDirectionWS.scaleToRef(n,this._sv1);var r=e.raycastInfo.hardPointWS;r.addToRef(this._sv1,this._sv2),e.raycastInfo.contactPointWS.copyFrom(this._sv2);var o=this._sv2,a=this._vehicleRaycaster.castRay(r,o,this._rayResults);if(e.raycastInfo.groundObject=null,a&&this._rayResults.hitNormalInWorld.y<.5&&(a=null),a){var s=this._rayResults.distFraction;i=n*s;var l=s*n-e.wheelRadius,u=this._rayResults.hitNormalInWorld.x,h=this._rayResults.hitNormalInWorld.y,c=this._rayResults.hitNormalInWorld.z,d=l,m=u,p=h,f=c;this.raycastSmoothingEnabled&&(e._contactLossFrames=0,this.smoothRaycastHit(e,l,u,h,c),d=e._smoothedSuspensionLength,m=e._smoothedContactNormal.x,p=e._smoothedContactNormal.y,f=e._smoothedContactNormal.z),e.raycastInfo.contactNormalWS.set(m,p,f),e.raycastInfo.isInContact=!0,e.raycastInfo.groundObject=a,e.raycastInfo.suspensionLength=d,this.setWheelContactFilters(e,this._rayResults.filterCollideMask,this._rayResults.filterMembershipMask);var g=e.getSuspensionRestLength()-.01*e.maxSuspensionTravelCm,y=e.getSuspensionRestLength()+.01*e.maxSuspensionTravelCm;e.raycastInfo.suspensionLength<g&&(e.raycastInfo.suspensionLength=g),e.raycastInfo.suspensionLength>y&&(e.raycastInfo.suspensionLength=y),e.raycastInfo.contactPointWS.copyFrom(this._rayResults.hitPointInWorld);var v=BABYLON.Vector3.Dot(e.raycastInfo.contactNormalWS,e.raycastInfo.wheelDirectionWS);this.velocityAtWorldPoint(this._chassisBody,e.raycastInfo.contactPointWS,this._sv3);var S=BABYLON.Vector3.Dot(e.raycastInfo.contactNormalWS,this._sv3),_=this.minContactDotSuspension;if(v>=-_)e.suspensionRelativeVelocity=0,e.clippedInvContactDotSuspension=1/_;else{var b=-1/v;e.suspensionRelativeVelocity=S*b,e.clippedInvContactDotSuspension=b}}else e.raycastInfo.suspensionLength=e.getSuspensionRestLength(),e.suspensionRelativeVelocity=0,e.raycastInfo.contactNormalWS.copyFrom(e.raycastInfo.wheelDirectionWS).scaleInPlace(-1),e.clippedInvContactDotSuspension=1,this.setWheelContactFilters(e,0,0),this.raycastSmoothingEnabled&&(e._contactLossFrames++,e._contactLossFrames>this.raycastContactLossGraceFrames&&(e._rayHistoryCount=0,e._rayHistoryIndex=0,e._smoothedSuspensionLength=-1,e._smoothedContactNormalValid=!1,e._prevSuspensionLength=-1));return i},i.prototype.smoothRaycastHit=function(e,t,i,n,r){var o=0|this.raycastHistoryBufferSize;o<2&&(o=2),e._rayHistoryLengths.length!==o&&(e._rayHistoryLengths=new Array(o),e._rayHistoryNormalsX=new Array(o),e._rayHistoryNormalsY=new Array(o),e._rayHistoryNormalsZ=new Array(o),e._rayHistoryCount=0,e._rayHistoryIndex=0),e._rayHistoryLengths[e._rayHistoryIndex]=t,e._rayHistoryNormalsX[e._rayHistoryIndex]=i,e._rayHistoryNormalsY[e._rayHistoryIndex]=n,e._rayHistoryNormalsZ[e._rayHistoryIndex]=r,e._rayHistoryIndex=(e._rayHistoryIndex+1)%o,e._rayHistoryCount<o&&e._rayHistoryCount++;var a=t;if(this.raycastOutlierRejectionEnabled&&e._rayHistoryCount>=3){var s=e._rayHistoryCount;this._raycastMedianScratch.length!==s&&(this._raycastMedianScratch=new Array(s));for(var l=0;l<s;l++)this._raycastMedianScratch[l]=e._rayHistoryLengths[l];this._raycastMedianScratch.sort(function(e,t){return e-t});var u=s%2==1?this._raycastMedianScratch[s-1>>1]:.5*(this._raycastMedianScratch[(s>>1)-1]+this._raycastMedianScratch[s>>1]),h=this.raycastOutlierThresholdMeters;h>0&&(a>u+h?a=u+h:a<u-h&&(a=u-h))}if(e._smoothedSuspensionLength<0)e._smoothedSuspensionLength=a;else{var c=a<e._smoothedSuspensionLength?this.raycastLengthCompressionAlpha:this.raycastLengthRelaxationAlpha;c<0?c=0:c>1&&(c=1),e._smoothedSuspensionLength=e._smoothedSuspensionLength*(1-c)+a*c}if(this.raycastMaxLengthChangePerSecond>0&&e._prevSuspensionLength>=0){var d=this.raycastMaxLengthChangePerSecond*(1/60),m=e._smoothedSuspensionLength-e._prevSuspensionLength;m>d?e._smoothedSuspensionLength=e._prevSuspensionLength+d:m<-d&&(e._smoothedSuspensionLength=e._prevSuspensionLength-d)}if(e._prevSuspensionLength=e._smoothedSuspensionLength,e._smoothedContactNormalValid){var p=this.raycastNormalSmoothingAlpha;p<0?p=0:p>1&&(p=1);var f=1-p,g=e._smoothedContactNormal.x*f+i*p,y=e._smoothedContactNormal.y*f+n*p,v=e._smoothedContactNormal.z*f+r*p,S=Math.sqrt(g*g+y*y+v*v);if(S>1e-6){var _=1/S;e._smoothedContactNormal.set(g*_,y*_,v*_)}else e._smoothedContactNormal.set(i,n,r)}else e._smoothedContactNormal.set(i,n,r),e._smoothedContactNormalValid=!0},i.prototype.getGravityUpToRef=function(e){var t=null!=this._chassisBody.transformNode?this._chassisBody.transformNode.getScene():null;if(null!=t&&null!=t.gravity){var i=t.gravity;if(i.lengthSquared()>1e-8)return e.copyFrom(i).scaleInPlace(-1),void e.normalize()}e.set(0,1,0)},i.prototype.computeStabilizationUpVector=function(e,t,i){if(i.set(0,0,0),t>0){for(var n=0;n<this._wheelInfo.length;n++){var r=this._wheelInfo[n];r.raycastInfo.isInContact&&i.addInPlace(r.raycastInfo.contactNormalWS)}if(i.lengthSquared()>1e-8){if(i.scaleInPlace(1/t),i.normalize(),this._stabilizationHasGroundNormal&&this.stabilizationNormalSmoothing>0){var o=BABYLON.Scalar.Clamp(this.stabilizationNormalSmoothing,0,.999),a=1-o;i.x=i.x*a+this._stabilizationGroundNormal.x*o,i.y=i.y*a+this._stabilizationGroundNormal.y*o,i.z=i.z*a+this._stabilizationGroundNormal.z*o,i.normalize()}return this._stabilizationGroundNormal.copyFrom(i),this._stabilizationHasGroundNormal=!0,void(this._stabilizationAirborneTime=0)}}this._stabilizationAirborneTime+=e,this._stabilizationHasGroundNormal&&(this.airborneGroundNormalHoldTime<=0||this._stabilizationAirborneTime<=this.airborneGroundNormalHoldTime)?i.copyFrom(this._stabilizationGroundNormal):this.getGravityUpToRef(i)},i.prototype.applyFlyingStabilization=function(e,t){if(!(e<=0||this.smoothFlyingImpulse<=0)){var i=this._chassisTransform.m,n=this._indexRightAxis,r=this._indexUpAxis,o=this._indexForwardAxis;this._stb1.set(i[4*n],i[4*n+1],i[4*n+2]),this._stb2.set(i[4*r],i[4*r+1],i[4*r+2]),this._stb3.set(i[4*o],i[4*o+1],i[4*o+2]),this._chassisBody.getAngularVelocityToRef(this._stb4);var a=BABYLON.Vector3.Dot(this._stb4,this._stb1),s=BABYLON.Vector3.Dot(this._stb4,this._stb2),l=BABYLON.Vector3.Dot(this._stb4,this._stb3),u=(BABYLON.Scalar.Clamp(BABYLON.Vector3.Dot(this._stb2,t),-1,1),BABYLON.Scalar.Clamp(1-Math.exp(-this.smoothFlyingImpulse*e),0,.95));a*=1-u,l*=1-u,BABYLON.Vector3.CrossToRef(this._stb2,t,this._stb5);var h=this._stb5.lengthSquared();this._stb4.set(this._stb1.x*a+this._stb2.x*s+this._stb3.x*l,this._stb1.y*a+this._stb2.y*s+this._stb3.y*l,this._stb1.z*a+this._stb2.z*s+this._stb3.z*l),h>1e-8&&(this._stb5.scaleInPlace(this.smoothFlyingImpulse*e),this._stb4.addInPlace(this._stb5)),this._chassisBody.setAngularVelocity(this._stb4)}},i.prototype.applyGroundedAutoLevel=function(e,t,i,n){if(!this.groundedAutoLevelEnabled||e<=0)this._groundedAutoLevelWasActive=!1;else{var r=this._wheelInfo.length;if(r<=0||t<=0)this._groundedAutoLevelWasActive=!1;else{var o=this._chassisTransform.m,a=this._indexRightAxis,s=this._indexUpAxis,l=this._indexForwardAxis;this._stb1.set(o[4*a],o[4*a+1],o[4*a+2]),this._stb2.set(o[4*s],o[4*s+1],o[4*s+2]),this._stb3.set(o[4*l],o[4*l+1],o[4*l+2]),this.getGravityUpToRef(this._stb4);var u=BABYLON.Scalar.Clamp(BABYLON.Vector3.Dot(i,this._stb4),-1,1),h=1;if(u<1){var c=BABYLON.Scalar.Clamp(this.groundedAutoLevelTrackNormalMinDot,-1,.999);h=BABYLON.Scalar.Clamp((u-c)/(1-c),0,1)}this._stb5.set(this._stb4.x*(1-h)+i.x*h,this._stb4.y*(1-h)+i.y*h,this._stb4.z*(1-h)+i.z*h),this._stb5.lengthSquared()<=1e-8?this._stb5.copyFrom(this._stb4):this._stb5.normalize();var d=BABYLON.Scalar.Clamp(BABYLON.Vector3.Dot(this._stb2,this._stb5),-1,1),m=BABYLON.Scalar.Clamp(this.groundedAutoLevelDeadzoneDeg,0,89),p=BABYLON.Scalar.Clamp(Math.min(this.groundedAutoLevelSettleDeg,m),0,m),f=BABYLON.Scalar.Clamp(this.groundedAutoLevelHysteresisDeg,0,p),g=m*Math.PI/180,y=p*Math.PI/180,v=f*Math.PI/180,S=Math.min(y+v,g),_=Math.max(y-v,0),b=this._groundedAutoLevelWasActive?_:S,B=Math.acos(d);if(B<=b)this._groundedAutoLevelWasActive=!1;else if(BABYLON.Vector3.CrossToRef(this._stb2,this._stb5,this._stb4),this._stb4.lengthSquared()<=1e-8)this._groundedAutoLevelWasActive=!1;else{var C=Math.abs(this._currentVehicleSpeedKmHour),A=1,T=this.groundedAutoLevelFullKmh-this.groundedAutoLevelStartKmh;T>0?A=BABYLON.Scalar.Clamp((C-this.groundedAutoLevelStartKmh)/T,0,1):C<this.groundedAutoLevelStartKmh&&(A=0);var M=this.groundedAutoLevelStrength*(.45+.55*A);if(t<r&&(M*=this.groundedAutoLevelPartialContactBoost),n&&(M*=this.groundedAutoLevelSlideScale),M<=0)this._groundedAutoLevelWasActive=!1;else{var L=this.groundedAutoLevelMaxRate,P=0;if(B<=g){var w=Math.max(g-b,.05),x=BABYLON.Scalar.Clamp((B-b)/w,0,1);P=M*BABYLON.Scalar.Clamp(this.groundedAutoLevelSettleScale,0,1)*(.4+.6*x),L*=.35+.45*x}else{var O=Math.max(20*Math.PI/180-g,.05);P=M*(.35+.65*BABYLON.Scalar.Clamp((B-g)/O,0,1))}if(P<=1e-4)this._groundedAutoLevelWasActive=!1;else{this._chassisBody.getAngularVelocityToRef(this._sv9);var R=BABYLON.Vector3.Dot(this._sv9,this._stb1),I=BABYLON.Vector3.Dot(this._sv9,this._stb2),N=BABYLON.Vector3.Dot(this._sv9,this._stb3),k=BABYLON.Scalar.Clamp(BABYLON.Vector3.Dot(this._stb4,this._stb1)*P,-L,L),F=BABYLON.Scalar.Clamp(BABYLON.Vector3.Dot(this._stb4,this._stb3)*P,-L,L),D=BABYLON.Scalar.Clamp(1-Math.exp(-P*e),0,.85);R+=(k-R)*D,N+=(F-N)*D,this._sv9.set(this._stb1.x*R+this._stb2.x*I+this._stb3.x*N,this._stb1.y*R+this._stb2.y*I+this._stb3.y*N,this._stb1.z*R+this._stb2.z*I+this._stb3.z*N),this._chassisBody.setAngularVelocity(this._sv9),this._groundedAutoLevelWasActive=!0}}}}}},i.prototype.applyTrackConnectionAndDownforce=function(e,t,i){if(!(e<=0||this._chassisMass<=0)){var n=this._wheelInfo.length;if(!(n<=0)){var r=9.81,o=null!=this._chassisBody.transformNode?this._chassisBody.transformNode.getScene():null;if(null!=o&&null!=o.gravity){var a=o.gravity.length();a>1e-4&&(r=a)}this._chassisBody.getObjectCenterWorldToRef(this._sv7);var s=Math.abs(this._currentVehicleSpeedKmHour),l=s/3.6;if(this.trackConnectionAccel>0&&t<n){var u=(n-t)/n,h=this.trackConnectionAccel;if(0===t&&this.airborneTrackConnectionMaxAccel>h){var c=1,d=this.airborneTrackConnectionFullKmh-this.airborneTrackConnectionStartKmh;d>0?c=BABYLON.Scalar.Clamp((s-this.airborneTrackConnectionStartKmh)/d,0,1):s<this.airborneTrackConnectionStartKmh&&(c=0),h+=(this.airborneTrackConnectionMaxAccel-h)*c}var m=h*this._chassisMass*u;i.scaleToRef(-m*e,this._sv1),this._chassisBody.applyImpulse(this._sv1,this._sv7)}if(t<=0){if(this.airborneRiseDamping>0||this.airborneMaxRiseSpeed>0){this._chassisBody.getLinearVelocityToRef(this._sv8);var p=BABYLON.Vector3.Dot(this._sv8,i);if(p>0){var f=0;if(this.airborneRiseDamping>0&&(f+=p*BABYLON.Scalar.Clamp(1-Math.exp(-this.airborneRiseDamping*e),0,.95)),this.airborneMaxRiseSpeed>0){var g=p-f;g>this.airborneMaxRiseSpeed&&(f+=g-this.airborneMaxRiseSpeed)}if((f=BABYLON.Scalar.Clamp(f,0,p))>1e-4){var y=f*this._chassisMass;i.scaleToRef(-y,this._sv1),this._chassisBody.applyImpulse(this._sv1,this._sv7)}}}}else{if(this.constantDownforce>0){var v=this._chassisMass*r*this.constantDownforce;i.scaleToRef(-v*e,this._sv1),this._chassisBody.applyImpulse(this._sv1,this._sv7)}if(this.downforceCoefficient>0&&l>1){var S=this.downforceCoefficient*l*l;i.scaleToRef(-S*e,this._sv1),this._chassisBody.applyImpulse(this._sv1,this._sv7)}}}}},i.prototype.updateVehicle=function(t){var i=this._wheelInfo.length;t>1/30&&(t=1/30),this.getChassisWorldTransform();for(var n=0;n<i;n++)this.updateWheelTransform(n,!1);this._chassisBody.getLinearVelocityToRef(this._sv1),this._currentVehicleSpeedKmHour=3.6*Math.sqrt(this._sv1.x*this._sv1.x+this._sv1.y*this._sv1.y+this._sv1.z*this._sv1.z);var r=this._chassisTransform.m,o=this._indexForwardAxis;this._sv2.set(r[4*o],r[4*o+1],r[4*o+2]),BABYLON.Vector3.Dot(this._sv2,this._sv1)<0&&(this._currentVehicleSpeedKmHour*=-1),this.raycastDebugLogEnabled&&this._raycastDebugFrameCounter++;var a=0;for(n=0;n<i;n++){var s=this._wheelInfo[n];this.rayCast(s);var l=s.raycastInfo.isInContact;l||!0!==this.enableMultiRaycast||(this.rayCast(s,.95),l=s.raycastInfo.isInContact),l&&a++}this.computeStabilizationUpVector(t,a,this._sv10),0===a&&this.smoothFlyingImpulse>0&&this.applyFlyingStabilization(t,this._sv10);var u=Math.abs(this._currentVehicleSpeedKmHour),h=this.isArcadeHandBrakeActive||this.isArcadeWheelSkidActive||this.isArcadeBurnoutModeActive||this.isArcadeDonutModeActive;if(this.sideToSideStabilityEnabled&&a>0&&u>this.sideToSideStabilityStartKmh&&!h){var c=this.sideToSideStabilityFullKmh-this.sideToSideStabilityStartKmh;c>0&&Math.min((u-this.sideToSideStabilityStartKmh)/c,1)}e.RigidbodyPhysics.SetAngularFactor(this._chassisBody,this.angularDamping.x,1,this.angularDamping.z),this.applyGroundedAutoLevel(t,a,this._sv10,h),this.applyHandbrakeYawAssist(t,u,this._currentVehicleSpeedKmHour),this.applyEasyDonutYawAssist(t,u,this._currentVehicleSpeedKmHour),this.updateSuspension(t);var d=0,m=0;for(this._sv6.set(0,0,0),n=0;n<i;n++)if((s=this._wheelInfo[n]).raycastInfo.isInContact){var p=s.suspensionForce;p>s.maxSuspensionForce&&(p=s.maxSuspensionForce),d+=p,this._sv6.addInPlace(s.raycastInfo.contactNormalWS),m++}for(m>0&&(d/=m,this._sv6.scaleInPlace(1/m),this._sv6.normalize()),this._chassisBody.getObjectCenterWorldToRef(this._sv5),m>0&&(this._sv6.scaleToRef(d*t*m,this._sv1),this._chassisBody.applyImpulse(this._sv1,this._sv5)),n=0;n<i;n++)if((s=this._wheelInfo[n]).raycastInfo.isInContact){var f=s.suspensionForce;f>s.maxSuspensionForce&&(f=s.maxSuspensionForce);var g=f-d;0!==g&&(s.raycastInfo.contactNormalWS.scaleToRef(g*t,this._sv1),this._chassisBody.applyImpulse(this._sv1,s.raycastInfo.contactPointWS))}this.updateFriction(t),this.updateArcadeWheelRotationBoost(t),this.applyTrackConnectionAndDownforce(t,a,this._sv10);for(var y=!0===this.isArcadeBurnoutModeActive||!0===this.isArcadeDonutModeActive||!0===this.isArcadeHandBrakeActive||!0===this.isArcadeWheelSkidActive,v=!1,S=0;S<i;S++)if(Math.abs(this._wheelInfo[S].engineForce)>1e-4){v=!0;break}var _=this.wheelAtRestSpeedThresholdKmh>0&&Math.abs(this._currentVehicleSpeedKmHour)<this.wheelAtRestSpeedThresholdKmh&&(!y||!v);for(n=0;n<i;n++){s=this._wheelInfo[n];var b=0;if(this.velocityAtWorldPoint(this._chassisBody,s.raycastInfo.hardPointWS,this._sv1),s.raycastInfo.isInContact){this._sv2.set(r[4*o],r[4*o+1],r[4*o+2]);var B=BABYLON.Vector3.Dot(this._sv2,s.raycastInfo.contactNormalWS);s.raycastInfo.contactNormalWS.scaleToRef(B,this._sv3),this._sv2.subtractInPlace(this._sv3),b=BABYLON.Vector3.Dot(this._sv2,this._sv1)/s.wheelRadius}if(!0!==_){var C=this.getWheelAngularVelocity(n,b,t,s.raycastInfo.isInContact);s.deltaRotation=C*t,s.rotation+=s.deltaRotation,s.deltaRotation*=.99}else s.rotationBoost=0,s.deltaRotation=0}this.clampChassisYawRate(t)},i.prototype.updateSuspension=function(e){for(var t=this._chassisMass,i=0;i<this._wheelInfo.length;i++){var n=this._wheelInfo[i];if(n.raycastInfo.isInContact){var r,o=n.getSuspensionRestLength()-n.raycastInfo.suspensionLength;r=n.suspensionStiffness*o*n.clippedInvContactDotSuspension;var a,s=n.suspensionRelativeVelocity;if(a=s<0?n.dampingCompression:n.dampingRelaxation,1!==this.suspensionDampingOverdrive&&(a*=this.suspensionDampingOverdrive),r-=a*s,n.suspensionForce=r*t,n.suspensionForce<0&&(n.suspensionForce=0),this.suspensionForceSmoothing>0&&n._prevSuspensionForce>=0){var l=this.suspensionForceSmoothing;n.suspensionForce=n.suspensionForce*(1-l)+n._prevSuspensionForce*l}n._prevSuspensionForce=n.suspensionForce}else this.trackConnectionAccel>0?n.suspensionForce=-this.trackConnectionAccel*t:n.suspensionForce=0,n._prevSuspensionForce=-1}},i.prototype.getSteeringAuthorityInput=function(){var e=BABYLON.Scalar.Clamp(this.currentSteeringInput,-1,1);if(Math.abs(e)>.001)return e;var t=this.getSignedFrontSteeringAngleRad();return BABYLON.Scalar.Clamp(t/.6,-1,1)},i.prototype.getSteeringMagnitude=function(){return Math.abs(this.getSteeringAuthorityInput())},i.prototype.applyEasyDonutYawAssist=function(e,t,i){if(!0!==this.isArcadeDonutModeActive)return this._arcadeDonutHoldElapsedSec=0,void(this._arcadeDonutDirectionSign=0);if(!0===this.arcadeDonutDirectYawEnabled){var n=this.getSignedFrontSteeringAngleRad();if(Math.abs(n)<=.02||this.arcadeSteeringAssist<=0)this._arcadeDonutHoldElapsedSec+=e;else{var r=this.arcadeDonutDirectYawDurationMs>0?this.arcadeDonutDirectYawDurationMs/1e3:0,o=this.arcadeDonutDirectYawFadeMs>0?this.arcadeDonutDirectYawFadeMs/1e3:0,a=this._arcadeDonutHoldElapsedSec,s=o>0?BABYLON.Scalar.Clamp(a/o,0,1):1,l=1;if(r>0){var u=r-a;u<=0?l=0:o>0&&u<o&&(l=u/o)}var h=Math.min(s,l);if(h<=0)this._arcadeDonutHoldElapsedSec+=e;else{var c=this._chassisTransform.m,d=this._indexForwardAxis,m=this._indexUpAxis,p=this._sv6,f=this._sv5;p.set(c[4*d],c[4*d+1],c[4*d+2]),f.set(c[4*m],c[4*m+1],c[4*m+2]),this._chassisBody.getLinearVelocityToRef(this._sv8);var g=BABYLON.Vector3.Dot(this._sv8,p),y=n>=0?1:-1;0===this._arcadeDonutDirectionSign&&(this._arcadeDonutDirectionSign=Math.abs(g)>.25?g>=0?1:-1:y);var v=BABYLON.Tools.ToRadians(this.arcadeDonutDirectYawDegPerSec)*this._arcadeDonutDirectionSign*y*h;if(Math.abs(v)<=1e-5)this._arcadeDonutHoldElapsedSec+=e;else{this._chassisBody.getAngularVelocityToRef(this._sv9);var S=BABYLON.Vector3.Dot(this._sv9,f),_=S+(v-S)*BABYLON.Scalar.Clamp(1-Math.exp(-14*e),0,1),b=.55*Math.abs(v);(Math.sign(_)!==Math.sign(v)||Math.abs(_)<b)&&(_=Math.sign(v)*b),f.scaleToRef(S,this._sv1),this._sv9.subtractToRef(this._sv1,this._sv2),f.scaleToRef(_,this._sv3),this._sv2.addToRef(this._sv3,this._sv9),this._chassisBody.setAngularVelocity(this._sv9),this._arcadeDonutHoldElapsedSec+=e}}}}},i.prototype.applyHandbrakeYawAssist=function(e,t,i){if(this.isArcadeYawAssistActive=!1,this.arcadeHandbrakeAssistEnabled){var n=this.getSteeringMagnitude(),r=this.getSteeringAuthorityInput();if(this.isArcadeHandBrakeActive&&!(n<.02)){var o=Math.max(0,t/3.6),a=BABYLON.Scalar.Clamp((o-.5)/3,0,1);if(!(a<=0)){var s=this._chassisTransform.m,l=this._indexRightAxis,u=this._indexUpAxis,h=this._indexForwardAxis;this._stb1.set(s[4*l],s[4*l+1],s[4*l+2]),this._stb2.set(s[4*u],s[4*u+1],s[4*u+2]),this._stb3.set(s[4*h],s[4*h+1],s[4*h+2]),this._chassisBody.getAngularVelocityToRef(this._sv9);var c=BABYLON.Vector3.Dot(this._sv9,this._stb1),d=BABYLON.Vector3.Dot(this._sv9,this._stb2),m=BABYLON.Vector3.Dot(this._sv9,this._stb3),p=this.getSignedFrontSteeringAngleRad(),f=this.getApproxWheelbaseMeters(),g=0;f>.5&&o>.2&&Math.abs(p)>1e-4&&(g=o/f*Math.tan(p));var y=r*this.arcadeSteeringAssist*(.25+1*n)*a,v=Math.abs(g)>Math.abs(y)?g:y;if(v*d>=0&&Math.abs(d)>=Math.abs(v))this.isArcadeYawAssistActive=!0;else{var S=(.15+.35*n)*a,_=BABYLON.Scalar.Clamp(v*(2+4*n)*e,-S,S);Math.abs(_)<1e-6||(d+=_,this._sv9.set(this._stb1.x*c+this._stb2.x*d+this._stb3.x*m,this._stb1.y*c+this._stb2.y*d+this._stb3.y*m,this._stb1.z*c+this._stb2.z*d+this._stb3.z*m),this._chassisBody.setAngularVelocity(this._sv9),this.isArcadeYawAssistActive=!0)}}}}},i.prototype.resolveWheelSpinDirection=function(e,t,i){if(Math.abs(t)>1e-4)return t<0?-1:1;if(Math.abs(i)>1e-4)return i<0?-1:1;var n=this._wheelInfo[e];if(null!=n){if(Math.abs(n.deltaRotation)>1e-4)return n.deltaRotation<0?-1:1;if(Math.abs(n.rotationBoost)>1e-4)return n.rotationBoost<0?-1:1}return 0},i.prototype.updateArcadeWheelRotationBoost=function(e){for(var t=this.isArcadeBurnoutModeActive||this.isArcadeDonutModeActive,i=this.isArcadeBurnoutModeActive&&this.isArcadeHandBrakeActive&&Math.abs(this._currentVehicleSpeedKmHour)<=this.wheelAtRestSpeedThresholdKmh+2,n=BABYLON.Scalar.Clamp(e*this.arcadeWheelSpinBuildSpeed,0,1),r=0;r<this._wheelInfo.length;r++){var o=this._wheelInfo[r];this._arcadePreviousWheelSpin[r]=o.rotationBoost;var a=o.rotationBoost,s=0,l=o.defaultFriction>0?o.defaultFriction:o.frictionSlip,u=l>0?BABYLON.Scalar.Clamp(o.frictionSlip/l,0,1):1,h=o.engineForce*e,c=0;if(Math.abs(h)>1e-4&&r<this._forwardImpulse.length){var d=this._forwardImpulse[r];(h>0&&d>0||h<0&&d<0)&&(c=Math.sign(h)*Math.min(Math.abs(d),Math.abs(h)))}var m=Math.max(0,Math.abs(h)-Math.abs(c)),p=Math.abs(h)>1e-4?BABYLON.Scalar.Clamp(m/Math.abs(h),0,1):0,f=Math.max(0,o.suspensionForce*e*o.frictionSlip),g=o.raycastInfo.groundObject&&f>1e-4?BABYLON.Scalar.Clamp(Math.abs(this._sideImpulse[r])/f,0,1):0,y=BABYLON.Scalar.Clamp(1-o.skidInfo,0,1),v=this.resolveWheelSpinDirection(r,h,c);if(t&&0!==v&&Math.abs(h)>1e-4){var S=p,_=1;if(this.isArcadeBurnoutModeActive&&(S=Math.max(S,.65*y),_=Math.max(_,this.arcadeBurnoutWheelSpinGain),i&&(S=Math.max(S,1),_=Math.max(_,this.arcadeStationaryBurnoutWheelSpinGain))),this.isArcadeDonutModeActive&&(S=Math.max(S,.9*g,.5*y),_=Math.max(_,this.arcadeDonutWheelSpinGain)),o.raycastInfo.groundObject||(S=Math.max(S,1)),S>0){var b=m*this._chassisInvMass;if(o.raycastInfo.groundObject||(b=Math.max(b,Math.abs(h)*this._chassisInvMass)),s=v*(b/Math.max(o.wheelRadius,1e-4)/Math.max(e,1e-4))*_*BABYLON.Scalar.Lerp(.2,1,S),i){var B=Math.max(0,this.arcadeStationaryBurnoutMinAngularVelocity);Math.abs(s)<B&&(s=v*B)}}}if(Math.abs(s)>0){if(a*s<0){var C=BABYLON.Scalar.Clamp(e*this.arcadeWheelSpinRecoverySpeed*2,0,1);a=BABYLON.Scalar.Lerp(a,0,C)}a=BABYLON.Scalar.Lerp(a,s,n)}if(o.raycastInfo.groundObject){var A=Math.max(p,.5*y);this.isArcadeDonutModeActive&&(A=Math.max(A,g));var T=this.arcadeWheelSpinRecoverySpeed*(.25+.75*u)*(1-Math.min(A,.92));t||(T=this.arcadeWheelSpinRecoverySpeed*(.75+1.5*u));var M=BABYLON.Scalar.Clamp(e*T,0,1);a=BABYLON.Scalar.Lerp(a,0,M)}else a*=Math.pow(this.arcadeWheelSpinAirDamping,60*e);a=BABYLON.Scalar.Clamp(a,-this.arcadeWheelSpinMaxAngularVelocity,this.arcadeWheelSpinMaxAngularVelocity),Math.abs(this._currentVehicleSpeedKmHour)<1&&(!t||Math.abs(h)<=1e-4)&&(a=0),Math.abs(a)<.001&&(a=0),o.rotationBoost=a}},i.prototype.getWheelAngularVelocity=function(e,t,i,n){var r=this._wheelInfo[e];return null==r||i<=0?0:n?t+r.rotationBoost:r.deltaRotation/i-(e<this._arcadePreviousWheelSpin.length?this._arcadePreviousWheelSpin[e]:0)+r.rotationBoost},i.prototype.getArcadeBurnoutDirectionChangeFactor=function(e,t){if(!this.isArcadeBurnoutModeActive||null==e||Math.abs(e.engineForce)<=1e-4)return 0;var i=Math.max(0,this.arcadeBurnoutDirectionChangeSpeedKmh);if(i>0&&Math.abs(this._currentVehicleSpeedKmHour)>i)return 0;var n=-t*(e.engineForce<0?-1:1);if(n<=.15)return 0;var r=BABYLON.Scalar.Clamp((n-.15)/2.5,0,1);if(i<=0)return r;var o=1-BABYLON.Scalar.Clamp(Math.abs(this._currentVehicleSpeedKmHour)/i,0,1);return r*BABYLON.Scalar.Lerp(.45,1,o)},i.prototype.updateArcadeSkidInfo=function(e,t,i){var n=e<this._arcadeSkidInfo.length?this._arcadeSkidInfo[e]:1,r=BABYLON.Scalar.Clamp(t,0,1),o=r<n?this.wheelSkidFadeInSpeed:this.wheelSkidFadeOutSpeed,a=BABYLON.Scalar.Clamp(i*o,0,1);return n=BABYLON.Scalar.Lerp(n,r,a),Math.abs(n-r)<.001&&(n=r),this._arcadeSkidInfo[e]=n,n},i.prototype.updateFriction=function(e){var t=this._wheelInfo.length;if(0!==t){for(var i=0,n=0;n<t;n++)(le=this._wheelInfo[n]).raycastInfo.groundObject&&i++,this._sideImpulse[n]=0,this._forwardImpulse[n]=0;for(n=0;n<t;n++)if((le=this._wheelInfo[n]).raycastInfo.groundObject){var r=this._sv5;le.raycastInfo.wheelDirectionWS.negateToRef(r),BABYLON.Quaternion.RotationAxisToRef(r,le.steering,this._sq1),BABYLON.Matrix.FromQuaternionToRef(this._sq1,this._sm2),BABYLON.Vector3.TransformNormalToRef(le.raycastInfo.wheelAxleWS,this._sm2,this._axle[n]);var o=le.raycastInfo.contactNormalWS,a=BABYLON.Vector3.Dot(this._axle[n],o);if(o.scaleToRef(a,this._sv6),this._axle[n].subtractInPlace(this._sv6),this._axle[n].normalize(),BABYLON.Vector3.CrossToRef(o,this._axle[n],this._forwardWS[n]),this._forwardWS[n].normalize(),this._sideImpulse[n]=this.resolveSingleBilateral(this._chassisBody,le.raycastInfo.contactPointWS,this._axle[n]),this._sideImpulse[n]*=this.sideFrictionStiffness,this.arcadeSideSlipSaturationEnabled&&0!==this._sideImpulse[n]){this.velocityAtWorldPoint(this._chassisBody,le.raycastInfo.contactPointWS,this._sv8);var s=BABYLON.Vector3.Dot(this._axle[n],this._sv8),l=BABYLON.Vector3.Dot(this._forwardWS[n],this._sv8),u=s*s+l*l,h=this.arcadeSideSlipMinSpeedMps;if(u>h*h){var c=Math.atan2(Math.abs(s),Math.max(Math.abs(l),.001)),d=BABYLON.Tools.ToRadians(Math.max(this.arcadeSideSlipPeakDeg,.1));if(c>d){var m=Math.sin(d)/Math.max(Math.sin(c),.001),p=Math.max(this.arcadeSideSlipFalloffDeg-this.arcadeSideSlipPeakDeg,.1),f=Math.min(Math.max((BABYLON.Tools.ToDegrees(c)-this.arcadeSideSlipPeakDeg)/p,0),1),g=BABYLON.Scalar.Lerp(1,this.arcadeSideSlipFalloffFactor,f);this._sideImpulse[n]*=m*g}}}}for(var y=!1,v=0;v<t;v++){var S=0,_=1,b=!1,B=!1,C=0,A=0,T=0;if((le=this._wheelInfo[v]).raycastInfo.groundObject)if(0!==le.engineForce)S=le.engineForce*e;else{var M=le.brake?le.brake:0;S=this.calcRollingFriction(this._chassisBody,le.raycastInfo.contactPointWS,this._forwardWS[v],M,i)}if(this._forwardImpulse[v]=0,this._wheelInfo[v].skidInfo=1,le.raycastInfo.groundObject){this._wheelInfo[v].skidInfo=1;var L=le.suspensionForce*e*le.frictionSlip,P=L*L;this._forwardImpulse[v]=S;var w=.5*this._forwardImpulse[v],x=1*this._sideImpulse[v],O=w*w+x*x,R=Math.sqrt(O);if(O>P){y=!0;var I=L/Math.sqrt(O);this._wheelInfo[v].skidInfo*=I}if(B=(b=(this.isArcadeHandBrakeActive||this.isArcadeWheelSkidActive)&&le.brake>0&&0===le.engineForce)||this.isArcadeWheelSkidActive||this.isArcadeBurnoutModeActive||this.isArcadeDonutModeActive){this.velocityAtWorldPoint(this._chassisBody,le.raycastInfo.contactPointWS,this._sv3);var N=BABYLON.Vector3.Dot(this._forwardWS[v],this._sv3);C=Math.abs(N),A=Math.abs(BABYLON.Vector3.Dot(this._axle[v],this._sv3)),T=this.getArcadeBurnoutDirectionChangeFactor(le,N)}if(this.isArcadeBurnoutModeActive&&L>0){var k=L;T>0&&(k*=BABYLON.Scalar.Lerp(1,this.arcadeBurnoutDirectionChangeGripScale,T));var F=Math.abs(this._forwardImpulse[v]);if(F>k){var D=k/F;this._forwardImpulse[v]*=D,this._wheelInfo[v].skidInfo=Math.min(this._wheelInfo[v].skidInfo,D),y=!0}if(T>0){var E=BABYLON.Scalar.Lerp(.18,.02,T);this._wheelInfo[v].skidInfo=Math.min(this._wheelInfo[v].skidInfo,E),y=!0}}if(B){var V=BABYLON.Scalar.Clamp((Math.abs(this._currentVehicleSpeedKmHour)-2)/20,0,1),Y=BABYLON.Scalar.Clamp((C-.5)/6,0,1),U=BABYLON.Scalar.Clamp((A-.2)/4,0,1),W=L>0?BABYLON.Scalar.Clamp((R/L-.55)/.45,0,1):0,G=L>0?BABYLON.Scalar.Clamp(Math.abs(this._forwardImpulse[v])/L,0,1):0;if(b){var H=Math.max(Y,V);H>0&&(_=Math.min(_,BABYLON.Scalar.Lerp(.32,.02,H)))}if(this.isArcadeWheelSkidActive){var z=Math.max(W,U,.85*Y);z>0&&(_=Math.min(_,BABYLON.Scalar.Lerp(.34,.05,z)))}if(this.isArcadeBurnoutModeActive&&0!==le.engineForce){var K=Math.max(G,Y,.7*V);if(T>0&&(K=Math.max(K,T)),K>0){var X=le.isFrontWheel?.38:.28,Q=le.isFrontWheel?.12:.04;_=Math.min(_,BABYLON.Scalar.Lerp(X,Q,K))}if(T>0){var j=le.isFrontWheel?.24:.1,Z=le.isFrontWheel?.08:.02;_=Math.min(_,BABYLON.Scalar.Lerp(j,Z,T))}}if(this.isArcadeDonutModeActive){var J=Math.max(U,G,.9*V,.75*Y);if(le.isFrontWheel||(J=Math.max(J,.55*V)),J>0){var q=le.isFrontWheel?.42:.24,$=le.isFrontWheel?.16:.03;_=Math.min(_,BABYLON.Scalar.Lerp(q,$,J))}}}}var ee=this.updateArcadeSkidInfo(v,_,e);le.raycastInfo.groundObject&&(this._wheelInfo[v].skidInfo=Math.min(this._wheelInfo[v].skidInfo,ee))}if(y)for(v=0;v<t;v++)0!==this._sideImpulse[v]&&this._wheelInfo[v].skidInfo<1&&(this.isArcadeBurnoutModeActive||(this._forwardImpulse[v]*=this._wheelInfo[v].skidInfo),this._sideImpulse[v]*=this._wheelInfo[v].skidInfo);var te=0,ie=0;for(v=0;v<t;v++)this._wheelInfo[v].raycastInfo.groundObject&&0!==this._sideImpulse[v]&&(te+=this._sideImpulse[v],ie++);ie>0&&(te/=ie);var ne=0,re=Math.abs(this._currentVehicleSpeedKmHour);if(!(this.isArcadeHandBrakeActive||this.isArcadeWheelSkidActive||this.isArcadeBurnoutModeActive||this.isArcadeDonutModeActive)&&this.sideToSideStabilityEnabled&&re>this.sideToSideStabilityStartKmh){var oe=this.sideToSideStabilityFullKmh-this.sideToSideStabilityStartKmh;oe>0&&(ne=.7*Math.min((re-this.sideToSideStabilityStartKmh)/oe,1))}this._chassisBody.getObjectCenterWorldToRef(this._sv7);var ae=this._indexUpAxis,se=this._chassisTransform.m;for(this._sv2.set(se[4*ae],se[4*ae+1],se[4*ae+2]),v=0;v<t;v++){var le=this._wheelInfo[v];if(0!==this._forwardImpulse[v]&&(this._forwardWS[v].scaleToRef(this._forwardImpulse[v],this._sv1),this._chassisBody.applyImpulse(this._sv1,this._sv7)),0!==this._sideImpulse[v]){le.raycastInfo.contactPointWS.subtractToRef(this._sv7,this._sv1);var ue=BABYLON.Vector3.Dot(this._sv2,this._sv1);this._sv2.scaleToRef(ue*(1-le.rollInfluence),this._sv3),this._sv1.subtractInPlace(this._sv3),this._sv7.addToRef(this._sv1,this._sv4);var he=this._sideImpulse[v]-te,ce=te+he*ne,de=he*(1-ne);this._axle[v].scaleToRef(ce,this._sv5),this._chassisBody.applyImpulse(this._sv5,this._sv7),0!==de&&(this._axle[v].scaleToRef(de,this._sv5),this._chassisBody.applyImpulse(this._sv5,this._sv4))}}}},i.prototype.velocityAtWorldPoint=function(e,t,i){e.getObjectCenterWorldToRef(this._vapCenter),t.subtractToRef(this._vapCenter,this._vapRelPos),e.getAngularVelocityToRef(this._vapAngVel),BABYLON.Vector3.CrossToRef(this._vapAngVel,this._vapRelPos,this._vapCross),e.getLinearVelocityToRef(this._vapLinVel),this._vapLinVel.addToRef(this._vapCross,i)},i.prototype.resolveSingleBilateral=function(e,t,i){return i.lengthSquared()>1.1?0:(this.velocityAtWorldPoint(e,t,this._rsbVel1),-.2*BABYLON.Vector3.Dot(i,this._rsbVel1)*this._chassisMass)},i.prototype.calcRollingFriction=function(e,t,i,n,r){this.velocityAtWorldPoint(e,t,this._crfVel1);var o=-BABYLON.Vector3.Dot(i,this._crfVel1)*this._chassisMass;return r>0&&(o/=r),o>n&&(o=n),o<-n&&(o=-n),o},i.prototype.clampChassisYawRate=function(e){if(!(this.maximumYawRateLow<=0&&this.maximumYawRateHigh<=0)){var t=!0===this.isArcadeHandBrakeActive||!0===this.isArcadeBurnoutModeActive||!0===this.isArcadeDonutModeActive;if(!(!0===t&&!0===this.isArcadeHandBrakeActive&&this.arcadeHandbrakeYawCapMultiplier<=0||!0===t&&!0===this.isArcadeBurnoutModeActive&&this.arcadeBurnoutYawCapMultiplier<=0||!0===t&&!0===this.isArcadeDonutModeActive&&this.arcadeDonutYawCapMultiplier<=0)){var i=BABYLON.Scalar.Lerp(this.maximumYawRateLow,this.maximumYawRateHigh,this.smoothedGradientSpeed);if(!0===t&&(!0===this.isArcadeHandBrakeActive&&(i*=this.arcadeHandbrakeYawCapMultiplier),!0===this.isArcadeBurnoutModeActive&&(i*=this.arcadeBurnoutYawCapMultiplier),!0===this.isArcadeDonutModeActive&&(i*=this.arcadeDonutYawCapMultiplier)),!(i<=0)){var n=BABYLON.Tools.ToRadians(i),r=this._chassisBody.getAngularVelocity();if(null!=r){var o=Math.abs(r.y);if(o>n)r.y=Math.sign(r.y)*n*.95,this._chassisBody.setAngularVelocity(r);else if(o>.85*n){var a=(o-.85*n)/(.15*n);r.y*=1-.15*a,this._chassisBody.setAngularVelocity(r)}}}}}},i.prototype.getNaturalWheelSlip=function(e){var t=!1;return null!=this._wheelInfo[e]&&(t=!!this._wheelInfo[e].raycastInfo.groundObject&&this._wheelInfo[e].skidInfo<.999&&!this.isArcadeHandBrakeActive&&!this.isArcadeBurnoutModeActive&&!this.isArcadeDonutModeActive),t},i.prototype.getSignedFrontSteeringAngleRad=function(){for(var e=0,t=0,i=0;i<this._wheelInfo.length;i++)this._wheelInfo[i].isFrontWheel&&(e+=this._wheelInfo[i].steering,t++);return t>0?e/t:0},i.prototype.getApproxWheelbaseMeters=function(){for(var e=0,t=0,i=0,n=0,r=0;r<this._wheelInfo.length;r++){var o=this._wheelInfo[r].chassisConnectionPointCS.z;this._wheelInfo[r].isFrontWheel?(e+=o,i++):(t+=o,n++)}return 0===i||0===n?2.5:Math.abs(e/i-t/n)},i.prototype.dispose=function(){this._chassisBody=null,this._vehicleRaycaster=null,this._wheelInfo.length=0,this._forwardWS.length=0,this._axle.length=0,this._forwardImpulse.length=0,this._sideImpulse.length=0,this._arcadeSkidInfo.length=0,this._arcadePreviousWheelSpin.length=0},i.FILTER_GROUP_ALL_COLLIDERS=4294967295,i.FILTER_GROUP_VEHICLE_COLLIDERS=1048576,i.FILTER_GROUP_BRIDGE_COLLIDERS=2097152,i.FILTER_GROUP_ROAD_COLLIDERS=4194304,i.FILTER_GROUP_GRASS_COLLIDERS=8388608,i.FILTER_GROUP_CURB_COLLIDERS=16777216,i.FILTER_GROUP_FENCE_COLLIDERS=33554432,i.FILTER_GROUP_ALL_VEHICLE_COLLIDERS=66060288,i.VEHICLE_MESH_TAG="Vehicle",i.BRIDGE_MESH_TAG="Bridge",i.ROAD_MESH_TAG="Road",i.GRASS_MESH_TAG="Grass",i.CURB_MESH_TAG="Curb",i.FENCE_MESH_TAG="Fence",i}();e.btRaycastVehicle=o}(n||(n={})),function(e){var t=function(){function e(){}return e.CreatePostProcess=function(e,t,i){var n,r=(null==i?void 0:i.lutA)||null,o=(null==i?void 0:i.lutB)||null,a=null!==(n=null==i?void 0:i.mix)&&void 0!==n?n:0,s=new BABYLON.PostProcess("lutBlend","\n precision highp float;\n varying vec2 vUV;\n uniform sampler2D textureSampler;\n uniform sampler2D lutA;\n uniform sampler2D lutB;\n uniform float mixVal;\n uniform float lutTileCountA; // number of tiles per row for LUT A\n uniform float lutTileCountB; // number of tiles per row for LUT B\n\n vec3 sampleLUT(in sampler2D lut, in vec3 color, in float tileCount) {\n if (tileCount <= 0.5) return color;\n float tc = floor(tileCount + 0.5);\n float tileSize = 1.0 / tc;\n\n // For normalized RGB [0..1], compute position in LUT\n float r = color.r;\n float g = color.g;\n float b = color.b;\n\n // Determine slice and tile coords\n float slice = b * (tc - 1.0);\n float sliceIndex = floor(slice + 0.5);\n\n float tx = mod(sliceIndex, tc);\n float ty = floor(sliceIndex / tc);\n\n vec2 uv = vec2(tx * tileSize + r * tileSize, ty * tileSize + g * tileSize);\n vec3 sampled = texture2D(lut, uv).rgb;\n return sampled;\n }\n\n void main(void) {\n vec4 sceneColor = texture2D(textureSampler, vUV);\n vec3 a = sceneColor.rgb;\n if (lutTileCountA <= 0.5 || lutTileCountB <= 0.5) {\n // No LUT size provided fallback to passthrough\n gl_FragColor = sceneColor;\n return;\n }\n vec3 colA = sampleLUT(lutA, a, lutTileCountA);\n vec3 colB = sampleLUT(lutB, a, lutTileCountB);\n vec3 outc = mix(colA, colB, mixVal);\n gl_FragColor = vec4(outc, sceneColor.a);\n }\n ",["mixVal","lutTileCountA","lutTileCountB"],["lutA","lutB"],1,t,BABYLON.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1);function l(e,t){if(!e||!t)return 0;if(e%t===0)return Math.round(e/t);if(t%e===0)return Math.round(t/e);if(e===t){var i=Math.round(Math.sqrt(e));return i*i===e?i:Math.round(Math.sqrt(e))}return Math.round(Math.pow(e*t,1/3))}var u=0,h=0;return s.onApply=function(t){if(t.setFloat("mixVal",a),r&&"string"==typeof r){var i=new BABYLON.Texture(r,e,!0,!1,BABYLON.Texture.TRILINEAR_SAMPLINGMODE,void 0,void 0,void 0,!1);i.onLoadObservable.addOnce(function(){u=l(i.getSize?i.getSize().width:i.width,i.getSize?i.getSize().height:i.height)}),t.setTexture("lutA",i)}else if(r instanceof BABYLON.Texture){var n=r;u=l(n.getSize?n.getSize().width:n.width,n.getSize?n.getSize().height:n.height),t.setTexture("lutA",n)}if(o&&"string"==typeof o){var s=new BABYLON.Texture(o,e,!0,!1,BABYLON.Texture.TRILINEAR_SAMPLINGMODE,void 0,void 0,void 0,!1);s.onLoadObservable.addOnce(function(){h=l(s.getSize?s.getSize().width:s.width,s.getSize?s.getSize().height:s.height)}),t.setTexture("lutB",s)}else if(o instanceof BABYLON.Texture){var c=o;h=l(c.getSize?c.getSize().width:c.width,c.getSize?c.getSize().height:c.height),t.setTexture("lutB",c)}t.setFloat("lutTileCountA",u),t.setFloat("lutTileCountB",h)},s._detectedTileCountA=function(){return u},s._detectedTileCountB=function(){return h},s},e.prototype.getWGSLShaderCode=function(){return"\n [[group(0), binding(0)]] var textureSampler: texture_2d<f32>;\n [[group(0), binding(1)]] var textureSamplerSampler: sampler;\n [[group(0), binding(2)]] var lutA: texture_2d<f32>;\n [[group(0), binding(3)]] var lutASampler: sampler;\n [[group(0), binding(4)]] var lutB: texture_2d<f32>;\n [[group(0), binding(5)]] var lutBSampler: sampler;\n\n [[block]] struct Uniforms {\n mixVal: f32;\n lutTileCountA: f32;\n lutTileCountB: f32;\n };\n [[group(0), binding(6)]] var<uniform> uniforms: Uniforms;\n\n fn sampleLUT(lut: texture_2d<f32>, lutSamp: sampler, color: vec3<f32>, tileCount: f32) -> vec3<f32> {\n if (tileCount <= 0.5) { return color; }\n let tc = floor(tileCount + 0.5);\n let tileSize = 1.0 / tc;\n\n let r = color.r;\n let g = color.g;\n let b = color.b;\n\n let slice = b * (tc - 1.0);\n let sliceIndex = floor(slice + 0.5);\n\n let tx = sliceIndex % tc;\n let ty = floor(sliceIndex / tc);\n\n let uv = vec2<f32>(tx * tileSize + r * tileSize, ty * tileSize + g * tileSize);\n let sampled = textureSample(lut, lutSamp, uv).rgb;\n return sampled;\n }\n\n fn mainImage(vUV: vec2<f32>) -> vec4<f32> {\n let sceneColor = textureSample(textureSampler, textureSamplerSampler, vUV);\n let a = sceneColor.rgb;\n if (uniforms.lutTileCountA <= 0.5 || uniforms.lutTileCountB <= 0.5) {\n return sceneColor;\n }\n let colA = sampleLUT(lutA, lutASampler, a, uniforms.lutTileCountA);\n let colB = sampleLUT(lutB, lutBSampler, a, uniforms.lutTileCountB);\n let outc = mix(colA, colB, uniforms.mixVal);\n return vec4<f32>(outc, sceneColor.a);\n }\n "},e}();e.LUTBlendPlugin=t}(n||(n={})),function(e){var t=function(){function e(e){var t,i,n,r,o,a;this._distortionIntensity=null!==(t=null==e?void 0:e.distortionIntensity)&&void 0!==t?t:0,this._distortionIntensityX=null!==(i=null==e?void 0:e.distortionIntensityX)&&void 0!==i?i:0,this._distortionIntensityY=null!==(n=null==e?void 0:e.distortionIntensityY)&&void 0!==n?n:0,this._distortionCenterX=null!==(r=null==e?void 0:e.distortionCenterX)&&void 0!==r?r:.5,this._distortionCenterY=null!==(o=null==e?void 0:e.distortionCenterY)&&void 0!==o?o:.5,this._distortionScale=null!==(a=null==e?void 0:e.distortionScale)&&void 0!==a?a:1,this._updateEnabledState()}return Object.defineProperty(e.prototype,"distortionIntensity",{get:function(){return this._distortionIntensity},set:function(e){this._distortionIntensity!==e&&(this._distortionIntensity=e,this._updateEnabledState())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"distortionIntensityX",{get:function(){return this._distortionIntensityX},set:function(e){this._distortionIntensityX!==e&&(this._distortionIntensityX=e,this._updateEnabledState())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"distortionIntensityY",{get:function(){return this._distortionIntensityY},set:function(e){this._distortionIntensityY!==e&&(this._distortionIntensityY=e,this._updateEnabledState())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"distortionCenterX",{get:function(){return this._distortionCenterX},set:function(e){this._distortionCenterX=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"distortionCenterY",{get:function(){return this._distortionCenterY},set:function(e){this._distortionCenterY=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"distortionScale",{get:function(){return this._distortionScale},set:function(e){this._distortionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},enumerable:!1,configurable:!0}),e.prototype._updateEnabledState=function(){this._isEnabled=0!==this._distortionIntensity||0!==this._distortionIntensityX||0!==this._distortionIntensityY},e.prototype.getUniforms=function(){return{distortionIntensity:{type:"float",value:this._distortionIntensity},distortionIntensityX:{type:"float",value:this._distortionIntensityX},distortionIntensityY:{type:"float",value:this._distortionIntensityY},distortionCenter:{type:"vec2",value:[this._distortionCenterX,this._distortionCenterY]},distortionScale:{type:"float",value:this._distortionScale}}},e.prototype.getFragmentShaderCode=function(){return"\n uniform float distortionIntensity;\n uniform float distortionIntensityX;\n uniform float distortionIntensityY;\n uniform vec2 distortionCenter;\n uniform float distortionScale;\n\n void applyLensDistortion(inout vec4 color, vec2 uv) {\n // Calculate UV coordinates relative to center\n vec2 uvCentered = uv - distortionCenter;\n\n // Apply different distortion for X and Y if specified\n float intensityX = distortionIntensity + distortionIntensityX;\n float intensityY = distortionIntensity + distortionIntensityY;\n\n // Calculate distortion amount based on distance from center\n float r = length(uvCentered);\n float r2 = r * r;\n\n // Barrel distortion formula: r' = r * (1 + k1 * r^2 + k2 * r^4 + ...)\n // For simplicity, we use a quadratic approximation\n float distortion = 1.0 + intensityX * r2 + intensityY * r2 * r2;\n\n // Scale the distortion\n distortion *= distortionScale;\n\n // Apply distortion to UV coordinates\n vec2 distortedUV = distortionCenter + uvCentered * distortion;\n\n // Ensure UV coordinates stay within bounds\n distortedUV = clamp(distortedUV, vec2(0.0), vec2(1.0));\n\n // Sample the texture at the distorted position\n vec4 distortedColor = texture2D(diffuseSampler, distortedUV);\n\n // Mix with original color based on distortion strength\n float mixFactor = clamp(abs(distortionIntensity) + abs(distortionIntensityX) + abs(distortionIntensityY), 0.0, 1.0);\n color = mix(color, distortedColor, mixFactor);\n }\n "},e.prototype.getWGSLShaderCode=function(){return"\n [[group(0), binding(0)]] var diffuseSampler: texture_2d<f32>;\n [[group(0), binding(1)]] var diffuseSamplerSampler: sampler;\n\n struct Uniforms {\n distortionIntensity: f32;\n distortionIntensityX: f32;\n distortionIntensityY: f32;\n distortionCenter: vec2<f32>;\n distortionScale: f32;\n };\n\n [[group(0), binding(2)]] var<uniform> uniforms: Uniforms;\n\n fn applyLensDistortion(color: ptr<function, vec4<f32>>, uv: vec2<f32>) {\n // Calculate UV coordinates relative to center\n let uvCentered = uv - uniforms.distortionCenter;\n\n // Apply different distortion for X and Y if specified\n let intensityX = uniforms.distortionIntensity + uniforms.distortionIntensityX;\n let intensityY = uniforms.distortionIntensity + uniforms.distortionIntensityY;\n\n // Calculate distortion amount based on distance from center\n let r = length(uvCentered);\n let r2 = r * r;\n\n // Barrel distortion formula: r' = r * (1 + k1 * r^2 + k2 * r^4 + ...)\n let distortion = 1.0 + intensityX * r2 + intensityY * r2 * r2;\n\n // Scale the distortion\n let distortion_scaled = distortion * uniforms.distortionScale;\n\n // Apply distortion to UV coordinates\n let distortedUV = uniforms.distortionCenter + uvCentered * distortion_scaled;\n\n // Ensure UV coordinates stay within bounds\n let clampedUV = clamp(distortedUV, vec2<f32>(0.0), vec2<f32>(1.0));\n\n // Sample the texture at the distorted position\n let distortedColor = textureSample(diffuseSampler, diffuseSamplerSampler, clampedUV);\n\n // Mix with original color based on distortion strength\n let mixFactor = clamp(abs(uniforms.distortionIntensity) + abs(uniforms.distortionIntensityX) + abs(uniforms.distortionIntensityY), 0.0, 1.0);\n *color = mix(*color, distortedColor, mixFactor);\n }\n "},e.CreatePostProcess=function(e,t,i){var n,r,o,a,s,l,u={distortionIntensity:null!==(n=null==i?void 0:i.distortionIntensity)&&void 0!==n?n:0,distortionIntensityX:null!==(r=null==i?void 0:i.distortionIntensityX)&&void 0!==r?r:0,distortionIntensityY:null!==(o=null==i?void 0:i.distortionIntensityY)&&void 0!==o?o:0,distortionCenterX:null!==(a=null==i?void 0:i.distortionCenterX)&&void 0!==a?a:.5,distortionCenterY:null!==(s=null==i?void 0:i.distortionCenterY)&&void 0!==s?s:.5,distortionScale:null!==(l=null==i?void 0:i.distortionScale)&&void 0!==l?l:1},h=new BABYLON.PostProcess("lensDistortion","\n precision highp float;\n\n uniform float distortionIntensity;\n uniform float distortionIntensityX;\n uniform float distortionIntensityY;\n uniform vec2 distortionCenter;\n uniform float distortionScale;\n\n varying vec2 vUV;\n uniform sampler2D textureSampler;\n\n void main(void) {\n // Calculate UV coordinates relative to center\n vec2 uvCentered = vUV - distortionCenter;\n\n // Apply different distortion for X and Y if specified\n float intensityX = distortionIntensity + distortionIntensityX;\n float intensityY = distortionIntensity + distortionIntensityY;\n\n // Calculate distortion amount based on distance from center\n float r = length(uvCentered);\n float r2 = r * r;\n\n // Barrel distortion formula: r' = r * (1 + k1 * r^2 + k2 * r^4 + ...)\n float distortion = 1.0 + intensityX * r2 + intensityY * r2 * r2;\n\n // Scale the distortion\n distortion *= distortionScale;\n\n // Apply distortion to UV coordinates\n vec2 distortedUV = distortionCenter + uvCentered * distortion;\n\n // Ensure UV coordinates stay within bounds\n distortedUV = clamp(distortedUV, vec2(0.0), vec2(1.0));\n\n // Sample the texture at the distorted position\n vec4 distortedColor = texture2D(textureSampler, distortedUV);\n\n // Mix with original color based on distortion strength\n float mixFactor = clamp(abs(distortionIntensity) + abs(distortionIntensityX) + abs(distortionIntensityY), 0.0, 1.0);\n gl_FragColor = mix(texture2D(textureSampler, vUV), distortedColor, mixFactor);\n }\n ",["distortionIntensity","distortionIntensityX","distortionIntensityY","distortionCenter","distortionScale"],[],1,t,BABYLON.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1);return h.onApply=function(e){e.setFloat("distortionIntensity",u.distortionIntensity),e.setFloat("distortionIntensityX",u.distortionIntensityX),e.setFloat("distortionIntensityY",u.distortionIntensityY),e.setVector2("distortionCenter",new BABYLON.Vector2(u.distortionCenterX,u.distortionCenterY)),e.setFloat("distortionScale",u.distortionScale)},h},e}();e.LensDistortionPlugin=t}(n||(n={})),function(e){var t,i,n=function(t){function i(i,n,r,o){void 0===r&&(r={}),void 0===o&&(o="TOOLKIT.NavigationAgent");var a=t.call(this,i,n,r,o)||this;return a.crowd=null,a.type=0,a.distanceToTarget=0,a.teleporting=!1,a.moveDirection=new BABYLON.Vector3(0,0,0),a.resetPosition=new BABYLON.Vector3(0,0,0),a.lastPosition=new BABYLON.Vector3(0,0,0),a.distancePosition=new BABYLON.Vector3(0,0,0),a.currentPosition=new BABYLON.Vector3(0,0,0),a.currentRotation=new BABYLON.Quaternion(0,0,0,1),a.currentVelocity=new BABYLON.Vector3(0,0,0),a.currentWaypoint=new BABYLON.Vector3(0,0,0),a.m_navStatus=e.NavMoveStatus.Idle,a.m_stuckCounter=0,a.m_reachObserver=null,a.m_navMeshDestroyObserver=null,a.speed=3.5,a.heightOffset=0,a.angularSpeed=120,a.updatePosition=!0,a.updateRotation=!0,a.distanceEpsilon=.1,a.velocityEpsilon=1.1,a.offMeshVelocity=1.5,a.stoppingDistance=0,a.reachRadius=.1,a.stuckFrameThreshold=180,a.onReadyObservable=new BABYLON.Observable,a.onPreUpdateObservable=new BABYLON.Observable,a.onPostUpdateObservable=new BABYLON.Observable,a.onNavCompleteObservable=new BABYLON.Observable,a.onNavStuckObservable=new BABYLON.Observable,a.m_agentState=0,a.m_agentIndex=-1,a.m_agentReady=!1,a.m_agentGhost=null,a.m_agentParams=null,a.m_agentMovement=new BABYLON.Vector3(0,0,0),a.m_agentDirection=new BABYLON.Vector3(0,0,1),a.m_agentQuaternion=new BABYLON.Quaternion(0,0,0,1),a.m_agentDestination=null,a.m_debugDestinationSphere=null,a}return o(i,t),i.prototype.isReady=function(){return this.m_agentReady},i.prototype.isNavigating=function(){return this.m_navStatus===e.NavMoveStatus.Moving},i.prototype.isTeleporting=function(){return this.teleporting},i.prototype.isOnOffMeshLink=function(){return this.m_agentState===e.CrowdAgentState.DT_CROWDAGENT_STATE_OFFMESH},i.prototype.getAgentType=function(){return this.type},i.prototype.getAgentState=function(){return this.m_agentState},i.prototype.getAgentIndex=function(){return this.m_agentIndex},i.prototype.getAgentOffset=function(){return this.baseOffset},i.prototype.getTargetDistance=function(){return this.distanceToTarget},i.prototype.getCurrentPosition=function(){return this.currentPosition},i.prototype.getCurrentRotation=function(){return this.currentRotation},i.prototype.getCurrentVelocity=function(){return this.currentVelocity},i.prototype.getAgentParameters=function(){return this.m_agentParams},i.prototype.setAgentParameters=function(e){this.m_agentParams=e,this.updateAgentParameters()},i.prototype.getNavStatus=function(){return this.m_navStatus},i.prototype.isStuck=function(){return this.m_navStatus===e.NavMoveStatus.Stuck},i.prototype.awake=function(){this.awakeNavigationAgent()},i.prototype.update=function(){this.updateNavigationAgent()},i.prototype.destroy=function(){this.destroyNavigationAgent()},i.prototype.awakeNavigationAgent=function(){var t=this;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 BABYLON.TransformNode(this.transform.name+".Agent",this.scene),this.m_agentGhost.position=new BABYLON.Vector3(0,0,0),this.m_agentGhost.rotation=new BABYLON.Vector3(0,0,0),e.Utilities.ValidateTransformQuaternion(this.m_agentGhost),this.m_agentGhost.position.copyFrom(this.transform.position),this.lastPosition.copyFrom(this.transform.position),this.m_debugDestinationSphere=BABYLON.MeshBuilder.CreateSphere(this.transform.name+".DebugDestination",{diameter:.5},this.scene);var i=new BABYLON.StandardMaterial(this.transform.name+".DebugDestinationMat",this.scene);i.emissiveColor=new BABYLON.Color3(1,0,0),i.disableLighting=!0,this.m_debugDestinationSphere.material=i,this.m_debugDestinationSphere.isVisible=!1,null!=e.SceneManager.OnNavMeshDestroyObservable&&(this.m_navMeshDestroyObserver=e.SceneManager.OnNavMeshDestroyObservable.add(function(){t.releaseNavigationCrowd()}))},i.prototype.updateNavigationAgent=function(){var t=this;if(null==this.crowd)if(!0===e.NavigationAgent.GLOBAL_CROWD_INSTANCE)this.crowd=e.SceneManager.GetCrowdInterface(this.scene);else{var i=e.SceneManager.GetNavigationPlugin();null!=i&&e.SceneManager.HasNavigationData()?this.crowd=i.createCrowd(e.SceneManager.MAX_AGENT_COUNT,e.SceneManager.MAX_AGENT_RADIUS,this.scene):this.crowd=null}if(null!=this.crowd)if(this.m_agentIndex<0){if(this.m_agentParams={radius:this.avoidRadius,height:this.avoidHeight,maxSpeed:this.speed,maxAcceleration:this.acceleration,reachRadius:this.reachRadius},e.Utilities.GetAbsolutePositionToRef(this.transform,this.resetPosition),this.m_agentIndex=this.crowd.addAgent(this.resetPosition,this.m_agentParams,this.m_agentGhost),this.m_agentIndex>=0){this.m_agentReady=!0;var n=this.m_agentIndex;this.m_reachObserver=this.crowd.onReachTargetObservable.add(function(i){if(i.agentIndex===n&&t.m_navStatus===e.NavMoveStatus.Moving){t.m_navStatus=e.NavMoveStatus.Reached,t.m_stuckCounter=0,t.m_agentDestination=null;var r=t.getAgentPosition();null!=r&&null!=t.crowd&&t.crowd.agentTeleport(n,r),t.onNavCompleteObservable&&t.onNavCompleteObservable.hasObservers()&&t.onNavCompleteObservable.notifyObservers(t.transform)}}),this.onReadyObservable&&this.onReadyObservable.hasObservers()&&this.onReadyObservable.notifyObservers(this.transform)}}else{this.m_agentState=this.crowd.getAgentState(this.m_agentIndex),this.getAgentWaypointToRef(this.currentWaypoint),this.getAgentPositionToRef(this.currentPosition),this.distancePosition.copyFrom(this.currentPosition),this.isOnOffMeshLink()?(this.currentPosition.subtractToRef(this.lastPosition,this.currentVelocity),this.currentVelocity.scaleInPlace(this.speed*this.offMeshVelocity)):this.getAgentVelocityToRef(this.currentVelocity),this.onPreUpdateObservable&&this.onPreUpdateObservable.hasObservers()&&this.onPreUpdateObservable.notifyObservers(this.transform),this.currentPosition.y+=this.baseOffset+this.heightOffset;var r=this.currentVelocity.length();if(r>=this.velocityEpsilon){this.currentVelocity.normalize();var o=this.angularSpeed*e.NavigationAgent.ANGULAR_SPEED_RATIO*this.getDeltaSeconds();if(this.isOnOffMeshLink()){this.moveDirection.copyFrom(this.m_agentDirection),this.m_agentDirection.set(this.moveDirection.x+(this.currentVelocity.x-this.moveDirection.x),this.moveDirection.y+(this.currentVelocity.y-this.moveDirection.y),this.moveDirection.z+(this.currentVelocity.z-this.moveDirection.z)),this.m_agentDirection.normalize();var a=e.NavigationAgent.TARGET_ANGLE_FACTOR-Math.atan2(this.m_agentDirection.x,this.m_agentDirection.z);BABYLON.Quaternion.FromEulerAnglesToRef(0,a,0,this.currentRotation),this.isNavigating()&&!0===this.updateRotation&&BABYLON.Quaternion.SlerpToRef(this.transform.rotationQuaternion,this.currentRotation,o,this.transform.rotationQuaternion)}else this.m_agentQuaternion.copyFrom(this.transform.rotationQuaternion),this.isNavigating()&&!0===this.updateRotation&&this.transform.lookAt(this.currentWaypoint),this.transform.rotationQuaternion.toEulerAnglesToRef(this.m_agentDirection),BABYLON.Quaternion.FromEulerAnglesToRef(0,this.m_agentDirection.y,0,this.currentRotation),this.isNavigating()&&!0===this.updateRotation&&BABYLON.Quaternion.SlerpToRef(this.m_agentQuaternion,this.currentRotation,o,this.transform.rotationQuaternion)}if(this.isNavigating()&&!0===this.updatePosition&&this.transform.position.copyFrom(this.currentPosition),this.isNavigating()){if(this.distanceToTarget=BABYLON.Vector3.Distance(this.distancePosition,this.m_agentDestination),this.m_navStatus!==e.NavMoveStatus.Reached){var s=Math.max(this.reachRadius,this.stoppingDistance,this.distanceEpsilon);if(this.distanceToTarget<=s){this.m_navStatus=e.NavMoveStatus.Reached,this.m_stuckCounter=0,this.m_agentDestination=null;var l=this.getAgentPosition();null!=l&&null!=this.crowd&&this.m_agentIndex>=0&&this.crowd.agentTeleport(this.m_agentIndex,l),this.onNavCompleteObservable&&this.onNavCompleteObservable.hasObservers()&&this.onNavCompleteObservable.notifyObservers(this.transform)}else r>=this.velocityEpsilon?(this.m_stuckCounter=0,this.m_navStatus=e.NavMoveStatus.Moving):(this.m_stuckCounter++,this.m_stuckCounter>=this.stuckFrameThreshold&&(this.m_navStatus=e.NavMoveStatus.Stuck,this.m_stuckCounter=0,this.cancelNavigation(),this.onNavStuckObservable&&this.onNavStuckObservable.hasObservers()&&this.onNavStuckObservable.notifyObservers(this.transform)))}}else this.distanceToTarget=0,this.m_stuckCounter=0;this.lastPosition.copyFrom(this.currentPosition),this.onPostUpdateObservable&&this.onPostUpdateObservable.hasObservers()&&this.onPostUpdateObservable.notifyObservers(this.transform),null!=this.m_debugDestinationSphere&&(null!=this.m_agentDestination?this.m_debugDestinationSphere.position.copyFrom(this.m_agentDestination):this.m_debugDestinationSphere.position.set(0,0,0)),this.teleporting=!1}},i.prototype.updateAgentParameters=function(){null!=this.crowd&&this.m_agentIndex>=0&&this.crowd.updateAgentParameters(this.m_agentIndex,this.m_agentParams)},i.prototype.destroyNavigationAgent=function(){if(null!=this.m_navMeshDestroyObserver&&(null!=e.SceneManager.OnNavMeshDestroyObservable&&e.SceneManager.OnNavMeshDestroyObservable.remove(this.m_navMeshDestroyObserver),this.m_navMeshDestroyObserver=null),null!=this.m_reachObserver&&null!=this.crowd&&(this.crowd.onReachTargetObservable.remove(this.m_reachObserver),this.m_reachObserver=null),null!=this.crowd){if(!1===e.NavigationAgent.GLOBAL_CROWD_INSTANCE)try{this.crowd.dispose()}catch(e){BABYLON.Tools.Warn("Failed to dispose navigation crowd: "+e)}this.crowd=null}this.m_agentIndex=-1,this.m_agentReady=!1,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.currentRotation=null,this.currentVelocity=null,this.currentWaypoint=null,this.onReadyObservable.clear(),this.onReadyObservable=null,this.onPreUpdateObservable.clear(),this.onPreUpdateObservable=null,this.onPostUpdateObservable.clear(),this.onPostUpdateObservable=null,this.onNavCompleteObservable.clear(),this.onNavCompleteObservable=null,this.onNavStuckObservable.clear(),this.onNavStuckObservable=null,null!=this.m_agentGhost&&(this.m_agentGhost.dispose(),this.m_agentGhost=null),null!=this.m_debugDestinationSphere&&(this.m_debugDestinationSphere.dispose(),this.m_debugDestinationSphere=null)},i.prototype.move=function(t,i){void 0===i&&(i=!0);var n=e.SceneManager.GetNavigationPlugin();null!=n&&null!=this.crowd?(this.crowd.getAgentPosition(this.m_agentIndex).addToRef(t,this.m_agentMovement),this.m_agentDestination=!0===i?n.getClosestPoint(this.m_agentMovement):this.m_agentMovement.clone(),this.m_navStatus=e.NavMoveStatus.Moving,this.m_stuckCounter=0,this.m_agentIndex>=0&&this.crowd.agentGoto(this.m_agentIndex,this.m_agentDestination)):BABYLON.Tools.Warn("No recast navigation mesh or crowd interface data available!")},i.prototype.teleport=function(t,i,n){void 0===i&&(i=!0);var r=e.SceneManager.GetNavigationPlugin();null!=r&&null!=this.crowd?(this.teleporting=!0,this.m_agentDestination=!0===i?r.getClosestPoint(t):t.clone(),null!=n&&(this.currentRotation.copyFrom(n),this.m_agentQuaternion.copyFrom(n),BABYLON.Vector3.Forward().rotateByQuaternionToRef(n,this.m_agentDirection),!0===this.updateRotation&&this.transform.rotationQuaternion.copyFrom(n)),this.m_navStatus=e.NavMoveStatus.Moving,this.m_stuckCounter=0,this.m_agentIndex>=0&&this.crowd.agentTeleport(this.m_agentIndex,this.m_agentDestination)):BABYLON.Tools.Warn("No recast navigation mesh or crowd interface data available!")},i.prototype.setDestination=function(t,i,n){void 0===i&&(i=!0);var r=e.SceneManager.GetNavigationPlugin();null!=r&&null!=this.crowd?(this.m_agentDestination=!0===i?r.getClosestPoint(t):t.clone(),null!=n&&(this.currentRotation.copyFrom(n),this.m_agentQuaternion.copyFrom(n),BABYLON.Vector3.Forward().rotateByQuaternionToRef(n,this.m_agentDirection),!0===this.updateRotation&&this.transform.rotationQuaternion.copyFrom(n)),this.m_navStatus=e.NavMoveStatus.Moving,this.m_stuckCounter=0,this.m_agentIndex>=0&&this.crowd.agentGoto(this.m_agentIndex,this.m_agentDestination)):BABYLON.Tools.Warn("No recast navigation mesh or crowd interface data available!")},i.prototype.setAcceleration=function(e){null!=this.m_agentParams&&(this.acceleration=e,this.m_agentParams.maxAcceleration=this.acceleration,this.updateAgentParameters())},i.prototype.setMovementSpeed=function(e){null!=this.m_agentParams&&(this.speed=e,this.m_agentParams.maxSpeed=this.speed,this.updateAgentParameters())},i.prototype.setSeparationWeight=function(e){null!=this.m_agentParams&&(this.m_agentParams.separationWeight=e,this.updateAgentParameters())},i.prototype.setOptimizationRange=function(e){null!=this.m_agentParams&&(this.m_agentParams.pathOptimizationRange=e,this.updateAgentParameters())},i.prototype.setCollisionQueryRange=function(e){null!=this.m_agentParams&&(this.m_agentParams.collisionQueryRange=e,this.updateAgentParameters())},i.prototype.setAgentRadius=function(e){null!=this.m_agentParams&&(this.m_agentParams.radius=e,this.updateAgentParameters())},i.prototype.setAgentHeight=function(e){null!=this.m_agentParams&&(this.m_agentParams.height=e,this.updateAgentParameters())},i.prototype.getAgentVelocity=function(){return null!=this.crowd&&this.m_agentIndex>=0?this.crowd.getAgentVelocity(this.m_agentIndex):null},i.prototype.getAgentVelocityToRef=function(e){null!=this.crowd&&this.m_agentIndex>=0&&this.crowd.getAgentVelocityToRef(this.m_agentIndex,e)},i.prototype.getAgentPosition=function(){return null!=this.crowd&&this.m_agentIndex>=0?this.crowd.getAgentPosition(this.m_agentIndex):null},i.prototype.getAgentPositionToRef=function(e){null!=this.crowd&&this.m_agentIndex>=0&&this.crowd.getAgentPositionToRef(this.m_agentIndex,e)},i.prototype.getAgentWaypoint=function(){return null!=this.crowd&&this.m_agentIndex>=0?this.crowd.getAgentNextTargetPath(this.m_agentIndex):null},i.prototype.getAgentWaypointToRef=function(e){null!=this.crowd&&this.m_agentIndex>=0&&this.crowd.getAgentNextTargetPathToRef(this.m_agentIndex,e)},i.prototype.cancelNavigation=function(){this.m_navStatus===e.NavMoveStatus.Moving&&(this.m_navStatus=e.NavMoveStatus.Cancelled),this.m_stuckCounter=0,this.m_agentDestination=null;var t=this.getAgentPosition();null!=t&&null!=this.crowd&&this.m_agentIndex>=0&&this.crowd.agentTeleport(this.m_agentIndex,t)},i.prototype.releaseNavigationCrowd=function(){if(this.m_navStatus===e.NavMoveStatus.Moving&&(this.m_navStatus=e.NavMoveStatus.Cancelled),null!=this.m_reachObserver&&null!=this.crowd){try{this.crowd.onReachTargetObservable.remove(this.m_reachObserver)}catch(e){}this.m_reachObserver=null}if(null!=this.crowd){if(!1===e.NavigationAgent.GLOBAL_CROWD_INSTANCE)try{this.crowd.dispose()}catch(e){BABYLON.Tools.Warn("Failed to dispose navigation crowd: "+e)}this.crowd=null}this.m_agentIndex=-1,this.m_agentReady=!1,this.m_stuckCounter=0,this.m_agentDestination=null},i.prototype.getDebugDestinationMesh=function(){return this.m_debugDestinationSphere},i.prototype.showDebugDestination=function(e){null!=this.m_debugDestinationSphere&&(this.m_debugDestinationSphere.isVisible=e)},i.TARGET_ANGLE_FACTOR=.5*Math.PI,i.ANGULAR_SPEED_RATIO=.05,i.GLOBAL_CROWD_INSTANCE=!1,i}(e.ScriptComponent);e.NavigationAgent=n,(i=e.CrowdAgentState||(e.CrowdAgentState={}))[i.DT_CROWDAGENT_STATE_INVALID=0]="DT_CROWDAGENT_STATE_INVALID",i[i.DT_CROWDAGENT_STATE_WALKING=1]="DT_CROWDAGENT_STATE_WALKING",i[i.DT_CROWDAGENT_STATE_OFFMESH=2]="DT_CROWDAGENT_STATE_OFFMESH",(t=e.NavMoveStatus||(e.NavMoveStatus={})).Idle="idle",t.Moving="moving",t.Reached="reached",t.Stuck="stuck",t.Cancelled="cancelled",e.SceneManager.RegisterClass("TOOLKIT.NavigationAgent",n)}(n||(n={})),function(e){var t=function(t){function i(i,n,r,o){void 0===r&&(r={}),void 0===o&&(o="TOOLKIT.PostProcessor");var a=t.call(this,i,n,r,o)||this;return a.highDynamicRange=!0,a.neutralToneMapping=!1,a.toneMappingMode=-1,a.defaultContrast=1,a.defaultExposure=1,a.defaultLookupTable=null,a.colorGradingSettings=null,a.bloomSettings=null,a.vignetteSettings=null,a.sharpenSettings=null,a.grainSettings=null,a.chromaticAberrationSettings=null,a.depthOfFieldSettings=null,a.motionBlurSettings=null,a.lensDistortionSettings=null,a.autoExposureSettings=null,a.colorFilterPP=null,a.coloredBloomPP=null,a.motionBlurPP=null,a.roundedVignettePP=null,a.lensDistortionPP=null,a.defaultRenderPipeline=null,a.screenSpaceAOPipeline=null,a.screenSpaceRPipeline=null,e.PostProcessor.GlobalInstance=a,a}return o(i,t),Object.defineProperty(i,"Instance",{get:function(){return i.GlobalInstance},enumerable:!1,configurable:!0}),i.prototype.GetDefaultRenderPipeline=function(){return this.defaultRenderPipeline},i.prototype.GetSSAORRenderPipeline=function(){return this.screenSpaceAOPipeline},i.prototype.GetSSRRenderPipeline=function(){return this.screenSpaceRPipeline},i.prototype.ready=function(){var e=this.getProperties();if(e.isglobal){if(null!=e.effects&&Array.isArray(e.effects))for(var t=0,i=e.effects;t<i.length;t++){var n=i[t];if(n&&n.effecttype){var r=n.effecttype.toLowerCase();switch(r){case"colorgrading":this.colorGradingSettings=this.parseColorGradingSettings(n.parameters);break;case"ambientocclusion":var o=this.parseAmbientOcclusionSettings(n.parameters);null!=o&&(this.screenSpaceAOPipeline=new BABYLON.SSAORenderingPipeline("SSAO",this.scene,1,this.scene.cameras),o.intensity&&!1!==o.intensity.overrideState&&(this.screenSpaceAOPipeline.totalStrength=Number(o.intensity.value)),o.radius&&!1!==o.radius.overrideState&&(this.screenSpaceAOPipeline.radius=Number(o.radius.value)),o.thicknessModifier&&!1!==o.thicknessModifier.overrideState&&(this.screenSpaceAOPipeline.fallOff=Number(o.thicknessModifier.value)));break;case"screenspacereflections":var a=this.parseScreenSpaceReflectionsSettings(n.parameters);if(null!=a){if(this.screenSpaceRPipeline=new BABYLON.SSRRenderingPipeline("SSR",this.scene,this.scene.cameras),a.preset&&!1!==a.preset.overrideState){var s=Number(a.preset.value);this.screenSpaceRPipeline.step=Math.max(.1,1/(s+1)),this.screenSpaceRPipeline.strength=Math.min(2,.5*s+.5)}a.maximumIterationCount&&!1!==a.maximumIterationCount.overrideState&&(this.screenSpaceRPipeline.maxSteps=Number(a.maximumIterationCount.value)),a.thickness&&!1!==a.thickness.overrideState&&(this.screenSpaceRPipeline.thickness=Number(a.thickness.value))}break;case"autoexposure":this.autoExposureSettings=this.parseAutoExposure(n.parameters);break;case"bloom":this.bloomSettings=this.parseBloomSettings(n.parameters);break;case"chromaticaberration":this.chromaticAberrationSettings=this.parseChromaticAberrationSettings(n.parameters);break;case"depthoffield":this.depthOfFieldSettings=this.parseDepthOfFieldSettings(n.parameters);break;case"grain":this.grainSettings=this.parseGrainSettings(n.parameters);break;case"lensdistortion":this.lensDistortionSettings=this.parseLensDistortionSettings(n.parameters);break;case"motionblur":this.motionBlurSettings=this.parseMotionBlurSettings(n.parameters);break;case"vignette":this.vignetteSettings=this.parseVignetteSettings(n.parameters);break;case"sharpen":this.sharpenSettings=this.parseSharpenSettings(n.parameters);break;default:console.warn("[PostProcessor] Unsupported effect type:",r)}}}}else console.warn("[PostProcessor] Non global volumes are not supported..");this.defaultRenderPipeline=new BABYLON.DefaultRenderingPipeline("DefaultPostProcessor",this.highDynamicRange,this.scene,this.scene.cameras,!0),this.defaultRenderPipeline.imageProcessingEnabled=!0,this.defaultRenderPipeline.samples=1,this.applyColorGradingSettings(),this.applyBloomSettings(),this.applyVignetteSettings(),this.applySharpenSettings(),this.applyGrainSettings(),this.applyChromaticAberrationSettings(),this.applyDepthOfFieldSettings(),this.applyMotionBlurSettings(),this.applyLensDistortionSettings(),this.applyAutoExposureSettings(),console.log("[PostProcessor] Initialized DefaultRenderingPipeline",this)},i.prototype.parseColorGradingSettings=function(t){if(!t)return null;var i=function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)},n={tonemapper:i("tonemapper"),postExposure:i("postexposure"),saturation:i("saturation"),contrast:i("contrast"),lut:i("lut")||i("externallut")||i("ldrlut"),lut2:i("lut2"),lutCrossFade:i("lutCrossFade")||i("lutBlend")||i("mix"),lift:i("lift"),gamma:i("gamma"),gain:i("gain"),tonecurvetoestrength:i("tonecurvetoestrength"),tonecurvetoelength:i("tonecurvetoelength"),tonecurveshoulderstrength:i("tonecurveshoulderstrength"),tonecurveshoulderlength:i("tonecurveshoulderlength"),tonecurveshoulderangle:i("tonecurveshoulderangle"),tonecurvegamma:i("tonecurvegamma"),temperature:i("temperature"),tint:i("tint"),colorfilter:i("colorfilter")};if(this.colorGradingSettings=n,n.tonemapper&&!1!==n.tonemapper.overrideState&&null!=n.tonemapper.value){var r=this.mapToneMapper(n.tonemapper);r&&r.enabled&&(this.toneMappingMode=1===r.type?BABYLON.ImageProcessingConfiguration.TONEMAPPING_ACES:2===r.type?BABYLON.ImageProcessingConfiguration.TONEMAPPING_KHR_PBR_NEUTRAL:BABYLON.ImageProcessingConfiguration.TONEMAPPING_STANDARD)}if(n.postExposure&&!1!==n.postExposure.overrideState&&null!=n.postExposure.value){var o=Math.pow(2,Number(n.postExposure.value));this.defaultExposure=1*o}return n.contrast&&!1!==n.contrast.overrideState&&null!=n.contrast.value&&(this.defaultContrast=.05*Number(n.contrast.value)),n},i.prototype.applyColorGradingSettings=function(){if(this.colorGradingSettings&&this.defaultRenderPipeline&&this.defaultRenderPipeline.imageProcessing){console.log("[PostProcessor] Applying Color Grading Settings:",this.colorGradingSettings),this.colorGradingSettings;var e=this.defaultRenderPipeline.imageProcessing;0!=this.defaultExposure&&(e.exposure=this.defaultExposure),0===e.exposure&&(e.exposure=1),0!=this.defaultContrast&&(e.contrast=this.defaultContrast),0===e.contrast&&(e.contrast=1),this.toneMappingMode>=0&&(e.toneMappingType=this.toneMappingMode,e.toneMappingEnabled=!0)}},i.prototype.mapToneMapper=function(t){var i=e.PostProcessor.extractParam(t);if(!i||null==i.value)return{enabled:!1,type:null};if(!1===i.overrideState)return{enabled:!1,type:null};var n=i.value,r=null;"object"==typeof n?n.name?r=(""+n.name).toUpperCase():null!=n.value&&"string"==typeof n.value&&(r=(""+n.value).toUpperCase()):r=(""+n).toUpperCase();var o=BABYLON.ImageProcessingConfiguration.TONEMAPPING_ACES,a=BABYLON.ImageProcessingConfiguration.TONEMAPPING_KHR_PBR_NEUTRAL,s=BABYLON.ImageProcessingConfiguration.TONEMAPPING_STANDARD;return r&&r.indexOf("ACES")>=0?{enabled:!0,type:o}:r&&r.indexOf("NEUTRAL")>=0?{enabled:!0,type:a}:r&&(r.indexOf("NONE")>=0||r.indexOf("DISABLED")>=0)||isNaN(Number(n))?{enabled:!1,type:s}:{enabled:!0,type:Number(n)}},i.prototype.parseBloomSettings=function(t){if(!t)return null;var i=function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)};return{intensity:i("intensity"),threshold:i("threshold"),softKnee:i("softKnee")||i("softknee"),clamp:i("clamp"),diffusion:i("diffusion"),anamorphicRatio:i("anamorphicRatio")||i("anamorphicratio"),color:i("color"),fastMode:i("fastMode")||i("fastmode")}},i.prototype.applyBloomSettings=function(){var t;if(this.bloomSettings&&this.defaultRenderPipeline){console.log("[PostProcessor] Applying Bloom Settings:",this.bloomSettings);var i=this.bloomSettings,n=this.defaultRenderPipeline;if(i.intensity&&!1!==i.intensity.overrideState&&null!=i.intensity.value&&(n.bloomWeight=Number(i.intensity.value)),i.threshold&&!1!==i.threshold.overrideState&&null!=i.threshold.value&&(n.bloomThreshold=Number(i.threshold.value)),i.diffusion&&!1!==i.diffusion.overrideState&&null!=i.diffusion.value){var r=Number(i.diffusion.value);n.bloomKernel=Math.max(1,Math.floor(10*r)),n.bloomScale=r}i.color&&!1!==i.color.overrideState&&Array.isArray(i.color.value)&&(n.bloomWeight=0,this.coloredBloomPP=e.ColoredBloomPlugin.CreateColoredBloom(this.scene,this.scene.activeCamera,{threshold:n.bloomThreshold,color:i.color.value,weight:Number((null===(t=i.intensity)||void 0===t?void 0:t.value)||1),kernel:n.bloomKernel,saturation:1}),this.coloredBloomPP.name="ColoredBloomPostProcess")}},i.prototype.parseSharpenSettings=function(t){return t?{intensity:function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)}("intensity")}:null},i.prototype.applySharpenSettings=function(){if(this.sharpenSettings&&this.defaultRenderPipeline&&this.defaultRenderPipeline.sharpen){console.log("[PostProcessor] Applying Sharpen Settings:",this.sharpenSettings);var e=this.sharpenSettings,t=this.defaultRenderPipeline.sharpen;e.intensity&&!1!==e.intensity.overrideState&&null!=e.intensity.value&&(t.edgeAmount=Number(e.intensity.value))}},i.prototype.parseGrainSettings=function(t){if(!t)return null;var i=function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)};return{intensity:i("intensity"),size:i("size"),lumContrib:i("lumContrib")||i("lumcontrib"),colored:i("colored")}},i.prototype.applyGrainSettings=function(){if(this.grainSettings&&this.defaultRenderPipeline&&this.defaultRenderPipeline.grain){console.log("[PostProcessor] Applying Grain Settings:",this.grainSettings);var e=this.grainSettings,t=this.defaultRenderPipeline.grain;e.intensity&&!1!==e.intensity.overrideState&&null!=e.intensity.value&&(t.intensity=Number(e.intensity.value))}},i.prototype.parseVignetteSettings=function(t){if(!t)return null;var i=function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)};return{color:i("color"),center:i("center"),intensity:i("intensity"),smoothness:i("smoothness"),rounded:i("rounded"),mode:i("mode")||i("blendMode")}},i.prototype.applyVignetteSettings=function(){if(this.vignetteSettings&&this.defaultRenderPipeline&&this.defaultRenderPipeline.imageProcessing){console.log("[PostProcessor] Applying Vignette Settings:",this.vignetteSettings);var t=this.vignetteSettings,i=this.defaultRenderPipeline.imageProcessing;t.color&&!1!==t.color.overrideState&&Array.isArray(t.color.value)&&(i.vignetteColor=new BABYLON.Color4(t.color.value[0]||0,t.color.value[1]||0,t.color.value[2]||0,null!=t.color.value[3]?t.color.value[3]:1)),t.center&&!1!==t.center.overrideState&&Array.isArray(t.center.value)&&(i.vignetteCenterX=(t.center.value[0]||.5)-.5,i.vignetteCenterY=(t.center.value[1]||.5)-.5),t.intensity&&!1!==t.intensity.overrideState&&null!=t.intensity.value&&(i.vignetteWeight=10*Number(t.intensity.value)),t.smoothness&&!1!==t.smoothness.overrideState&&null!=t.smoothness.value&&(i.vignetteBlendMode=Number(t.smoothness.value)),t.rounded&&!1!==t.rounded.overrideState&&!0===t.rounded.value&&(i.vignetteWeight=0,this.roundedVignettePP=e.RoundedVignettePlugin.CreatePostProcess(this.scene,this.scene.activeCamera,{color:i.vignetteColor?[i.vignetteColor.r,i.vignetteColor.g,i.vignetteColor.b,i.vignetteColor.a]:[0,0,0,1],center:[(i.vignetteCenterX||.5)-.5,(i.vignetteCenterY||.5)-.5],intensity:i.vignetteWeight,smoothness:i.vignetteBlendMode,rounded:!0,blendMode:t.mode&&t.mode.value?t.mode.value:"multiply"}),this.roundedVignettePP.name="RoundedVignettePostProcess"),i.vignetteEnabled=!0}},i.prototype.parseDepthOfFieldSettings=function(t){if(!t)return null;var i=function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)};return{focusDistance:i("focusDistance")||i("focusdistance"),aperture:i("aperture"),focalLength:i("focalLength")||i("focallength"),kernelSize:i("kernelSize")||i("kernelsize")}},i.prototype.applyDepthOfFieldSettings=function(){if(this.depthOfFieldSettings&&this.defaultRenderPipeline&&this.defaultRenderPipeline.depthOfField){console.log("[PostProcessor] Applying Depth Of Field Settings:",this.depthOfFieldSettings);var e=this.depthOfFieldSettings,t=this.defaultRenderPipeline.depthOfField;if(e.focusDistance&&!1!==e.focusDistance.overrideState&&null!=e.focusDistance.value&&(t.focusDistance=Number(e.focusDistance.value)),e.aperture&&!1!==e.aperture.overrideState&&null!=e.aperture.value&&(t.fStop=Number(e.aperture.value)),e.focalLength&&!1!==e.focalLength.overrideState&&null!=e.focalLength.value&&(t.focalLength=Number(e.focalLength.value)),e.kernelSize&&!1!==e.kernelSize.overrideState&&null!=e.kernelSize.value){var i=Number(e.kernelSize.value);t.fStop=Math.max(.1,2-i)}t._enable([this.scene.activeCamera])}},i.prototype.parseMotionBlurSettings=function(t){if(!t)return null;var i=function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)};return{shutterAngle:i("shutterAngle")||i("shutterangle"),sampleCount:i("sampleCount")||i("samplecount")}},i.prototype.applyMotionBlurSettings=function(){if(this.motionBlurSettings){console.log("[PostProcessor] Applying Motion Blur Settings:",this.motionBlurSettings);var e=this.motionBlurSettings;this.motionBlurPP=new BABYLON.MotionBlurPostProcess("motionBlur",this.scene,1,this.scene.activeCamera),this.motionBlurPP.name="MotionBlurPostProcess",e.sampleCount&&!1!==e.sampleCount.overrideState&&null!=e.sampleCount.value&&(this.motionBlurPP.samples=Number(e.sampleCount.value))}},i.prototype.parseAutoExposure=function(t){if(!t)return null;var i=function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)};return{filtering:i("filtering"),minimum:i("minimum"),maximum:i("maximum"),speedUp:i("speedUp")||i("speedup"),speedDown:i("speedDown")||i("speeddown")}},i.prototype.applyAutoExposureSettings=function(){if(this.autoExposureSettings&&this.defaultRenderPipeline&&this.defaultRenderPipeline.imageProcessing){console.log("[PostProcessor] Applying Auto Exposure Settings:",this.autoExposureSettings);var e=this.autoExposureSettings;this.defaultRenderPipeline.imageProcessing,e.minimum&&!1!==e.minimum.overrideState&&e.minimum.value,e.maximum&&!1!==e.maximum.overrideState&&e.maximum.value,console.warn("[PostProcessor] Auto-exposure is partially supported; full adaptive exposure requires custom implementation.")}},i.prototype.parseLensDistortionSettings=function(t){if(!t)return null;var i=function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)};return{intensity:i("intensity"),intensityX:i("intensityX")||i("intensityx"),intensityY:i("intensityY")||i("intensityy"),centerX:i("centerX")||i("centerx"),centerY:i("centerY")||i("centery"),scale:i("scale")}},i.prototype.applyLensDistortionSettings=function(){var t,i,n,r,o,a;if(this.lensDistortionSettings){console.log("[PostProcessor] Applying Lens Distortion Settings:",this.lensDistortionSettings);var s=this.lensDistortionSettings;this.lensDistortionPP=e.LensDistortionPlugin.CreatePostProcess(this.scene,this.scene.activeCamera,{distortionIntensity:(null===(t=s.intensity)||void 0===t?void 0:t.value)||0,distortionIntensityX:(null===(i=s.intensityX)||void 0===i?void 0:i.value)||0,distortionIntensityY:(null===(n=s.intensityY)||void 0===n?void 0:n.value)||0,distortionCenterX:(null===(r=s.centerX)||void 0===r?void 0:r.value)||.5,distortionCenterY:(null===(o=s.centerY)||void 0===o?void 0:o.value)||.5,distortionScale:(null===(a=s.scale)||void 0===a?void 0:a.value)||1}),this.lensDistortionPP.name="LensDistortionPostProcess"}},i.prototype.parseChromaticAberrationSettings=function(t){if(!t)return null;var i=function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)};return{intensity:i("intensity"),fastMode:i("fastMode")||i("fastmode")}},i.prototype.applyChromaticAberrationSettings=function(){if(this.chromaticAberrationSettings&&this.defaultRenderPipeline&&this.defaultRenderPipeline.chromaticAberration){console.log("[PostProcessor] Applying Chromatic Aberration Settings:",this.chromaticAberrationSettings);var e=this.chromaticAberrationSettings,t=this.defaultRenderPipeline.chromaticAberration;e.intensity&&!1!==e.intensity.overrideState&&null!=e.intensity.value&&(t.aberrationAmount=Number(e.intensity.value))}},i.prototype.parseAmbientOcclusionSettings=function(t){if(!t)return null;var i=function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)};return{intensity:i("intensity"),radius:i("radius"),sampleCount:i("sampleCount")||i("samplecount"),downsampling:i("downsampling"),thicknessModifier:i("thicknessModifier")||i("thicknessmodifier")}},i.prototype.parseScreenSpaceReflectionsSettings=function(t){if(!t)return null;var i=function(i){if(!t)return{value:null,overrideState:null};var n=null!=t[i]?t[i]:null!=t[i.toLowerCase()]?t[i.toLowerCase()]:null;return e.PostProcessor.extractParam(n)};return{preset:i("preset"),maximumIterationCount:i("maximumIterationCount")||i("maximumiterationcount"),thickness:i("thickness"),resolution:i("resolution"),bounce:i("bounce")}},i.unwrapParam=function(e){if(null==e)return e;try{if("object"==typeof e&&"value"in e)return e.value}catch(e){}return e},i.extractParam=function(e){if(null==e)return{value:null,overrideState:null};try{if("object"==typeof e&&"value"in e){var t=null!=e.overrideState?!!e.overrideState:null;return{value:e.value,overrideState:t}}}catch(e){}return{value:e,overrideState:null}},i.GlobalInstance=null,i}(e.ScriptComponent);e.PostProcessor=t,e.SceneManager.RegisterClass("TOOLKIT.PostProcessor",t)}(n||(n={})),function(e){var t=function(){function t(t,i,n){this._centerMass=new BABYLON.Vector3(0,0,0),this._chassisMesh=null,this._tempVectorPos=new BABYLON.Vector3(0,0,0),this.lockedWheelIndexes=null,this.m_scene=null,this.m_vehicle=null,this.m_vehicleTuning=null,this.m_vehicleRaycaster=null,this.m_vehicleColliders=null,this.m_tempPosition=null,this.m_wheelDirectionCS0=null,this.m_wheelAxleCS=null,this._chassisMesh=i,this._centerMass=n,this.m_scene=t,this.m_vehicleTuning=new e.btVehicleTuning,this.m_vehicleRaycaster=new e.btDefaultVehicleRaycaster({shouldHitTriggers:!1,ignoreBody:this._chassisMesh.physicsBody}),this.m_vehicleColliders=null!=this._chassisMesh.metadata&&null!=this._chassisMesh.metadata.toolkit&&null!=this._chassisMesh.metadata.toolkit.wheels?this._chassisMesh.metadata.toolkit.wheels:null,this.m_vehicle=new e.btRaycastVehicle(this.m_vehicleTuning,this._chassisMesh.physicsBody,this.m_vehicleRaycaster),this.m_vehicle.setCoordinateSystem(0,1,2),this.m_wheelDirectionCS0=new BABYLON.Vector3(0,-1,0),this.m_wheelAxleCS=new BABYLON.Vector3(-1,0,0),this.m_tempPosition=null,this.setupWheelInformation()}return t.prototype.getCenterMassOffset=function(){return this._centerMass},t.prototype.getInternalVehicle=function(){return this.m_vehicle},t.prototype.getUpAxis=function(){return null!=this.m_vehicle?this.m_vehicle.getUpAxis():null},t.prototype.getRightAxis=function(){return null!=this.m_vehicle?this.m_vehicle.getRightAxis():null},t.prototype.getForwardAxis=function(){return null!=this.m_vehicle?this.m_vehicle.getForwardAxis():null},t.prototype.getForwardVector=function(){return null!=this.m_vehicle?this.m_vehicle.getForwardVector():null},t.prototype.getNumWheels=function(){return null!=this.m_vehicle?this.m_vehicle.getNumWheels():null},t.prototype.getWheelInfo=function(e){return null!=this.m_vehicle?this.m_vehicle.getWheelInfo(e):null},t.prototype.resetSuspension=function(){null!=this.m_vehicle&&this.m_vehicle.resetSuspension()},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.updateWheelTransform=function(e,t){null!=this.m_vehicle&&this.m_vehicle.updateWheelTransform(e,t)},t.prototype.getWheelTransformPosition=function(e){return null!=this.m_vehicle?this.m_vehicle.getWheelInfo(e).worldTransformPosition:null},t.prototype.getWheelTransformRotation=function(e){return null!=this.m_vehicle?this.m_vehicle.getWheelInfo(e).worldTransformRotation:null},t.prototype.getRawCurrentSpeedKph=function(){return null!=this.m_vehicle?this.m_vehicle.getCurrentSpeedKmHour():null},t.prototype.getRawCurrentSpeedMph=function(){return null!=this.m_vehicle?this.m_vehicle.getCurrentSpeedKmHour()*e.System.Kph2Mph:null},t.prototype.getAbsCurrentSpeedKph=function(){return null!=this.m_vehicle?Math.abs(this.m_vehicle.getCurrentSpeedKmHour()):null},t.prototype.getAbsCurrentSpeedMph=function(){return null!=this.m_vehicle?Math.abs(this.m_vehicle.getCurrentSpeedKmHour())*e.System.Kph2Mph:null},t.prototype.getVehicleTuningSystem=function(){return this.m_vehicleTuning},t.prototype.getChassisWorldTransform=function(){return null!=this.m_vehicle?this.m_vehicle.getChassisWorldTransform():null},t.prototype.dispose=function(){this.deleteWheelInformation(),null!=this.m_vehicle&&(this.m_vehicle=null),null!=this.m_vehicleTuning&&(this.m_vehicleTuning=null),null!=this.m_vehicleRaycaster&&(this.m_vehicleRaycaster=null),null!=this.m_wheelDirectionCS0&&(this.m_wheelDirectionCS0=null),null!=this.m_wheelAxleCS&&(this.m_wheelAxleCS=null),null!=this.m_tempPosition&&(this.m_tempPosition=null),this.m_vehicleColliders=null},t.GetInstance=function(t,i){var n=i;return null==n.m_raycastVehicle&&(i.hasWheelColliders()?n.m_raycastVehicle=new e.RaycastVehicle(t,n.transform,n._centerOfMass):BABYLON.Tools.Warn("No wheel collider metadata found for: "+n.transform.name)),n.m_raycastVehicle},t.prototype.tickVehicleController=function(e){null!=this.m_vehicle&&this.m_vehicle.updateVehicle(e)},t.prototype.getEnableMultiRaycast=function(){var e=!1;return null!=this.m_vehicle&&(e=this.m_vehicle.enableMultiRaycast),e},t.prototype.setEnableMultiRaycast=function(e){null!=this.m_vehicle&&(this.m_vehicle.enableMultiRaycast=e)},t.prototype.getSmoothedGradientSpeed=function(){var e=-1;return null!=this.m_vehicle&&(e=this.m_vehicle.smoothedGradientSpeed),e},t.prototype.setSmoothedGradientSpeed=function(e){null!=this.m_vehicle&&(this.m_vehicle.smoothedGradientSpeed=e)},t.prototype.getMaximumYawRateLow=function(){var e=-1;return null!=this.m_vehicle&&(e=this.m_vehicle.maximumYawRateLow),e},t.prototype.setMaximumYawRateLow=function(e){null!=this.m_vehicle&&(this.m_vehicle.maximumYawRateLow=e)},t.prototype.getMaximumYawRateHigh=function(){var e=-1;return null!=this.m_vehicle&&(e=this.m_vehicle.maximumYawRateHigh),e},t.prototype.setMaximumYawRateHigh=function(e){null!=this.m_vehicle&&(this.m_vehicle.maximumYawRateHigh=e)},t.prototype.getAngularDampingControl=function(){var e=new BABYLON.Vector3;return null!=this.m_vehicle&&(e=this.m_vehicle.angularDamping),e},t.prototype.setAngularDampingControl=function(e){null!=this.m_vehicle&&(this.m_vehicle.angularDamping=e)},t.prototype.getSmoothFlyingImpulse=function(){var e=-1;return null!=this.m_vehicle&&this.m_vehicle.smoothFlyingImpulse&&(e=this.m_vehicle.smoothFlyingImpulse),e},t.prototype.setSmoothFlyingImpulse=function(e){null!=this.m_vehicle&&(this.m_vehicle.smoothFlyingImpulse=e)},t.prototype.setGroundedAutoLevelEnabled=function(e){null!=this.m_vehicle&&(this.m_vehicle.groundedAutoLevelEnabled=e)},t.prototype.setGroundedAutoLevelStrength=function(e){null!=this.m_vehicle&&(this.m_vehicle.groundedAutoLevelStrength=e)},t.prototype.setGroundedAutoLevelDeadzone=function(e){null!=this.m_vehicle&&(this.m_vehicle.groundedAutoLevelDeadzoneDeg=e)},t.prototype.setGroundedAutoLevelSettleDeg=function(e){null!=this.m_vehicle&&(this.m_vehicle.groundedAutoLevelSettleDeg=e)},t.prototype.setGroundedAutoLevelSettleScale=function(e){null!=this.m_vehicle&&(this.m_vehicle.groundedAutoLevelSettleScale=e)},t.prototype.setGroundedAutoLevelHysteresis=function(e){null!=this.m_vehicle&&(this.m_vehicle.groundedAutoLevelHysteresisDeg=e)},t.prototype.setGroundedAutoLevelSpeedRange=function(e,t){null!=this.m_vehicle&&(this.m_vehicle.groundedAutoLevelStartKmh=e,this.m_vehicle.groundedAutoLevelFullKmh=t)},t.prototype.setGroundedAutoLevelMaxRate=function(e){null!=this.m_vehicle&&(this.m_vehicle.groundedAutoLevelMaxRate=e)},t.prototype.getTrackConnectionAccel=function(){var e=-1;return null!=this.m_vehicle&&this.m_vehicle.trackConnectionAccel&&(e=this.m_vehicle.trackConnectionAccel),e},t.prototype.setTrackConnectionAccel=function(e){null!=this.m_vehicle&&(this.m_vehicle.trackConnectionAccel=e)},t.prototype.setAirborneTrackConnectionMaxAccel=function(e){null!=this.m_vehicle&&(this.m_vehicle.airborneTrackConnectionMaxAccel=e)},t.prototype.setAirborneTrackConnectionSpeedRange=function(e,t){null!=this.m_vehicle&&(this.m_vehicle.airborneTrackConnectionStartKmh=e,this.m_vehicle.airborneTrackConnectionFullKmh=t)},t.prototype.setAirborneRiseDamping=function(e){null!=this.m_vehicle&&(this.m_vehicle.airborneRiseDamping=e)},t.prototype.setAirborneMaxRiseSpeed=function(e){null!=this.m_vehicle&&(this.m_vehicle.airborneMaxRiseSpeed=e)},t.prototype.getMinimumWheelContacts=function(){var e=-1;return null!=this.m_vehicle&&this.m_vehicle.minimumWheelContacts&&(e=this.m_vehicle.minimumWheelContacts),e},t.prototype.setMinimumWheelContacts=function(e){null!=this.m_vehicle&&(this.m_vehicle.minimumWheelContacts=e)},t.prototype.getDownforceCoefficient=function(){return null!=this.m_vehicle?this.m_vehicle.downforceCoefficient:0},t.prototype.setDownforceCoefficient=function(e){null!=this.m_vehicle&&(this.m_vehicle.downforceCoefficient=e)},t.prototype.getConstantDownforce=function(){return null!=this.m_vehicle?this.m_vehicle.constantDownforce:0},t.prototype.setConstantDownforce=function(e){null!=this.m_vehicle&&(this.m_vehicle.constantDownforce=e)},t.prototype.getWheelIndexByID=function(e){var t=-1;if(null!=this.m_vehicleColliders&&this.m_vehicleColliders.length>0)for(var i=0;i<this.m_vehicleColliders.length;i++){var n=this.m_vehicleColliders[i];if(e.toLowerCase()===n.id.toLowerCase()){t=i;break}}return t},t.prototype.getWheelIndexByName=function(e){var t=-1;if(null!=this.m_vehicleColliders&&this.m_vehicleColliders.length>0)for(var i=0;i<this.m_vehicleColliders.length;i++){var n=this.m_vehicleColliders[i];if(e.toLowerCase()===n.name.toLowerCase()){t=i;break}}return t},t.prototype.getWheelColliderInfo=function(e){var t=-1;return null!=this.m_vehicleColliders&&this.m_vehicleColliders.length>0&&this.m_vehicleColliders.length>e&&(t=this.m_vehicleColliders[e]),t},t.prototype.setWheelTransformMesh=function(e,t){if(null!=t){var i=this.getWheelInfo(e);null!=i&&(i.transform=t)}},t.prototype.ensureNodeRotationQuaternion=function(e){return null==e.rotationQuaternion&&(e.rotationQuaternion=BABYLON.Quaternion.FromEulerAngles(e.rotation.x,e.rotation.y,e.rotation.z)),e.rotationQuaternion},t.prototype.normalizeWheelRotation=function(e){var t=2*Math.PI;return isFinite(e)?((e%=t)>Math.PI&&(e-=t),e<-Math.PI&&(e+=t),e):0},t.prototype.syncWheelSpinnerRotation=function(e){var t=e.spinner;if(null!=t){var i=this.ensureNodeRotationQuaternion(t);null!=e.spinnerBaseRotation&&e.spinnerBaseNode===t||(e.spinnerBaseRotation=i.clone(),e.spinnerBaseNode=t);var n=this.normalizeWheelRotation(e.rotation||0);!0===e.invertWheelDirection&&(n=-n),i.copyFrom(e.spinnerBaseRotation),t.rotate(BABYLON.Axis.X,n,BABYLON.Space.LOCAL)}},t.prototype.rebaseWheelSpinnerRotation=function(e){var t=e.spinner;if(null!=t){var i=this.ensureNodeRotationQuaternion(t),n=this.normalizeWheelRotation(e.rotation||0);!0===e.invertWheelDirection&&(n=-n);var r=i.clone();i.copyFrom(r),t.rotate(BABYLON.Axis.X,-n,BABYLON.Space.LOCAL),e.spinnerBaseRotation=i.clone(),e.spinnerBaseNode=t,i.copyFrom(r)}},t.prototype.getWheelSkidFadeInSpeed=function(){return this.m_vehicle,3},t.prototype.setWheelSkidFadeInSpeed=function(e){this.m_vehicle},t.prototype.getWheelSkidFadeOutSpeed=function(){return this.m_vehicle,3.5},t.prototype.setWheelSkidFadeOutSpeed=function(e){this.m_vehicle},t.prototype.isArcadeYawAssistActive=function(){var e=!1;return null!=this.m_vehicle&&(e=this.m_vehicle.isArcadeYawAssistActive),e},t.prototype.getArcadeSteeringAssist=function(){return null!=this.m_vehicle?this.m_vehicle.arcadeSteeringAssist:1},t.prototype.setArcadeSteeringAssist=function(e){null!=this.m_vehicle&&(this.m_vehicle.arcadeSteeringAssist=e)},t.prototype.getArcadeDonutDirectYawEnabled=function(){return null!=this.m_vehicle&&this.m_vehicle.arcadeDonutDirectYawEnabled},t.prototype.setArcadeDonutDirectYawEnabled=function(e){null!=this.m_vehicle&&(this.m_vehicle.arcadeDonutDirectYawEnabled=e)},t.prototype.getArcadeDonutDirectYawDegPerSec=function(){return null!=this.m_vehicle?this.m_vehicle.arcadeDonutDirectYawDegPerSec:1},t.prototype.setArcadeDonutDirectYawDegPerSec=function(e){null!=this.m_vehicle&&(this.m_vehicle.arcadeDonutDirectYawDegPerSec=e)},t.prototype.getArcadeHandbrakeYawCapMultiplier=function(){return null!=this.m_vehicle?this.m_vehicle.arcadeHandbrakeYawCapMultiplier:1},t.prototype.setArcadeHandbrakeYawCapMultiplier=function(e){null!=this.m_vehicle&&(this.m_vehicle.arcadeHandbrakeYawCapMultiplier=e)},t.prototype.getArcadeBurnoutYawCapMultiplier=function(){return null!=this.m_vehicle?this.m_vehicle.arcadeBurnoutYawCapMultiplier:1},t.prototype.setArcadeBurnoutYawCapMultiplier=function(e){null!=this.m_vehicle&&(this.m_vehicle.arcadeBurnoutYawCapMultiplier=e)},t.prototype.getArcadeDonutYawCapMultiplier=function(){return null!=this.m_vehicle?this.m_vehicle.arcadeDonutYawCapMultiplier:1},t.prototype.setArcadeDonutYawCapMultiplier=function(e){null!=this.m_vehicle&&(this.m_vehicle.arcadeDonutYawCapMultiplier=e)},t.prototype.getArcadeBurnoutActive=function(){var e=!1;return null!=this.m_vehicle&&(e=this.m_vehicle.getIsArcadeBurnoutActive()),e},t.prototype.setArcadeBurnoutActive=function(e){null!=this.m_vehicle&&this.m_vehicle.setIsArcadeBurnoutActive(e)},t.prototype.getArcadeDonutActive=function(){var e=!1;return null!=this.m_vehicle&&(e=this.m_vehicle.getIsArcadeDonutActive()),e},t.prototype.setArcadeDonutActive=function(e){null!=this.m_vehicle&&this.m_vehicle.setIsArcadeDonutActive(e)},t.prototype.getArcadeFootBrakeActive=function(){var e=!1;return null!=this.m_vehicle&&(e=this.m_vehicle.getIsArcadeFootBrakeActive()),e},t.prototype.setArcadeFootBrakeActive=function(e){null!=this.m_vehicle&&this.m_vehicle.setIsArcadeFootBrakeActive(e)},t.prototype.getArcadeHandBrakeActive=function(){var e=!1;return null!=this.m_vehicle&&(e=this.m_vehicle.getIsArcadeHandBrakeActive()),e},t.prototype.setArcadeHandBrakeActive=function(e){null!=this.m_vehicle&&this.m_vehicle.setIsArcadeHandBrakeActive(e)},t.prototype.setArcadeBurnoutDirectionChangeSpeed=function(t){null!=this.m_vehicle&&(this.m_vehicle.arcadeBurnoutDirectionChangeSpeedKmh=t*e.System.Mph2Kph)},t.prototype.getApproxWheelbaseMeters=function(){var e=2.5;return null!=this.m_vehicle&&(e=this.m_vehicle.getApproxWheelbaseMeters()),e},t.prototype.getSignedFrontSteeringAngleRad=function(){var e=0;return null!=this.m_vehicle&&(e=this.m_vehicle.getSignedFrontSteeringAngleRad()),e},t.prototype.getVisualSteeringAngle=function(e){var t=0,i=this.getWheelInfo(e);return null!=i&&null!=i.steeringAngle&&(t=i.steeringAngle),t},t.prototype.setVisualSteeringAngle=function(e,t){var i=this.getWheelInfo(t);null!=i&&(i.steeringAngle=e)},t.prototype.getPhysicsSteeringAngle=function(e){return null!=this.m_vehicle?Math.abs(this.m_vehicle.getSteeringValue(e)):0},t.prototype.setPhysicsSteeringAngle=function(e,t){null!=this.m_vehicle&&this.m_vehicle.setSteeringValue(e,t)},t.prototype.setupWheelInformation=function(){if(null!=this._chassisMesh&&this._chassisMesh.physicsBody,null!=this.m_vehicle&&null!=this.m_vehicleColliders&&this.m_vehicleColliders.length>0){var t=-1;for(t=0;t<this.m_vehicleColliders.length;t++){var i=null!=(p=this.m_vehicleColliders[t]).name?p.name:"Unknown",n=null!=p.radius?p.radius:.35,r=null!=p.position&&p.position.length>=3?p.position[0]:1,o=null!=p.position&&p.position.length>=3?p.position[2]:-1,a=null!=p.wheelconnectionpoint?p.wheelconnectionpoint:.5,s=null!=p.suspensionrestlength?p.suspensionrestlength:.3,l=null!=p.frontwheel||i.toLowerCase().indexOf("front")>=0,u=o,h=r,c=-this._centerMass.x,d=-this._centerMass.z;null==e.RaycastVehicle.TempVector&&(e.RaycastVehicle.TempVector=new BABYLON.Vector3(0,0,0)),e.RaycastVehicle.TempVector.set(h+c,a,u+d),this.m_vehicle.addWheel(e.RaycastVehicle.TempVector,this.m_wheelDirectionCS0,this.m_wheelAxleCS,s,n,this.m_vehicleTuning,l)}if(this.m_vehicle.getNumWheels()===this.m_vehicleColliders.length){var m=[];for(t=0;t<this.m_vehicleColliders.length;t++){var p,f=null!=(p=this.m_vehicleColliders[t]).totalsuspensionforces?p.totalsuspensionforces:0,g=null!=p.suspensiontravelcm?p.suspensiontravelcm:50,y=null!=p.rollinfluence?p.rollinfluence:.1,v=null!=p.frictionslip?p.frictionslip:10,S=null!=p.suspensionstiffness?p.suspensionstiffness:50,_=null!=p.dampingcompression?p.dampingcompression:2.5,b=null!=p.dampingrelaxation?p.dampingrelaxation:4.5,B=null!=p.invertWheelDirection&&p.invertWheelDirection,C=null!=p.maxVisualTravelRange?p.maxVisualTravelRange:0,A=this.m_vehicle.getWheelInfo(t);null!=A&&(A.steeringAngle=0,A.rotationBoost=0,A.defaultFriction=v,A.invertWheelDirection=B,A.maxVisualTravelRange=C,A.frictionSlip=v,A.rollInfluence=y,A.maxSuspensionTravelCm=g,A.suspensionStiffness=S,A.dampingCompression=_,A.dampingRelaxation=b,f>0?A.maxSuspensionForce=f:m.push(t))}this.applyAutoSuspensionForce(m)}else BABYLON.Tools.Warn("Failed to create proper number of wheels for: "+this._chassisMesh.name);this.m_vehicle.cacheMassProperties()}},t.prototype.applyAutoSuspensionForce=function(t){if(null!=this.m_vehicle&&null!=t&&0!==t.length){var i=null!=this._chassisMesh?this._chassisMesh.physicsBody:null;if(null!=i){var n=i.getMassProperties(),r=null!=n&&null!=n.mass?n.mass:0;if(r>0){var o=9.81;if(null!=this.m_scene&&null!=this.m_scene.gravity){var a=this.m_scene.gravity.length();a>1e-4&&(o=a)}var s=e.RaycastVehicle.AutoSuspensionForceReserve,l=this.m_vehicle.getNumWheels();if(!(l<=0)){for(var u=0,h=0,c=0,d=0,m=0;m<l;m++)if(null!=(C=this.m_vehicle.getWheelInfo(m))){var p=this.getWheelForwardPosition(C.chassisConnectionPointCS);C.isFrontWheel?(u+=p,c++):(h+=p,d++)}var f=0,g=0;if(c>0&&d>0){var y=u/c,v=h/d,S=Math.abs(y-v);if((y>=0&&v<=0||y<=0&&v>=0)&&S>1e-4){var _=Math.abs(y),b=r*o;f=b*(Math.abs(v)/S)/c,g=b*(_/S)/d}}if(!(f>0&&g>0)){var B=r*o/l;f=B,g=B}for(m=0;m<t.length;m++){var C,A=t[m];if(null!=(C=this.m_vehicle.getWheelInfo(A))){var T=C.isFrontWheel?f:g;C.maxSuspensionForce=T*s}}}}}}},t.prototype.getWheelForwardPosition=function(e){if(null==e||null==this.m_vehicle)return 0;switch(this.m_vehicle.getForwardAxis()){case 0:return e.x;case 1:return e.y;default:return e.z}},t.prototype.getNaturalWheelSlip=function(e){var t=!1;return null!=this.m_vehicle&&(t=this.m_vehicle.getNaturalWheelSlip(e)),t},t.prototype.getWheelAtRestSpeedThresholdKmh=function(){return null!=this.m_vehicle?this.m_vehicle.wheelAtRestSpeedThresholdKmh:1},t.prototype.setWheelAtRestSpeedThresholdKmh=function(e){null!=this.m_vehicle&&(this.m_vehicle.wheelAtRestSpeedThresholdKmh=e)},t.prototype.updateWheelInformation=function(){var t=this.getNumWheels();if(t>0)for(var i=0;i<t;i++){var n=this.getWheelInfo(i);if(null!=n){var r=this.lockedWheelInformation(i);if(this.updateWheelTransform(i,!1),this.m_tempPosition=this.getWheelTransformPosition(i),null!=n.transform){var o=n.transform;if(null!=o.parent){this._tempVectorPos.copyFrom(this.m_tempPosition),e.Utilities.InverseTransformPointToRef(o.parent,this._tempVectorPos,this._tempVectorPos),o.position.y=this._tempVectorPos.y,this.ensureNodeRotationQuaternion(o);var a=null!=n.steeringAngle?n.steeringAngle:0;BABYLON.Quaternion.FromEulerAnglesToRef(0,a,0,o.rotationQuaternion),null!=n.spinner&&(!0===r?n.spinnerLocked=!0:(!0===n.spinnerLocked&&(this.rebaseWheelSpinnerRotation(n),n.spinnerLocked=!1),this.syncWheelSpinnerRotation(n)))}}}}},t.prototype.lockedWheelInformation=function(e){var t=!1;if(null!=this.lockedWheelIndexes&&this.lockedWheelIndexes.length>0)for(var i=0;i<this.lockedWheelIndexes.length;i++)if(this.lockedWheelIndexes[i]===e){t=!0;break}return t},t.prototype.deleteWheelInformation=function(){var e=this.getNumWheels();if(e>0)for(var t=0;t<e;t++){var i=this.getWheelInfo(t);null!=i&&(null!=i.transform&&delete i.transform,null!=i.spinner&&delete i.spinner,null!=i.steeringAngle&&delete i.steeringAngle,null!=i.rotationBoost&&delete i.rotationBoost,null!=i.invertWheelDirection&&delete i.invertWheelDirection,null!=i.defaultFriction&&delete i.defaultFriction,null!=i.spinnerBaseRotation&&delete i.spinnerBaseRotation,null!=i.spinnerBaseNode&&delete i.spinnerBaseNode,null!=i.spinnerLocked&&delete i.spinnerLocked)}},t.TempVector=null,t.AutoSuspensionForceReserve=3.5,t}();e.RaycastVehicle=t}(n||(n={})),function(e){var t=function(t){function i(e,i,n,r){void 0===n&&(n={}),void 0===r&&(r="TOOLKIT.RigidbodyPhysics");var o=t.call(this,e,i,n,r)||this;return o._isKinematic=!1,o._centerOfMass=new BABYLON.Vector3(0,0,0),o.m_raycastVehicle=null,o}return o(i,t),i.prototype.awake=function(){this.awakeRigidbodyState()},i.prototype.update=function(){this.updateRigidbodyState()},i.prototype.fixed=function(){this.fixedRigidbodyState()},i.prototype.destroy=function(){this.destroyRigidbodyState()},i.prototype.awakeRigidbodyState=function(){this._isKinematic=this.getProperty("isKinematic",this._isKinematic),null!=this.transform.metadata&&null!=this.transform.metadata.toolkit&&null!=this.transform.metadata.toolkit.physics&&(this._centerOfMass=null!=this.transform.metadata.toolkit.physics.center?e.Utilities.ParseVector3(this.transform.metadata.toolkit.physics.center,this._centerOfMass):this._centerOfMass),this.hasWheelColliders()&&(this._isKinematic=!1,this.transform.physicsBody.disablePreStep=!1,this.m_raycastVehicle=new e.RaycastVehicle(this.scene,this.transform,this._centerOfMass),e.Utilities.ShowDebugColliders()&&console.log("Raycase Vehicle Created For: "+this.transform.name))},i.prototype.updateRigidbodyState=function(){null!=this.m_raycastVehicle&&this.m_raycastVehicle.updateWheelInformation()},i.prototype.fixedRigidbodyState=function(){null!=this.m_raycastVehicle&&this.m_raycastVehicle.tickVehicleController(e.RigidbodyPhysics.PHYSICS_STEP_TIME)},i.prototype.destroyRigidbodyState=function(){null!=this.m_raycastVehicle&&(this.m_raycastVehicle.dispose(),this.m_raycastVehicle=null)},i.prototype.isKinematic=function(){return this._isKinematic},i.prototype.hasWheelColliders=function(){return null!=this.transform.metadata&&null!=this.transform.metadata.toolkit&&null!=this.transform.metadata.toolkit.wheels},i.prototype.getRaycastVehicle=function(){return this.m_raycastVehicle},i.GetHavokInstance=function(){return globalThis.HK},i.Raycast=function(t,i,n,r){return null==e.RigidbodyPhysics.RaycastResult&&(e.RigidbodyPhysics.RaycastResult=new BABYLON.PhysicsRaycastResult),null==e.RigidbodyPhysics.RaycastDestination&&(e.RigidbodyPhysics.RaycastDestination=new BABYLON.Vector3(0,0,0)),e.RigidbodyPhysics.RaycastResult.reset(),e.RigidbodyPhysics.RaycastDestination.set(0,0,0),e.Utilities.CalculateDestinationPointToRef(t,i,n,e.RigidbodyPhysics.RaycastDestination),e.RigidbodyPhysics.RaycastToRef(t,e.RigidbodyPhysics.RaycastDestination,e.RigidbodyPhysics.RaycastResult,r),e.RigidbodyPhysics.RaycastResult},i.Shapecast=function(t){return null==e.RigidbodyPhysics.LocalShapeResult&&(e.RigidbodyPhysics.LocalShapeResult=new BABYLON.ShapeCastResult),null==e.RigidbodyPhysics.WorldShapeResult&&(e.RigidbodyPhysics.WorldShapeResult=new BABYLON.ShapeCastResult),e.RigidbodyPhysics.LocalShapeResult.reset(),e.RigidbodyPhysics.WorldShapeResult.reset(),e.RigidbodyPhysics.ShapecastToRef(t,e.RigidbodyPhysics.LocalShapeResult,e.RigidbodyPhysics.WorldShapeResult),{local:e.RigidbodyPhysics.LocalShapeResult,world:e.RigidbodyPhysics.WorldShapeResult}},i.RaycastToRef=function(t,i,n,r){var o=e.Utilities.GetHavokPlugin();if(o){null==e.RigidbodyPhysics.RaycastResult&&(e.RigidbodyPhysics.RaycastResult=new BABYLON.PhysicsRaycastResult),null==e.RigidbodyPhysics.RaycastDestination&&(e.RigidbodyPhysics.RaycastDestination=new BABYLON.Vector3(0,0,0)),e.RigidbodyPhysics.RaycastResult.reset(),e.RigidbodyPhysics.RaycastDestination.set(0,0,0);var a=null!=n?n:e.RigidbodyPhysics.RaycastResult;o.raycast(t,i,a,r)}else BABYLON.Tools.Warn("Havok.js physics library not loaded")},i.ShapecastToRef=function(t,i,n){var r=e.Utilities.GetHavokPlugin();if(r){null==e.RigidbodyPhysics.LocalShapeResult&&(e.RigidbodyPhysics.LocalShapeResult=new BABYLON.ShapeCastResult),null==e.RigidbodyPhysics.WorldShapeResult&&(e.RigidbodyPhysics.WorldShapeResult=new BABYLON.ShapeCastResult),e.RigidbodyPhysics.LocalShapeResult.reset(),e.RigidbodyPhysics.WorldShapeResult.reset();var o=null!=i?i:e.RigidbodyPhysics.LocalShapeResult,a=null!=n?n:e.RigidbodyPhysics.WorldShapeResult;r.shapeCast(t,o,a)}else BABYLON.Tools.Warn("Havok.js physics library not loaded")},i.SetMaxVelocities=function(t,i){var n=e.Utilities.GetHavokPlugin();if(n){var r=n._hknp.HEAP8.buffer,o=new Int32Array(r,Number(n.world),100),a=new Int32Array(r,o[8],500),s=new Int32Array(r,a[428],100),l=new Float32Array(r,s[8],300);l[32]=t,l[33]=i,l[60]=t,l[61]=i,l[88]=t,l[89]=i,l[144]=t,l[145]=i,l[172]=t,l[173]=i,l[200]=t,l[201]=i,l[228]=t}else BABYLON.Tools.Warn("Havok.js physics library not loaded")},i.ConfigurePhysicsEngine=function(t){return s(this,arguments,void 0,function(t,i,n,r,o,a,s){var u,h,c,d,m,p,f;return void 0===i&&(i=!0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===o&&(o=!0),void 0===a&&(a=1e-4),void 0===s&&(s=null),l(this,function(r){switch(r.label){case 0:if(!BABYLON.HavokPlugin)return[3,7];r.label=1;case 1:return r.trys.push([1,5,6,7]),t.isPhysicsEnabled()?[3,4]:null!=(u=e.RigidbodyPhysics.GetHavokInstance())?[3,3]:(h=globalThis,[4,BABYLON.HavokPhysics()]);case 2:h.HK=r.sent(),u=globalThis.HK,r.label=3;case 3:return c=new BABYLON.Vector3(0,-9.81,0),d=null!=s?s:c,globalThis.HKP=new BABYLON.HavokPlugin(!i,u),t.enablePhysics(d,globalThis.HKP),[3,4];case 4:return[3,7];case 5:return m=r.sent(),console.warn(m),[3,7];case 6:e.RigidbodyPhysics.PhysicsShapeCache={},e.RigidbodyPhysics.NewPhysicsShapeCount=0,e.RigidbodyPhysics.CachedPhysicsShapeCount=0;try{null===(f=t.getPhysicsEngine())||void 0===f||f.setSubTimeStep(n),BABYLON.Tools.Log("Havok.js initialized with sub time step of "+n),p=e.RigidbodyPhysics.GetPhysicsHeapSize(),BABYLON.Tools.Log("Havok.js initialized with a heap size of "+p+" MB")}catch(e){console.warn(e)}try{null!=e.RigidbodyPhysics.OnSetupPhysicsPlugin&&e.RigidbodyPhysics.OnSetupPhysicsPlugin(t)}catch(e){console.warn(e)}return[7];case 7:return[2]}})})},i.SetupPhysicsComponent=function(t,i){var n=null!=i.metadata&&null!=i.metadata.toolkit?i.metadata.toolkit:null,r=null!=n.layermask?n.layermask:-1;if(null!=n&&(null!=n.physics||null!=n.collision)){var o=null!=n.physics,a=null!=n.physics&&null!=n.physics.filter?n.physics.filter:-1,s=null!=n.physics&&null!=n.physics.vehicle&&n.physics.vehicle,l=null!=n.physics&&null!=n.physics.root&&n.physics.root,u=null!=n.collision&&null!=n.collision.compoundcolliders,h=null!=n.physics&&null!=n.physics.mass?n.physics.mass:0,c=null!=n.physics&&null!=n.physics.center?n.physics.center:{x:0,y:0,z:0},d=null==n.physics||null==n.physics.kinematic||n.physics.kinematic,m=null==n.physics||null==n.physics.truestatic||n.physics.truestatic,p=BABYLON.PhysicsMotionType.DYNAMIC;if(p=!0===m?BABYLON.PhysicsMotionType.STATIC:!0===d?BABYLON.PhysicsMotionType.ANIMATED:BABYLON.PhysicsMotionType.DYNAMIC,!0===o){if(s){var f=null,g=i.getChildren(null,!1);null!=g&&g.length>0&&g.forEach(function(t){if(null!=t.metadata&&null!=t.metadata.toolkit&&null!=t.metadata.toolkit.collision){var n=t.metadata.toolkit.collision,r=null!=n.wheelinformation?n.wheelinformation:null;null!=r&&(e.Utilities.ShowDebugColliders()&&console.log("Setup raycast wheel collider: "+t.name+" --\x3e on to: "+i.name,i),null==f&&(f=[]),f.push(r))}}),null!=f&&f.length>0&&(null==i.metadata&&(i.metadata={}),null==i.metadata.toolkit&&(i.metadata.toolkit={}),i.metadata.toolkit.wheels=f)}if(u){var y=n.collision.compoundcolliders;if(null!=y&&y.length>0){var v=0,S=0,_=0,b=!1,B=[];if(y.forEach(function(n){if(null!=n){var o=null!=n.type?n.type:"BoxCollider",s=null!=n.restitutioncombine?e.RigidbodyPhysics.GetPhysicsMaterialCombine(n.restitutioncombine):0,l=null!=n.frictioncombine?e.RigidbodyPhysics.GetPhysicsMaterialCombine(n.frictioncombine):0,u=null!=n.dynamicfriction?n.dynamicfriction:.6,h=null!=n.staticfriction?n.staticfriction:.6,c=null!=n.restitution?n.restitution:0,d=null!=n.trigger&&n.trigger;u>v&&(v=u),h>S&&(S=h),c>_&&(_=c),1==d&&(b=!0);var m=e.RigidbodyPhysics.BoxImpostor;m="MeshCollider"===o?e.RigidbodyPhysics.ConvexHullImpostor:"CapsuleCollider"===o?e.RigidbodyPhysics.CapsuleImpostor:"SphereCollider"===o?e.RigidbodyPhysics.SphereImpostor:e.RigidbodyPhysics.BoxImpostor;var p=n,f=null!=p.center?p.center:{x:0,y:0,z:0},g=null!=p.persist&&p.persist,y=new e.PhyscisContainerData;e.Utilities.ShowDebugColliders()&&console.log("Setup simple compound child collider type ("+o+") --\x3e on to: "+i.name,i),e.RigidbodyPhysics.CreateCompoundPhysicsShapeAndBody(t,i,i,p,m,h,u,c,l,s,B,y,f,!1,d,g,r,a)}}),B.length>0){e.Utilities.ReparentColliders()||i.setParent(null,!0,!0);var C=new BABYLON.Vector3(c.x,c.y,c.z),A=new BABYLON.PhysicsShapeContainer(t);B.forEach(function(e){A.addChild(e.shape,e.translation,e.rotation,e.scale)}),A.material=B[0].shape.material;var T=new BABYLON.PhysicsBody(i,p,!1,t);T.shape=A,e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,i,!1,b,n.physics,h,C),e.Utilities.ShowDebugColliders()||null!=(k=i).material&&"CenterBox-Material"===k.material.name&&(k.isVisible=!1),e.Utilities.ShowDebugColliders()&&(null==e.RigidbodyPhysics.DebugPhysicsViewer&&(e.RigidbodyPhysics.DebugPhysicsViewer=new BABYLON.Debug.PhysicsViewer),null!=e.RigidbodyPhysics.DebugPhysicsViewer&&e.RigidbodyPhysics.DebugPhysicsViewer.showBody(T))}}}else if(l){var M=0,L=0,P=0,w=!1,x=[],O=null!=n.physics&&null!=n.physics.center?e.Utilities.ParseVector3(n.physics.center,BABYLON.Vector3.Zero()):BABYLON.Vector3.Zero(),R=i.getChildren(null,!0);null!=R&&R.length>0&&R.forEach(function(e){e.position.subtractInPlace(O)});var I=i.getChildren(null,!1);if(null!=I&&I.length>0&&I.forEach(function(n){if(null!=n.metadata&&null!=n.metadata.toolkit&&null!=n.metadata.toolkit.collision){var o=n.metadata.toolkit.collision,s=null!=o.restitutioncombine?e.RigidbodyPhysics.GetPhysicsMaterialCombine(o.restitutioncombine):0,u=null!=o.frictioncombine?e.RigidbodyPhysics.GetPhysicsMaterialCombine(o.frictioncombine):0,h=null!=o.dynamicfriction?o.dynamicfriction:.6,c=null!=o.staticfriction?o.staticfriction:.6,d=null!=o.restitution?o.restitution:0,m=null!=o.trigger&&o.trigger,p=null!=o.type?o.type:"BoxCollider";h>M&&(M=h),c>L&&(L=c),d>P&&(P=d),1==m&&(w=!0);var f=e.RigidbodyPhysics.BoxImpostor;f="MeshCollider"===p?e.RigidbodyPhysics.ConvexHullImpostor:"CapsuleCollider"===p?e.RigidbodyPhysics.CapsuleImpostor:"SphereCollider"===p?e.RigidbodyPhysics.SphereImpostor:e.RigidbodyPhysics.BoxImpostor;var g=o,y=null!=g.center?g.center:{x:0,y:0,z:0},v=null!=g.persist&&g.persist,S=new e.PhyscisContainerData;e.Utilities.ShowDebugColliders()&&console.log("Setup complex compound child collider type ("+p+") --\x3e on to: "+i.name,i),e.RigidbodyPhysics.CreateCompoundPhysicsShapeAndBody(t,i,n,g,f,c,h,d,u,s,x,S,y,l,m,v,r,a)}}),x.length>0){e.Utilities.ReparentColliders()||i.setParent(null,!0,!0),C=new BABYLON.Vector3(c.x,c.y,c.z);var N=new BABYLON.PhysicsShapeContainer(t);N.material=x[0].shape.material,x.forEach(function(e){N.addChild(e.shape,e.translation,e.rotation,e.scale)});var k,F=new BABYLON.PhysicsBody(i,p,!1,t);F.shape=N,e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,i,!1,w,n.physics,h,C),e.Utilities.ShowDebugColliders()||null!=(k=i).material&&"CenterBox-Material"===k.material.name&&(k.isVisible=!1),e.Utilities.ShowDebugColliders()&&(null==e.RigidbodyPhysics.DebugPhysicsViewer&&(e.RigidbodyPhysics.DebugPhysicsViewer=new BABYLON.Debug.PhysicsViewer),null!=e.RigidbodyPhysics.DebugPhysicsViewer&&e.RigidbodyPhysics.DebugPhysicsViewer.showBody(F))}}else if(null!=n.collision){var D=null!=n.collision.type?n.collision.type:"BoxCollider",E=null!=n.collision.convexmesh&&n.collision.convexmesh,V=null!=n.collision.restitutioncombine?e.RigidbodyPhysics.GetPhysicsMaterialCombine(n.collision.restitutioncombine):0,Y=null!=n.collision.frictioncombine?e.RigidbodyPhysics.GetPhysicsMaterialCombine(n.collision.frictioncombine):0,U=null!=n.collision.dynamicfriction?n.collision.dynamicfriction:.6,W=null!=n.collision.staticfriction?n.collision.staticfriction:.6,G=null!=n.collision.restitution?n.collision.restitution:0,H=null!=n.collision.terraindata?n.collision.terraindata:null,z=null!=n.collision.trigger&&n.collision.trigger,K=null!=n.collision.persist&&n.collision.persist,X=e.RigidbodyPhysics.BoxImpostor;X="MeshCollider"===D?!0===E?e.RigidbodyPhysics.ConvexHullImpostor:e.RigidbodyPhysics.MeshImpostor:"TerrainCollider"===D?e.RigidbodyPhysics.HeightmapImpostor:"CapsuleCollider"===D?e.RigidbodyPhysics.CapsuleImpostor:"SphereCollider"===D?e.RigidbodyPhysics.SphereImpostor:e.RigidbodyPhysics.BoxImpostor,e.RigidbodyPhysics.CreateStandardPhysicsShapeAndBody(t,i,n,X,z,m,p,h,W,U,G,Y,V,H,c,K,r,a)}}null!=i&&null!=i.physicsBody&&!0===d&&(i.physicsBody.disablePreStep=!1)}},i.GetPhysicsMaterialCombine=function(e){switch(e){case 0:default:return BABYLON.PhysicsMaterialCombineMode.ARITHMETIC_MEAN;case 1:return BABYLON.PhysicsMaterialCombineMode.MULTIPLY;case 2:return BABYLON.PhysicsMaterialCombineMode.MINIMUM;case 3:return BABYLON.PhysicsMaterialCombineMode.MAXIMUM}},i.GetCachedPhysicsMeshShape=function(t,i,n,r,o,a,s,l,u,h){if(null==n||""===n)return console.warn("Invalid mesh key specfifed for child collider: "+i.name),null;n+="_SF"+r+"_DF"+o+"_R"+a+"_T0_L"+u+"_X"+h;var c=e.RigidbodyPhysics.PhysicsShapeCache[n];return null==c?((c=new BABYLON.PhysicsShapeMesh(i,t)).material={friction:o,staticFriction:r,restitution:a,frictionCombine:s,restitutionCombine:l},c.isTrigger=!1,c.filterMembershipMask=u,e.RigidbodyPhysics.NewPhysicsShapeCount++,e.RigidbodyPhysics.PhysicsShapeCache[n]=c):e.RigidbodyPhysics.CachedPhysicsShapeCount++,c},i.GetCachedPhysicsConvexHullShape=function(t,i,n,r,o,a,s,l,u,h){if(null==n||""===n)return console.warn("Invalid mesh key specfifed for child collider: "+i.name),null;n+="_SF"+r+"_DF"+o+"_R"+a+"_T0_L"+u+"_X"+h;var c=e.RigidbodyPhysics.PhysicsShapeCache[n];return null==c?((c=new BABYLON.PhysicsShapeConvexHull(i,t)).material={friction:o,staticFriction:r,restitution:a,frictionCombine:s,restitutionCombine:l},c.isTrigger=!1,c.filterMembershipMask=u,e.RigidbodyPhysics.NewPhysicsShapeCount++,e.RigidbodyPhysics.PhysicsShapeCache[n]=c):e.RigidbodyPhysics.CachedPhysicsShapeCount++,c},i.GetCachedPhysicsBoxShape=function(t,i,n,r,o,a,s,l,u){var h="SHAPE_BOX_SF"+n+"_DF"+r+"_R"+o+"_T"+(1==i?"1":"0")+"_L"+l+"_X"+u,c=e.RigidbodyPhysics.PhysicsShapeCache[h];return null==c?((c=new BABYLON.PhysicsShapeBox(new BABYLON.Vector3(0,0,0),new BABYLON.Quaternion(0,0,0,1),new BABYLON.Vector3(1,1,1),t)).material={friction:r,staticFriction:n,restitution:o,frictionCombine:a,restitutionCombine:s},c.isTrigger=i,c.filterMembershipMask=l,e.RigidbodyPhysics.NewPhysicsShapeCount++,e.RigidbodyPhysics.PhysicsShapeCache[h]=c):e.RigidbodyPhysics.CachedPhysicsShapeCount++,c},i.GetCachedPhysicsSphereShape=function(t,i,n,r,o,a,s,l,u){var h="SHAPE_SPHERE_SF"+n+"_DF"+r+"_R"+o+"_T"+(1==i?"1":"0")+"_L"+l+"_X"+u,c=e.RigidbodyPhysics.PhysicsShapeCache[h];return null==c?((c=new BABYLON.PhysicsShapeSphere(new BABYLON.Vector3(0,0,0),1,t)).material={friction:r,staticFriction:n,restitution:o,frictionCombine:a,restitutionCombine:s},c.isTrigger=i,c.filterMembershipMask=l,e.RigidbodyPhysics.NewPhysicsShapeCount++,e.RigidbodyPhysics.PhysicsShapeCache[h]=c):e.RigidbodyPhysics.CachedPhysicsShapeCount++,c},i.GetCachedPhysicsCapsuleShape=function(t,i,n,r,o,a,s,l,u){var h="SHAPE_CAPSULE_SF"+n+"_DF"+r+"_R"+o+"_T"+(1==i?"1":"0")+"_L"+l+"_X"+u,c=e.RigidbodyPhysics.PhysicsShapeCache[h];return null==c?((c=new BABYLON.PhysicsShapeCapsule(new BABYLON.Vector3(0,-1,0),new BABYLON.Vector3(0,1,0),1,t)).material={friction:r,staticFriction:n,restitution:o,frictionCombine:a,restitutionCombine:s},c.isTrigger=i,c.filterMembershipMask=l,e.RigidbodyPhysics.NewPhysicsShapeCount++,e.RigidbodyPhysics.PhysicsShapeCache[h]=c):e.RigidbodyPhysics.CachedPhysicsShapeCount++,c},i.GetCachedPhysicsCylinderShape=function(t,i,n,r,o,a,s,l,u){var h="SHAPE_CYLINDER_SF"+n+"_DF"+r+"_R"+o+"_T"+(1==i?"1":"0")+"_L"+l+"_X"+u,c=e.RigidbodyPhysics.PhysicsShapeCache[h];return null==c?((c=new BABYLON.PhysicsShapeCylinder(new BABYLON.Vector3(0,-.5,0),new BABYLON.Vector3(0,.5,0),1,t)).material={friction:r,staticFriction:n,restitution:o,frictionCombine:a,restitutionCombine:s},c.isTrigger=i,c.filterMembershipMask=l,e.RigidbodyPhysics.NewPhysicsShapeCount++,e.RigidbodyPhysics.PhysicsShapeCache[h]=c):e.RigidbodyPhysics.CachedPhysicsShapeCount++,c},i.CreateStandardPhysicsShapeAndBody=function(t,i,n,r,o,a,s,l,u,h,c,d,m,p,f,g,y,v){var S=n.collision,_=null!=S.meshkey?S.meshkey:null,b=null!=S.center?S.center:{x:0,y:0,z:0};if(r==e.RigidbodyPhysics.HeightmapImpostor)if(null!=p){e.Utilities.ReparentColliders()||i.setParent(null,!0,!0);var B=i,C=p.index,A=p.segments,T=p.resolution,M=p.width,L=(p.height,p.length);if(1===(null!=p.collider?p.collider:0)){var P=1,w=1,x=0,O=0;if(1===A)x=.5*(M+(P=M/(T-1))),O=.5*(L-(w=L/(T-1)));else if(2===A){var R=M/A,I=L/A;P=M/(T-1),w=L/(T-1),0===C?(x=.5*(R+P)+0,O=.5*(I-w)+0):1===C?(x=.5*(1*R+P)+0,O=.5*(I-w)+I):2===C?(x=.5*(1*R+P)+R,O=.5*(I-w)+0):3===C&&(x=.5*(1*R+P)+R,O=.5*(I-w)+I)}var N=e.RigidbodyPhysics.CreateHeightFieldTerrainShapeFromMesh(B,P,w),k=new BABYLON.PhysicsShape({type:BABYLON.PhysicsShapeType.HEIGHTFIELD,pluginData:N},t);k.filterMembershipMask=y,k.material={friction:h,staticFriction:u,restitution:c,frictionCombine:d,restitutionCombine:m};var F="TERRAIN_MESH_ID"+B.uniqueId+"_SF"+u+"_DF"+h+"_R"+c+"_T0_L"+y+"_X"+v;e.RigidbodyPhysics.NewPhysicsShapeCount++,e.RigidbodyPhysics.PhysicsShapeCache[F]=k;var D=new BABYLON.Vector3(x,0,O),E=new BABYLON.Quaternion(0,0,0,1),V=new BABYLON.Vector3(1,1,1),Y=new BABYLON.PhysicsShapeContainer(t);Y.material=k.material,e.Utilities.FromEulerToRef(0,90,0,E),k.isTrigger=!1,Y.addChild(k,D,E,V);var U=new BABYLON.PhysicsBody(i,BABYLON.PhysicsMotionType.STATIC,!1,t);U.shape=Y,e.Utilities.ShowDebugColliders()&&console.log("Setup standard terrain heightmap physics collider for: "+i.name,i),e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,i,!1,o,n.physics,0,new BABYLON.Vector3(f.x,f.y,f.z)),e.Utilities.ShowDebugColliders()||null!=(Be=i).material&&"CenterBox-Material"===Be.material.name&&(Be.isVisible=!1),e.Utilities.ShowDebugColliders()&&(null==e.RigidbodyPhysics.DebugPhysicsViewer&&(e.RigidbodyPhysics.DebugPhysicsViewer=new BABYLON.Debug.PhysicsViewer),null!=e.RigidbodyPhysics.DebugPhysicsViewer&&e.RigidbodyPhysics.DebugPhysicsViewer.showBody(U))}else(H=new BABYLON.PhysicsShapeMesh(B,t)).filterMembershipMask=y,H.material={friction:h,staticFriction:u,restitution:c,frictionCombine:d,restitutionCombine:m},(G=new BABYLON.PhysicsBody(i,BABYLON.PhysicsMotionType.STATIC,!1,t)).shape=H,e.Utilities.ShowDebugColliders()&&console.log("Setup terrain mesh physics collider for: "+i.name,i),e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,i,!1,o,n.physics,0,new BABYLON.Vector3(f.x,f.y,f.z)),e.Utilities.ShowDebugColliders()||null!=(Be=i).material&&"CenterBox-Material"===Be.material.name&&(Be.isVisible=!1),e.Utilities.ShowDebugColliders()&&(null==e.RigidbodyPhysics.DebugPhysicsViewer&&(e.RigidbodyPhysics.DebugPhysicsViewer=new BABYLON.Debug.PhysicsViewer),null!=e.RigidbodyPhysics.DebugPhysicsViewer&&e.RigidbodyPhysics.DebugPhysicsViewer.showBody(G))}else BABYLON.Tools.Warn("No terrain collision data found for: "+i.name+". No terrain collision impostor will be created.");else if(r==e.RigidbodyPhysics.MeshImpostor){var W=e.SceneManager.FindChildTransformNode(i,i.name+".Collider",e.SearchType.ExactMatch,!0);if(null!=W){e.Utilities.ReparentColliders()||i.setParent(null,!0,!0);var G=new BABYLON.PhysicsBody(i,BABYLON.PhysicsMotionType.STATIC,!1,t),H=e.RigidbodyPhysics.GetCachedPhysicsMeshShape(t,W,_,u,h,c,d,m,y,v),z=new BABYLON.PhysicsShapeContainer(t);z.material=H.material,e.RigidbodyPhysics.AddChildShapeFromParent(z,i,H,W),G.shape=z,!1===g&&e.Utilities.AddLoaderItemMarkedForDisposal(W),e.Utilities.ShowDebugColliders()&&console.log("Setup standard mesh physics collider for: "+i.name,i),e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,i,!1,o,n.physics,0,new BABYLON.Vector3(f.x,f.y,f.z)),e.Utilities.ShowDebugColliders()||null!=(Be=i).material&&"CenterBox-Material"===Be.material.name&&(Be.isVisible=!1),e.Utilities.ShowDebugColliders()&&(null==e.RigidbodyPhysics.DebugPhysicsViewer&&(e.RigidbodyPhysics.DebugPhysicsViewer=new BABYLON.Debug.PhysicsViewer),null!=e.RigidbodyPhysics.DebugPhysicsViewer&&e.RigidbodyPhysics.DebugPhysicsViewer.showBody(G))}else BABYLON.Tools.Warn("No mesh collider found for: "+i.name+".")}else if(r==e.RigidbodyPhysics.ConvexHullImpostor){var K=e.SceneManager.FindChildTransformNode(i,i.name+".Collider",e.SearchType.ExactMatch,!0);if(null!=K){!1===g&&e.Utilities.AddLoaderItemMarkedForDisposal(K),e.Utilities.ReparentColliders()||i.setParent(null,!0,!0);var X=e.RigidbodyPhysics.GetCachedPhysicsConvexHullShape(t,K,_,u,h,c,d,m,y,v),Q=new BABYLON.PhysicsShapeContainer(t);Q.material=X.material,e.RigidbodyPhysics.AddChildShapeFromParent(Q,i,X,K);var j=new BABYLON.PhysicsBody(i,s,!1,t);j.shape=Q,e.Utilities.ShowDebugColliders()&&console.log("Setup standard convex hull physics collider for: "+i.name,i),e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,i,!0,!1,n.physics,l,new BABYLON.Vector3(f.x,f.y,f.z)),e.Utilities.ShowDebugColliders()||null!=(Be=i).material&&"CenterBox-Material"===Be.material.name&&(Be.isVisible=!1),e.Utilities.ShowDebugColliders()&&(null==e.RigidbodyPhysics.DebugPhysicsViewer&&(e.RigidbodyPhysics.DebugPhysicsViewer=new BABYLON.Debug.PhysicsViewer),null!=e.RigidbodyPhysics.DebugPhysicsViewer&&e.RigidbodyPhysics.DebugPhysicsViewer.showBody(j))}else BABYLON.Tools.Warn("No convex hull child mesh collider found for: "+i.name+".")}else if(r==e.RigidbodyPhysics.BoxImpostor){e.Utilities.ReparentColliders()||i.setParent(null,!0,!0);var Z=null!=S.boxsize?S.boxsize:{x:1,y:1,z:1},J=Z.x*parseFloat(i.scaling.x.toFixed(4)),q=Z.y*parseFloat(i.scaling.y.toFixed(4)),$=Z.z*parseFloat(i.scaling.z.toFixed(4)),ee=b.x*parseFloat(i.scaling.x.toFixed(4)),te=b.y*parseFloat(i.scaling.y.toFixed(4)),ie=b.z*parseFloat(i.scaling.z.toFixed(4)),ne=new BABYLON.Vector3(ee,te,ie),re=e.RigidbodyPhysics.GetCachedPhysicsBoxShape(t,o,u,h,c,d,m,y,v),oe=new BABYLON.PhysicsShapeContainer(t);oe.material=re.material,oe.addChild(re,ne,new BABYLON.Quaternion(0,0,0,1),new BABYLON.Vector3(J,q,$));var ae=new BABYLON.PhysicsBody(i,s,!1,t);ae.shape=oe,e.Utilities.ShowDebugColliders()&&console.log("Setup standard box physics collider for: "+i.name,i),e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,i,!1,!1,n.physics,l,ne.add(new BABYLON.Vector3(f.x,f.y,f.z))),e.Utilities.ShowDebugColliders()||null!=(Be=i).material&&"CenterBox-Material"===Be.material.name&&(Be.isVisible=!1),e.Utilities.ShowDebugColliders()&&(null==e.RigidbodyPhysics.DebugPhysicsViewer&&(e.RigidbodyPhysics.DebugPhysicsViewer=new BABYLON.Debug.PhysicsViewer),null!=e.RigidbodyPhysics.DebugPhysicsViewer&&e.RigidbodyPhysics.DebugPhysicsViewer.showBody(ae))}else if(r==e.RigidbodyPhysics.SphereImpostor){e.Utilities.ReparentColliders()||i.setParent(null,!0,!0);var se=null!=S.sphereradius?S.sphereradius:.5,le=parseFloat(i.scaling.x.toFixed(4)),ue=parseFloat(i.scaling.y.toFixed(4)),he=parseFloat(i.scaling.z.toFixed(4)),ce=Math.max(le,ue,he)*se,de=(ee=b.x*parseFloat(i.scaling.x.toFixed(4)),te=b.y*parseFloat(i.scaling.y.toFixed(4)),ie=b.z*parseFloat(i.scaling.z.toFixed(4)),ne=new BABYLON.Vector3(ee,te,ie),e.RigidbodyPhysics.GetCachedPhysicsSphereShape(t,o,u,h,c,d,m,y,v)),me=new BABYLON.PhysicsShapeContainer(t);me.material=de.material,me.addChild(de,ne,new BABYLON.Quaternion(0,0,0,1),new BABYLON.Vector3(ce,ce,ce));var pe=new BABYLON.PhysicsBody(i,s,!1,t);pe.shape=me,e.Utilities.ShowDebugColliders()&&console.log("Setup standard sphere physics collider for: "+i.name,i),e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,i,!1,!1,n.physics,l,ne.add(new BABYLON.Vector3(f.x,f.y,f.z))),e.Utilities.ShowDebugColliders()||null!=(Be=i).material&&"CenterBox-Material"===Be.material.name&&(Be.isVisible=!1),e.Utilities.ShowDebugColliders()&&(null==e.RigidbodyPhysics.DebugPhysicsViewer&&(e.RigidbodyPhysics.DebugPhysicsViewer=new BABYLON.Debug.PhysicsViewer),null!=e.RigidbodyPhysics.DebugPhysicsViewer&&e.RigidbodyPhysics.DebugPhysicsViewer.showBody(pe))}else if(r==e.RigidbodyPhysics.CapsuleImpostor){e.Utilities.ReparentColliders()||i.setParent(null,!0,!0);var fe=null!=S.cylinder&&S.cylinder,ge=null!=S.capsulesize?S.capsulesize:{x:.5,y:2,z:1},ye=ge.x*parseFloat(i.scaling.x.toFixed(4)),ve=ge.y*parseFloat(i.scaling.y.toFixed(4)),Se=parseFloat(i.scaling.z.toFixed(4));Se=!0===fe?e.RigidbodyPhysics.GetCachedPhysicsCylinderShape(t,o,u,h,c,d,m,y,v):e.RigidbodyPhysics.GetCachedPhysicsCapsuleShape(t,o,u,h,c,d,m,y,v);var _e=new BABYLON.Quaternion(0,0,0,1);0!==ge.z&&2!==ge.z||(0===ge.z?e.Utilities.FromEulerToRef(0,0,90,_e):2===ge.z&&e.Utilities.FromEulerToRef(90,0,0,_e)),ee=b.x*parseFloat(i.scaling.x.toFixed(4)),te=b.y*parseFloat(i.scaling.y.toFixed(4)),ie=b.z*parseFloat(i.scaling.z.toFixed(4)),ne=new BABYLON.Vector3(ee,te,ie);var be=new BABYLON.PhysicsShapeContainer(t);be.material=Se.material,be.addChild(Se,ne,_e,new BABYLON.Vector3(ye,ve,ye));var Be,Ce=new BABYLON.PhysicsBody(i,s,!1,t);Ce.shape=be,e.Utilities.ShowDebugColliders()&&console.log("Setup standard "+(!0===fe?"cylinder":"capsule")+" physics collider for: "+i.name,i),e.RigidbodyPhysics.ConfigRigidbodyPhysics(t,i,!1,!1,n.physics,l,ne.add(new BABYLON.Vector3(f.x,f.y,f.z))),e.Utilities.ShowDebugColliders()||null!=(Be=i).material&&"CenterBox-Material"===Be.material.name&&(Be.isVisible=!1),e.Utilities.ShowDebugColliders()&&(null==e.RigidbodyPhysics.DebugPhysicsViewer&&(e.RigidbodyPhysics.DebugPhysicsViewer=new BABYLON.Debug.PhysicsViewer),null!=e.RigidbodyPhysics.DebugPhysicsViewer&&e.RigidbodyPhysics.DebugPhysicsViewer.showBody(Ce))}},i.CreateCompoundPhysicsShapeAndBody=function(t,i,n,r,o,a,s,l,u,h,c,d,m,p,f,g,y,v){var S=0,_=0,b=0,B=new BABYLON.Vector3(0,0,0),C=new BABYLON.Quaternion(0,0,0,1),A=new BABYLON.Vector3(1,1,1);if(!1===g&&!0===p&&e.Utilities.AddLoaderItemMarkedForDisposal(n),o==e.RigidbodyPhysics.ConvexHullImpostor){var T=e.SceneManager.FindChildTransformNode(n,n.name+".Collider",e.SearchType.ExactMatch,!0);if(null!=T){var M=1,L=1,P=1;if(T instanceof BABYLON.InstancedMesh){!0===p&&(M*=parseFloat(i.scaling.x.toFixed(4)),L*=parseFloat(i.scaling.y.toFixed(4)),P*=parseFloat(i.scaling.z.toFixed(4))),A.set(M,L,P);var w=T.sourceMesh;if(null!=w){var x=null!=T.metadata&&null!=T.metadata.toolkit&&null!=T.metadata.toolkit.collision&&null!=T.metadata.toolkit.collision.sourcescale?T.metadata.toolkit.collision.sourcescale:null,O=null!=w.metadata&&null!=w.metadata.toolkit&&null!=w.metadata.toolkit.collision&&null!=w.metadata.toolkit.collision.sourcescale?w.metadata.toolkit.collision.sourcescale:null;if(null!=O&&null!=x){var R=new BABYLON.Vector3(1,1,1),I=new BABYLON.Vector3(x.x,x.y,x.z),N=new BABYLON.Vector3(O.x,O.y,O.z);I.divideToRef(N,R),A.multiplyInPlace(R)}}}else A.set(M,L,P);var k=null!=r.meshkey?r.meshkey:null,F=e.RigidbodyPhysics.GetCachedPhysicsConvexHullShape(t,T,k,a,s,l,u,h,y,v);if(!0===p){var D=n.position.x*parseFloat(i.scaling.x.toFixed(4)),E=n.position.y*parseFloat(i.scaling.y.toFixed(4)),V=n.position.z*parseFloat(i.scaling.z.toFixed(4));B.set(D,E,V),C.multiplyInPlace(n.rotationQuaternion)}else S=m.x*parseFloat(n.scaling.x.toFixed(4)),_=m.y*parseFloat(n.scaling.y.toFixed(4)),b=m.z*parseFloat(n.scaling.z.toFixed(4)),B.set(S,_,b);d.shape=F,d.translation=B,d.rotation=C,d.scale=A,c.push(d)}}else if(o==e.RigidbodyPhysics.CapsuleImpostor){var Y=null!=r.cylinder&&r.cylinder,U=null!=r.capsulesize?r.capsulesize:{x:.5,y:2,z:1},W=U.x*parseFloat(n.scaling.x.toFixed(4)),G=U.y*parseFloat(n.scaling.y.toFixed(4));parseFloat(n.scaling.z.toFixed(4)),!0===p&&(W*=parseFloat(i.scaling.x.toFixed(4)),G*=parseFloat(i.scaling.y.toFixed(4)),parseFloat(i.scaling.z.toFixed(4))),A.set(W,G,W);var H;H=!0===Y?e.RigidbodyPhysics.GetCachedPhysicsCylinderShape(t,f,a,s,l,u,h,y,v):e.RigidbodyPhysics.GetCachedPhysicsCapsuleShape(t,f,a,s,l,u,h,y,v),0!==U.z&&2!==U.z||(0===U.z?e.Utilities.FromEulerToRef(0,0,90,C):2===U.z&&e.Utilities.FromEulerToRef(90,0,0,C)),!0===p?(0===m.x&&0===m.y&&0===m.z||console.warn("WARNING: Center offset not supported for complex compound item: "+n.name),D=n.position.x*parseFloat(i.scaling.x.toFixed(4)),E=n.position.y*parseFloat(i.scaling.y.toFixed(4)),V=n.position.z*parseFloat(i.scaling.z.toFixed(4)),B.set(D,E,V),C.multiplyInPlace(n.rotationQuaternion)):(S=m.x*parseFloat(n.scaling.x.toFixed(4)),_=m.y*parseFloat(n.scaling.y.toFixed(4)),b=m.z*parseFloat(n.scaling.z.toFixed(4)),B.set(S,_,b)),d.shape=H,d.translation=B,d.rotation=C,d.scale=A,c.push(d)}else if(o==e.RigidbodyPhysics.SphereImpostor){var z=null!=r.sphereradius?r.sphereradius:.5,K=parseFloat(n.scaling.x.toFixed(4)),X=parseFloat(n.scaling.y.toFixed(4)),Q=parseFloat(n.scaling.z.toFixed(4)),j=Math.max(K,X,Q)*z;if(!0===p){var Z=parseFloat(i.scaling.x.toFixed(4)),J=parseFloat(i.scaling.y.toFixed(4)),q=parseFloat(i.scaling.z.toFixed(4));j*=Math.max(Z,J,q)}A.set(j,j,j);var $=e.RigidbodyPhysics.GetCachedPhysicsSphereShape(t,f,a,s,l,u,h,y,v);!0===p?(0===m.x&&0===m.y&&0===m.z||console.warn("WARNING: Center offset not supported for complex compound item: "+n.name),D=n.position.x*parseFloat(i.scaling.x.toFixed(4)),E=n.position.y*parseFloat(i.scaling.y.toFixed(4)),V=n.position.z*parseFloat(i.scaling.z.toFixed(4)),B.set(D,E,V),C.multiplyInPlace(n.rotationQuaternion)):(S=m.x*parseFloat(n.scaling.x.toFixed(4)),_=m.y*parseFloat(n.scaling.y.toFixed(4)),b=m.z*parseFloat(n.scaling.z.toFixed(4)),B.set(S,_,b)),d.shape=$,d.translation=B,d.rotation=C,d.scale=A,c.push(d)}else if(o==e.RigidbodyPhysics.BoxImpostor){var ee=null!=r.boxsize?r.boxsize:{x:1,y:1,z:1},te=ee.x*parseFloat(n.scaling.x.toFixed(4)),ie=ee.y*parseFloat(n.scaling.y.toFixed(4)),ne=ee.z*parseFloat(n.scaling.z.toFixed(4));!0===p&&(te*=parseFloat(i.scaling.x.toFixed(4)),ie*=parseFloat(i.scaling.y.toFixed(4)),ne*=parseFloat(i.scaling.z.toFixed(4))),A.set(te,ie,ne);var re=e.RigidbodyPhysics.GetCachedPhysicsBoxShape(t,f,a,s,l,u,h,y,v);!0===p?(0===m.x&&0===m.y&&0===m.z||console.warn("WARNING: Center offset not supported for complex compound item: "+n.name),D=n.position.x*parseFloat(i.scaling.x.toFixed(4)),E=n.position.y*parseFloat(i.scaling.y.toFixed(4)),V=n.position.z*parseFloat(i.scaling.z.toFixed(4)),B.set(D,E,V),C.multiplyInPlace(n.rotationQuaternion)):(S=m.x*parseFloat(n.scaling.x.toFixed(4)),_=m.y*parseFloat(n.scaling.y.toFixed(4)),b=m.z*parseFloat(n.scaling.z.toFixed(4)),B.set(S,_,b)),d.shape=re,d.translation=B,d.rotation=C,d.scale=A,c.push(d)}},i.CreateHeightFieldTerrainShapeFromMesh=function(t,i,n){var r=e.RigidbodyPhysics.GetHavokInstance();if(!r)return BABYLON.Tools.Warn("Havok.js physics library not loaded"),null;var o=t.getVerticesData(BABYLON.VertexBuffer.PositionKind),a=o.length/3,s=r._malloc(4*a),l=Math.sqrt(a),u=l;if(l%1!=0)return console.error("Terrain mesh does not seem to be a regular square grid: "+t.name),null;for(var h=0,c=u-1;c>=0;c--)for(var d=0;d<l;d++){var m=c*l+d;r.HEAPF32[s+h>>2]=o[3*m+1],h+=4}var p=r.HP_Shape_CreateHeightField(l,u,[i,1,n],s)[1];return r._free(s),p},i.GetPhysicsHeapSize=function(){var t=e.RigidbodyPhysics.GetHavokInstance();if(!t)return BABYLON.Tools.Warn("Havok.js physics library not loaded"),0;var i=0;return t.HEAP8&&t.HEAP8.length&&(i=t.HEAP8.length/1048576),i},i.ConfigRigidbodyPhysics=function(e,t,i,n,r,o,a){if(null!=t&&null!=t.physicsBody){!1===(null==r||null==r.gravity||r.gravity)&&t.physicsBody.setGravityFactor(0);var s=null!=r&&null!=r.ldrag?r.ldrag:0,l=null!=r&&null!=r.adrag?r.adrag:.05;t.physicsBody.setLinearDamping(s),t.physicsBody.setAngularDamping(l);var u=null!=r&&null!=r.freeze?r.freeze:null,h=1,c=1,d=1;null!=u&&(null!=u.positionx&&u.positionx,null!=u.positiony&&u.positiony,null!=u.positionz&&u.positionz,h=null!=u.rotationx&&!0===u.rotationx?0:1,c=null!=u.rotationy&&!0===u.rotationy?0:1,d=null!=u.rotationz&&!0===u.rotationz?0:1),t.physicsBody.setMassProperties({mass:o,centerOfMass:a,inertia:new BABYLON.Vector3(h,c,d)})}},i.CreatePhysicsMetadata=function(e,t,i,n){void 0===t&&(t=0),void 0===i&&(i=.05),void 0===n&&(n=null);var r=null!=n?n:new BABYLON.Vector3(0,0,0);return{type:"rigidbody",mass:e,ldrag:t,adrag:i,center:{x:r.x,y:r.y,z:r.z}}},i.CreateCollisionMetadata=function(e,t,i,n,r,o){return void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===n&&(n=0),void 0===r&&(r=.6),void 0===o&&(o=.6),{type:e,trigger:t,convexmesh:i,restitution:n,dynamicfriction:r,staticfriction:o,wheelinformation:null}},i.CreatePhysicsProperties=function(e,t,i,n,r){return void 0===t&&(t=0),void 0===i&&(i=.05),void 0===n&&(n=!0),void 0===r&&(r=!1),{mass:e,drag:t,angularDrag:i,useGravity:n,isKinematic:r}},i.AddChildShapeFromParent=function(t,i,n,r){var o,a=r.computeWorldMatrix(!0),s=i.computeWorldMatrix(!0),l=BABYLON.TmpVectors.Matrix[0];a.multiplyToRef(BABYLON.Matrix.Invert(s),l);var u=BABYLON.TmpVectors.Vector3[0],h=BABYLON.TmpVectors.Quaternion[0],c=BABYLON.TmpVectors.Vector3[1];l.decompose(c,h,u);var d=new BABYLON.Vector3(c.x,c.y,c.z);if(r instanceof BABYLON.InstancedMesh){var m=r.sourceMesh;if(null!=m){var p=null!=r.metadata&&null!=r.metadata.toolkit&&null!=r.metadata.toolkit.collision&&null!=r.metadata.toolkit.collision.sourcescale?r.metadata.toolkit.collision.sourcescale:null,f=null!=m.metadata&&null!=m.metadata.toolkit&&null!=m.metadata.toolkit.collision&&null!=m.metadata.toolkit.collision.sourcescale?m.metadata.toolkit.collision.sourcescale:null;if(null!=f&&null!=p){var g=new BABYLON.Vector3(1,1,1),y=new BABYLON.Vector3(p.x,p.y,p.z),v=new BABYLON.Vector3(f.x,f.y,f.z);y.divideToRef(v,g),d.multiplyInPlace(g)}}}null===(o=e.Utilities.GetHavokPlugin())||void 0===o||o.addChild(t,n,u,h,d)},i.PHYSICS_STEP_TIME=.016,i.RaycastResult=null,i.LocalShapeResult=null,i.WorldShapeResult=null,i.RaycastDestination=null,i.PhysicsShapeCache={},i.NewPhysicsShapeCount=0,i.CachedPhysicsShapeCount=0,i.DebugPhysicsViewer=null,i.OnSetupPhysicsPlugin=null,i.NoImpostor=0,i.SphereImpostor=1,i.BoxImpostor=2,i.PlaneImpostor=3,i.MeshImpostor=4,i.CapsuleImpostor=6,i.CylinderImpostor=7,i.ParticleImpostor=8,i.HeightmapImpostor=9,i.ConvexHullImpostor=10,i.CustomImpostor=100,i.RopeImpostor=101,i.ClothImpostor=102,i.SoftbodyImpostor=103,i._factorAngVel=new BABYLON.Vector3,i._factorLinVel=new BABYLON.Vector3,i._factorLocalVel=new BABYLON.Vector3,i._dampingAngVel=new BABYLON.Vector3,i._dampingLinVel=new BABYLON.Vector3,i._dampingLocalVel=new BABYLON.Vector3,i._tempMatrix=new BABYLON.Matrix,i.SetDamping=function(e,t,i){e.setLinearDamping(Math.max(0,Math.min(1,t))),e.setAngularDamping(Math.max(0,Math.min(1,i)))},i.GetDamping=function(e){return{linearDamping:e.getLinearDamping(),angularDamping:e.getAngularDamping()}},i.ApplyDamping=function(t,i,n,r){var o=Math.pow(1-Math.max(0,Math.min(1,i)),r),a=Math.pow(1-Math.max(0,Math.min(1,n)),r);t.getLinearVelocityToRef(e.RigidbodyPhysics._dampingLinVel),e.RigidbodyPhysics._dampingLinVel.scaleInPlace(o),t.setLinearVelocity(e.RigidbodyPhysics._dampingLinVel),t.getAngularVelocityToRef(e.RigidbodyPhysics._dampingAngVel),e.RigidbodyPhysics._dampingAngVel.scaleInPlace(a),t.setAngularVelocity(e.RigidbodyPhysics._dampingAngVel)},i.ApplyPerAxisAngularDamping=function(t,i,n,r,o){t.getAngularVelocityToRef(e.RigidbodyPhysics._dampingAngVel);var a=t.transformNode.getWorldMatrix();a.invertToRef(e.RigidbodyPhysics._tempMatrix),BABYLON.Vector3.TransformNormalToRef(e.RigidbodyPhysics._dampingAngVel,e.RigidbodyPhysics._tempMatrix,e.RigidbodyPhysics._dampingLocalVel),e.RigidbodyPhysics._dampingLocalVel.x*=Math.pow(1-Math.max(0,Math.min(1,i)),o),e.RigidbodyPhysics._dampingLocalVel.y*=Math.pow(1-Math.max(0,Math.min(1,n)),o),e.RigidbodyPhysics._dampingLocalVel.z*=Math.pow(1-Math.max(0,Math.min(1,r)),o),BABYLON.Vector3.TransformNormalToRef(e.RigidbodyPhysics._dampingLocalVel,a,e.RigidbodyPhysics._dampingAngVel),t.setAngularVelocity(e.RigidbodyPhysics._dampingAngVel)},i.SetAngularFactor=function(t,i,n,r){var o=Math.max(0,Math.min(1,i)),a=Math.max(0,Math.min(1,n)),s=Math.max(0,Math.min(1,r));t.getAngularVelocityToRef(e.RigidbodyPhysics._factorAngVel);var l=t.transformNode.getWorldMatrix();l.invertToRef(e.RigidbodyPhysics._tempMatrix),BABYLON.Vector3.TransformNormalToRef(e.RigidbodyPhysics._factorAngVel,e.RigidbodyPhysics._tempMatrix,e.RigidbodyPhysics._factorLocalVel),e.RigidbodyPhysics._factorLocalVel.x*=o,e.RigidbodyPhysics._factorLocalVel.y*=a,e.RigidbodyPhysics._factorLocalVel.z*=s,BABYLON.Vector3.TransformNormalToRef(e.RigidbodyPhysics._factorLocalVel,l,e.RigidbodyPhysics._factorAngVel),t.setAngularVelocity(e.RigidbodyPhysics._factorAngVel)},i.SetLinearFactor=function(t,i,n,r){var o=Math.max(0,Math.min(1,i)),a=Math.max(0,Math.min(1,n)),s=Math.max(0,Math.min(1,r));t.getLinearVelocityToRef(e.RigidbodyPhysics._factorLinVel),e.RigidbodyPhysics._factorLinVel.x*=o,e.RigidbodyPhysics._factorLinVel.y*=a,e.RigidbodyPhysics._factorLinVel.z*=s,t.setLinearVelocity(e.RigidbodyPhysics._factorLinVel)},i.SetFactors=function(t,i,n){e.RigidbodyPhysics.SetLinearFactor(t,i.x,i.y,i.z),e.RigidbodyPhysics.SetAngularFactor(t,n.x,n.y,n.z)},i}(e.ScriptComponent);e.RigidbodyPhysics=t;e.PhyscisContainerData=function(){},e.SceneManager.RegisterClass("TOOLKIT.RigidbodyPhysics",t)}(n||(n={})),function(e){var t=function(){function e(){}return e.CreatePostProcess=function(e,t,i){var n=i||{},r=Array.isArray(n.color)?n.color:n.color?[n.color.r||0,n.color.g||0,n.color.b||0,n.color.a||1]:[0,0,0,1],o=n.center&&Array.isArray(n.center)?n.center:[.5,.5],a=null!=n.intensity?n.intensity:1,s=null!=n.smoothness?n.smoothness:.5,l=!!n.rounded,u=new BABYLON.PostProcess("roundedVignette","\n precision highp float;\n varying vec2 vUV;\n uniform sampler2D textureSampler;\n uniform vec4 vignetteColor;\n uniform vec2 center;\n uniform float intensity;\n uniform float smoothness;\n uniform float rounded; // 0 or 1\n uniform int blendMode; // 0 = multiply, 1 = overlay\n\n vec3 overlayBlend(vec3 base, vec3 blend) {\n vec3 res;\n for (int i = 0; i < 3; i++) {\n float b = base[i];\n float f = blend[i];\n float outv = (b < 0.5) ? (2.0 * b * f) : (1.0 - 2.0 * (1.0 - b) * (1.0 - f));\n res[i] = outv;\n }\n return res;\n }\n\n void main(void) {\n vec4 scene = texture2D(textureSampler, vUV);\n vec2 p = vUV - center;\n float d;\n if (rounded > 0.5) {\n d = length(p);\n } else {\n // ellipse based on aspect ratio (approx using normalized coords)\n d = sqrt((p.x*p.x) + (p.y*p.y));\n }\n float vig = 1.0 - smoothstep(0.0, 1.0, (d - (1.0 - intensity)) / smoothness);\n float weight = (1.0 - vig);\n vec3 vcol = vignetteColor.rgb;\n vec3 outc;\n if (blendMode == 1) {\n outc = mix(scene.rgb, overlayBlend(scene.rgb, vcol), weight);\n } else {\n // multiply\n outc = mix(scene.rgb, scene.rgb * vcol, weight);\n }\n gl_FragColor = vec4(outc, scene.a);\n }\n ",["vignetteColor","center","intensity","smoothness","rounded","blendMode"],[],1,t,BABYLON.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1);return u.onApply=function(e){e.setFloat4("vignetteColor",r[0]||0,r[1]||0,r[2]||0,null!=r[3]?r[3]:1),e.setVector2("center",new BABYLON.Vector2(o[0]||.5,o[1]||.5)),e.setFloat("intensity",a),e.setFloat("smoothness",s),e.setFloat("rounded",l?1:0),e.setInt("blendMode","overlay"===n.blendMode||1===n.blendMode?1:0)},u._blendMode="overlay"===n.blendMode||1===n.blendMode?"overlay":"multiply",u},e}();e.RoundedVignettePlugin=t}(n||(n={})),function(e){var t=function(t){function i(e,i,n,r){void 0===n&&(n={}),void 0===r&&(r="TOOLKIT.ShurikenParticles");var o=t.call(this,e,i,n,r)||this;return o.m_particleSystem=null,o.m_emitterMesh=null,o.m_systemProperties=null,o.m_isInitialized=!1,o.m_playOnAwake=!0,o.m_autoStart=!0,o.m_systemTime=0,o.m_isLooping=!0,o.m_duration=5,o.m_emissionTimer=0,o.m_burstTimers=[],o.m_prewarm=!1,o.m_startDelay=null,o.m_simulationSpeed=1,o.m_scalingMode=0,o.m_emitterVelocityMode=0,o.m_customSimulationSpace=0,o.m_emitterVelocity=new BABYLON.Vector3(0,0,0),o.m_gravitySource=0,o.m_useUnscaledTime=!1,o.m_reportedDeltaTime=0,o.m_isSystemRunning=!1,o.m_cullingMode=0,o.m_isVisible=!0,o.m_pausedTime=0,o.m_lastVisibilityCheck=0,o.m_animationCurves=new Map,o.m_gradients=new Map,o}return o(i,t),i.prototype.getParticleSystem=function(){return this.m_particleSystem},i.prototype.getEmitterMesh=function(){return this.m_emitterMesh},i.prototype.internalPlay=function(){var e=this;if(this.m_particleSystem){if(this.m_prewarm&&this.m_isLooping&&this.m_duration>0)if(this.m_systemTime=this.m_duration,this.m_emissionTimer=this.m_duration,this.m_particleSystem instanceof BABYLON.ParticleSystem){var t=this.m_particleSystem.emitRate,i=Math.min(Math.ceil(t*this.m_duration),this.m_particleSystem.getCapacity());this.m_particleSystem.emitRate=60*i,this.m_particleSystem.start(),setTimeout(function(){e.m_particleSystem instanceof BABYLON.ParticleSystem&&(e.m_particleSystem.emitRate=t)},16)}else this.m_particleSystem.start();else this.m_systemTime=0,this.m_emissionTimer=0,this.m_particleSystem.start();this.m_isSystemRunning=!0,this.resetBurstTimers()}},i.prototype.play=function(){var t=this,i=this.calculateStartDelay();i>0?(this.m_systemTime=0,this.m_emissionTimer=0,this.m_isSystemRunning=!1,e.WindowManager.SetTimeout(1e3*i,function(){t.internalPlay()})):(this.m_systemTime=0,this.m_emissionTimer=0,this.internalPlay())},i.prototype.stop=function(){this.m_particleSystem&&(this.m_particleSystem.stop(),this.m_isSystemRunning=!1)},i.prototype.pause=function(){var e,t;this.m_particleSystem&&(this.m_particleSystem instanceof BABYLON.ParticleSystem?this.m_particleSystem.stop():null===(t=(e=this.m_particleSystem).pause)||void 0===t||t.call(e),this.m_isSystemRunning=!1)},i.prototype.reset=function(){this.m_particleSystem&&(this.m_particleSystem.reset(),this.m_systemTime=0,this.m_emissionTimer=0,this.resetBurstTimers(),this.m_isSystemRunning=!1)},i.prototype.isPlaying=function(){return this.m_isSystemRunning&&this.m_isInitialized},i.prototype.getParticleCount=function(){return this.m_particleSystem?this.m_particleSystem.getActiveCount():0},i.prototype.getCustomSimulationSpace=function(){return this.m_customSimulationSpace},i.prototype.getEmitterVelocity=function(){return this.m_emitterVelocity.clone()},i.prototype.getGravitySource=function(){return this.m_gravitySource},i.prototype.getUseUnscaledTime=function(){return this.m_useUnscaledTime},i.prototype.getCustomDeltaTime=function(){return this.m_reportedDeltaTime},i.prototype.getReportedDeltaTime=function(){return this.m_reportedDeltaTime},i.prototype.getEffectiveDeltaTime=function(){return(this.m_useUnscaledTime?this.scene.getEngine().getDeltaTime()/1e3:this.getDeltaTime())*this.m_simulationSpeed},i.prototype.calculateStartDelay=function(){var e,t,i=0;if(null!=this.m_startDelay){var n=this.convertMinMaxCurve(this.m_startDelay);switch(null!==(e=this.m_startDelay.mode)&&void 0!==e?e:0){case 0:case 1:default:i=n.value;break;case 2:case 3:i=Math.random()*(n.max-n.min)+n.min}void 0!==(null===(t=this.m_systemProperties.main)||void 0===t?void 0:t.startDelayMultiplier)&&(i*=this.m_systemProperties.main.startDelayMultiplier)}return parseFloat(Math.max(0,i).toFixed(2))},i.prototype.awake=function(){this.initializeParticleSystem()},i.prototype.start=function(){this.m_isInitialized&&this.m_autoStart&&this.m_playOnAwake&&this.play()},i.prototype.ready=function(){},i.prototype.update=function(){if(this.m_particleSystem&&this.m_systemProperties&&this.m_isSystemRunning){if(!this.shouldSimulateThisFrame()){if(1===this.m_cullingMode){var e=this.m_useUnscaledTime?this.scene.getEngine().getDeltaTime()/1e3:this.getDeltaTime();this.m_pausedTime+=e}return}var t=(this.m_useUnscaledTime?this.scene.getEngine().getDeltaTime()/1e3:this.getDeltaTime())*this.m_simulationSpeed;this.updateSystem(t),this.updateEmission(t),this.updateAnimationProperties(),this.updateBursts(t),this.updateEmitterVelocityInheritance(t),this.updateCustomSimulationSpace(t),this.updateRingBufferMode(t),!this.m_isLooping&&this.m_duration>0&&this.m_systemTime>=this.m_duration&&this.handleStopAction()}},i.prototype.shouldSimulateThisFrame=function(){switch(this.m_cullingMode){case 0:case 1:case 2:default:return this.m_isVisible;case 3:return!0}},i.prototype.late=function(){},i.prototype.step=function(){},i.prototype.fixed=function(){},i.prototype.after=function(){},i.prototype.destroy=function(){this.disposeParticleSystem()},i.mergeWithDefaults=function(e){return e?i.deepMerge(JSON.parse(JSON.stringify(i.DEFAULT_PARTICLE_PROPERTIES)),e):JSON.parse(JSON.stringify(i.DEFAULT_PARTICLE_PROPERTIES))},i.deepMerge=function(e,t){if(!t||"object"!=typeof t)return e;if(!e||"object"!=typeof e)return t;for(var n in t)t.hasOwnProperty(n)&&(t[n]&&"object"==typeof t[n]&&!Array.isArray(t[n])?e[n]=i.deepMerge(e[n]||{},t[n]):e[n]=t[n]);return e},i.getPropertyWithDefault=function(e,t){for(var n=e.split("."),r=t,o=i.DEFAULT_PARTICLE_PROPERTIES,a=0,s=n;a<s.length;a++){var l=s[a];r=null==r?void 0:r[l],o=null==o?void 0:o[l]}return void 0!==r?r:o},i.getMinimalSerializationData=function(e){if(!e)return{};var t=i.DEFAULT_PARTICLE_PROPERTIES;return i.extractDifferences(e,t)},i.extractDifferences=function(e,t){if(!e||"object"!=typeof e)return e;if(!t||"object"!=typeof t)return e;var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=e[r],a=t[r];if(void 0!==o)if(Array.isArray(o))Array.isArray(a)&&o.length===a.length&&i.arraysEqual(o,a)||(n[r]=o);else if(o&&"object"==typeof o){var s=i.extractDifferences(o,a);Object.keys(s).length>0&&(n[r]=s)}else o!==a&&(n[r]=o)}return n},i.arraysEqual=function(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++){var r=e[n],o=t[n];if(Array.isArray(r)&&Array.isArray(o)){if(!i.arraysEqual(r,o))return!1}else if(r&&"object"==typeof r&&o&&"object"==typeof o){var a=i.extractDifferences(r,o);if(Object.keys(a).length>0)return!1}else if(r!==o)return!1}return!0},i.getDefaultProperties=function(){return JSON.parse(JSON.stringify(i.DEFAULT_PARTICLE_PROPERTIES))},i.prototype.initializeParticleSystem=function(){try{var e=this._properties;if(this.m_systemProperties=i.mergeWithDefaults(e),!this.m_systemProperties)return void BABYLON.Tools.Warn("ShurikenParticles: Failed to create merged particle system properties");if(!this.m_systemProperties.main)return void BABYLON.Tools.Warn("### ShurikenParticles: No main module found in merged properties");this.createEmitterMesh(),this.shouldUseGPUParticles()?this.createGPUParticleSystem():this.createCPUParticleSystem(),this.configureMainModule(),this.configureEmissionModule(),this.configureShapeModule(),this.configureRendererModule(),this.configureVelocityOverLifetimeModule(),this.configureLimitVelocityOverLifetimeModule(),this.configureColorOverLifetimeModule(),this.configureSizeOverLifetimeModule(),this.configureRotationOverLifetimeModule(),this.configureTextureSheetAnimationModule(),this.configureNoiseModule(),this.configureCollisionModule(),this.configureTrailsModule(),this.configureSubEmittersModule(),this.ensureBasicConfiguration(),this.m_isInitialized=!0}catch(e){BABYLON.Tools.Error("ShurikenParticles: Failed to initialize particle system: "+e)}},i.prototype.shouldUseGPUParticles=function(){var e,t,i,n,r,o,a=null!==(t=null===(e=this.m_systemProperties.main)||void 0===e?void 0:e.maxParticles)&&void 0!==t?t:1e3,s=(null===(i=this.m_systemProperties.noise)||void 0===i?void 0:i.enabled)||(null===(n=this.m_systemProperties.collision)||void 0===n?void 0:n.enabled)||(null===(r=this.m_systemProperties.trails)||void 0===r?void 0:r.enabled)||(null===(o=this.m_systemProperties.subEmitters)||void 0===o?void 0:o.enabled);return a>5e3&&!s},i.prototype.createEmitterMesh=function(){this.m_emitterMesh=BABYLON.MeshBuilder.CreateBox(this.transform.name+"_ParticleProxy",{size:.1},this.scene);var e=null!=i.EMITTER_POSITION_OFFSET?i.EMITTER_POSITION_OFFSET:new BABYLON.Vector3(0,0,0),t=null!=i.EMITTER_ROTATION_OFFSET?i.EMITTER_ROTATION_OFFSET:new BABYLON.Vector3(0,0,0);this.m_emitterMesh.parent=this.transform,this.m_emitterMesh.position.copyFrom(e),this.m_systemProperties.shape,t.set(90,0,0),this.m_emitterMesh.rotationQuaternion=BABYLON.Quaternion.FromEulerAngles(BABYLON.Tools.ToRadians(t.x),BABYLON.Tools.ToRadians(t.y),BABYLON.Tools.ToRadians(t.z)),this.m_emitterMesh.isVisible=!1,this.m_emitterMesh.isPickable=!1},i.prototype.createDefaultParticleTexture=function(){if(null!=e.ShurikenParticles.DefaultParticleTexture)return e.ShurikenParticles.DefaultParticleTexture;var t=64,i=document.createElement("canvas");i.width=t,i.height=t;var n=i.getContext("2d");n.clearRect(0,0,t,t);var r=n.createRadialGradient(32,32,0,32,32,32);r.addColorStop(0,"rgba(255, 255, 255, 1.0)"),r.addColorStop(.15,"rgba(255, 255, 255, 0.95)"),r.addColorStop(.3,"rgba(255, 255, 255, 0.7)"),r.addColorStop(.6,"rgba(255, 255, 255, 0.2)"),r.addColorStop(.85,"rgba(255, 255, 255, 0.05)"),r.addColorStop(1,"rgba(255, 255, 255, 0.0)"),n.fillStyle=r,n.fillRect(0,0,t,t);var o=i.toDataURL("image/png"),a=new BABYLON.Texture(o,this.scene);return a.name=this.transform.name+"_DefaultParticleTexture",a.hasAlpha=!0,a.wrapU=BABYLON.Texture.CLAMP_ADDRESSMODE,a.wrapV=BABYLON.Texture.CLAMP_ADDRESSMODE,e.ShurikenParticles.DefaultParticleTexture=a,e.ShurikenParticles.DefaultParticleTexture},i.prototype.createCPUParticleSystem=function(){var e,t,i=null!==(t=null===(e=this.m_systemProperties.main)||void 0===e?void 0:e.maxParticles)&&void 0!==t?t:1e3;this.m_particleSystem=new BABYLON.ParticleSystem(this.transform.name+"_ParticleSystem",i,this.scene),this.m_particleSystem.emitter=this.m_emitterMesh,this.m_particleSystem.particleTexture||(this.m_particleSystem.particleTexture=this.createDefaultParticleTexture()),this.m_particleSystem.blendMode=BABYLON.ParticleSystem.BLENDMODE_STANDARD,this.m_particleSystem.particleTexture&&(this.m_particleSystem.particleTexture.wrapU=BABYLON.Texture.CLAMP_ADDRESSMODE,this.m_particleSystem.particleTexture.wrapV=BABYLON.Texture.CLAMP_ADDRESSMODE),this.m_particleSystem.color1=new BABYLON.Color4(1,1,1,1),this.m_particleSystem.color2=new BABYLON.Color4(1,1,1,1),this.m_particleSystem.colorDead=new BABYLON.Color4(1,1,1,0),this.m_particleSystem.minSize=1,this.m_particleSystem.maxSize=1,this.m_particleSystem.minInitialRotation=0,this.m_particleSystem.maxInitialRotation=0,this.m_particleSystem.minAngularSpeed=0,this.m_particleSystem.maxAngularSpeed=0},i.prototype.createGPUParticleSystem=function(){var e,t,i=null!==(t=null===(e=this.m_systemProperties.main)||void 0===e?void 0:e.maxParticles)&&void 0!==t?t:1e3;this.m_particleSystem=new BABYLON.GPUParticleSystem(this.transform.name+"_GPUParticleSystem",{capacity:i},this.scene),this.m_particleSystem.emitter=this.m_emitterMesh,this.m_particleSystem.particleTexture||(this.m_particleSystem.particleTexture=this.createDefaultParticleTexture()),this.m_particleSystem.blendMode=BABYLON.GPUParticleSystem.BLENDMODE_STANDARD,this.m_particleSystem.particleTexture&&(this.m_particleSystem.particleTexture.wrapU=BABYLON.Texture.CLAMP_ADDRESSMODE,this.m_particleSystem.particleTexture.wrapV=BABYLON.Texture.CLAMP_ADDRESSMODE),this.m_particleSystem.color1=new BABYLON.Color4(1,1,1,1),this.m_particleSystem.color2=new BABYLON.Color4(1,1,1,1),this.m_particleSystem.colorDead=new BABYLON.Color4(1,1,1,0),this.m_particleSystem.minSize=.25,this.m_particleSystem.maxSize=.25,this.m_particleSystem.minInitialRotation=0,this.m_particleSystem.maxInitialRotation=0,this.m_particleSystem.minAngularSpeed=0,this.m_particleSystem.maxAngularSpeed=0},i.prototype.configureMainModule=function(){var e,t,n,r,o,a,s,l,u,h,c,d,m,p,f,g,y,v,S,_,b,B;if(this.m_systemProperties.main&&this.m_particleSystem){var C=this.m_systemProperties.main;if(void 0!==C.loop&&(this.m_isLooping=C.loop),void 0!==C.duration&&(this.m_duration=C.duration),this.m_isLooping&&(this.m_duration=0),C.prewarm&&C.loop?this.m_prewarm=!0:this.m_prewarm=!1,C.startDelay?this.m_startDelay=C.startDelay:this.m_startDelay=null,void 0!==C.playOnAwake&&(this.m_playOnAwake=C.playOnAwake,this.m_autoStart=C.playOnAwake),C.maxParticles,void 0!==C.scalingMode){var A=C.scalingMode;this.m_scalingMode=A}if(void 0!==C.emitterVelocityMode){var T=C.emitterVelocityMode;this.m_emitterVelocityMode=T}if(void 0!==C.emitterVelocity){var M=C.emitterVelocity;this.m_emitterVelocity.set(M.x||0,M.y||0,M.z||0),this.m_emitterVelocity.length()}if(void 0!==C.customSimulationSpace){var L=C.customSimulationSpace;this.m_customSimulationSpace=L}if(void 0!==C.stopAction&&C.stopAction,void 0!==C.ringBufferMode)C.ringBufferMode>0&&C.ringBufferLoopRange&&C.ringBufferLoopRange;var P=this.convertMinMaxGradient(C.startColor),w=null!==(t=null===(e=C.startColor)||void 0===e?void 0:e.mode)&&void 0!==t?t:0,x=(null===(n=C.startColor)||void 0===n?void 0:n.color)||{r:1,g:1,b:1,a:1};0===w?(this.m_particleSystem.color1=new BABYLON.Color4(x.r,x.g,x.b,x.a),this.m_particleSystem.color2=new BABYLON.Color4(x.r,x.g,x.b,x.a),this.m_particleSystem.colorDead=new BABYLON.Color4(x.r,x.g,x.b,i.UNITY_TO_BABYLON_DEATH_FADE_ALPHA)):(this.m_particleSystem.color1=P.colorMin,this.m_particleSystem.color2=P.colorMax,this.m_particleSystem.colorDead=new BABYLON.Color4(P.colorMin.r,P.colorMin.g,P.colorMin.b,i.UNITY_TO_BABYLON_DEATH_FADE_ALPHA));var O=this.convertMinMaxCurve(C.startLifetime);0===(null!==(o=null===(r=C.startLifetime)||void 0===r?void 0:r.mode)&&void 0!==o?o:0)?(this.m_particleSystem.minLifeTime=O.value*i.UNITY_TO_BABYLON_LIFETIME_RATIO,this.m_particleSystem.maxLifeTime=O.value*i.UNITY_TO_BABYLON_LIFETIME_RATIO):(this.m_particleSystem.minLifeTime=O.min*i.UNITY_TO_BABYLON_LIFETIME_RATIO,this.m_particleSystem.maxLifeTime=O.max*i.UNITY_TO_BABYLON_LIFETIME_RATIO);var R=this.convertMinMaxCurve(C.startSpeed),I=null!==(s=null===(a=C.startSpeed)||void 0===a?void 0:a.mode)&&void 0!==s?s:0;if(0===R.min&&0===R.max?(this.m_particleSystem.minEmitPower=0,this.m_particleSystem.maxEmitPower=0):0===I?(this.m_particleSystem.minEmitPower=R.value*i.UNITY_TO_BABYLON_EMIT_POWER_RATIO,this.m_particleSystem.maxEmitPower=R.value*i.UNITY_TO_BABYLON_EMIT_POWER_RATIO):(this.m_particleSystem.minEmitPower=R.min*i.UNITY_TO_BABYLON_EMIT_POWER_RATIO,this.m_particleSystem.maxEmitPower=R.max*i.UNITY_TO_BABYLON_EMIT_POWER_RATIO),C.startSize3D){var N=this.convertMinMaxCurve(C.startSizeX),k=this.convertMinMaxCurve(C.startSizeY),F=this.convertMinMaxCurve(C.startSizeZ),D=null!==(u=null===(l=C.startSizeX)||void 0===l?void 0:l.mode)&&void 0!==u?u:0,E=null!==(c=null===(h=C.startSizeY)||void 0===h?void 0:h.mode)&&void 0!==c?c:0,V=null!==(m=null===(d=C.startSizeZ)||void 0===d?void 0:d.mode)&&void 0!==m?m:0,Y=void 0,U=void 0;0===D&&0===E&&0===V?U=Y=Math.max(N.value,k.value,F.value):(Y=Math.max(N.min,k.min,F.min),U=Math.max(N.max,k.max,F.max)),this.m_particleSystem.minSize=Y*i.UNITY_TO_BABYLON_SIZE_RATIO,this.m_particleSystem.maxSize=U*i.UNITY_TO_BABYLON_SIZE_RATIO}else{var W=this.convertMinMaxCurve(C.startSize);0===(null!==(f=null===(p=C.startSize)||void 0===p?void 0:p.mode)&&void 0!==f?f:0)?(this.m_particleSystem.minSize=W.value*i.UNITY_TO_BABYLON_SIZE_RATIO,this.m_particleSystem.maxSize=W.value*i.UNITY_TO_BABYLON_SIZE_RATIO):(this.m_particleSystem.minSize=W.min*i.UNITY_TO_BABYLON_SIZE_RATIO,this.m_particleSystem.maxSize=W.max*i.UNITY_TO_BABYLON_SIZE_RATIO)}if(C.startRotation3D){this.convertMinMaxCurve(C.startRotationX),this.convertMinMaxCurve(C.startRotationY);var G=this.convertMinMaxCurve(C.startRotationZ),H=(null===(g=C.startRotationX)||void 0===g?void 0:g.mode,void(null===(y=C.startRotationY)||void 0===y?void 0:y.mode)),z=void 0;0===(null!==(S=null===(v=C.startRotationZ)||void 0===v?void 0:v.mode)&&void 0!==S?S:0)?(H=G.value,z=G.value):(H=G.min,z=G.max),this.m_particleSystem instanceof BABYLON.ParticleSystem&&(this.m_particleSystem.minInitialRotation=H,this.m_particleSystem.maxInitialRotation=z)}else{var K=this.convertMinMaxCurve(C.startRotation);0===(null!==(b=null===(_=C.startRotation)||void 0===_?void 0:_.mode)&&void 0!==b?b:0)?this.m_particleSystem instanceof BABYLON.ParticleSystem&&(this.m_particleSystem.minInitialRotation=K.value,this.m_particleSystem.maxInitialRotation=K.value):this.m_particleSystem instanceof BABYLON.ParticleSystem&&(this.m_particleSystem.minInitialRotation=K.min,this.m_particleSystem.maxInitialRotation=K.max)}if(C.flipRotation&&C.flipRotation>0){if(this.m_particleSystem instanceof BABYLON.ParticleSystem){var X=this.m_particleSystem.minAngularSpeed||0,Q=this.m_particleSystem.maxAngularSpeed||0,j=Math.max(Math.abs(X),Math.abs(Q));this.m_particleSystem.minAngularSpeed=-j*C.flipRotation,this.m_particleSystem.maxAngularSpeed=j*C.flipRotation}}else this.m_particleSystem instanceof BABYLON.ParticleSystem&&(this.m_particleSystem.minAngularSpeed=0,this.m_particleSystem.maxAngularSpeed=0);if(void 0!==C.cullingMode){var Z=C.cullingMode;this.m_cullingMode=Z,3!==Z?this.setupCullingVisibilityCheck():this.m_isVisible=!0}var J,q=this.convertMinMaxCurve(C.gravityModifier);if(null===(B=C.gravityModifier)||void 0===B?void 0:B.mode,J=q.value*i.UNITY_TO_BABYLON_GRAVITY_RATIO,this.m_particleSystem.gravity=new BABYLON.Vector3(0,-9.81*J,0),void 0!==C.gravitySource){var $=C.gravitySource;this.m_gravitySource=$}if(void 0!==C.gravitySource&&1===this.m_gravitySource){var ee=this.m_particleSystem.gravity;this.m_particleSystem.gravity=new BABYLON.Vector3(0,ee.y,0)}this.m_particleSystem.worldOffset=BABYLON.Vector3.Zero(),1===C.simulationSpace?this.m_particleSystem.emitter=this.m_emitterMesh.getAbsolutePosition().clone():this.m_particleSystem.emitter=this.m_emitterMesh;var te=C.simulationSpeed||1;if(this.m_simulationSpeed=1!==te?te:1,void 0!==C.useUnscaledTime){var ie=C.useUnscaledTime;this.m_useUnscaledTime=ie}void 0!==C.deltaTime?this.m_reportedDeltaTime=C.deltaTime:this.m_reportedDeltaTime=0}},i.prototype.configureEmissionModule=function(){var e,t;if(this.m_systemProperties.emission&&this.m_particleSystem){var n=this.m_systemProperties.emission;if(n.enabled){if(n.rateOverTime){var r=this.convertMinMaxCurve(n.rateOverTime),o=(null===(e=n.rateOverTime)||void 0===e?void 0:e.mode,r.value*i.UNITY_TO_BABYLON_EMIT_RATE_RATIO);this.m_particleSystem.emitRate=o}else this.m_particleSystem.emitRate=0;if(n.rateOverDistance){var a=this.convertMinMaxCurve(n.rateOverDistance);null===(t=n.rateOverDistance)||void 0===t?void 0:t.mode,a.value,void 0!==n.rateOverDistanceMultiplier&&n.rateOverDistanceMultiplier}if(n.bursts&&n.bursts.length>0){var s=n.bursts.filter(function(e){return e&&"number"==typeof e.time&&void 0!==e.count});s.length>0&&(this.setupBursts(s),void 0!==n.burstCount&&(n.burstCount,s.length))}else n.burstCount&&n.burstCount}else this.m_particleSystem.emitRate=0;n.enabled&&this.m_particleSystem.emitRate>0&&this.m_particleSystem.emitRate<.1&&(this.m_particleSystem.emitRate=.1)}},i.prototype.configureShapeModule=function(){var e;if(this.m_systemProperties.shape&&this.m_particleSystem){var t=this.m_systemProperties.shape;if(t.enabled)this.configureEmissionShape(t);else if(this.m_particleSystem instanceof BABYLON.ParticleSystem){var n=this.m_systemProperties.shape,r=null!==(e=null==n?void 0:n.radius)&&void 0!==e?e:i.DEFAULT_PARTICLE_PROPERTIES.shape.radius;this.createSphereShapeEmitter(r,0,0)}}},i.prototype.configureRendererModule=function(){var e,t;if(this.m_systemProperties.renderer&&this.m_particleSystem){var i=this.m_systemProperties.renderer;if(void 0!==i.renderMode)switch(i.renderMode){case 0:break;case 1:void 0!==i.lengthScale&&i.lengthScale>0&&this.implementStretchRendering(i.lengthScale,i.velocityScale,i.freeformStretching);break;case 2:this.implementConstrainedBillboarding("horizontal");break;case 3:this.implementConstrainedBillboarding("vertical");break;case 4:this.implementMeshRendering(i);break;case 5:this.m_particleSystem instanceof BABYLON.ParticleSystem&&(this.m_particleSystem.renderingGroupId=-1)}if(void 0!==i.minParticleSize||void 0!==i.maxParticleSize){var n=null!==(e=i.minParticleSize)&&void 0!==e?e:0,r=null!==(t=i.maxParticleSize)&&void 0!==t?t:.5;this.m_particleSystem.minSize<n&&(this.m_particleSystem.minSize=n),this.m_particleSystem.maxSize>r&&(this.m_particleSystem.maxSize=r)}void 0!==i.sortMode&&this.implementParticleSorting(i.sortMode,i.sortingFudge),void 0!==i.alignment&&this.implementParticleAlignment(i.alignment),!i.flip||0===i.flip.x&&0===i.flip.y||this.implementParticleFlipping(i.flip),!i.pivot||0===i.pivot.x&&0===i.pivot.y&&0===i.pivot.z||this.implementParticlePivot(i.pivot),void 0!==i.allowRoll&&this.implementParticleRoll(i.allowRoll),void 0!==i.velocityScale&&i.velocityScale>0&&this.implementVelocityScaling(i.velocityScale,i.cameraVelocityScale),void 0!==i.normalDirection&&this.implementNormalDirection(i.normalDirection),void 0!==i.freeformStretching&&this.implementFreeformStretching(i.freeformStretching),void 0!==i.maskInteraction&&i.maskInteraction>0&&this.implementMaskInteraction(i.maskInteraction),void 0!==i.rotateWithStretchDirection&&this.implementStretchRotation(i.rotateWithStretchDirection),void 0!==i.shadowBias&&0!==i.shadowBias&&this.implementShadowBias(i.shadowBias),void 0!==i.meshCount&&i.meshCount>1&&i.meshes&&this.implementMultiMeshRendering(i.meshes,i.meshDistribution),void 0!==i.activeVertexStreamsCount&&i.activeVertexStreamsCount>0&&this.implementCustomVertexStreams(i.activeVertexStreamsCount),i.trailMaterial&&this.implementTrailMaterial(i.trailMaterial),i.materials&&i.materials.length>0&&this.implementMaterialConfiguration(i.materials),void 0===i.shadowCastingMode&&void 0===i.receiveShadows||this.implementShadowConfiguration(i.shadowCastingMode,i.receiveShadows),void 0===i.lightProbeUsage&&void 0===i.reflectionProbeUsage||this.implementProbeConfiguration(i.lightProbeUsage,i.reflectionProbeUsage),void 0===i.enableGPUInstancing&&void 0===i.supportsMeshInstancing||this.implementGPUInstancing(i.enableGPUInstancing,i.supportsMeshInstancing),void 0===i.sortingLayerID&&void 0===i.sortingOrder||this.implementSortingLayer(i.sortingLayerID,i.sortingOrder)}},i.prototype.implementStretchRendering=function(e,t,i){this.m_particleSystem instanceof BABYLON.ParticleSystem&&(this.m_particleSystem.stretchSettings={lengthScale:e,velocityScale:null!=t?t:1,freeform:null!=i&&i})},i.prototype.implementConstrainedBillboarding=function(e){this.m_particleSystem instanceof BABYLON.ParticleSystem&&(this.m_particleSystem.billboardConstraint=e)},i.prototype.implementMeshRendering=function(e){e.mesh&&(this.m_particleSystem,BABYLON.GPUParticleSystem)},i.prototype.implementParticleSorting=function(e,t){switch(e){case 1:this.m_particleSystem instanceof BABYLON.ParticleSystem&&(this.m_particleSystem.blendMode=BABYLON.ParticleSystem.BLENDMODE_ONEONE);break;case 2:case 3:this.m_particleSystem.customSortMode=e,void 0!==t&&(this.m_particleSystem.sortingFudge=t)}},i.prototype.implementParticleAlignment=function(e){switch(e){case 1:this.m_particleSystem.worldAlignment=!0;break;case 2:this.m_particleSystem.localAlignment=!0;break;case 3:case 4:this.m_particleSystem.velocityAlignment=!0}},i.prototype.implementParticleFlipping=function(e){this.m_particleSystem.flipSettings={x:e.x,y:e.y}},i.prototype.implementParticlePivot=function(e){this.m_particleSystem.pivotOffset=new BABYLON.Vector3(e.x,e.y,e.z)},i.prototype.implementParticleRoll=function(e){this.m_particleSystem.allowRoll=e},i.prototype.implementVelocityScaling=function(e,t){this.m_particleSystem.velocityScaling={scale:e,cameraScale:null!=t?t:1}},i.prototype.implementNormalDirection=function(e){this.m_particleSystem.normalDirection=e},i.prototype.implementFreeformStretching=function(e){this.m_particleSystem.freeformStretching=e},i.prototype.implementMaskInteraction=function(e){switch(e){case 1:this.m_particleSystem.maskMode="inside";break;case 2:this.m_particleSystem.maskMode="outside"}},i.prototype.implementStretchRotation=function(e){this.m_particleSystem.rotateWithStretch=e},i.prototype.implementShadowBias=function(e){this.m_particleSystem.shadowBias=e},i.prototype.implementMultiMeshRendering=function(e,t){this.m_particleSystem.multiMeshSettings={meshes:e,distribution:t}},i.prototype.implementCustomVertexStreams=function(e){this.m_particleSystem.customVertexStreams=e},i.prototype.implementTrailMaterial=function(e){this.m_particleSystem.trailMaterial=e},i.prototype.implementMaterialConfiguration=function(e){if(e.length>0){var t=e[0];t&&t.name,e.length>1&&(this.m_particleSystem.additionalMaterials=e.slice(1))}},i.prototype.implementShadowConfiguration=function(e,t){void 0!==e&&(this.m_particleSystem.shadowCastingMode=e),void 0!==t&&(this.m_particleSystem.receiveShadows=t)},i.prototype.implementProbeConfiguration=function(e,t){void 0!==e&&(this.m_particleSystem.lightProbeUsage=e),void 0!==t&&(this.m_particleSystem.reflectionProbeUsage=t)},i.prototype.implementGPUInstancing=function(e,t){void 0!==e&&(this.m_particleSystem.gpuInstancesEnabled=e),void 0!==t&&(this.m_particleSystem.meshInstancingSupported=t)},i.prototype.implementSortingLayer=function(e,t){void 0!==e&&(this.m_particleSystem.sortingLayerID=e),void 0!==t&&(this.m_particleSystem instanceof BABYLON.ParticleSystem&&(this.m_particleSystem.renderingGroupId=Math.max(0,Math.min(3,t))),this.m_particleSystem.sortingOrder=t)},i.prototype.configureVelocityOverLifetimeModule=function(){var e,t,i,n,r,o,a,s,l,u,h;if(this.m_systemProperties.velocityOverLifetime&&this.m_particleSystem){var c=this.m_systemProperties.velocityOverLifetime;c.enabled&&(this.convertMinMaxCurve(c.x),this.convertMinMaxCurve(c.y),this.convertMinMaxCurve(c.z),null===(e=c.x)||void 0===e?void 0:e.mode,null===(t=c.y)||void 0===t?void 0:t.mode,null===(i=c.z)||void 0===i?void 0:i.mode,(c.orbitalX||c.orbitalY||c.orbitalZ)&&(this.convertMinMaxCurve(c.orbitalX),this.convertMinMaxCurve(c.orbitalY),this.convertMinMaxCurve(c.orbitalZ),null===(n=c.orbitalX)||void 0===n?void 0:n.mode,null===(r=c.orbitalY)||void 0===r?void 0:r.mode,null===(o=c.orbitalZ)||void 0===o?void 0:o.mode),(c.orbitalOffsetX||c.orbitalOffsetY||c.orbitalOffsetZ)&&(this.convertMinMaxCurve(c.orbitalOffsetX),this.convertMinMaxCurve(c.orbitalOffsetY),this.convertMinMaxCurve(c.orbitalOffsetZ),null===(a=c.orbitalOffsetX)||void 0===a?void 0:a.mode,null===(s=c.orbitalOffsetY)||void 0===s?void 0:s.mode,null===(l=c.orbitalOffsetZ)||void 0===l?void 0:l.mode),c.radial&&(this.convertMinMaxCurve(c.radial),null===(u=c.radial)||void 0===u?void 0:u.mode),c.speedModifier&&(this.convertMinMaxCurve(c.speedModifier),null===(h=c.speedModifier)||void 0===h?void 0:h.mode),this.setupVelocityOverLifetime(c))}},i.prototype.configureLimitVelocityOverLifetimeModule=function(){if(this.m_systemProperties.limitVelocityOverLifetime&&this.m_particleSystem){var e=this.m_systemProperties.limitVelocityOverLifetime;e.enabled&&this.setupLimitVelocity(e)}},i.prototype.configureColorOverLifetimeModule=function(){if(this.m_systemProperties.colorOverLifetime&&this.m_particleSystem){var e=this.m_systemProperties.colorOverLifetime;if(e.enabled&&e.color&&this.m_particleSystem instanceof BABYLON.ParticleSystem){var t=this.convertMinMaxGradient(e.color);if(this.m_particleSystem.addColorGradient(0,t.colorMin),this.m_particleSystem.addColorGradient(1,t.colorMax),e.color.gradient&&e.color.gradient.colorKeys){this.m_particleSystem.removeColorGradient(0),this.m_particleSystem.removeColorGradient(1);for(var i=0,n=e.color.gradient.colorKeys;i<n.length;i++){var r=n[i],o=this.convertColor(r.color);this.m_particleSystem.addColorGradient(r.time,o)}if(e.color.gradient.alphaKeys)for(var a=0,s=e.color.gradient.alphaKeys;a<s.length;a++)s[a]}}else e.enabled}},i.prototype.configureSizeOverLifetimeModule=function(){var e,t,i,n,r;if(this.m_systemProperties.sizeOverLifetime&&this.m_particleSystem){var o=this.m_systemProperties.sizeOverLifetime;if(o.enabled&&this.m_particleSystem instanceof BABYLON.ParticleSystem)if(o.separateAxes){var a=this.convertMinMaxCurve(o.x),s=this.convertMinMaxCurve(o.y),l=this.convertMinMaxCurve(o.z),u=(null===(e=o.x)||void 0===e?void 0:e.mode,null===(t=o.y)||void 0===t?void 0:t.mode,null===(i=o.z)||void 0===i?void 0:i.mode,Math.max(a.min,s.min,l.min)),h=Math.max(a.max,s.max,l.max);this.m_particleSystem.addSizeGradient(0,u),this.m_particleSystem.addSizeGradient(1,h)}else{var c=this.convertMinMaxCurve(o.size);u=void 0,h=void 0,0===(null!==(r=null===(n=o.size)||void 0===n?void 0:n.mode)&&void 0!==r?r:0)?(u=c.value,h=c.value):(u=c.min,h=c.max),this.m_particleSystem.addSizeGradient(0,u),this.m_particleSystem.addSizeGradient(1,h)}else o.enabled}},i.prototype.configureRotationOverLifetimeModule=function(){var e,t,i,n,r,o;if(this.m_systemProperties.rotationOverLifetime&&this.m_particleSystem){var a=this.m_systemProperties.rotationOverLifetime;if(a.enabled&&this.m_particleSystem instanceof BABYLON.ParticleSystem)if(a.separateAxes){this.convertMinMaxCurve(a.x),this.convertMinMaxCurve(a.y);var s=this.convertMinMaxCurve(a.z),l=(null===(e=a.x)||void 0===e?void 0:e.mode,void(null===(t=a.y)||void 0===t?void 0:t.mode)),u=void 0;0===(null!==(n=null===(i=a.z)||void 0===i?void 0:i.mode)&&void 0!==n?n:0)?(l=s.value,u=s.value):(l=s.min,u=s.max),this.m_particleSystem.addAngularSpeedGradient(0,l),this.m_particleSystem.addAngularSpeedGradient(1,u)}else{var h=this.convertMinMaxCurve(a.z);l=void 0,u=void 0,0===(null!==(o=null===(r=a.z)||void 0===r?void 0:r.mode)&&void 0!==o?o:0)?(l=h.value,u=h.value):(l=h.min,u=h.max),this.m_particleSystem.addAngularSpeedGradient(0,l),this.m_particleSystem.addAngularSpeedGradient(1,u)}}},i.prototype.configureTextureSheetAnimationModule=function(){if(this.m_systemProperties.textureSheetAnimation&&this.m_particleSystem){var e=this.m_systemProperties.textureSheetAnimation;e.enabled&&this.m_particleSystem instanceof BABYLON.ParticleSystem?(this.m_particleSystem.spriteCellChangeSpeed=e.fps||1,this.m_particleSystem.spriteCellWidth=1/(e.numTilesX||1),this.m_particleSystem.spriteCellHeight=1/(e.numTilesY||1),this.m_particleSystem.spriteRandomStartCell=e.useRandomRow||!1,e.frameOverTime&&this.convertMinMaxCurve(e.frameOverTime),e.startFrame&&this.convertMinMaxCurve(e.startFrame),e.speedRange):e.enabled}},i.prototype.ensureBasicConfiguration=function(){var e;if(this.m_particleSystem&&(this.m_particleSystem.emitRate<0&&(this.m_particleSystem.emitRate=0),this.m_particleSystem.minLifeTime<=0&&(this.m_particleSystem.minLifeTime=5*i.UNITY_TO_BABYLON_LIFETIME_RATIO,this.m_particleSystem.maxLifeTime=5*i.UNITY_TO_BABYLON_LIFETIME_RATIO),this.m_particleSystem.minSize<=0&&(this.m_particleSystem.minSize=1*i.UNITY_TO_BABYLON_SIZE_RATIO,this.m_particleSystem.maxSize=1*i.UNITY_TO_BABYLON_SIZE_RATIO),this.m_particleSystem instanceof BABYLON.ParticleSystem&&(!this.m_particleSystem.direction1||!this.m_particleSystem.direction2||this.m_particleSystem.direction1.equals(new BABYLON.Vector3(-1,1,-1))&&this.m_particleSystem.direction2.equals(new BABYLON.Vector3(1,1,1))))){var t=this.m_systemProperties.shape,n=null!==(e=null==t?void 0:t.radius)&&void 0!==e?e:i.DEFAULT_PARTICLE_PROPERTIES.shape.radius;this.createSphereShapeEmitter(n,0,0)}},i.prototype.convertMinMaxCurve=function(e){var t,i,n,r,o,a,s,l;if(!e)return console.warn("### ShurikenParticles: ERROR - No curve data provided from Unity export"),{min:0,max:0,value:0};var u=null!==(t=e.mode)&&void 0!==t?t:0;(u<0||u>3)&&console.warn("### ShurikenParticles: WARNING - Invalid Unity curve mode:",u,"using mode 0 (Constant)");var h=e.multiplier||1;switch(u){case 0:var c=null!==(i=e.constant)&&void 0!==i?i:0;return{min:c,max:c,value:c};case 1:if(e.curve&&e.curve.keys&&e.curve.keys.length>0){var d=this.evaluateCurveAtTime(e.curve,0)*h,m=this.evaluateCurveAtTime(e.curve,.5)*h,p=this.evaluateCurveAtTime(e.curve,1)*h;return{min:Math.min(d,m,p),max:Math.max(d,m,p),value:(d+m+p)/3}}var f=(null!==(n=e.constant)&&void 0!==n?n:1)*h;return{min:f,max:f,value:f};case 2:var g=null!==(r=e.constantMin)&&void 0!==r?r:0,y=null!==(o=e.constantMax)&&void 0!==o?o:0;return{min:g,max:y,value:(g+y)/2};case 3:if(e.curveMin&&e.curveMax&&e.curveMin.keys&&e.curveMax.keys){var v=this.evaluateCurveAtTime(e.curveMin,0)*h,S=this.evaluateCurveAtTime(e.curveMin,.5)*h,_=this.evaluateCurveAtTime(e.curveMin,1)*h,b=this.evaluateCurveAtTime(e.curveMax,0)*h,B=this.evaluateCurveAtTime(e.curveMax,.5)*h,C=this.evaluateCurveAtTime(e.curveMax,1)*h,A=Math.min(v,S,_,b,B,C),T=Math.max(v,S,_,b,B,C);return{min:A,max:T,value:(A+T)/2}}var M=(null!==(a=e.constantMin)&&void 0!==a?a:0)*h,L=(null!==(s=e.constantMax)&&void 0!==s?s:0)*h;return{min:M,max:L,value:(M+L)/2};default:var P=null!==(l=e.constant)&&void 0!==l?l:0;return{min:P,max:P,value:P}}},i.prototype.convertMinMaxGradient=function(e){if(!e){var t=new BABYLON.Color4(1,1,1,1);return{colorMin:t,colorMax:t}}var i,n;switch(e.mode){case 0:var r=this.convertColor(e.color);i=r,n=r;break;case 2:i=this.convertColor(e.colorMin),n=this.convertColor(e.colorMax);break;case 1:if(e.gradient&&e.gradient.colorKeys&&e.gradient.colorKeys.length>0){var o=e.gradient.colorKeys[0],a=e.gradient.colorKeys[e.gradient.colorKeys.length-1];i=this.convertColor(o.color),n=this.convertColor(a.color)}else if(e.color)i=l=this.convertColor(e.color),n=l;else{var s=new BABYLON.Color4(1,1,1,1);i=s,n=s}break;case 3:e.gradientMin&&e.gradientMax&&e.gradientMin.colorKeys&&e.gradientMin.colorKeys.length>0&&e.gradientMax.colorKeys&&e.gradientMax.colorKeys.length>0?(i=this.convertColor(e.gradientMin.colorKeys[0].color),n=this.convertColor(e.gradientMax.colorKeys[0].color)):(i=this.convertColor(e.colorMin),n=this.convertColor(e.colorMax));break;case 4:e.gradient&&e.gradient.colorKeys&&e.gradient.colorKeys.length>0?(o=e.gradient.colorKeys[0],a=e.gradient.colorKeys[e.gradient.colorKeys.length-1],i=this.convertColor(o.color),n=this.convertColor(a.color)):(i=this.convertColor(e.colorMin),n=this.convertColor(e.colorMax));break;default:var l;e.color?(i=l=this.convertColor(e.color),n=l):(i=this.convertColor(e.colorMin),n=this.convertColor(e.colorMax))}return{colorMin:i,colorMax:n}},i.prototype.convertColor=function(e){if(!e)return new BABYLON.Color4(1,1,1,1);var t="number"==typeof e.r&&!isNaN(e.r)&&isFinite(e.r)?e.r:1,i="number"==typeof e.g&&!isNaN(e.g)&&isFinite(e.g)?e.g:1,n="number"==typeof e.b&&!isNaN(e.b)&&isFinite(e.b)?e.b:1,r="number"==typeof e.a&&!isNaN(e.a)&&isFinite(e.a)?e.a:1;return 1!==t||1!==i||1!==n||1!==r||1===e.r&&1===e.g&&1===e.b&&1===e.a?new BABYLON.Color4(t,i,n,r):new BABYLON.Color4(1,1,1,1)},i.prototype.colorsEqual=function(e,t){if(!e&&!t)return!0;if(!e||!t)return!1;var i=1e-4;return Math.abs(e.r-t.r)<i&&Math.abs(e.g-t.g)<i&&Math.abs(e.b-t.b)<i&&Math.abs(e.a-t.a)<i},i.prototype.applyUnityGradientToBabylon=function(e,t){if(!e||!e.colorKeys||0===e.colorKeys.length)return!1;t.removeColorGradient(0),t.removeColorGradient(1);for(var i=0,n=e.colorKeys;i<n.length;i++){var r=n[i],o=this.convertColor(r.color);t.addColorGradient(r.time,o)}return e.alphaKeys&&e.alphaKeys.length>0&&console.warn("### ShurikenParticles: Alpha keys detected but not fully supported yet"),!0},i.prototype.convertVector3=function(e){return e?new BABYLON.Vector3(e.x,e.y,e.z):BABYLON.Vector3.Zero()},i.prototype.evaluateCurveAtTime=function(e,t){if(!e||!e.keys||0===e.keys.length)return 1;var i=e.keys;if(t<=i[0].time)return i[0].value;if(t>=i[i.length-1].time)return i[i.length-1].value;for(var n=0;n<i.length-1;n++){var r=i[n],o=i[n+1];if(t>=r.time&&t<=o.time){var a=(t-r.time)/(o.time-r.time);return r.value+a*(o.value-r.value)}}return i[0].value},i.prototype.setupBursts=function(e){if(this.m_burstTimers=[],e&&e.length>0)for(var t=0;t<e.length;t++){var i=e[t];this.m_burstTimers.push(-i.time)}},i.prototype.resetBurstTimers=function(){var e;if((null===(e=this.m_systemProperties.emission)||void 0===e?void 0:e.bursts)&&this.m_burstTimers)for(var t=0;t<this.m_systemProperties.emission.bursts.length;t++){var i=this.m_systemProperties.emission.bursts[t];this.m_burstTimers[t]=-i.time}},i.prototype.updateSystem=function(e){this.m_systemTime+=e},i.prototype.updateEmission=function(e){this.m_emissionTimer+=e},i.prototype.updateAnimationProperties=function(){},i.prototype.updateBursts=function(e){var t,i,n;if(null===(t=this.m_systemProperties.emission)||void 0===t?void 0:t.bursts)for(var r=0;r<this.m_systemProperties.emission.bursts.length;r++){var o=this.m_systemProperties.emission.bursts[r];if(this.m_systemTime>=o.time&&this.m_burstTimers[r]<0){var a=void 0!==o.probability?o.probability:1;if(Math.random()>a){this.m_burstTimers[r]=this.m_systemTime;continue}var s=this.convertMinMaxCurve(o.count),l=void 0;switch(null!==(n=null===(i=o.count)||void 0===i?void 0:i.mode)&&void 0!==n?n:0){case 0:case 1:default:l=s.value;break;case 2:case 3:l=Math.random()*(s.max-s.min)+s.min}(l=Math.max(0,Math.round(l)))>0&&this.triggerBurst(l),this.m_burstTimers[r]=this.m_systemTime;var u=void 0!==o.cycleCount?o.cycleCount:1;(-1===u||u>1)&&void 0!==o.repeatInterval&&o.repeatInterval}}},i.prototype.triggerBurst=function(e){var t=this;if(this.m_particleSystem instanceof BABYLON.ParticleSystem){var i=this.m_particleSystem.emitRate;this.m_particleSystem.emitRate=60*e,setTimeout(function(){t.m_particleSystem&&(t.m_particleSystem.emitRate=i)},16)}},i.prototype.configureEmissionShape=function(e){var t,i,n;if(e.radiusSpeed&&(this.convertMinMaxCurve(e.radiusSpeed),null===(t=e.radiusSpeed)||void 0===t?void 0:t.mode),e.meshSpawnSpeed&&(this.convertMinMaxCurve(e.meshSpawnSpeed),null===(i=e.meshSpawnSpeed)||void 0===i?void 0:i.mode),e.arcSpeed&&(this.convertMinMaxCurve(e.arcSpeed),null===(n=e.arcSpeed)||void 0===n?void 0:n.mode),e.rotation&&this.m_emitterMesh){var r=this.convertVector3(e.rotation),o=BABYLON.Quaternion.FromEulerAngles(BABYLON.Tools.ToRadians(r.x),BABYLON.Tools.ToRadians(r.y),BABYLON.Tools.ToRadians(r.z)),a=this.m_emitterMesh.rotationQuaternion||BABYLON.Quaternion.Identity();this.m_emitterMesh.rotationQuaternion=a.multiply(o)}switch(e.shapeType){case 4:case 7:case 8:case 9:var s=e.radius||1,l=e.angle||25,u=(e.length,e.arc,e.radiusSpread,e.scale||{x:1,y:1,z:1}),h=(e.radiusMode,s*((u.x+u.z)/2)),c=Math.max(.1,l*Math.PI/180),d=Math.max(.5,h);this.createConeShapeEmitter(d,c);break;case 0:case 1:var m=e.radius||1,p=e.scale||{x:1,y:1,z:1},f=e.radiusSpread||0,g=e.radiusMode||0,y=(e.donutRadius,m);2===g&&f>0&&(y=m*(1+.5*f));var v=y*((p.x+p.y+p.z)/3);e.shapeType,this.m_particleSystem.createSphereEmitter(v);break;case 2:case 3:var S=e.radius||1,_=e.scale||{x:1,y:1,z:1},b=e.radiusSpread||0,B=e.radiusMode||0,C=(e.donutRadius,e.arc,S);2===B&&b>0&&(C=S*(1+.5*b));var A=C*((_.x+_.y+_.z)/3);e.shapeType,this.m_particleSystem.createHemisphericEmitter(A);break;case 10:case 11:var T=e.radius||1,M=e.scale||{x:1,y:1,z:1},L=(e.arc,e.donutRadius,e.radiusSpread||0),P=e.radiusMode||0,w=(e.length,T);2===P&&L>0&&(w=T*(1+.5*L));var x=w*((M.x+M.z)/2);M.y,this.m_particleSystem.createDirectedSphereEmitter(x,new BABYLON.Vector3(0,1,0),new BABYLON.Vector3(0,1,0));break;case 5:case 15:case 16:var O=e.scale||{x:1,y:1,z:1},R=e.boxThickness||{x:0,y:0,z:0};15!==e.shapeType&&16!==e.shapeType||(O={x:Math.max(.1,O.x-R.x),y:Math.max(.1,O.y-R.y),z:Math.max(.1,O.z-R.z)}),this.m_particleSystem.createBoxEmitter(new BABYLON.Vector3(-O.x/2,-O.y/2,-O.z/2),new BABYLON.Vector3(O.x/2,O.y/2,O.z/2),new BABYLON.Vector3(0,1,0),new BABYLON.Vector3(0,1,0));break;case 17:var I=e.radius||1,N=e.donutRadius||.2,k=e.scale||{x:1,y:1,z:1},F=(e.arc,e.radiusSpread||0),D=I;2===(e.radiusMode||0)&&F>0&&(D=I*(1+.5*F));var E=(k.x+k.z)/2,V=(D*E+N*E)/2;this.m_particleSystem.createDirectedSphereEmitter(V,new BABYLON.Vector3(0,1,0),new BABYLON.Vector3(0,1,0));break;case 18:var Y=e.scale||{x:1,y:1,z:1},U=e.length||1,W=(e.arc,Y.x),G=Y.z,H=U*Y.y;this.m_particleSystem.createBoxEmitter(new BABYLON.Vector3(-W/2,-H/2,-G/2),new BABYLON.Vector3(W/2,H/2,G/2),new BABYLON.Vector3(0,1,0),new BABYLON.Vector3(0,1,0));break;case 12:var z=e.length||1,K=e.scale||{x:1,y:1,z:1},X=e.radius||.1,Q=z*K.x,j=X*Math.max(K.y,K.z);this.m_particleSystem.createBoxEmitter(new BABYLON.Vector3(-Q/2,-j/2,-j/2),new BABYLON.Vector3(Q/2,j/2,j/2),new BABYLON.Vector3(0,1,0),new BABYLON.Vector3(0,1,0));break;default:if(6===e.shapeType||13===e.shapeType||14===e.shapeType){var Z=e.radius||1,J=e.scale||{x:1,y:1,z:1},q=Z*((J.x+J.y+J.z)/3);this.m_particleSystem.createSphereEmitter(q)}else if(19===e.shapeType||20===e.shapeType){var $=e.scale||{x:1,y:1,z:1};this.m_particleSystem.createBoxEmitter(new BABYLON.Vector3(-$.x/2,-$.y/2,-.1),new BABYLON.Vector3($.x/2,$.y/2,.1),new BABYLON.Vector3(0,0,1),new BABYLON.Vector3(0,0,1))}else{var ee=e.radius||1,te=(e.angle||25)*Math.PI/180,ie=e.length||1,ne=e.scale||{x:1,y:1,z:1},re=te,oe=(ee+(ee+ie*Math.tan(re)))/2,ae=3*ee;(oe*=(ne.x+ne.z)/2)>ae&&(oe=ae);var se=Math.min(re,Math.PI/4);this.createConeShapeEmitter(oe,se)}}if(e.position&&(0!==e.position.x||0!==e.position.y||0!==e.position.z)){var le=this.convertVector3(e.position);this.m_emitterMesh&&(this.m_emitterMesh.position.clone(),this.m_emitterMesh.position.addInPlace(le))}!e.rotation||0===e.rotation.x&&0===e.rotation.y&&0===e.rotation.z||this.m_emitterMesh,e.randomDirectionAmount,e.randomPositionAmount,e.sphericalDirectionAmount,e.alignToDirection,e.arc,void 0!==e.normalOffset&&e.normalOffset},i.prototype.setupVelocityOverLifetime=function(e){},i.prototype.setupLimitVelocity=function(e){},i.prototype.createColorGradient=function(e){return this.convertMinMaxGradient(e)},i.prototype.setupSpriteAnimation=function(e){this.m_particleSystem instanceof BABYLON.ParticleSystem&&(this.m_particleSystem.spriteCellChangeSpeed=e.fps||1,this.m_particleSystem.spriteCellWidth=1/e.numTilesX,this.m_particleSystem.spriteCellHeight=1/e.numTilesY,this.m_particleSystem.spriteRandomStartCell=e.useRandomRow)},i.prototype.createBoxShapeEmitter=function(e,t){if(this.m_particleSystem instanceof BABYLON.ParticleSystem){var i=e||{x:1,y:1,z:1};this.m_particleSystem.createBoxEmitter(new BABYLON.Vector3(-i.x/2,-i.y/2,-i.z/2),new BABYLON.Vector3(i.x/2,i.y/2,i.z/2),new BABYLON.Vector3(0,1,0),new BABYLON.Vector3(0,1,0))}},i.prototype.createSphereShapeEmitter=function(e,t,i){if(this.m_particleSystem instanceof BABYLON.ParticleSystem){var n=e||1;this.m_particleSystem.createSphereEmitter(n)}},i.prototype.createConeShapeEmitter=function(e,t){if(this.m_particleSystem instanceof BABYLON.ParticleSystem){var n=e||1,r=t||Math.PI/7.2,o=this.m_particleSystem.createConeEmitter(n*i.UNITY_TO_BABYLON_CONE_SCALE_RATIO,r*i.UNITY_TO_BABYLON_CONE_SCALE_RATIO);o.radiusRange=1,o.heightRange=1,o.directionRandomizer=1,o.emitFromSpawnPointOnly=!1}},i.prototype.configureNoiseModule=function(){},i.prototype.configureCollisionModule=function(){},i.prototype.configureTrailsModule=function(){},i.prototype.configureSubEmittersModule=function(){},i.prototype.updateEmitterVelocityInheritance=function(e){var t;this.m_emitterVelocity.length()>0&&void 0!==(null===(t=this.m_systemProperties.main)||void 0===t?void 0:t.emitterVelocityMode)&&this.m_systemProperties.main.emitterVelocityMode},i.prototype.updateCustomSimulationSpace=function(e){this.m_customSimulationSpace},i.prototype.updateRingBufferMode=function(e){var t=this.m_systemProperties.main;(null==t?void 0:t.ringBufferMode)&&t.ringBufferMode>0&&t.ringBufferLoopRange&&(t.ringBufferLoopRange,2===t.ringBufferMode||t.ringBufferMode)},i.prototype.handleStopAction=function(){var e=this,t=this.m_systemProperties.main;void 0!==(null==t?void 0:t.stopAction)?1===t.stopAction?setTimeout(function(){e.transform&&e.transform.dispose&&e.transform.dispose()},0):this.stop():this.stop()},i.prototype.setupCullingVisibilityCheck=function(){var e=this,t=function(){if(e.m_isInitialized&&e.m_emitterMesh){var t=Date.now();if(!(t-e.m_lastVisibilityCheck<100)){e.m_lastVisibilityCheck=t;var i=e.m_isVisible;e.m_isVisible=e.isEmitterVisible(),i!==e.m_isVisible&&e.handleVisibilityChange(i,e.m_isVisible)}}};this.scene.registerBeforeRender(t);var i=this.disposeParticleSystem.bind(this);this.disposeParticleSystem=function(){e.scene.unregisterBeforeRender(t),i()}},i.prototype.isEmitterVisible=function(){if(!this.m_emitterMesh||!this.scene.activeCamera)return!0;var e=this.m_emitterMesh.getBoundingInfo();if(!e)return!0;var t=this.scene.activeCamera;if(t.isInFrustum&&e.boundingBox)return t.isInFrustum(e.boundingBox);var i=this.m_emitterMesh.getAbsolutePosition(),n=t.position;return BABYLON.Vector3.Distance(i,n)<=1e3},i.prototype.handleVisibilityChange=function(e,t){var i=this.m_cullingMode;!e&&t?1===i&&this.m_pausedTime>0&&(this.m_pausedTime=0):e&&!t&&(this.m_pausedTime=0)},i.prototype.disposeParticleSystem=function(){this.m_particleSystem&&(this.m_particleSystem.dispose(),this.m_particleSystem=null),this.m_emitterMesh&&this.m_emitterMesh.parent===this.transform&&(this.m_emitterMesh.dispose(),this.m_emitterMesh=null),this.m_animationCurves.clear(),this.m_gradients.clear(),this.m_isInitialized=!1},i.DefaultParticleTexture=null,i.DEFAULT_PARTICLE_PROPERTIES={isPlaying:!0,isPaused:!1,isStopped:!1,isEmitting:!0,particleCount:50,time:0,randomSeed:0,useAutoRandomSeed:!0,name:"",instanceId:0,enabled:!0,transformPosition:{x:0,y:0,z:0},transformRotation:{x:0,y:0,z:0},transformScale:{x:1,y:1,z:1},main:{duration:5,loop:!0,prewarm:!0,startDelay:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},startDelayMultiplier:0,startLifetime:{mode:0,constant:5,constantMin:0,constantMax:5,multiplier:1},startLifetimeMultiplier:5,startSpeed:{mode:0,constant:5,constantMin:0,constantMax:5,multiplier:1},startSpeedMultiplier:5,startSize3D:!1,startSize:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},startSizeMultiplier:1,startSizeX:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},startSizeXMultiplier:1,startSizeY:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},startSizeYMultiplier:1,startSizeZ:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},startSizeZMultiplier:1,startRotation3D:!1,startRotation:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},startRotationMultiplier:0,startRotationX:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},startRotationXMultiplier:0,startRotationY:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},startRotationYMultiplier:0,startRotationZ:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},startRotationZMultiplier:0,flipRotation:0,startColor:{mode:0,color:{r:1,g:1,b:1,a:1},colorMin:{r:0,g:0,b:0,a:0},colorMax:{r:1,g:1,b:1,a:1}},gravityModifier:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},gravityModifierMultiplier:0,simulationSpace:0,simulationSpeed:1,deltaTime:0,scalingMode:1,playOnAwake:!0,emitterVelocityMode:1,maxParticles:1e3,stopAction:0,cullingMode:0,ringBufferMode:0,ringBufferLoopRange:{x:0,y:1},customSimulationSpace:0,emitterVelocity:{x:0,y:0,z:0},gravitySource:0,useUnscaledTime:!1},emission:{enabled:!0,rateOverTime:{mode:0,constant:10,constantMin:0,constantMax:10,multiplier:1},rateOverTimeMultiplier:10,rateOverDistance:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},rateOverDistanceMultiplier:0,burstCount:0,bursts:[]},shape:{enabled:!0,shapeType:0,angle:25,radius:.025,radiusMode:0,radiusSpread:0,radiusSpeed:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},radiusSpeedMultiplier:1,donutRadius:.2,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1},alignToDirection:!1,randomDirectionAmount:0,sphericalDirectionAmount:0,randomPositionAmount:0,biasOnTriangles:!1,useMeshMaterialIndex:!1,meshMaterialIndex:0,useMeshColors:!0,normalOffset:0,meshSpawnMode:0,meshSpawnSpread:0,meshSpawnSpeed:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},meshSpawnSpeedMultiplier:1,arc:360,arcMode:0,arcSpread:0,arcSpeed:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},arcSpeedMultiplier:1,length:5,boxThickness:{x:0,y:0,z:0}},renderer:{enabled:!0,materials:[],renderMode:0,cameraVelocityScale:0,velocityScale:0,lengthScale:2,normalDirection:1,sortMode:0,sortingFudge:0,minParticleSize:0,maxParticleSize:.5,alignment:0,flip:{x:0,y:0},allowRoll:!0,pivot:{x:0,y:0,z:0},shadowCastingMode:1,receiveShadows:!0,motionVectorGenerationMode:1,lightProbeUsage:1,reflectionProbeUsage:1,enableGPUInstancing:!0,mesh:null,sortingLayerID:0,sortingOrder:0,freeformStretching:!1,maskInteraction:0,meshCount:0,meshDistribution:0,rotateWithStretchDirection:!1,shadowBias:0,supportsMeshInstancing:!0,activeVertexStreamsCount:0,activeTrailVertexStreamsCount:0,meshes:[],trailMaterial:null},velocityOverLifetime:{enabled:!1,space:0,x:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},y:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},z:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},xMultiplier:0,yMultiplier:0,zMultiplier:0,orbitalX:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},orbitalY:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},orbitalZ:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},orbitalXMultiplier:0,orbitalYMultiplier:0,orbitalZMultiplier:0,orbitalOffsetX:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},orbitalOffsetY:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},orbitalOffsetZ:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},orbitalOffsetXMultiplier:0,orbitalOffsetYMultiplier:0,orbitalOffsetZMultiplier:0,radial:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},radialMultiplier:0,speedModifier:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},speedModifierMultiplier:1},limitVelocityOverLifetime:{enabled:!1,limitX:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},limitY:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},limitZ:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},limitXMultiplier:1,limitYMultiplier:1,limitZMultiplier:1,limit:{mode:0,constant:1,constantMin:0,constantMax:1,multiplier:1},limitMultiplier:1,dampen:0,separateAxes:!1,space:0,drag:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},dragMultiplier:0,multiplyDragByParticleSize:!0,multiplyDragByParticleVelocity:!0},colorOverLifetime:{enabled:!1,color:{mode:1,color:{r:0,g:0,b:0,a:0},colorMin:{r:0,g:0,b:0,a:0},colorMax:{r:0,g:0,b:0,a:0}}},sizeOverLifetime:{enabled:!1,size:{mode:1,constant:0,constantMin:0,constantMax:0,multiplier:1},sizeMultiplier:1,x:{mode:1,constant:0,constantMin:0,constantMax:0,multiplier:1},xMultiplier:1,y:{mode:1,constant:0,constantMin:0,constantMax:0,multiplier:1},yMultiplier:1,z:{mode:1,constant:0,constantMin:0,constantMax:0,multiplier:1},zMultiplier:1,separateAxes:!1},rotationOverLifetime:{enabled:!1,x:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},xMultiplier:0,y:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},yMultiplier:0,z:{mode:0,constant:.7853982,constantMin:0,constantMax:.7853982,multiplier:1},zMultiplier:.7853982,separateAxes:!1},textureSheetAnimation:{enabled:!1,mode:0,timeMode:0,fps:30,numTilesX:1,numTilesY:1,animation:0,useRandomRow:!0,frameOverTime:{mode:1,constant:0,constantMin:0,constantMax:0,multiplier:.9999},frameOverTimeMultiplier:.9999,startFrame:{mode:0,constant:0,constantMin:0,constantMax:0,multiplier:1},startFrameMultiplier:0,cycleCount:1,rowIndex:0,rowMode:1,uvChannelMask:-1,flipU:0,flipV:0,speedRange:{x:0,y:1}}},i.UNITY_TO_BABYLON_SIZE_RATIO=1,i.UNITY_TO_BABYLON_GRAVITY_RATIO=1,i.UNITY_TO_BABYLON_EMIT_RATE_RATIO=2,i.UNITY_TO_BABYLON_EMIT_POWER_RATIO=2,i.UNITY_TO_BABYLON_CONE_SCALE_RATIO=2,i.UNITY_TO_BABYLON_LIFETIME_RATIO=.65,i.UNITY_TO_BABYLON_DEATH_FADE_ALPHA=.2,i.EMITTER_POSITION_OFFSET=new BABYLON.Vector3(0,0,0),i.EMITTER_ROTATION_OFFSET=new BABYLON.Vector3(90,0,0),i}(e.ScriptComponent);e.ShurikenParticles=t,e.SceneManager.RegisterClass("TOOLKIT.ShurikenParticles",t)}(n||(n={})),function(e){var t=function(){function e(){this.blendWithPhysicsNormal=0,this.maxLookupDistance=8,this.searchRadius=1,this.useProjectionTest=!0,this._v0x=null,this._v0y=null,this._v0z=null,this._v1x=null,this._v1y=null,this._v1z=null,this._v2x=null,this._v2y=null,this._v2z=null,this._n0x=null,this._n0y=null,this._n0z=null,this._n1x=null,this._n1y=null,this._n1z=null,this._n2x=null,this._n2y=null,this._n2z=null,this._fnx=null,this._fny=null,this._fnz=null,this._cx=null,this._cy=null,this._cz=null,this._triangleCount=0,this._cellTriangles=null,this._htKeys=null,this._htStarts=null,this._htCounts=null,this._cellSize=2,this._hashOriginX=0,this._hashOriginZ=0,this._sourceMesh=null,this._worldMatrix=BABYLON.Matrix.Identity(),this._invWorldMatrix=BABYLON.Matrix.Identity(),this._matrixDirty=!0,this._scratchV0=new BABYLON.Vector3,this._scratchLocal=new BABYLON.Vector3,this._candidatesBuf=[],this._uniqueBuf=[],this._seenSet=new Set,this._barycentricScratch=[0,0,0]}return Object.defineProperty(e.prototype,"triangleCount",{get:function(){return this._triangleCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellSize",{get:function(){return this._cellSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!1,configurable:!0}),e.prototype.buildFromMesh=function(e,t){void 0===t&&(t=2),this._sourceMesh=e,this._cellSize=Math.max(.01,t),this._htKeys=null,this._htStarts=null,this._htCounts=null,this._cellTriangles=null,this._triangleCount=0,this._matrixDirty=!0;var i=e.geometry;if(!i)return console.warn("[MeshNormalProxy] Mesh '"+e.name+"' has no geometry. Ensure the mesh is fully loaded before calling buildFromMesh."),!1;var n=i.getVerticesData(BABYLON.VertexBuffer.PositionKind),r=i.getVerticesData(BABYLON.VertexBuffer.NormalKind),o=i.getIndices();if(!n||0===n.length)return console.warn("[MeshNormalProxy] Mesh '"+e.name+"' has no position data."),!1;if(!r||0===r.length)return console.warn("[MeshNormalProxy] Mesh '"+e.name+"' has no normal data. Ensure normals are baked into the mesh."),!1;if(!o||0===o.length)return console.warn("[MeshNormalProxy] Mesh '"+e.name+"' has no index data."),!1;var a=Math.floor(o.length/3);if(0===a)return console.warn("[MeshNormalProxy] Mesh '"+e.name+"' has zero triangles."),!1;this._v0x=new Float32Array(a),this._v0y=new Float32Array(a),this._v0z=new Float32Array(a),this._v1x=new Float32Array(a),this._v1y=new Float32Array(a),this._v1z=new Float32Array(a),this._v2x=new Float32Array(a),this._v2y=new Float32Array(a),this._v2z=new Float32Array(a),this._n0x=new Float32Array(a),this._n0y=new Float32Array(a),this._n0z=new Float32Array(a),this._n1x=new Float32Array(a),this._n1y=new Float32Array(a),this._n1z=new Float32Array(a),this._n2x=new Float32Array(a),this._n2y=new Float32Array(a),this._n2z=new Float32Array(a),this._fnx=new Float32Array(a),this._fny=new Float32Array(a),this._fnz=new Float32Array(a),this._cx=new Float32Array(a),this._cy=new Float32Array(a),this._cz=new Float32Array(a);for(var s=1/0,l=1/0,u=-1/0,h=-1/0,c=0;c<a;c++){var d=o[3*c+0],m=o[3*c+1],p=o[3*c+2],f=n[3*d],g=n[3*d+1],y=n[3*d+2],v=n[3*m],S=n[3*m+1],_=n[3*m+2],b=n[3*p],B=n[3*p+1],C=n[3*p+2];this._v0x[c]=f,this._v0y[c]=g,this._v0z[c]=y,this._v1x[c]=v,this._v1y[c]=S,this._v1z[c]=_,this._v2x[c]=b,this._v2y[c]=B,this._v2z[c]=C,this._n0x[c]=r[3*d],this._n0y[c]=r[3*d+1],this._n0z[c]=r[3*d+2],this._n1x[c]=r[3*m],this._n1y[c]=r[3*m+1],this._n1z[c]=r[3*m+2],this._n2x[c]=r[3*p],this._n2y[c]=r[3*p+1],this._n2z[c]=r[3*p+2];var A=v-f,T=S-g,M=_-y,L=b-f,P=B-g,w=C-y,x=T*w-M*P,O=M*L-A*w,R=A*P-T*L,I=Math.sqrt(x*x+O*O+R*R);I>1e-10&&(x/=I,O/=I,R/=I),this._fnx[c]=x,this._fny[c]=O,this._fnz[c]=R;var N=(f+v+b)/3,k=(g+S+B)/3,F=(y+_+C)/3;this._cx[c]=N,this._cy[c]=k,this._cz[c]=F,(E=Math.min(f,v,b))<s&&(s=E),(V=Math.max(f,v,b))>u&&(u=V),(Y=Math.min(y,_,C))<l&&(l=Y),(U=Math.max(y,_,C))>h&&(h=U)}this._triangleCount=a,this._hashOriginX=s-this._cellSize,this._hashOriginZ=l-this._cellSize;var D=new Map;for(c=0;c<a;c++)for(var E=Math.min(this._v0x[c],this._v1x[c],this._v2x[c]),V=Math.max(this._v0x[c],this._v1x[c],this._v2x[c]),Y=Math.min(this._v0z[c],this._v1z[c],this._v2z[c]),U=Math.max(this._v0z[c],this._v1z[c],this._v2z[c]),W=Math.floor((E-this._hashOriginX)/this._cellSize),G=Math.floor((V-this._hashOriginX)/this._cellSize),H=Math.floor((Y-this._hashOriginZ)/this._cellSize),z=Math.floor((U-this._hashOriginZ)/this._cellSize),K=W;K<=G;K++)for(var X=H;X<=z;X++){var Q=this._makeHashKey(K,X),j=D.get(Q);D.set(Q,void 0!==j?j+1:1)}var Z=D.size,J=new Uint32Array(Z),q=0;D.forEach(function(e,t){J[q++]=t}),J.sort(),this._htKeys=new Uint32Array(Z),this._htStarts=new Int32Array(Z),this._htCounts=new Int32Array(Z);for(var $=0,ee=0;ee<Z;ee++){var te=J[ee];this._htKeys[ee]=te,this._htStarts[ee]=$,this._htCounts[ee]=D.get(te),$+=this._htCounts[ee]}this._cellTriangles=new Int32Array($);var ie=new Map;for(ee=0;ee<Z;ee++)ie.set(this._htKeys[ee],this._htStarts[ee]);for(c=0;c<a;c++)for(E=Math.min(this._v0x[c],this._v1x[c],this._v2x[c]),V=Math.max(this._v0x[c],this._v1x[c],this._v2x[c]),Y=Math.min(this._v0z[c],this._v1z[c],this._v2z[c]),U=Math.max(this._v0z[c],this._v1z[c],this._v2z[c]),W=Math.floor((E-this._hashOriginX)/this._cellSize),G=Math.floor((V-this._hashOriginX)/this._cellSize),H=Math.floor((Y-this._hashOriginZ)/this._cellSize),z=Math.floor((U-this._hashOriginZ)/this._cellSize),K=W;K<=G;K++)for(X=H;X<=z;X++){Q=this._makeHashKey(K,X);var ne=ie.get(Q);this._cellTriangles[ne]=c,ie.set(Q,ne+1)}return!0},e.prototype.invalidateTransform=function(){this._matrixDirty=!0},e.prototype.getNormalAtPointToRef=function(e,t,i){if(void 0===i&&(i=null),0===this._triangleCount||!this._sourceMesh)return!1;this._matrixDirty&&(this._worldMatrix.copyFrom(this._sourceMesh.getWorldMatrix()),this._worldMatrix.invertToRef(this._invWorldMatrix),this._matrixDirty=!1),BABYLON.Vector3.TransformCoordinatesToRef(e,this._invWorldMatrix,this._scratchLocal);var n=this._scratchLocal.x,r=this._scratchLocal.y,o=this._scratchLocal.z,a=Math.floor((n-this._hashOriginX)/this._cellSize),s=Math.floor((o-this._hashOriginZ)/this._cellSize),l=this._candidatesBuf;l.length=0;for(var u=this.searchRadius,h=-u;h<=u;h++)for(var c=-u;c<=u;c++)if((f=this._bsearchCell(this._makeHashKey(a+h,s+c)))>=0)for(var d=(g=this._htStarts[f])+this._htCounts[f],m=g;m<d;m++)l.push(this._cellTriangles[m]);if(0===l.length){var p=u+1;for(h=-p;h<=p;h++)for(c=-p;c<=p;c++){var f,g;if((f=this._bsearchCell(this._makeHashKey(a+h,s+c)))>=0)for(d=(g=this._htStarts[f])+this._htCounts[f],m=g;m<d;m++)l.push(this._cellTriangles[m])}}if(0===l.length)return!1;var y=this._seenSet;y.clear();var v=this._uniqueBuf;for(v.length=0,m=0;m<l.length;m++)y.has(l[m])||(y.add(l[m]),v.push(l[m]));for(var S=-1,_=1/0,b=-1,B=1/0,C=this.maxLookupDistance*this.maxLookupDistance,A=0;A<v.length;A++){var T=v[A],M=n-this._cx[T],L=o-this._cz[T],P=M*M+L*L;if(!(P>C))if(this.useProjectionTest){var w,x=this._fnx[T],O=this._fny[T],R=this._fnz[T],I=(h=n-this._v0x[T])*x+(r-this._v0y[T])*O+(c=o-this._v0z[T])*R,N=Math.abs(I),k=n-I*x,F=r-I*O,D=o-I*R,E=(W=this._computeBarycentricInline(k,F,D,T))[0],V=W[1],Y=W[2];E>=-.01&&V>=-.01&&Y>=-.01?(w=N+.001*P)<B&&(B=w,b=T):(w=N+.1*P)<_&&(_=w,S=T)}else P<_&&(_=P,S=T)}var U=b>=0?b:S;if(U<0)return!1;x=this._fnx[U],O=this._fny[U],R=this._fnz[U],k=n-(I=(h=n-this._v0x[U])*x+(r-this._v0y[U])*O+(c=o-this._v0z[U])*R)*x,F=r-I*O,D=o-I*R;var W=this._computeBarycentricInline(k,F,D,U),G=Math.max(0,W[0]),H=Math.max(0,W[1]),z=Math.max(0,W[2]),K=G+H+z;K<1e-8?G=H=z=1/3:(G/=K,H/=K,z/=K);var X=G*this._n0x[U]+H*this._n1x[U]+z*this._n2x[U],Q=G*this._n0y[U]+H*this._n1y[U]+z*this._n2y[U],j=G*this._n0z[U]+H*this._n1z[U]+z*this._n2z[U];if(this._scratchV0.set(X,Q,j),BABYLON.Vector3.TransformNormalToRef(this._scratchV0,this._worldMatrix,t),t.normalize(),this.blendWithPhysicsNormal>0&&i){var Z=this.blendWithPhysicsNormal;t.x=t.x*(1-Z)+i.x*Z,t.y=t.y*(1-Z)+i.y*Z,t.z=t.z*(1-Z)+i.z*Z,t.normalize()}return!0},e.prototype.dispose=function(){this._v0x=null,this._v0y=null,this._v0z=null,this._v1x=null,this._v1y=null,this._v1z=null,this._v2x=null,this._v2y=null,this._v2z=null,this._n0x=null,this._n0y=null,this._n0z=null,this._n1x=null,this._n1y=null,this._n1z=null,this._n2x=null,this._n2y=null,this._n2z=null,this._fnx=null,this._fny=null,this._fnz=null,this._cx=null,this._cy=null,this._cz=null,this._cellTriangles=null,this._htKeys=null,this._htStarts=null,this._htCounts=null,this._triangleCount=0,this._sourceMesh=null},e.prototype._makeHashKey=function(e,t){return e+32768+65536*(t+32768)>>>0},e.prototype._bsearchCell=function(e){for(var t=0,i=this._htKeys.length-1;t<=i;){var n=t+i>>>1,r=this._htKeys[n];if(r===e)return n;r<e?t=n+1:i=n-1}return-1},e.prototype._computeBarycentricInline=function(e,t,i,n){var r=this._v0x[n],o=this._v0y[n],a=this._v0z[n],s=this._v1x[n]-r,l=this._v1y[n]-o,u=this._v1z[n]-a,h=this._v2x[n]-r,c=this._v2y[n]-o,d=this._v2z[n]-a,m=e-r,p=t-o,f=i-a,g=s*s+l*l+u*u,y=s*h+l*c+u*d,v=h*h+c*c+d*d,S=m*s+p*l+f*u,_=m*h+p*c+f*d,b=g*v-y*y;if(Math.abs(b)<1e-12)return this._barycentricScratch[0]=1/3,this._barycentricScratch[1]=1/3,this._barycentricScratch[2]=1/3,this._barycentricScratch;var B=(v*S-y*_)/b,C=(g*_-y*S)/b,A=1-B-C;return this._barycentricScratch[0]=A,this._barycentricScratch[1]=B,this._barycentricScratch[2]=C,this._barycentricScratch},e}();e.MeshNormalProxy=t;var i=function(){function e(){this._registry=new Map}return Object.defineProperty(e,"instance",{get:function(){return e._instance||(e._instance=new e),e._instance},enumerable:!1,configurable:!0}),e.prototype.register=function(e,t){e?t&&0!==t.triangleCount?this._registry.set(e,t):console.warn("[SmoothMeshNormalSystem] register: proxy is null or empty — did you call buildFromMesh()?"):console.warn("[SmoothMeshNormalSystem] register: body is null.")},e.prototype.unregister=function(e,t){void 0===t&&(t=!1);var i=this._registry.get(e);i&&(t&&i.dispose(),this._registry.delete(e))},e.prototype.lookup=function(e){return this._registry.get(e)||null},e.prototype.has=function(e){return this._registry.has(e)},Object.defineProperty(e.prototype,"count",{get:function(){return this._registry.size},enumerable:!1,configurable:!0}),e.prototype.disposeAll=function(){this._registry.forEach(function(e){e.dispose()}),this._registry.clear()},e.buildAndRegister=function(i,n,r,o){if(void 0===r&&(r=2),void 0===o&&(o=0),!i)return console.warn("[SmoothMeshNormalSystem] buildAndRegister: mesh is null."),null;if(!i.geometry)return console.warn("[SmoothMeshNormalSystem] buildAndRegister: mesh '"+i.name+"' has no geometry. Ensure the mesh has been properly initialized."),null;if(!n)return console.warn("[SmoothMeshNormalSystem] buildAndRegister: mesh '"+i.name+"' has no physicsBody. Ensure RigidbodyPhysics has run first."),null;var a=new t;return a.blendWithPhysicsNormal=Math.max(0,Math.min(1,o)),a.buildFromMesh(i,r)?(e.instance.register(n,a),a):(a.dispose(),null)},e._instance=null,e}();e.SmoothMeshNormalSystem=i}(n||(n={})),function(e){var t;!function(e){e[e.None=0]="None",e[e.ToGamma=1]="ToGamma",e[e.ToLinear=2]="ToLinear"}(t=e.ColorCorrectionMode||(e.ColorCorrectionMode={}));var i=function(i){function n(e,t,n,r){void 0===n&&(n={}),void 0===r&&(r="TOOLKIT.TerrainBuilder");var o=i.call(this,e,t,n,r)||this;return o.detailLayerContainers=[],o.detailMeshSources=new Map,o}return o(n,i),n.prototype.awake=function(){var t=this.getProperties();t&&e.TerrainBuilder.BuildDetailPrototypes(t,this.transform,this.scene,this)},n.prototype.destroy=function(){this.disposeDetailLayers()},n.prototype.disposeDetailLayers=function(){for(var e=0,t=this.detailLayerContainers;e<t.length;e++)t[e].dispose();this.detailLayerContainers=[],this.detailMeshSources.forEach(function(e,t){try{e.dispose()}catch(e){}}),this.detailMeshSources.clear()},n.BuildDetailPrototypes=function(t,i,n,r){if(t&&t.detaillayers&&0!==t.detaillayers.length)for(var o=t.terrainsize?new BABYLON.Vector3(t.terrainsize[0],t.terrainsize[1],t.terrainsize[2]):new BABYLON.Vector3(500,100,500),a=i.position||BABYLON.Vector3.Zero(),s=t.detailobjectdensity||1,l=null!=t.detailbillboardingmode?t.detailbillboardingmode:0,u=null!=t.detailgrassshadowlevel?t.detailgrassshadowlevel:.7,h=null==t.detailgrassreceiveshadows||t.detailgrassreceiveshadows,c=null!=t.wavinggrassamount?t.wavinggrassamount:.5,d=null!=t.wavinggrassspeed?t.wavinggrassspeed:.5,m=null!=t.wavinggrasssize?t.wavinggrasssize:.5,p=t.wavinggrasstint?new BABYLON.Color4(t.wavinggrasstint[0],t.wavinggrasstint[1],t.wavinggrasstint[2],t.wavinggrasstint[3]||1):new BABYLON.Color4(.7,.8,.5,1),f=0;f<t.detaillayers.length;f++){var g=t.detaillayers[f];if(g.detailscattermode=t.detailscattermode,g.isvalid)try{if(g.useprototypemesh)e.TerrainBuilder.BuildMeshDetailLayer(g,o,a,i,n,s,r);else{var y=null!=s?s:1;e.TerrainBuilder.BuildGrassDetailLayer(g,o,a,i,n,y,c,d,m,p,l,u,h,r)}}catch(e){}}},n.BuildMeshDetailLayer=function(t,i,n,r,o,a,s){var l=t.prototypemeshnodeid?o.getNodeById(t.prototypemeshnodeid):null;if(l&&l instanceof BABYLON.Mesh){var u=new BABYLON.TransformNode("DetailLayer_".concat(t.layerindex,"_").concat(t.prototypemeshname),o);u.parent=r,s&&s.detailLayerContainers.push(u);var h=t.detailinstancepatches&&t.detailinstancepatches.length>0?e.TerrainBuilder.GenerateMeshInstancesFromUnityPatches(t,i,n):null;if(null!=h&&0!==h.length){var c=e.TerrainBuilder.CreateDetailThinInstancesFromDensityMap(l,h,u,o,t);c&&s&&s.detailMeshSources.set("layer_".concat(t.layerindex),c)}}},n.BuildGrassDetailLayer=function(t,i,n,r,o,a,s,l,u,h,c,d,m,p){var f=new BABYLON.TransformNode("DetailLayer_".concat(t.layerindex,"_Grass"),o);f.parent=r,p&&p.detailLayerContainers.push(f);var g=e.TerrainBuilder.CreateGrassPrototype(t,f,o,s,l,u,h,c,d);if(g){var y=e.TerrainBuilder.CreateGrassThinInstancesFromDensityMap(g,t,i,n,a,m,f,o);y&&p&&p.detailMeshSources.set("layer_".concat(t.layerindex),y)}else console.warn("Failed to create grass prototype mesh for layer ".concat(t.layerindex))},n.GenerateMeshInstancesFromUnityPatches=function(t,i,n){var r=[],o=t.detailinstancepatches;if(!o||0===o.length)return r;for(var a=0;a<o.length;a++){var s=o[a],l=s&&s.transforms?s.transforms:null;if(l&&!(l.length<6))for(var u=0;u+5<l.length;u+=6){var h=l[u+0],c=l[u+1],d=l[u+2],m=l[u+3],p=l[u+4],f=l[u+5],g=n.x+h-.5*i.x,y=n.z+d-.5*i.z,v=n.y+c,S=new BABYLON.Vector3(g,v,y),_=e.TerrainBuilder.NormalizeRotation(m),b=new BABYLON.Vector3(p,f,p),B=new BABYLON.Color4(1,1,1,1);r.push({position:S,rotation:_,scale:b,color:B})}}return r},n.CreateGrassThinInstancesFromDensityMap=function(t,i,n,r,o,a,s,l){var u;if(!i.densitymap||!i.densitywidth||!i.densityheight)return null;for(var h=i.densitywidth,c=i.densityheight,d=!1===i.usedensityscaling?1:null!=o?o:1,m=null!=i.targetcoverage?i.targetcoverage:null!=i.density?i.density:1,p=Math.max(0,Math.min(1,m)),f="CoverageMode"===(i.detailscattermode||i.detailScatterMode),g=null!=i.positionjitter?i.positionjitter:null!=i.positionsjitter?i.positionsjitter:null,y=null!=g?g:1,v=null!=i.noisespread?i.noisespread:1,S=n.x/h,_=n.z/c,b=i.minwidth||1,B=i.maxwidth||2,C=i.minheight||1,A=i.maxheight||2,T=Math.max(1e-4,.5*(b+B)),M=Math.max(1e-4,.5*(C+A)),L=S*_,P=T*M,w=!i.useprototypemesh&&(i.healthycolor||i.drycolor),x=i.healthycolor?i.healthycolor[0]:.3,O=i.healthycolor?i.healthycolor[1]:.8,R=i.healthycolor?i.healthycolor[2]:.2,I=i.healthycolor&&i.healthycolor[3]||1,N=i.drycolor?i.drycolor[0]:.8,k=i.drycolor?i.drycolor[1]:.7,F=i.drycolor?i.drycolor[2]:.3,D=i.drycolor&&i.drycolor[3]||1,E=null!=i.noiseseed?i.noiseseed:(null!=i.layerindex?i.layerindex:0)+1,V=function(t,i,n,r){var o=Math.floor(1e3*(v||1));return e.TerrainBuilder.HashToUnitFloat(t+o,i-o,n,E,r)},Y=function(e,t,i){if(i<=0)return 0;var n=0;if((n=f?Math.max(0,Math.min(1,i/255))*p*d*(L/P):i*d*p)<=0)return 0;var r=Math.floor(n),o=n-r;return o<=0?r:r+(V(e,t,0,907)<o?1:0)},U=0,W=0;W<c;W++)for(var G=0;G<h;G++){var H=W*h+G;(re=i.densitymap[H]||0)<=0||(U+=Y(G,W,re))}if(U<=0)return null;var z=new Float32Array(3*U),K=new Float32Array(U),X=new Float32Array(U),Q=new Float32Array(U),j=w?new Float32Array(4*U):null,Z=Number.POSITIVE_INFINITY,J=Number.POSITIVE_INFINITY,q=Number.NEGATIVE_INFINITY,$=Number.NEGATIVE_INFINITY,ee=i&&i.cellcornerheights?i.cellcornerheights:null,te=i&&i.cellheights?i.cellheights:null,ie=null!=i.groundOffset?i.groundOffset:.02,ne=0;for(W=0;W<c;W++)for(G=0;G<h;G++){var re;if(H=W*h+G,!((re=i.densitymap[H]||0)<=0)){var oe=Y(G,W,re);if(!(oe<=0))for(var ae=0;ae<oe;ae++){var se=V(G,W,ae,11),le=V(G,W,ae,43),ue=Math.min(Math.max(y,0),1),he=W*_+(.5+(le-.5)*ue)*_,ce=G*S+(.5+(se-.5)*ue)*S,de=r.x+he-.5*n.z,me=r.z+ce-.5*n.x,pe=r.y;if(ee&&ee.length===(h+1)*(c+1)){var fe=(de-(r.x-.5*n.x))/n.x,ge=(me-(r.z-.5*n.z))/n.z,ye=Math.max(0,Math.min(1,fe))*h,ve=Math.max(0,Math.min(1,ge))*c,Se=ye-(At=Math.floor(ye)),_e=ve-(Me=Math.floor(ve)),be=Math.max(0,Math.min(h,At)),Be=Math.max(0,Math.min(h,At+1)),Ce=Math.max(0,Math.min(c,Me)),Ae=Math.max(0,Math.min(c,Me+1)),Te=h+1;pe=(Oe=(Le=ee[Ce*Te+be])+((Pe=ee[Ce*Te+Be])-Le)*Se)+((we=ee[Ae*Te+be])+((xe=ee[Ae*Te+Be])-we)*Se-Oe)*_e,pe+=ie}else if(te&&te.length===h*c){var Me,Le,Pe,we,xe,Oe;fe=(de-(r.x-.5*n.x))/n.x,ge=(me-(r.z-.5*n.z))/n.z,ye=Math.max(0,Math.min(1,fe))*h-.5,ve=Math.max(0,Math.min(1,ge))*c-.5,Se=ye-(At=Math.floor(ye)),_e=ve-(Me=Math.floor(ve)),be=Math.max(0,Math.min(h-1,At)),Be=Math.max(0,Math.min(h-1,At+1)),Ce=Math.max(0,Math.min(c-1,Me)),Ae=Math.max(0,Math.min(c-1,Me+1)),pe=(Oe=(Le=te[Ce*h+be])+((Pe=te[Ce*h+Be])-Le)*Se)+((we=te[Ae*h+be])+((xe=te[Ae*h+Be])-we)*Se-Oe)*_e,pe+=ie;try{var Re=Math.max(Le,Pe,we,xe);Re-pe>.05&&(pe=.6*pe+.4*Re)}catch(e){}}else pe=r.y;z[0+(Ct=3*ne)]=de,z[Ct+1]=pe,z[Ct+2]=me,de<Z&&(Z=de),me<J&&(J=me),de>q&&(q=de),me>$&&($=me);var Ie=b+V(G,W,ae,71)*(B-b),Ne=(C+V(G,W,ae,17)*(A-C))*e.TerrainBuilder.grassHeightScale;K[ne]=Ie,X[ne]=Ne;var ke=2*Math.PI,Fe=0;if("GrassBillboard"!==(i&&i.rendermode?i.rendermode:"GrassBillboard")&&(Fe=V(G,W,ae,131)*ke,e.TerrainBuilder.grassRandomFlip&&V(G,W,ae,997)<.5&&(Fe+=Math.PI)),Q[ne]=Fe,j){var De=.5;if(i.colorvariationmap&&i.colorvariationmap.length===h*c){var Ee=W*h+G;if(De=i.colorvariationmap[Ee],0===ne&&0===i.layerindex){for(var Ve=1,Ye=0,Ue=0,We=0;We<i.colorvariationmap.length;We++){var Ge=i.colorvariationmap[We];Ge<Ve&&(Ve=Ge),Ge>Ye&&(Ye=Ge),Ue+=Ge}Ue/=i.colorvariationmap.length,console.log("[TerrainBuilder] Color variation map stats: min=".concat(Ve.toFixed(3),", max=").concat(Ye.toFixed(3),", avg=").concat(Ue.toFixed(3)))}}else De=V(G,W,ae,101),0===ne&&0===i.layerindex&&console.warn("[TerrainBuilder] No color variation map found for layer ".concat(i.layerindex,". Using per-instance random. Export colorvariationmap from Unity for exact matching."));var He=x+(N-x)*(De=1-(De=Math.min(1,Math.max(0,De)))),ze=O+(k-O)*De,Ke=R+(F-R)*De,Xe=I+(D-I)*De;j[0+(xt=4*ne)]=He,j[xt+1]=ze,j[xt+2]=Ke,j[xt+3]=Xe}ne++}}}var Qe=Math.min(ne,U);if(Qe<=0)return null;var je=null!==(u=e.TerrainBuilder.detailChunkMode)&&void 0!==u?u:0,Ze=Math.max(1,e.TerrainBuilder.detailChunkTargetInstances||8e3),Je=Math.max(1e-4,e.TerrainBuilder.detailChunkWorldSize||32),qe=Math.max(1,e.TerrainBuilder.detailChunkMaxChunksPerAxis||64),$e=Math.max(1,e.TerrainBuilder.detailChunkMaxTotalChunks||256),et=Math.max(1e-4,q-Z),tt=Math.max(1e-4,$-J),it=1,nt=1;if(0===je){if(it=Math.ceil(et/Je),nt=Math.ceil(tt/Je),it=Math.max(1,Math.min(qe,it)),nt=Math.max(1,Math.min(qe,nt)),(lt=it*nt)>$e){var rt=Math.sqrt(lt/$e);it=Math.max(1,Math.min(qe,Math.ceil(it/rt))),nt=Math.max(1,Math.min(qe,Math.ceil(nt/rt)))}}else{var ot=Math.max(1,Math.ceil(Qe/Ze)),at=Math.ceil(Math.sqrt(ot)),st=Math.max(1,Math.floor(Math.sqrt($e)));at=Math.max(1,Math.min(qe,Math.min(st,at)));var lt,ut=et/tt;it=at,nt=at,ut>1.5?(it=Math.min(qe,Math.ceil(at*Math.sqrt(ut))),nt=Math.max(1,Math.ceil(at/Math.sqrt(ut)))):ut<1/1.5&&(nt=Math.min(qe,Math.ceil(at*Math.sqrt(1/ut))),it=Math.max(1,Math.ceil(at/Math.sqrt(1/ut)))),(lt=it*nt)>$e&&(rt=Math.sqrt(lt/$e),it=Math.max(1,Math.min(qe,Math.ceil(it/rt))),nt=Math.max(1,Math.min(qe,Math.ceil(nt/rt))),lt=it*nt)}var ht=et/it,ct=tt/nt,dt=new BABYLON.TransformNode("".concat(t.name,"_Chunks_L").concat(i.layerindex),l);dt.parent=s;try{t.setEnabled(!1),t.isVisible=!1}catch(e){}var mt=new Map;for(ae=0;ae<Qe;ae++){var pt=z[0+(Ct=3*ae)],ft=z[Ct+2];(At=Math.floor((pt-Z)/ht))<0&&(At=0),(Tt=Math.floor((ft-J)/ct))<0&&(Tt=0),At>=it&&(At=it-1),Tt>=nt&&(Tt=nt-1);var gt=At+Tt*it;mt.set(gt,(mt.get(gt)||0)+1)}var yt=new Map;mt.forEach(function(e,t){var i=new Float32Array(16*e),n=j?new Float32Array(4*e):null;yt.set(t,{count:e,write:0,matrices:i,colors:n})});var vt=new BABYLON.Matrix,St=new BABYLON.Vector3(1,1,1),_t=new BABYLON.Vector3(0,0,0),bt=new BABYLON.Quaternion,Bt=BABYLON.Axis.Y;for(ae=0;ae<Qe;ae++){pt=z[0+(Ct=3*ae)];var Ct,At,Tt,Mt=z[Ct+1];ft=z[Ct+2],(At=Math.floor((pt-Z)/ht))<0&&(At=0),(Tt=Math.floor((ft-J)/ct))<0&&(Tt=0),At>=it&&(At=it-1),Tt>=nt&&(Tt=nt-1),gt=At+Tt*it;var Lt=yt.get(gt);if(Lt){var Pt=Lt.write++;_t.x=pt,_t.y=Mt,_t.z=ft;var wt=K[ae];if(St.x=wt,St.y=X[ae],St.z=wt,BABYLON.Quaternion.RotationAxisToRef(Bt,Q[ae],bt),BABYLON.Matrix.ComposeToRef(St,bt,_t,vt),vt.copyToArray(Lt.matrices,16*Pt),Lt.colors&&j){var xt=4*ae,Ot=(He=Math.min(1,j[xt+0]),ze=Math.min(1,j[xt+1]),Ke=Math.min(1,j[xt+2]),Xe=j[xt+3],4*Pt);Lt.colors[Ot+0]=e.TerrainBuilder.DoColorCorrection(He,e.TerrainBuilder.grassColorCorrectionMode),Lt.colors[Ot+1]=e.TerrainBuilder.DoColorCorrection(ze,e.TerrainBuilder.grassColorCorrectionMode),Lt.colors[Ot+2]=e.TerrainBuilder.DoColorCorrection(Ke,e.TerrainBuilder.grassColorCorrectionMode),Lt.colors[Ot+3]=Xe}}}var Rt=null,It=0;return yt.forEach(function(n,r){if(n&&!(n.count<=0)){var o=function(n,r){var o,s,u,h,c,d;if(!n||n.count<=0)return null;var m=r%it,p=Math.floor(r/it),f="".concat(t.name,"_L").concat(i.layerindex,"_C").concat(m,"_").concat(p,"_").concat(It),g=t.clone(f,dt);if(!g)return null;try{g.makeGeometryUnique()}catch(e){}g.setEnabled(!0),g.isVisible=!0,g.applyFog=e.TerrainBuilder.grassReceiveFog,g.receiveShadows=a,g.thinInstanceEnablePicking=!1;try{null===(s=(o=g).thinInstanceSetBuffer)||void 0===s||s.call(o,"matrix",null,16,!0)}catch(e){}try{null===(h=(u=g).thinInstanceSetBuffer)||void 0===h||h.call(u,"color",null,4,!0)}catch(e){}g.thinInstanceSetBuffer("matrix",n.matrices,16,!0),n.colors&&(g.thinInstanceSetBuffer("color",n.colors,4,!0),g.useVertexColors=!0,g.hasVertexAlpha=!0);try{null===(d=(c=g).thinInstanceRefreshBoundingInfo)||void 0===d||d.call(c,!0)}catch(e){}try{var y=g.material;if(y&&"function"==typeof y.setFloatValue){var v=null!=i.maxdistance?i.maxdistance:0;y.setFloatValue("g_maxDistance",v);var S=v>0?Math.max(0,.75*v):0;y.setFloatValue("g_fadeStart",S)}}catch(e){}try{l&&l.lights&&l.lights.forEach(function(t){try{var i=t.getShadowGenerator?t.getShadowGenerator():null;if(i){var n=i.getShadowMap?i.getShadowMap():null;if(n)if(e.TerrainBuilder.grassCastShadows)n.renderList||(n.renderList=[]),-1===n.renderList.indexOf(g)&&n.renderList.push(g);else if(n.renderList){var r=n.renderList.indexOf(g);-1!==r&&n.renderList.splice(r,1)}}}catch(e){}})}catch(e){}return g.metadata=g.metadata||{},g.metadata.toolkit=g.metadata.toolkit||{},g.metadata.toolkit.castRealtimeShadow=e.TerrainBuilder.grassCastShadows,g.metadata.toolkit.terrainDetailLayer=i.layerindex,g.metadata.toolkit.terrainDetailChunked=!0,g}(n,r);o&&(It++,Rt||(Rt=o))}}),Rt||(dt.dispose(),null)},n.CreateDetailThinInstancesFromDensityMap=function(t,i,n,r,o){var a,s;if(!i||0===i.length)return null;var l=t;try{var u=t.clone("".concat(t.name,"_DetailSourceNorm_L").concat(o.layerindex),n,!1,!1);if(u){try{u.makeGeometryUnique()}catch(e){}try{u.bakeCurrentTransformIntoVertices()}catch(e){}u.position.set(0,0,0),u.rotationQuaternion=BABYLON.Quaternion.Identity(),u.scaling.set(1,1,1),u.setEnabled(!1),u.isVisible=!1,l=u}}catch(e){l=t}for(var h=!!o.useprototypemesh,c=h?null!==(a=e.TerrainBuilder.meshDetailChunkMode)&&void 0!==a?a:1:null!==(s=e.TerrainBuilder.detailChunkMode)&&void 0!==s?s:0,d=Math.max(1,(h?e.TerrainBuilder.meshDetailChunkTargetInstances:e.TerrainBuilder.detailChunkTargetInstances)||8e3),m=Math.max(1e-4,(h?e.TerrainBuilder.meshDetailChunkWorldSize:e.TerrainBuilder.detailChunkWorldSize)||32),p=Math.max(1,e.TerrainBuilder.detailChunkMaxChunksPerAxis||64),f=Math.max(1,e.TerrainBuilder.detailChunkMaxTotalChunks||256),g=Number.POSITIVE_INFINITY,y=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,S=Number.NEGATIVE_INFINITY,_=0;_<i.length;_++){var b=i[_].position;b.x<g&&(g=b.x),b.z<y&&(y=b.z),b.x>v&&(v=b.x),b.z>S&&(S=b.z)}var B=Math.max(1e-4,v-g),C=Math.max(1e-4,S-y),A=1,T=1;if(0===c){if(A=Math.ceil(B/m),T=Math.ceil(C/m),A=Math.max(1,Math.min(p,A)),T=Math.max(1,Math.min(p,T)),(x=A*T)>f){var M=Math.sqrt(x/f);A=Math.max(1,Math.min(p,Math.ceil(A/M))),T=Math.max(1,Math.min(p,Math.ceil(T/M)))}}else{var L=Math.max(1,Math.ceil(i.length/d)),P=Math.ceil(Math.sqrt(L)),w=Math.max(1,Math.floor(Math.sqrt(f)));P=Math.max(1,Math.min(p,Math.min(w,P)));var x,O=B/C;A=P,T=P,O>1.5?(A=Math.min(p,Math.ceil(P*Math.sqrt(O))),T=Math.max(1,Math.ceil(P/Math.sqrt(O)))):O<1/1.5&&(T=Math.min(p,Math.ceil(P*Math.sqrt(1/O))),A=Math.max(1,Math.ceil(P/Math.sqrt(1/O)))),(x=A*T)>f&&(M=Math.sqrt(x/f),A=Math.max(1,Math.min(p,Math.ceil(A/M))),T=Math.max(1,Math.min(p,Math.ceil(T/M))),x=A*T)}var R=B/A,I=C/T,N=new BABYLON.TransformNode("".concat(t.name,"_Chunks_L").concat(o.layerindex),r);N.parent=n;var k=new Map;for(_=0;_<i.length;_++){var F=i[_],D=Math.floor((F.position.x-g)/R),E=Math.floor((F.position.z-y)/I);D<0&&(D=0),E<0&&(E=0),D>=A&&(D=A-1),E>=T&&(E=T-1);var V=D+E*A,Y=k.get(V);Y?Y.push(F):k.set(V,[F])}try{t.setEnabled(!1),t.isVisible=!1}catch(e){}var U=!o.useprototypemesh&&(o.healthycolor||o.drycolor),W=null,G=0;return k.forEach(function(i,n){if(i&&0!==i.length){var a=n%A,s=Math.floor(n/A),u=function(t,i){var n,a,s,u,h,c;if(!t||0===t.length)return null;var d=l.clone(i,N);if(!d)return null;try{d.makeGeometryUnique()}catch(e){}d.setEnabled(!0),d.isVisible=!0,d.receiveShadows=!1,d.applyFog=!0,d.thinInstanceEnablePicking=!1;for(var m=new Float32Array(16*t.length),p=U?new Float32Array(4*t.length):null,f=new BABYLON.Matrix,g=new BABYLON.Quaternion,y=0;y<t.length;y++){var v=t[y],S=16*y,_=v.scale;if(BABYLON.Quaternion.RotationAxisToRef(BABYLON.Axis.Y,v.rotation,g),BABYLON.Matrix.ComposeToRef(_,g,v.position,f),f.copyToArray(m,S),p){var b=4*y,B=Math.min(1,v.color.r),C=Math.min(1,v.color.g),A=Math.min(1,v.color.b);p[b]=e.TerrainBuilder.DoColorCorrection(B,e.TerrainBuilder.grassColorCorrectionMode),p[b+1]=e.TerrainBuilder.DoColorCorrection(C,e.TerrainBuilder.grassColorCorrectionMode),p[b+2]=e.TerrainBuilder.DoColorCorrection(A,e.TerrainBuilder.grassColorCorrectionMode),p[b+3]=v.color.a}}try{null===(a=(n=d).thinInstanceSetBuffer)||void 0===a||a.call(n,"matrix",null,16,!0)}catch(e){}try{null===(u=(s=d).thinInstanceSetBuffer)||void 0===u||u.call(s,"color",null,4,!0)}catch(e){}d.thinInstanceSetBuffer("matrix",m,16,!0),p&&(d.thinInstanceSetBuffer("color",p,4,!0),d.useVertexColors=!0,d.hasVertexAlpha=!0);try{null===(c=(h=d).thinInstanceRefreshBoundingInfo)||void 0===c||c.call(h,!0)}catch(e){}try{var T=d.material;if(T&&"function"==typeof T.setFloatValue){var M=null!=o.maxdistance?o.maxdistance:0;T.setFloatValue("g_maxDistance",M);var L=M>0?Math.max(0,.75*M):0;T.setFloatValue("g_fadeStart",L)}}catch(e){}try{r&&r.lights&&r.lights.forEach(function(t){try{var i=t.getShadowGenerator?t.getShadowGenerator():null;if(i){var n=i.getShadowMap?i.getShadowMap():null;if(n)if(e.TerrainBuilder.grassCastShadows)n.renderList||(n.renderList=[]),-1===n.renderList.indexOf(d)&&n.renderList.push(d);else if(n.renderList){var r=n.renderList.indexOf(d);-1!==r&&n.renderList.splice(r,1)}}}catch(e){}})}catch(e){}return d.metadata=d.metadata||{},d.metadata.toolkit=d.metadata.toolkit||{},d.metadata.toolkit.castRealtimeShadow=e.TerrainBuilder.grassCastShadows,d.metadata.toolkit.terrainDetailLayer=o.layerindex,d.metadata.toolkit.terrainDetailChunked=!0,d}(i,"".concat(t.name,"_L").concat(o.layerindex,"_C").concat(a,"_").concat(s,"_").concat(G));u&&(G++,W||(W=u))}}),W||(N.dispose(),null)},n.CreateGrassPrototype=function(t,i,n,r,o,a,s,l,u){var h=t.rendermode||"GrassBillboard",c=(null!=t.prototypetexture&&null!=t.prototypetexture.filename&&t.prototypetexture.filename,((t.minwidth||1)+(t.maxwidth||2))/2),d=((t.minheight||1)+(t.maxheight||2))/2*e.TerrainBuilder.grassHeightScale,m=null;if("GrassBillboard"===h?m=e.TerrainBuilder.CreateSingleQuadBillboard("GrassBillboard_".concat(t.layerindex),c,d,n):"Grass"===h?m=e.TerrainBuilder.CreateCrossQuadGrass("GrassCross_".concat(t.layerindex),c,d,n):"VertexLit"===h&&((m=BABYLON.MeshBuilder.CreatePlane("GrassPlane_".concat(t.layerindex),{width:c,height:d},n)).rotation.x=Math.PI/2),!m)return null;m.parent=i,m.isVisible=!1,m.applyFog=!0,"VertexLit"!==h&&e.TerrainBuilder.ApplyUpNormals(m);var p="GrassBillboard"===h?new e.GrassBillboardMaterial("GrassBillboardMaterial_".concat(t.layerindex),n):new e.GrassStandardMaterial("GrassStandardMaterial_".concat(t.layerindex),n);if(null!=t.prototypetexture&&null!=t.prototypetexture.filename&&""!==t.prototypetexture.filename){var f="scenes/".concat(t.prototypetexture.filename),g=new BABYLON.Texture(f,n);g.hasAlpha=!0,g.gammaSpace=!0,g.updateSamplingMode(BABYLON.Texture.TRILINEAR_SAMPLINGMODE),g.anisotropicFilteringLevel=4,g.wrapU=BABYLON.Texture.CLAMP_ADDRESSMODE,g.wrapV=BABYLON.Texture.CLAMP_ADDRESSMODE,(p instanceof e.GrassStandardMaterial||p instanceof e.GrassBillboardMaterial)&&(p.diffuseTexture=g,p.useAlphaFromDiffuseTexture=!0),p.alphaCutOff=.3;try{p.setFloatValue("g_alphaCutoff",null!=p.alphaCutOff?p.alphaCutOff:.3)}catch(e){}}else p.alphaCutOff=.3,p.emissiveColor=new BABYLON.Color3(0,0,0),t&&t.healthycolor&&(p instanceof e.GrassStandardMaterial||p instanceof e.GrassBillboardMaterial)&&(p.diffuseColor=new BABYLON.Color3(e.TerrainBuilder.DoColorCorrection(t.healthycolor[0],e.TerrainBuilder.grassColorCorrectionMode),e.TerrainBuilder.DoColorCorrection(t.healthycolor[1],e.TerrainBuilder.grassColorCorrectionMode),e.TerrainBuilder.DoColorCorrection(t.healthycolor[2],e.TerrainBuilder.grassColorCorrectionMode)));if(p instanceof e.GrassStandardMaterial){if(p.diffuseTexture){p.diffuseColor=new BABYLON.Color3(1,1,1);try{p.setFloatValue("g_alphaCutoff",null!=p.alphaCutOff?p.alphaCutOff:.3)}catch(e){}}}else if(p instanceof e.GrassBillboardMaterial&&p.diffuseTexture){p.diffuseColor=new BABYLON.Color3(1,1,1);try{p.setFloatValue("g_alphaCutoff",null!=p.alphaCutOff?p.alphaCutOff:.3)}catch(e){}}return p.roughness=1,p.twoSidedLighting=!0,p.backFaceCulling=!1,p.emissiveColor=new BABYLON.Color3(0,0,0),p.transparencyMode=BABYLON.Material.MATERIAL_ALPHATEST,p.separateCullingPass=!0,m.material=p,p.setFloatValue("g_maxDistance",0),p.setFloatValue("g_fadeStart",0),p.setFloatValue("g_windAmount",null!=r?r:.5),p.setFloatValue("g_waveSpeed",null!=o?o:.5),p.setFloatValue("g_waveSize",null!=a?a:.5),p.setVector4Value("g_windTint",new BABYLON.Vector4(s.r,s.g,s.b,s.a)),p.setShadowIntensity(u),p instanceof e.GrassBillboardMaterial&&p.setSphericalBillboardEnabled(0===l),m},n.CreateSingleQuadBillboard=function(e,t,i,n){var r=[],o=[],a=[],s=[],l=t/2;r.push(-l,0,0,l,0,0,l,i,0,-l,i,0),o.push(0,1,2,0,2,3),s.push(0,0,1,0,1,1,0,1);for(var u=0;u<4;u++)a.push(0,1,0);var h=new BABYLON.Mesh(e,n),c=new BABYLON.VertexData;return c.positions=r,c.indices=o,c.normals=a,c.uvs=s,c.applyToMesh(h),h},n.CreateCrossQuadGrass=function(e,t,i,n){var r=[],o=[],a=[],s=[],l=t/2;r.push(-l,0,0,l,0,0,l,i,0,-l,i,0),r.push(0,0,-l,0,0,l,0,i,l,0,i,-l),o.push(0,1,2,0,2,3,4,5,6,4,6,7),s.push(0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1);for(var u=0;u<8;u++)a.push(0,1,0);var h=new BABYLON.Mesh(e,n),c=new BABYLON.VertexData;return c.positions=r,c.indices=o,c.normals=a,c.uvs=s,c.applyToMesh(h),h},n.ApplyUpNormals=function(e){var t=e.getVerticesData(BABYLON.VertexBuffer.PositionKind);if(t){for(var i=new Array(t.length),n=0;n<t.length;n+=3)i[n]=0,i[n+1]=1,i[n+2]=0;e.setVerticesData(BABYLON.VertexBuffer.NormalKind,i,!1)}},n.HashToUnitFloat=function(e,t,i,n,r){var o=374761393*e+668265263*t+1442695041*i+374761393*n+374761393*r;return o=1274126177*(o^o>>13),((o^=o>>16)>>>0)/4294967296},n.NormalizeRotation=function(e){var t=2*Math.PI,i=e%t;return i<0&&(i+=t),i},n.DoColorCorrection=function(i,n){switch(n){case t.ToGamma:return e.TerrainBuilder.LinearToGamma(i);case t.ToLinear:return e.TerrainBuilder.GammaToLinear(i);case t.None:default:return i}},n.GammaToLinear=function(e){var t=Math.max(0,Math.min(1,e));return Math.pow(t,2.2)},n.LinearToGamma=function(e){var t=Math.max(0,Math.min(1,e));return Math.pow(t,1/2.2)},n.grassHeightScale=.85,n.grassRandomFlip=!1,n.grassCastShadows=!1,n.grassReceiveFog=!0,n.grassColorCorrectionMode=1,n.detailChunkMode=0,n.detailChunkTargetInstances=8e3,n.detailChunkWorldSize=32,n.detailChunkMaxChunksPerAxis=64,n.detailChunkMaxTotalChunks=256,n.meshDetailChunkMode=1,n.meshDetailChunkTargetInstances=2e4,n.meshDetailChunkWorldSize=64,n}(e.ScriptComponent);e.TerrainBuilder=i,e.SceneManager.RegisterClass("TOOLKIT.TerrainBuilder",i)}(n||(n={})),function(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t}(BABYLON.GUI.Slider);e.UnitySlider=t;var i=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._direction="LeftToRight",t}return o(t,e),Object.defineProperty(t.prototype,"direction",{get:function(){return this._direction},set:function(e){this._direction=e,this._markAsDirty()},enumerable:!1,configurable:!0}),t.prototype._getThumbPosition=function(){var e=(this.value-this.minimum)/(this.maximum-this.minimum),t=this.isVertical?this._currentMeasure.height-this._effectiveThumbThickness:this._currentMeasure.width-this._effectiveThumbThickness,i=e*t;return"RightToLeft"!==this._direction||this.isVertical?"TopToBottom"===this._direction&&this.isVertical&&(i=t-i):i=t-i,i},t.prototype.serialize=function(t){e.prototype.serialize.call(this,t),t.direction=this._direction},t.prototype._parseFromContent=function(t,i){e.prototype._parseFromContent.call(this,t,i),t.direction&&(this._direction=t.direction)},t}(BABYLON.GUI.ScrollBar);e.UnityScrollBar=i;var n=function(e){function t(t){var i=e.call(this,t||"dropdownMenu")||this;i._button=null,i._popup=null,i._options=[],i._selectedIndex=0,i.width="150px",i.height="30px",i.thickness=1,i.cornerRadius=3,i.color="#333333",i.background="transparent",console.warn("DropdownMenu is a custom control and may not be fully supported in all environments."),i._button=BABYLON.GUI.Button.CreateSimpleButton((i.name||"")+"_btn",""),i._button.width="100%",i._button.height="100%",i._button.horizontalAlignment=BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,i._button.verticalAlignment=BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER,i._button.cornerRadius=3,i._button.thickness=0,i._button.color="#000000",i._button.background="#ffffff00";var n=new BABYLON.GUI.TextBlock((i.name||"")+"_label","");n.textHorizontalAlignment=BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,n.paddingLeft="8px",n.resizeToFit=!1,n.text="",n.color="#000000",n.fontSize="14px",n.textWrapping=!0,i._button.addControl(n);var r=new BABYLON.GUI.TextBlock((i.name||"")+"_arrow","▼");r.width="24px",r.textHorizontalAlignment=BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER,r.horizontalAlignment=BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_RIGHT,r.paddingRight="6px",r.color="#222222",i._button.addControl(r),i._popup=new BABYLON.GUI.Container((i.name||"")+"_popup"),i._popup.width="150px",i._popup.isVisible=!1,i._popup.background="#ffffff",i._popup.thickness=1,i._popup.cornerRadius=3,i._popup.zIndex=1e3,i._popup.verticalAlignment=BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;var o=new BABYLON.GUI.StackPanel((i.name||"")+"_stack");return o.isVertical=!0,i._popup.addControl(o),i._button.onPointerUpObservable.add(function(){i._popup&&(i._popup.isVisible=!i._popup.isVisible)}),i.addControl(i._button),i.addControl(i._popup),i}return o(t,e),Object.defineProperty(t.prototype,"selectedIndex",{get:function(){return this._selectedIndex},set:function(e){this._selectedIndex=e,this._updateSelectedText()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{set:function(e){this._options=e||[],this._rebuildOptions()},enumerable:!1,configurable:!0}),t.prototype._updateSelectedText=function(){if(this._button){var e=this._button.getChildByName((this.name||"")+"_label");if(e){var t=this._options[this._selectedIndex];e.text=t?t.text:""}}},t.prototype._rebuildOptions=function(){var e=this;if(this._popup){this._popup.dispose(),this._popup=new BABYLON.GUI.Container((this.name||"")+"_popup"),this._popup.width="150px",this._popup.isVisible=!1,this._popup.background="#ffffff",this._popup.thickness=1,this._popup.cornerRadius=3,this._popup.zIndex=1e3,this._popup.verticalAlignment=BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;var t=new BABYLON.GUI.StackPanel((this.name||"")+"_stack");t.isVertical=!0,this._popup.addControl(t);for(var i=function(i){var r=n._options[i],o=BABYLON.GUI.Button.CreateSimpleButton((n.name||"")+"_opt_"+i,r.text||"");o.width="100%",o.height="28px",o.thickness=0,o.cornerRadius=0,o.color="#000000",o.horizontalAlignment=BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,o.onPointerUpObservable.add(function(){e.selectedIndex=i,e._popup&&(e._popup.isVisible=!1),e.onSelectionChanged&&e.onSelectionChanged(i)}),t.addControl(o)},n=this,r=0;r<this._options.length;r++)i(r);this.addControl(this._popup),this._updateSelectedText()}},t.prototype.serialize=function(){var e={};try{var t=BABYLON.GUI.Container.prototype.serialize;"function"==typeof t&&(e=t.call(this)||{})}catch(t){e={}}return(e=e||{}).className="UnityDropdownMenu",e.options=this._options.map(function(e){return{text:e.text,imageSource:e.imageSource}}),e.selectedIndex=this._selectedIndex,e},t.Parse=function(e,i,n){var r=new t(e.name||"dropdownMenu");try{Array.isArray(e.options)&&(r.options=e.options.map(function(e){return{text:e.text||"",imageSource:e.imageSource}})),"number"==typeof e.selectedIndex&&(r.selectedIndex=e.selectedIndex)}catch(e){console.warn(e)}return r},t}(BABYLON.GUI.Container);e.UnityDropdownMenu=n,e.SceneManager.RegisterClass("BABYLON.GUI.UnitySlider",t),e.SceneManager.RegisterClass("BABYLON.GUI.UnityScrollBar",i),e.SceneManager.RegisterClass("BABYLON.GUI.UnityDropdownMenu",n)}(n||(n={})),function(e){var t=function(t){function i(e,i,n,r){return void 0===n&&(n={}),void 0===r&&(r="TOOLKIT.UserInterface"),t.call(this,e,i,n,r)||this}return o(i,t),i.prototype.start=function(){return s(this,void 0,void 0,function(){var t,i,n,r,o;return l(this,function(a){switch(a.label){case 0:return null==(t=this.getProperty("gui"))?[3,2]:(i=e.SceneManager.GetRootUrl(this.scene)||"",n=!1,r=!0,o=this.extractRequiredFonts(t),[4,this.loadRequiredFonts(o,i)]);case 1:if(a.sent(),this.parseNodeObject(t.root||t.controls,i),e.UserInterface.LoadForegroundInterfaceData(this.scene,t,BABYLON.Texture.BILINEAR_SAMPLINGMODE,r,null,n),e.UserInterface.OnInterfaceLoaded&&e.UserInterface.OnInterfaceLoaded.hasObservers())try{e.UserInterface.OnInterfaceLoaded.notifyObservers(this.transform.name)}catch(e){console.warn(e instanceof Error?e.message:String(e))}a.label=2;case 2:return[2]}})})},i.prototype.parseNodeObject=function(e,t){var n=this;if(null!=e&&(this.processNodeSources(e,t),null!=e.children&&Array.isArray(e.children)&&e.children.forEach(function(e){n.parseNodeObject(e,t)}),i.OnParseNodeObject&&i.OnParseNodeObject.hasObservers()))try{i.OnParseNodeObject.notifyObservers(e)}catch(e){console.warn(e instanceof Error?e.message:String(e))}},i.prototype.processNodeSources=function(e,t){if(null!=e&&"object"==typeof e){if(e.source&&"string"==typeof e.source&&e.source.startsWith("assets/")){var i=t&&!t.endsWith("/")?t+"/":t;e.source,e.source=i+e.source}for(var n in e)e.hasOwnProperty(n)&&"object"==typeof e[n]&&null!==e[n]&&"children"!==n&&this.processNodeSources(e[n],t)}},i.prototype.extractRequiredFonts=function(e){var t=new Set,i=function(e){e.fontFamily&&"Arial"!==e.fontFamily&&"sans-serif"!==e.fontFamily&&t.add(e.fontFamily),e.children&&Array.isArray(e.children)&&e.children.forEach(i)};return e.root&&i(e.root),Array.from(t)},i.prototype.loadRequiredFonts=function(e,t){return s(this,void 0,void 0,function(){var i,n,r=this;return l(this,function(o){switch(o.label){case 0:return e&&0!==e.length?[4,this.loadFontManifest(t)]:[2];case 1:return i=o.sent(),n=e.map(function(e){return r.loadSingleFont(e,i,t)}),[4,Promise.allSettled(n)];case 2:return o.sent().forEach(function(t,i){"fulfilled"===t.status||console.warn("✗ Font failed: ".concat(e[i]),t.reason)}),[4,document.fonts.ready];case 3:return o.sent(),[2]}})})},i.prototype.loadFontManifest=function(e){return s(this,void 0,void 0,function(){var t;return l(this,function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),[4,fetch(e+"font-manifest.json")];case 1:return(t=i.sent()).ok?[4,t.json()]:[3,3];case 2:return[2,i.sent()];case 3:return[3,5];case 4:return i.sent(),console.warn("No Font Manifest Found, Using Web Fonts Fallback"),[3,5];case 5:return[2,[]]}})})},i.prototype.loadSingleFont=function(e,t,i){return s(this,void 0,void 0,function(){var n;return l(this,function(r){switch(r.label){case 0:return(n=t.find(function(t){return t.family===e}))?[4,this.loadUnityFont(n,i)]:[3,2];case 1:case 3:return r.sent(),[2];case 2:return this.isGoogleFont(e)?[4,this.loadGoogleFont(e)]:[3,4];case 4:return this.isSystemFontAvailable(e)||console.warn("Font Not Available: ".concat(e)),[2]}})})},i.prototype.loadUnityFont=function(e,t){return s(this,void 0,void 0,function(){var i,n,r;return l(this,function(o){switch(o.label){case 0:i=t+e.path,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,(n=new FontFace(e.family,"url('".concat(i,"') format('truetype')"),{style:e.style||"normal",weight:e.weight||"normal",display:"swap"})).load()];case 2:return o.sent(),document.fonts.add(n),[3,4];case 3:return r=o.sent(),console.warn("Failed To Load Unity Font: ".concat(e.family),r),[3,4];case 4:return[2]}})})},i.prototype.loadGoogleFont=function(e){return s(this,void 0,void 0,function(){return l(this,function(t){return[2,new Promise(function(t,i){var n=document.createElement("link");n.rel="stylesheet",n.href="https://fonts.googleapis.com/css2?family=".concat(encodeURIComponent(e),":wght@400;700&display=swap"),n.onload=function(){t()},n.onerror=function(){return i(new Error("Failed To Load Google Font: ".concat(e)))},document.head.appendChild(n)})]})})},i.prototype.isGoogleFont=function(e){return["Roboto","Open Sans","Lato","Montserrat","Source Sans Pro","Oswald","Raleway","Poppins","Merriweather","Nunito","Ubuntu","Playfair Display","Work Sans","Fira Sans","Noto Sans","PT Sans","Crimson Text","Inter"].includes(e)},i.prototype.isSystemFontAvailable=function(e){var t=document.createElement("canvas").getContext("2d"),i="mmmmmmmmmmlli";t.font="72px monospace";var n=t.measureText(i).width;return t.font='72px "'.concat(e,'", monospace'),t.measureText(i).width!==n},i.CreateInternalUserInterface=function(e,t,i,n){return 1==t?(e._foregroundTexture=BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("Default-Screen-UI",!0,e,i,n),e._foregroundTexture):(e._backgroundTexture=BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("Background-Screen-UI",!1,e,i,n),e._backgroundTexture)},i.LoadForegroundInterfaceData=function(t,i,n,r,o,a){if(null==t._foregroundTexture&&(t._foregroundTexture=e.UserInterface.CreateInternalUserInterface(t,!0,n,a)),null!=i){var s=t._foregroundTexture&&null!=t._foregroundTexture._textureInitialized&&!0===t._foregroundTexture._textureInitialized;e.UserInterface.ParseUserInterfaceObject(t,t._foregroundTexture,i,r,o,s),t._foregroundTexture._textureInitialized=!0}t.getEngine().resize(!0)},i.LoadBackgroundInterfaceData=function(t,i,n,r,o,a){if(null==t._backgroundTexture&&(t._backgroundTexture=e.UserInterface.CreateInternalUserInterface(t,!1,n,a)),null!=i){var s=t._backgroundTexture&&null!=t._backgroundTexture._textureInitialized&&!0===t._backgroundTexture._textureInitialized;e.UserInterface.ParseUserInterfaceObject(t,t._backgroundTexture,i,r,o,s),t._backgroundTexture._textureInitialized=!0}t.getEngine().resize(!0)},i.ParseUserInterfaceObject=function(t,i,n,r,o,a){if(n&&i){e.UserInterface.FixUserInterfacePrototypes();var s=t.getEngine().getHardwareScalingLevel()||1,l=Number.isFinite(+n.canvasScalerMode)?+n.canvasScalerMode:1,u=Number.isFinite(+n.renderScaleFactor)&&+n.renderScaleFactor>0?+n.renderScaleFactor:1,h=Number.isFinite(+n.fallbackScreenDpi)&&+n.fallbackScreenDpi>0?+n.fallbackScreenDpi:72,c=Number.isFinite(+n.defaultSpriteDpi)&&+n.defaultSpriteDpi>0?+n.defaultSpriteDpi:72,d=Number.isFinite(+n.referencePixelsPerUnit)&&+n.referencePixelsPerUnit>0?+n.referencePixelsPerUnit:100,m=Number.isFinite(+n.pixelScaleFactor)&&+n.pixelScaleFactor>0?+n.pixelScaleFactor:1,p=e.UserInterface.PHYSICAL_SIZE_POINT_FACTOR,f=Number(n.width),g=Number(n.height),y=Number.isFinite(f)&&f>0&&Number.isFinite(g)&&g>0,v=y?f:1920,S=y?g:1080,_=function(e){e.width="100%",e.height="100%",e.left="0px",e.top="0px",e.horizontalAlignment=BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,e.verticalAlignment=BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP},b=function(e){return JSON.parse(JSON.stringify(e))},B=function(e){if("number"==typeof e)return Number.isFinite(e);if("string"==typeof e){var t=e.trim().toLowerCase();return!t.endsWith("%")&&(t.endsWith("px")?Number.isFinite(parseFloat(t)):/^-?\d+(\.\d+)?$/.test(t))}return!1},C=function(e,t){if(e&&"object"==typeof e){var i=new Set(["left","top","width","height","minWidth","minHeight","maxWidth","maxHeight","marginLeft","marginRight","marginTop","marginBottom","paddingLeft","paddingRight","paddingTop","paddingBottom","fontSize","thickness","cornerRadius","shadowOffsetX","shadowOffsetY","shadowBlur","linkOffsetX","linkOffsetY"]),n=new Set(["cornerRadiusX","cornerRadiusY","cornerRadiusZ","cornerRadiusW"]),r=function(e){if(null==e)return e;if("number"==typeof e)return Math.round(e*t);if("string"==typeof e){var i=e.trim();if(i.endsWith("%"))return e;if(i.toLowerCase().endsWith("px")){var n=parseFloat(i);return Number.isFinite(n)?"".concat(Math.round(n*t),"px"):e}return/^-?\d+(\.\d+)?$/.test(i)?(n=parseFloat(i),Number.isFinite(n)?"".concat(Math.round(n*t),"px"):e):e}if("object"==typeof e){for(var o=0,a=["left","top","right","bottom","x","y","w","h","value"];o<a.length;o++){var s=a[o];s in e&&B(e[s])&&(e[s]=r(e[s]))}return e}return e};for(var o in e)(i.has(o)||n.has(o))&&(e[o]=r(e[o]));if(e.style&&"object"==typeof e.style)for(var o in e.style)(i.has(o)||n.has(o))&&(e.style[o]=r(e.style[o]));var a=e.children;if(Array.isArray(a))for(var s=0,l=a;s<l.length;s++){var u=l[s];C(u,t)}}};if(!0!==a){if(1===l){var A=Number(n.idealWidth),T=Number(n.idealHeight),M=Number.isFinite(A)&&A>0?A:NaN,L=Number.isFinite(T)&&T>0?T:NaN;!Number.isFinite(M)&&Number.isFinite(L)&&y?M=Math.round(L*v/S):!Number.isFinite(L)&&Number.isFinite(M)&&y&&(L=Math.round(M*S/v)),i.renderScale=1/s*u,Number.isFinite(M)&&Number.isFinite(L)?(i.idealWidth=M,i.idealHeight=L,i.useSmallestIdeal=!!n.useSmallestIdeal,i.renderAtIdealSize=!0):y?(i.idealWidth=v,i.idealHeight=S,i.useSmallestIdeal=!0,i.renderAtIdealSize=!0):i.renderAtIdealSize=!1;var P=BABYLON.GUI.Control.Parse(n.root,i,o);return _(P),i._rootContainer=P,e.UserInterface.ProcessTextSpacingProperties(P,n.root),e.UserInterface.ProcessHdrColors(P,n.root),e.UserInterface.ApplyHdrVisualEnhancements(P),e.UserInterface.ProcessPreserveAspectRatio(P,n.root),e.UserInterface.ProcessControlEvents(t,P,n.root),i.__canvasScalerMode=l,i.__cpsScale=1,i.__defaultSpriteDpi=c,i.__fallbackScreenDpi=h,i.__referencePixelsPerUnit=d,r&&!i.renderAtIdealSize&&i.scaleTo(v,S),void i.markAsDirty()}i.renderScale=1,i.renderAtIdealSize=!1,i.idealWidth=void 0,i.idealHeight=void 0,i.useSmallestIdeal=void 0;var w=0===l?m:p,x=b(n.root);Number.isFinite(w)&&1!==w&&C(x,w);var O=BABYLON.GUI.Control.Parse(x,i,o);_(O),i._rootContainer=O,e.UserInterface.ProcessTextSpacingProperties(O,n.root),e.UserInterface.ProcessHdrColors(O,n.root),e.UserInterface.ApplyHdrVisualEnhancements(O),e.UserInterface.ProcessPreserveAspectRatio(O,n.root),e.UserInterface.ProcessControlEvents(t,O,n.root),i.__canvasScalerMode=l,i.__cpsScale=0===l?m:1,i.__defaultSpriteDpi=c,i.__fallbackScreenDpi=h,i.__referencePixelsPerUnit=d,i.markAsDirty()}else{for(var R=null!=n.root&&null!=n.root.children&&n.root.children.length>0?n.root.children[0]:n.root,I=0===l?m:2===l?p:1,N=0,k=Array.isArray(null==R?void 0:R.children)&&(null==R?void 0:R.typeName)?R.children:[R];N<k.length;N++){var F=k[N],D=F;1===I||0!==l&&2!==l||(D=b(F),C(D,I));var E=BABYLON.GUI.Control.Parse(D,i,o);E&&(i.addControl(E),e.UserInterface.ProcessTextSpacingProperties(E,F),e.UserInterface.ProcessHdrColors(E,F),e.UserInterface.ApplyHdrVisualEnhancements(E),e.UserInterface.ProcessPreserveAspectRatio(E,F),e.UserInterface.ProcessControlEvents(t,E,F))}i.markAsDirty()}}},i.FixUserInterfacePrototypes=function(){var t=globalThis||window,i=t&&t.BABYLON,n=i&&i.GUI,r=n&&n.Image,o=n&&n.Control;o&&(o.__prototypeFunctionsPatched||(o.__prototypeFunctionsPatched=!0,o.prototype.getScene=function(){var e;return null===(e=this._host)||void 0===e?void 0:e.getScene()},r.prototype._renderNinePatch=function(t,i,n,r,o){var a,s,l,u,h,c,d,m,p,f,g,y,v,S=null!==(s=null===(a=this.host)||void 0===a?void 0:a.__canvasScalerMode)&&void 0!==s?s:1,_=null!==(u=null===(l=this.host)||void 0===l?void 0:l.__cpsScale)&&void 0!==u?u:1,b=null!==(c=null===(h=this.host)||void 0===h?void 0:h.__referencePixelsPerUnit)&&void 0!==c?c:100,B=null!==(m=null===(d=this.host)||void 0===d?void 0:d.__defaultSpriteDpi)&&void 0!==m?m:96,C=(null===(p=this.host)||void 0===p?void 0:p.__fallbackScreenDpi,null!==(g=null===(f=this.metadata)||void 0===f?void 0:f.spritePixelsPerUnit)&&void 0!==g?g:b),A=this.host.idealWidth?this._currentMeasure.width/this.host.idealWidth:this.host.idealHeight?this._currentMeasure.height/this.host.idealHeight:1;0===S?(A*=_,A*=b/C):1===S?(A=null!==(v=null===(y=this.host)||void 0===y?void 0:y.idealRatio)&&void 0!==v?v:1,A*=b/C):2===S&&(A*=e.UserInterface.PHYSICAL_SIZE_SLICE_FACTOR,A*=b/C,A*=1/(B/96*1));var T=this._sliceLeft,M=this._sliceTop,L=r-this._sliceRight,P=o-this._sliceBottom,w=this._sliceRight-this._sliceLeft,x=this._sliceBottom-this._sliceTop,O=Math.round(T*A),R=Math.round(M*A),I=Math.round(P*A),N=Math.round(L*A),k=Math.max(0,Math.round(this._currentMeasure.width)-N-O+2),F=Math.max(0,Math.round(this._currentMeasure.height)-I-R+2),D=Math.round(this._currentMeasure.left)+O-1,E=Math.round(this._currentMeasure.top)+R-1,V=Math.round(this._currentMeasure.left+this._currentMeasure.width)-N,Y=Math.round(this._currentMeasure.top+this._currentMeasure.height)-I;this._drawImage(t,i,n,T,M,this._currentMeasure.left,this._currentMeasure.top,O,R),this._drawImage(t,i+this._sliceLeft,n,w,M,D+1,this._currentMeasure.top,k-2,R),this._drawImage(t,i+this._sliceRight,n,L,M,V,this._currentMeasure.top,N,R),this._drawImage(t,i,n+this._sliceTop,T,x,this._currentMeasure.left,E+1,O,F-2),this._drawImage(t,i+this._sliceLeft,n+this._sliceTop,w,x,D+1,E+1,k-2,F-2),this._drawImage(t,i+this._sliceRight,n+this._sliceTop,L,x,V,E+1,N,F-2),this._drawImage(t,i,n+this._sliceBottom,T,P,this._currentMeasure.left,Y,O,I),this._drawImage(t,i+this._sliceLeft,n+this._sliceBottom,w,P,D+1,Y,k-2,I),this._drawImage(t,i+this._sliceRight,n+this._sliceBottom,L,P,V,Y,N,I)}))},i.ProcessControlEvents=function(e,t,i){var n=this,r=function(t,i){i&&t&&(n.processUnityUIEvents(e,t,i),n.processUIToolkitEvents(e,t,i),t instanceof BABYLON.GUI.Container&&t.children.forEach(function(e,t){var n=i&&i.children?i.children[t]:null;r(e,n)}))};r(t,i)},i.processUnityUIEvents=function(e,t,i){i.onClick&&this.isUnityUIEvent(i.onClick)&&this.wireUnityUIButtonEvents(e,t,i.onClick),i.onValueChanged&&this.isUnityUIEvent(i.onValueChanged)&&"Toggle"===i.className&&this.wireUnityUIToggleEvents(e,t,i.onValueChanged),i.onValueChanged&&this.isUnityUIEvent(i.onValueChanged)&&"Slider"===i.className&&this.wireUnityUISliderEvents(e,t,i.onValueChanged),i.onValueChanged&&this.isUnityUIEvent(i.onValueChanged)&&"Dropdown"===i.className&&this.wireUnityUIDropdownEvents(e,t,i.onValueChanged),i.onValueChanged&&this.isUnityUIEvent(i.onValueChanged)&&"ScrollRect"===i.className&&this.wireUnityUIScrollRectEvents(e,t,i.onValueChanged),"InputField"===i.className&&this.wireUnityUIInputFieldEvents(e,t,i)},i.processUIToolkitEvents=function(e,t,i){i.isUIToolkit&&(i.events&&"Button"===i.className&&this.wireUIToolkitButtonEvents(e,t,i),i.events&&"Toggle"===i.className&&this.wireUIToolkitToggleEvents(e,t,i),!i.events||"Slider"!==i.className&&"SliderInt"!==i.className||this.wireUIToolkitSliderEvents(e,t,i),i.events&&"DropdownField"===i.className&&this.wireUIToolkitDropdownEvents(e,t,i))},i.isUnityUIEvent=function(e){return e&&e.events&&Array.isArray(e.events)&&e.events.some(function(e){return e.targetName||e.targetType||e.methodName})},i.wireUnityUIButtonEvents=function(e,t,i){var n=this;i.events&&Array.isArray(i.events)&&i.events.forEach(function(i){var r=n.findTargetObject(e,i.targetName,i.targetPath,i.targetInstanceId,i.targetType);null!=r&&(r.args=n.extractParameters(i.mode,i.parameters),t.onPointerClickObservable.add(function(){n.executeUnityUIEvent(r,i)}))})},i.wireUnityUIToggleEvents=function(e,t,i){i.events&&Array.isArray(i.events)},i.wireUnityUISliderEvents=function(e,t,i){i.events&&Array.isArray(i.events)},i.wireUnityUIDropdownEvents=function(e,t,i){i.events&&Array.isArray(i.events)},i.wireUnityUIScrollRectEvents=function(e,t,i){i.events&&Array.isArray(i.events)},i.wireUnityUIInputFieldEvents=function(e,t,i){BABYLON.GUI.InputText},i.wireUIToolkitButtonEvents=function(e,t,i){i.events&&Array.isArray(i.events)},i.wireUIToolkitToggleEvents=function(e,t,i){i.events&&Array.isArray(i.events)},i.wireUIToolkitSliderEvents=function(e,t,i){i.events&&Array.isArray(i.events)},i.wireUIToolkitDropdownEvents=function(e,t,i){i.events&&Array.isArray(i.events)},i.executeUnityUIEvent=function(e,t){for(var i,n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];try{e.instance&&e.instance[t.methodName]&&"function"==typeof e.instance[t.methodName]?null!=e.args?(i=e.instance)[t.methodName].apply(i,e.args):e.instance[t.methodName]():console.warn("⚠️ UI Event: Target not found or method missing: ".concat(t.targetPath||t.targetName,".").concat(t.methodName))}catch(e){console.error("❌ Error Executing UI event: ".concat(t.methodName),e)}},i.executeUIToolkitEvent=function(e,t){for(var i=[],n=2;n<arguments.length;n++)i[n-2]=arguments[n]},i.findTargetObject=function(e,t,i,n,r){var o=null;if(null!=e&&null!=t){var a=e.getNodeByName(t);if(null!=a&&null!=a.metadata&&null!=a.metadata.toolkit&&null!=a.metadata.toolkit.components&&a.metadata.toolkit.components.length>0)for(var s=a.metadata.toolkit.components.length,l=0;l<s;l++){var u=a.metadata.toolkit.components[l],h=u.klass,c=h.lastIndexOf(".");if(-1!==c&&(h=h.substring(c+1)),h===r&&u.instanceID===n){o=u;break}}}return o},i.extractParameters=function(e,t){for(var i=[],n=2;n<arguments.length;n++)i[n-2]=arguments[n];var r=[];return i&&i.length>0&&r.push.apply(r,i),t?(6===e&&null!=t.boolArgument&&r.push(t.boolArgument),5===e&&null!=t.stringArgument&&r.push(t.stringArgument),4===e&&null!=t.floatArgument&&r.push(t.floatArgument),3===e&&null!=t.intArgument&&r.push(t.intArgument),2===e&&t.objectArgument,r):r},i.resolveObjectReference=function(e){return BABYLON.EngineStore.LastCreatedScene,null},i.executeUIToolkitCallback=function(e,t){for(var i=[],n=2;n<arguments.length;n++)i[n-2]=arguments[n];var r=window.uiToolkitCallbackRegistry;if(r&&r[e]&&r[e][t]){var o=r[e][t];"function"==typeof o&&o.apply(void 0,i)}else console.warn("⚠️ UI Toolkit callback not registered: ".concat(e,".").concat(t))},i.ProcessHdrColors=function(e,t){var i=this,n=function(e,t){if(e instanceof BABYLON.GUI.TextBlock&&t&&"TextBlock"===t.className){var r=e;if(t.colorIsHDR&&t.colorHdrMultiplier&&t.colorHdrMultiplier>1){var o=i.emulateUnityHDR(t.color,t.colorHdrMultiplier,t.hdrToneMapping);r.color=o.color,r._hdrMultiplier=t.colorHdrMultiplier,r._originalColor=t.color,i.applyHdrEffects(r,o,t.hdrToneMapping)}if(t.outlineColorIsHDR&&t.outlineColorHdrMultiplier&&t.outlineColorHdrMultiplier>1){var a=i.emulateUnityHDR(t.outlineColor,t.outlineColorHdrMultiplier,t.hdrToneMapping);r._hdrOutlineColor=a.color,r._hdrOutlineMultiplier=t.outlineColorHdrMultiplier}if(t.outlineBlur&&t.outlineBlur>0&&(r.outlineBlur=t.outlineBlur),t.faceSoftness&&t.faceSoftness>0&&(r.faceSoftness=t.faceSoftness),t.faceDilate&&0!==t.faceDilate&&(r.faceDilate=t.faceDilate),t.shadowColorIsHDR&&t.shadowColorHdrMultiplier&&t.shadowColorHdrMultiplier>1){var s=i.emulateUnityHDR(t.shadowColor,t.shadowColorHdrMultiplier,t.hdrToneMapping);r._hdrShadowColor=s.color,r._hdrShadowMultiplier=t.shadowColorHdrMultiplier}if(t.glowEnabled&&t.glowColor){var l=t.glowColorIsHDR&&t.glowColorHdrMultiplier>1?i.emulateUnityHDR(t.glowColor,t.glowColorHdrMultiplier,t.hdrToneMapping):{color:t.glowColor,cssFilter:""};r._glowEnabled=!0,r._glowColor=l.color,r._glowOffset=t.glowOffset||0,r._glowInner=t.glowInner||0,r._glowOuter=t.glowOuter||0,r._glowPower=t.glowPower||1,r._hdrGlowMultiplier=t.glowColorHdrMultiplier||1,i.applyGlowEffects(r,l,t)}if(t.lightingEnabled){var u=t.lightColorIsHDR&&t.lightColorHdrMultiplier>1?i.emulateUnityHDR(t.lightColor,t.lightColorHdrMultiplier,t.hdrToneMapping):{color:t.lightColor||"#ffffff",cssFilter:""},h=t.specularColorIsHDR&&t.specularColorHdrMultiplier>1?i.emulateUnityHDR(t.specularColor,t.specularColorHdrMultiplier,t.hdrToneMapping):{color:t.specularColor||"#ffffff",cssFilter:""},c=t.envMapColorIsHDR&&t.envMapColorHdrMultiplier>1?i.emulateUnityHDR(t.envMapColor,t.envMapColorHdrMultiplier,t.hdrToneMapping):{color:t.envMapColor||"#88aadd",cssFilter:""};r._lightingEnabled=!0,r._lightColor=u.color,r._bevelAmount=t.bevelAmount||0,r._bevelOffset=t.bevelOffset||0,r._bevelWidth=t.bevelWidth||0,r._bevelRoundness=t.bevelRoundness||0,r._bevelClamp=t.bevelClamp||1,r._lightAngle=t.lightAngle||0,r._specularPower=t.specularPower||1,r._reflectance=t.reflectance||.5,r._hdrLightMultiplier=t.lightColorHdrMultiplier||1,r._specularColor=h.color,r._shininess=t.shininess||1,r._envMapSampling=t.envMapSampling||0,r._envMapColor=c.color,r._bumpIntensity=t.bumpIntensity||0,r._hdrSpecularMultiplier=t.specularColorHdrMultiplier||1,r._hdrEnvMapMultiplier=t.envMapColorHdrMultiplier||1,i.applyAdvancedLightingEffects(r,u,h,c,t)}}e instanceof BABYLON.GUI.Container&&e.children.forEach(function(e,i){var r=t&&t.children?t.children[i]:null;n(e,r)})};n(e,t)},i.emulateUnityHDR=function(e,t,i){var n=this.parseRgbaColor(e);if(!n)return{color:e,cssFilter:""};var r=(null==i?void 0:i.exposure)||1,o=(null==i?void 0:i.gamma)||2.2,a=(null==i?void 0:i.saturation)||.9,s=(null==i?void 0:i.brightness)||1.1;return this.applyUnityHDRToneMapping(n,t,{exposure:r,gamma:o,saturation:a,brightness:s})},i.applyUnityHDRToneMapping=function(e,t,i){var n=Math.min(t*i.exposure,3),r=e.r/255,o=e.g/255,a=e.b/255,s=.299*(r=1-Math.exp(-r*n))+.587*(o=1-Math.exp(-o*n))+.114*(a=1-Math.exp(-a*n)),l=Math.min(.2*(t-1),.5);r=r*(1-l)+s*l,o=o*(1-l)+s*l,a=a*(1-l)+s*l;var u=1/i.gamma;r=Math.pow(r,u),o=Math.pow(o,u),a=Math.pow(a,u);var h=1+.3*(t-1);r=Math.min(r*h,1),o=Math.min(o*h,1),a=Math.min(a*h,1);var c=Math.round(255*r),d=Math.round(255*o),m=Math.round(255*a),p="rgba(".concat(c,",").concat(d,",").concat(m,",").concat(e.a,")"),f=Math.min(1+.15*(t-1),1.5),g=Math.max(i.saturation,.7);return{color:p,cssFilter:"brightness(".concat(f,") saturate(").concat(g,")")}},i.applyHdrEffects=function(e,t,i){e.color=t.color,e._hdrEnabled=!0,e._hdrCssFilter=t.cssFilter,e._hdrToneMapping=i},i.applyGlowEffects=function(e,t,i){e._glowEnabled=!0,e._glowColor=t.color,e._glowOffset=i.glowOffset||0,e._glowInner=i.glowInner||0,e._glowOuter=i.glowOuter||0,e._glowPower=i.glowPower||1;var n=i.glowInner||0,r=i.glowOuter||0,o=i.glowOffset||0,a=i.glowPower||1,s=Math.max(n,r),l=Math.max(2,8*s*a),u=[];if(n>0){var h=.3*l;u.push("0 0 ".concat(h,"px ").concat(t.color))}if(r>0){var c=l;if(u.push("".concat(o,"px ").concat(o,"px ").concat(c,"px ").concat(t.color)),r>.5){var d=1.5*l;u.push("0 0 ".concat(d,"px ").concat(t.color))}}u.length>0&&(e._glowCssFilter="drop-shadow(".concat(u.join(") drop-shadow("),")"))},i.applyLightingEffects=function(e,t,i){e._lightingEnabled=!0,e._lightColor=t.color,e._bevelAmount=i.bevelAmount||0,e._bevelOffset=i.bevelOffset||0,e._bevelWidth=i.bevelWidth||0,e._bevelRoundness=i.bevelRoundness||0,e._bevelClamp=i.bevelClamp||1,e._lightAngle=i.lightAngle||0,e._specularPower=i.specularPower||1,e._reflectance=i.reflectance||.5;var n=i.bevelAmount||0,r=i.bevelWidth||0,o=(i.lightAngle||0)*Math.PI/180;if(n>0&&r>0){var a=Math.cos(o)*r,s=Math.sin(o)*r,l=-a,u=-s,h=this.parseRgbaColor(t.color),c=h?"rgba(".concat(Math.min(255,h.r+50),", ").concat(Math.min(255,h.g+50),", ").concat(Math.min(255,h.b+50),", ").concat(.6*h.a,")"):"rgba(255, 255, 255, 0.6)",d=h?"rgba(".concat(Math.max(0,h.r-100),", ").concat(Math.max(0,h.g-100),", ").concat(Math.max(0,h.b-100),", ").concat(.4*h.a,")"):"rgba(0, 0, 0, 0.4)",m=[];if(m.push("".concat(a,"px ").concat(s,"px 0px ").concat(c)),m.push("".concat(l,"px ").concat(u,"px 0px ").concat(d)),n>.5){var p=h?"rgba(".concat(h.r,", ").concat(h.g,", ").concat(h.b,", ").concat(.3*h.a,")"):"rgba(255, 255, 255, 0.3)";m.push("".concat(.5*a,"px ").concat(.5*s,"px 1px ").concat(p))}e._lightingCssFilter="drop-shadow(".concat(m.join(") drop-shadow("),")")}},i.applyAdvancedLightingEffects=function(e,t,i,n,r){e._lightingEnabled=!0,e._lightColor=t.color,e._specularColor=i.color,e._envMapColor=n.color;var o=r.bevelAmount||0,a=r.bevelWidth||0,s=(r.lightAngle||0)*Math.PI/180,l=r.shininess||1,u=r.envMapSampling||0,h=r.bumpIntensity||0,c=r.specularPower||1,d=[];if(o>0&&a>0){var m=Math.cos(s)*a,p=Math.sin(s)*a,f=-m,g=-p,y=this.parseRgbaColor(t.color),v=y?"rgba(".concat(Math.min(255,y.r+50),", ").concat(Math.min(255,y.g+50),", ").concat(Math.min(255,y.b+50),", ").concat(.6*y.a,")"):"rgba(255, 255, 255, 0.6)",S=y?"rgba(".concat(Math.max(0,y.r-100),", ").concat(Math.max(0,y.g-100),", ").concat(Math.max(0,y.b-100),", ").concat(.4*y.a,")"):"rgba(0, 0, 0, 0.4)";d.push("".concat(m,"px ").concat(p,"px 0px ").concat(v)),d.push("".concat(f,"px ").concat(g,"px 0px ").concat(S))}if(l>1&&"#ffffff"!==i.color){var _=this.parseRgbaColor(i.color);if(_){var b=Math.min(1,l/10),B="rgba(".concat(_.r,", ").concat(_.g,", ").concat(_.b,", ").concat(.8*b,")"),C=Math.cos(s+Math.PI)*(.3*a),A=Math.sin(s+Math.PI)*(.3*a);if(d.push("".concat(C,"px ").concat(A,"px ").concat(Math.max(1,l),"px ").concat(B)),c>2){var T="rgba(".concat(_.r,", ").concat(_.g,", ").concat(_.b,", ").concat(.4*b,")");d.push("".concat(1.5*C,"px ").concat(1.5*A,"px ").concat(2*l,"px ").concat(T))}}}if(u>0&&"#88aadd"!==n.color){var M=this.parseRgbaColor(n.color);if(M){var L=Math.min(.6,u),P="rgba(".concat(M.r,", ").concat(M.g,", ").concat(M.b,", ").concat(L,")"),w=Math.max(2,5*u);d.push("0 0 ".concat(w,"px ").concat(P));var x=2*Math.cos(s+Math.PI/2),O=2*Math.sin(s+Math.PI/2);d.push("".concat(x,"px ").concat(O,"px ").concat(.7*w,"px ").concat(P))}}if(h>0){var R="rgba(0, 0, 0, ".concat(Math.min(.3,.5*h),")"),I="rgba(255, 255, 255, ".concat(Math.min(.2,.3*h),")"),N=.5*Math.cos(s),k=.5*Math.sin(s);d.push("".concat(N,"px ").concat(k,"px 0px ").concat(I)),d.push("".concat(-N,"px ").concat(-k,"px 0px ").concat(R))}d.length>0&&(e._lightingCssFilter="drop-shadow(".concat(d.join(") drop-shadow("),")"))},i.parseRgbaColor=function(e){var t=e.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3]),a:t[4]?parseFloat(t[4]):1}:null},i.ApplyHdrVisualEnhancements=function(e){var t=function(e){if(e instanceof BABYLON.GUI.TextBlock){var i=e;if(i._hdrEnabled){i._hdrCssFilter;var n=i._hdrMultiplier;n&&n>2&&(i._needsGlowEffect=!0)}}e instanceof BABYLON.GUI.Container&&e.children.forEach(function(e){t(e)})};t(e)},i.ProcessPreserveAspectRatio=function(e,t){},i.applyPreserveAspectRatio=function(e,t){},i.ProcessTextSpacingProperties=function(t,i){var n=this,r=function(t,i){if(t instanceof BABYLON.GUI.TextBlock&&i&&"TextBlock"===i.className){var o=t,a=o.fontSize||"18px",s=parseFloat(a.toString().replace(/px$/,""));if(i.characterSpacing&&0!==i.characterSpacing){var l=parseFloat(i.characterSpacing);if(!isNaN(l)&&0!==l){var u=l*(s*e.UserInterface.CHARACTER_WORD_SPACE_FACTOR);o._characterSpacing=u,n.applyCharacterSpacing(o,u)}}if(i.wordSpacing&&0!==i.wordSpacing&&(l=parseFloat(i.wordSpacing),isNaN(l)||0===l||(u=l*(s*e.UserInterface.CHARACTER_WORD_SPACE_FACTOR),o._wordSpacing=u,n.applyWordSpacing(o,u))),i.paragraphSpacing&&0!==i.paragraphSpacing&&(l=parseFloat(i.paragraphSpacing),!isNaN(l)&&0!==l))if(u=l*s,o._paragraphSpacing=u,o.lineSpacing){var h=parseFloat(o.lineSpacing.toString().replace(/px$/,""));o.lineSpacing=h+u+"px"}else o.lineSpacing=u+"px"}t instanceof BABYLON.GUI.Container&&t.children.forEach(function(e,t){var n=i&&i.children?i.children[t]:null;r(e,n)})};r(t,i)},i.applyCharacterSpacing=function(e,t){var i=e.text;if(i&&t>0){var n=e._drawText;if(n&&(e._drawText=function(e,i,r,o){if(t>0){o.save();var a=this.shadowOffsetX||0,s=this.shadowOffsetY||0,l=this.shadowBlur||0,u=this._hdrShadowColor||this.shadowColor||"transparent",h=this.outlineWidth||0,c=this.outlineBlur||0,d=this._hdrOutlineColor||this.outlineColor||"transparent",m=this.faceSoftness||0,p=this.faceDilate||0;if(0!==p){var f=Math.max(0,1+2*p);f>0&&(o.lineWidth=f,o.strokeStyle=o.fillStyle)}var g=this._hdrCssFilter,y=this._glowCssFilter,v=this._lightingCssFilter,S="";if(m>0){var _=Math.min(3,2*m);S="blur(".concat(_,"px)")}var b=[];g&&b.push(g),y&&b.push(y),v&&b.push(v),S&&b.push(S),b.length>0&&void 0!==o.filter&&(o.filter=b.join(" ")),(0!==a||0!==s||l>0)&&(o.shadowOffsetX=a,o.shadowOffsetY=s,o.shadowBlur=l,o.shadowColor=u),h>0&&(o.strokeStyle=d,o.lineWidth=h);for(var B=e.split(""),C=this._currentMeasure.left,A=0,T=0;T<B.length;T++)A+=o.measureText(B[T]).width,T<B.length-1&&(A+=t);for(this.textHorizontalAlignment===BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER?C+=(this._currentMeasure.width-A)/2:this.textHorizontalAlignment===BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_RIGHT&&(C+=this._currentMeasure.width-A),T=0;T<B.length;T++)h>0&&(c>0?(o.save(),o.shadowColor=d,o.shadowBlur=c,o.shadowOffsetX=0,o.shadowOffsetY=0,o.strokeStyle=d,o.lineWidth=h,o.strokeText(B[T],C,r),o.restore()):o.strokeText(B[T],C,r)),0!==p&&(o.save(),o.strokeStyle=o.fillStyle,o.lineWidth=Math.abs(2*p),o.strokeText(B[T],C,r),o.restore()),o.fillText(B[T],C,r),C+=o.measureText(B[T]).width+t;o.restore()}else n.call(this,e,i,r,o)}),!n){var r=i.split("").join(" ");e.text=r}}},i.applyWordSpacing=function(e,t){var i=e._drawText;if(i)e._drawText=function(e,n,r,o){if(t>0){o.save();var a=this.shadowOffsetX||0,s=this.shadowOffsetY||0,l=this.shadowBlur||0,u=this._hdrShadowColor||this.shadowColor||"transparent",h=this.outlineWidth||0,c=this.outlineBlur||0,d=this._hdrOutlineColor||this.outlineColor||"transparent",m=this.faceSoftness||0,p=this.faceDilate||0,f=this._hdrCssFilter,g=this._glowCssFilter,y=this._lightingCssFilter,v="";if(m>0){var S=Math.min(3,2*m);v="blur(".concat(S,"px)")}var _=[];f&&_.push(f),g&&_.push(g),y&&_.push(y),v&&_.push(v),_.length>0&&void 0!==o.filter&&(o.filter=_.join(" ")),(0!==a||0!==s||l>0)&&(o.shadowOffsetX=a,o.shadowOffsetY=s,o.shadowBlur=l,o.shadowColor=u),h>0&&(o.strokeStyle=d,o.lineWidth=h);for(var b=e.split(" "),B=this._currentMeasure.left,C=0,A=0;A<b.length;A++)C+=o.measureText(b[A]).width,A<b.length-1&&(C+=o.measureText(" ").width+t);for(this.textHorizontalAlignment===BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER?B+=(this._currentMeasure.width-C)/2:this.textHorizontalAlignment===BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_RIGHT&&(B+=this._currentMeasure.width-C),A=0;A<b.length;A++)h>0&&(c>0?(o.save(),o.shadowColor=d,o.shadowBlur=c,o.shadowOffsetX=0,o.shadowOffsetY=0,o.strokeStyle=d,o.lineWidth=h,o.strokeText(b[A],B,r),o.restore()):o.strokeText(b[A],B,r)),0!==p&&(o.save(),o.strokeStyle=o.fillStyle,o.lineWidth=Math.abs(2*p),o.strokeText(b[A],B,r),o.restore()),o.fillText(b[A],B,r),B+=o.measureText(b[A]).width,A<b.length-1&&(B+=o.measureText(" ").width+t);o.restore()}else i.call(this,e,n,r,o)};else{var n=e.text.split(" ").join(" ");e.text=n}},i.IsForegroundReady=function(e){return null!=e._foregroundTexture},i.SetForegroundTexture=function(e,t){e._foregroundTexture=t},i.GetForegroundTexture=function(t,i){return void 0===i&&(i=null),null==t._foregroundTexture&&null!=i&&(t._foregroundTexture=e.UserInterface.CreateInternalUserInterface(t,!0,null==i?void 0:i.samplerMode,null==i?void 0:i.adaptiveHardwareScaling)),t._foregroundTexture},i.IsBackgroundReady=function(e){return null!=e._backgroundTexture},i.SetBackgroundTexture=function(e,t){e._backgroundTexture=t},i.GetBackgroundTexture=function(t,i){return void 0===i&&(i=null),null==t._backgroundTexture&&null!=i&&(t._backgroundTexture=e.UserInterface.CreateInternalUserInterface(t,!1,null==i?void 0:i.samplerMode,null==i?void 0:i.adaptiveHardwareScaling)),t._backgroundTexture},i.GetCanvasElement=function(e,t){var i=t||BABYLON.EngineStore.LastCreatedScene;return null!=i._foregroundTexture?i._foregroundTexture.getControlByName(e):null},i.ShowCanvasElement=function(t){return s(this,arguments,void 0,function(t,i,n){var r;return void 0===i&&(i=0),void 0===n&&(n=1),l(this,function(o){switch(o.label){case 0:return null==t?[3,3]:i>0?(r=t.alpha,t.isVisible=!0,[4,e.SceneManager.TweenFromToAsync(t,{alpha:r},{alpha:1},{duration:i,speed:n})]):[3,2];case 1:return o.sent(),t.isEnabled=!0,[3,3];case 2:t.isEnabled=!0,t.isVisible=!0,t.alpha=1,o.label=3;case 3:return[2]}})})},i.HideCanvasElement=function(t){return s(this,arguments,void 0,function(t,i,n){var r;return void 0===i&&(i=0),void 0===n&&(n=1),l(this,function(o){switch(o.label){case 0:return null==t?[3,3]:i>0?(t.isEnabled=!1,r=t.alpha,t.isEnabled=!1,[4,e.SceneManager.TweenFromToAsync(t,{alpha:r},{alpha:0},{duration:i,speed:n})]):[3,2];case 1:return o.sent(),t.isVisible=!1,[3,3];case 2:t.isEnabled=!1,t.isVisible=!1,t.alpha=0,o.label=3;case 3:return[2]}})})},i.AttachClickHandler=function(e,t){return null==e||null==t?null:e.onPointerClickObservable.add(t)},i.PHYSICAL_SIZE_SLICE_FACTOR=1.5,i.PHYSICAL_SIZE_POINT_FACTOR=1.915,i.CHARACTER_WORD_SPACE_FACTOR=.01,i.OnParseNodeObject=new BABYLON.Observable,i.OnInterfaceLoaded=new BABYLON.Observable,i}(e.ScriptComponent);e.UserInterface=t,e.SceneManager.RegisterClass("TOOLKIT.UserInterface",t)}(n||(n={})),function(e){var t=function(t){function i(e,i,n,r){void 0===n&&(n={}),void 0===r&&(r="TOOLKIT.WebVideoPlayer");var o=t.call(this,e,i,n,r)||this;return o.videoLoop=!1,o.videoMuted=!1,o.videoAlpha=!1,o.videoFaded=!1,o.videoPoster=null,o.videoInvert=!0,o.videoSample=3,o.videoVolume=1,o.videoMipmaps=!1,o.videoPlayback=1,o.videoPlayOnAwake=!0,o.videoPreloaderUrl=null,o.videoBlobUrl=null,o.videoPreload=!1,o._initializedReadyInstance=!1,o.onReadyObservable=new BABYLON.Observable,o.m_abstractMesh=null,o.m_videoTexture=null,o.m_videoMaterial=null,o.m_diffuseIntensity=1,o}return o(i,t),i.prototype.getVideoMaterial=function(){return this.m_videoMaterial},i.prototype.getVideoTexture=function(){return this.m_videoTexture},i.prototype.getVideoElement=function(){return null!=this.m_videoTexture?this.m_videoTexture.video:null},i.prototype.getVideoScreen=function(){return this.m_abstractMesh},i.prototype.getVideoBlobUrl=function(){return this.videoBlobUrl},i.prototype.awake=function(){this.awakeWebVideoPlayer()},i.prototype.destroy=function(){this.destroyWebVideoPlayer()},i.prototype.awakeWebVideoPlayer=function(){this.videoLoop=this.getProperty("looping",!1),this.videoMuted=this.getProperty("muted",!1),this.videoInvert=this.getProperty("inverty",!0),this.videoSample=this.getProperty("sampling",3),this.videoVolume=this.getProperty("volume",1),this.videoMipmaps=this.getProperty("mipmaps",!1),this.videoAlpha=this.getProperty("texturealpha",!1),this.videoFaded=this.getProperty("diffusealpha",!1),this.videoPlayback=this.getProperty("playbackspeed",1),this.videoPlayOnAwake=this.getProperty("playonawake",!0),this.videoPreload=this.getProperty("preload",this.videoPreload),this.m_diffuseIntensity=this.getProperty("intensity",1),this.m_abstractMesh=this.getAbstractMesh(),!0===this.getProperty("poster")&&null!=this.m_abstractMesh&&null!=this.m_abstractMesh.material&&(this.m_abstractMesh.material instanceof BABYLON.PBRMaterial?null!=this.m_abstractMesh.material.albedoTexture&&null!=this.m_abstractMesh.material.albedoTexture.url&&""!==this.m_abstractMesh.material.albedoTexture.url&&(this.videoPoster=this.m_abstractMesh.material.albedoTexture.url.replace("data:","")):this.m_abstractMesh.material instanceof BABYLON.StandardMaterial&&null!=this.m_abstractMesh.material.diffuseTexture&&null!=this.m_abstractMesh.material.diffuseTexture.url&&""!==this.m_abstractMesh.material.diffuseTexture.url&&(this.videoPoster=this.m_abstractMesh.material.diffuseTexture.url.replace("data:","")));var t=this.getProperty("url",null),i=this.getProperty("source",null),n=t;null!=i&&null!=i.filename&&""!==i.filename&&(n=e.SceneManager.GetRootUrl(this.scene)+i.filename),null!=n&&""!==n&&(!0===this.videoPreload?this.videoPreloaderUrl=n:this.setDataSource(n))},i.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),this.revokeVideoBlobUrl()},i.prototype.isReady=function(){return null!=this.getVideoElement()},i.prototype.isPlaying=function(){var e=!1,t=this.getVideoElement();return null!=t&&(e=!1===t.paused),e},i.prototype.isPaused=function(){var e=!1,t=this.getVideoElement();return null!=t&&(e=!0===t.paused),e},i.prototype.play=function(){return s(this,void 0,void 0,function(){return l(this,function(t){switch(t.label){case 0:return[4,e.AudioSource.UnlockAudioEngine()];case 1:return t.sent(),this.internalPlay(),[2,!0]}})})},i.prototype.internalPlay=function(){var e=this;!0===this._initializedReadyInstance?this.checkedPlay():this.onReadyObservable.addOnce(function(){e.checkedPlay()})},i.prototype.checkedPlay=function(){var e=this,t=this.getVideoElement();null!=t&&t.play().then(function(){!0===t.paused&&e.checkedRePlay()})},i.prototype.checkedRePlay=function(){var e=this.getVideoElement();null!=e&&e.play().then(function(){})},i.prototype.pause=function(){var e=!1,t=this.getVideoElement();return null!=t&&(t.pause(),e=!0),e},i.prototype.mute=function(){var e=!1,t=this.getVideoElement();return null!=t&&(t.muted=!0,e=!0),e},i.prototype.unmute=function(){var e=!1,t=this.getVideoElement();return null!=t&&(t.muted=!1,e=!0),e},i.prototype.getVolume=function(){var e=0,t=this.getVideoElement();return null!=t&&(e=t.volume),e},i.prototype.setVolume=function(e){var t=!1,i=this.getVideoElement();return null!=i&&(i.volume=e,t=!0),t},i.prototype.setDataSource=function(e){var t=this;null!=this.m_abstractMesh&&(null==this.m_videoMaterial&&(this.m_videoMaterial=new BABYLON.StandardMaterial(this.transform.name+".VideoMat",this.scene),this.m_videoMaterial.roughness=1,this.m_videoMaterial.diffuseColor=new BABYLON.Color3(1,1,1),this.m_videoMaterial.emissiveColor=new BABYLON.Color3(1,1,1),this.m_videoMaterial.useAlphaFromDiffuseTexture=this.videoFaded,this.m_abstractMesh.material=this.m_videoMaterial),null!=this.m_videoMaterial?(this.m_videoMaterial.diffuseTexture=null,null!=this.m_videoTexture&&(this.m_videoTexture.dispose(),this.m_videoTexture=null),this._initializedReadyInstance=!1,this.m_videoTexture=new BABYLON.VideoTexture(this.transform.name+".VideoTex",e,this.scene,this.videoMipmaps,this.videoInvert,this.videoSample,{autoUpdateTexture:!0,poster:this.videoPoster}),null!=this.m_videoTexture&&(this.m_videoTexture.hasAlpha=this.videoAlpha,null!=this.m_videoTexture.video&&(this.m_videoTexture.video.loop=this.videoLoop,this.m_videoTexture.video.muted=this.videoMuted,this.m_videoTexture.video.volume=this.videoVolume,this.m_videoTexture.video.playbackRate=this.videoPlayback,this.m_videoTexture.video.addEventListener("loadeddata",function(){t._initializedReadyInstance=!0,t.onReadyObservable&&t.onReadyObservable.hasObservers()&&t.onReadyObservable.notifyObservers(t.m_videoTexture),!0===t.videoPlayOnAwake&&t.play()}),this.m_videoTexture.video.load())),null!=this.m_videoTexture&&(this.m_videoTexture.level=this.m_diffuseIntensity,this.m_videoMaterial.diffuseTexture=this.m_videoTexture)):BABYLON.Tools.Warn("No video mesh or material available for: "+this.transform.name))},i.prototype.revokeVideoBlobUrl=function(){null!=this.videoBlobUrl&&(URL.revokeObjectURL(this.videoBlobUrl),this.videoBlobUrl=null)},i.prototype.addPreloaderTasks=function(e){var t=this;if(!0===this.videoPreload){var i=e.addBinaryFileTask(this.transform.name+".VideoTask",this.videoPreloaderUrl);i.onSuccess=function(e){t.revokeVideoBlobUrl(),t.videoBlobUrl=URL.createObjectURL(new Blob([e.data])),t.setDataSource(t.videoBlobUrl)},i.onError=function(e,t,i){console.error(t,i)}}},i}(e.ScriptComponent);e.WebVideoPlayer=t,e.SceneManager.RegisterClass("TOOLKIT.WebVideoPlayer",t)}(n||(n={})),"undefined"!=typeof window?(window.TOOLKIT=n,window.SM=n.SceneManager,window.WM=n.WindowManager,window.UI=n.UserInterface,window.IC=n.InputController,window.PROJECT=r):(globalThis.TOOLKIT=n,globalThis.SM=n.SceneManager,globalThis.WM=n.WindowManager,globalThis.UI=n.UserInterface,globalThis.IC=n.InputController,globalThis.PROJECT=r);const h=n;return t.default})());
|