12 |
- var __extends=this&&this.__extends||function(e,n){function t(){this.constructor=e}for(var a in n)n.hasOwnProperty(a)&&(e[a]=n[a]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},BABYLON;!function(e){var n=function(){function n(e,n,t,a){if(void 0===t&&(t=!0),void 0===a&&(a={}),this.register=null,this.dispose=null,this.tick=!1,this._engine=null,this._scene=null,this._before=null,this._after=null,this._started=!1,this._initialized=!1,this._properties=null,this._manager=null,this._owned=null,null==e)throw new Error("Null owner scene obejct specified.");if(null==n)throw new Error("Null host scene obejct specified.");this.tick=t,this._owned=e,this._started=!1,this._manager=null,this._initialized=!1,this._properties=a,this._engine=n.getEngine(),this._scene=n;var r=this;r.register=function(){r.registerInstance(r)},r._before=function(){r.updateInstance(r)},r._after=function(){r.afterInstance(r)},r.dispose=function(){r.disposeInstance(r)}}return Object.defineProperty(n.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"engine",{get:function(){return this._engine},enumerable:!0,configurable:!0}),n.prototype.start=function(){},n.prototype.update=function(){},n.prototype.after=function(){},n.prototype.destroy=function(){},Object.defineProperty(n.prototype,"manager",{get:function(){return null==this._manager&&(this._manager=e.SceneManager.GetInstance(this.scene)),this._manager},enumerable:!0,configurable:!0}),n.prototype.setProperty=function(e,n){null!=this._properties&&(this._properties[e]=n)},n.prototype.getProperty=function(e,n){void 0===n&&(n=null);var t=null;return null!=this._properties&&(t=this._properties[e]),null==t&&(t=n),null!=t?t:null},n.prototype.getMetadata=function(){return this.manager.getSceneMetadata(this._owned)},n.prototype.findComponent=function(e){return this.manager.findSceneComponent(e,this._owned)},n.prototype.findComponents=function(e){return this.manager.findSceneComponents(e,this._owned)},n.prototype.registerInstance=function(e){e._scene.registerBeforeRender(e._before),e._scene.registerAfterRender(e._after)},n.prototype.updateInstance=function(e){e._started?e._started&&e.tick&&(e.update(),e.updateIntersectionList&&e.updateIntersectionList()):(e.start(),e._started=!0)},n.prototype.afterInstance=function(e){e._started&&e.tick&&e.after()},n.prototype.disposeInstance=function(e){e._scene.unregisterBeforeRender(e._before),e._scene.unregisterAfterRender(e._after),e.destroy(),e.tick=!1,e._started=!1,e._before=null,e._after=null,e._properties=null,e._engine=null,e._scene=null,e._owned=null,e._manager=null,e.register=null,e.dispose=null},n}();e.SceneComponent=n;var t=function(e){function n(n,t,a,r){void 0===a&&(a=!0),void 0===r&&(r={}),e.call(this,n,t,a,r),this._camera=null,this._camera=n}return __extends(n,e),Object.defineProperty(n.prototype,"camera",{get:function(){return this._camera},enumerable:!0,configurable:!0}),n}(e.SceneComponent);e.CameraComponent=t;var a=function(e){function n(n,t,a,r){void 0===a&&(a=!0),void 0===r&&(r={}),e.call(this,n,t,a,r),this._light=null,this._light=n}return __extends(n,e),Object.defineProperty(n.prototype,"light",{get:function(){return this._light},enumerable:!0,configurable:!0}),n}(e.SceneComponent);e.LightComponent=a;var r=function(e){function n(n,t,a,r){void 0===a&&(a=!0),void 0===r&&(r={}),e.call(this,n,t,a,r),this.onIntersectionEnter=null,this.onIntersectionStay=null,this.onIntersectionExit=null,this._list=[],this._mesh=null,this._collider=null,this._intersecting=!1,this._mesh=n}return __extends(n,e),Object.defineProperty(n.prototype,"mesh",{get:function(){return this._mesh},enumerable:!0,configurable:!0}),n.prototype.hasCollisionMesh=function(){return this.manager.hasCollisionMesh(this._mesh)},n.prototype.getCollisionMesh=function(){return this.manager.getCollisionMesh(this._mesh)},n.prototype.setIntersectionMeshes=function(e){var n=this;null!=e&&e.forEach(function(e){if(null!=e){var t=n.manager.getCollisionMesh(e);null!=t&&n._list.push({mesh:t,intersecting:!1})}})},n.prototype.clearIntersectionList=function(){this._list=[]},n.prototype.updateIntersectionList=function(){var e=this;null==this._collider&&(this._collider=this.getCollisionMesh()),null!=this._collider&&null!=this._list&&this._list.length>0&&this._list.forEach(function(n){e._intersecting=e._collider.intersectsMesh(n.mesh),e._intersecting?n.intersecting?null!=e.onIntersectionStay&&e.onIntersectionStay(n.mesh):null!=e.onIntersectionEnter&&e.onIntersectionEnter(n.mesh):n.intersecting&&null!=e.onIntersectionExit&&e.onIntersectionExit(n.mesh),n.intersecting=e._intersecting})},n}(e.SceneComponent);e.MeshComponent=r;var o=function(e){function n(n,t,a,r){void 0===a&&(a=!0),void 0===r&&(r={}),e.call(this,n,t,a,r)}return __extends(n,e),n}(e.MeshComponent);e.SceneController=o;var i=function(){function e(e){this._metadata=null,this._metadata=e}return Object.defineProperty(e.prototype,"type",{get:function(){return this._metadata.type},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"objectId",{get:function(){return this._metadata.objectId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"objectName",{get:function(){return this._metadata.objectName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tagName",{get:function(){return this._metadata.tagName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"layerIndex",{get:function(){return this._metadata.layerIndex},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"layerName",{get:function(){return this._metadata.layerName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"areaIndex",{get:function(){return this._metadata.areaIndex},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"navAgent",{get:function(){return this._metadata.navAgent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"meshLink",{get:function(){return this._metadata.meshLink},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"meshObstacle",{get:function(){return this._metadata.meshObstacle},enumerable:!0,configurable:!0}),e.prototype.setProperty=function(e,n){null!=this._metadata.properties&&(this._metadata.properties[e]=n)},e.prototype.getProperty=function(e,n){void 0===n&&(n=null);var t=null;return null!=this._metadata.properties&&(t=this._metadata.properties[e]),null==t&&(t=n),null!=t?t:null},e}();e.ObjectMetadata=i,function(e){e[e.None=-1]="None",e[e.Generic=0]="Generic",e[e.Xbox360=1]="Xbox360"}(e.GamepadType||(e.GamepadType={}));e.GamepadType;!function(e){e[e.Left=0]="Left",e[e.Right=1]="Right"}(e.Xbox360Trigger||(e.Xbox360Trigger={}));e.Xbox360Trigger;!function(e){e[e.Left=0]="Left",e[e.Middle=1]="Middle",e[e.Right=2]="Right"}(e.UserInputPointer||(e.UserInputPointer={}));e.UserInputPointer;!function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.ClientX=2]="ClientX",e[e.ClientY=3]="ClientY",e[e.MouseX=4]="MouseX",e[e.MouseY=5]="MouseY"}(e.UserInputAxis||(e.UserInputAxis={}));e.UserInputAxis;!function(e){e[e.Backspace=8]="Backspace",e[e.Tab=9]="Tab",e[e.Enter=13]="Enter",e[e.Shift=16]="Shift",e[e.Ctrl=17]="Ctrl",e[e.Alt=18]="Alt",e[e.Pause=19]="Pause",e[e.Break=19]="Break",e[e.CapsLock=20]="CapsLock",e[e.Escape=27]="Escape",e[e.Space=32]="Space",e[e.PageUp=33]="PageUp",e[e.PageDown=34]="PageDown",e[e.End=35]="End",e[e.Home=36]="Home",e[e.LeftArrow=37]="LeftArrow",e[e.UpArrow=38]="UpArrow",e[e.RightArrow=39]="RightArrow",e[e.DownArrow=40]="DownArrow",e[e.Insert=45]="Insert",e[e.Delete=46]="Delete",e[e.Num0=48]="Num0",e[e.Num1=49]="Num1",e[e.Num2=50]="Num2",e[e.Num3=51]="Num3",e[e.Num4=52]="Num4",e[e.Num5=53]="Num5",e[e.Num6=54]="Num6",e[e.Num7=55]="Num7",e[e.Num8=56]="Num8",e[e.Num9=57]="Num9",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.LeftWindowKey=91]="LeftWindowKey",e[e.RightWindowKey=92]="RightWindowKey",e[e.SelectKey=93]="SelectKey",e[e.Numpad0=96]="Numpad0",e[e.Numpad1=97]="Numpad1",e[e.Numpad2=98]="Numpad2",e[e.Numpad3=99]="Numpad3",e[e.Numpad4=100]="Numpad4",e[e.Numpad5=101]="Numpad5",e[e.Numpad6=102]="Numpad6",e[e.Numpad7=103]="Numpad7",e[e.Numpad8=104]="Numpad8",e[e.Numpad9=105]="Numpad9",e[e.Multiply=106]="Multiply",e[e.Add=107]="Add",e[e.Subtract=109]="Subtract",e[e.DecimalPoint=110]="DecimalPoint",e[e.Divide=111]="Divide",e[e.F1=112]="F1",e[e.F2=113]="F2",e[e.F3=114]="F3",e[e.F4=115]="F4",e[e.F5=116]="F5",e[e.F6=117]="F6",e[e.F7=118]="F7",e[e.F8=119]="F8",e[e.F9=120]="F9",e[e.F10=121]="F10",e[e.F11=122]="F11",e[e.F12=123]="F12",e[e.NumLock=144]="NumLock",e[e.ScrollLock=145]="ScrollLock",e[e.SemiColon=186]="SemiColon",e[e.EqualSign=187]="EqualSign",e[e.Comma=188]="Comma",e[e.Dash=189]="Dash",e[e.Period=190]="Period",e[e.ForwardSlash=191]="ForwardSlash",e[e.GraveAccent=192]="GraveAccent",e[e.OpenBracket=219]="OpenBracket",e[e.BackSlash=220]="BackSlash",e[e.CloseBraket=221]="CloseBraket",e[e.SingleQuote=222]="SingleQuote"}(e.UserInputKey||(e.UserInputKey={}));var s=(e.UserInputKey,function(){function e(){}return e.JoystickRightHandleColor="yellow",e.JoystickLeftSensibility=.15,e.JoystickRightSensibility=.05,e.JoystickDeadStickValue=.01,e.JoystickLStickXInverted=!1,e.JoystickLStickYInverted=!1,e.JoystickRStickXInverted=!1,e.JoystickRStickYInverted=!1,e.JoystickAngularSensibility=1,e.JoystickMovementSensibility=1,e.GamepadDeadStickValue=.25,e.GamepadLStickXInverted=!1,e.GamepadLStickYInverted=!1,e.GamepadRStickXInverted=!1,e.GamepadRStickYInverted=!1,e.GamepadAngularSensibility=1,e.GamepadMovementSensibility=1,e.PointerAngularSensibility=10,e}());e.UserInputOptions=s}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var n=function(){function n(n,t,a){var r=this;if(this.onrender=null,this.controller=null,this._ie=!1,this._url="",this._filename="",this._render=null,this._running=!1,this._markup="",this._gui="None",this._input=!1,this._scene=null,this._navmesh=null,this._navigation=null,null==a)throw new Error("Null host scene obejct specified.");this._ie=!!document.all,this._url=n,this._filename=t,this._scene=a,this._input=!1,this._navmesh=null,this._navigation=null,e.SceneManager.engine=this._scene.getEngine(),e.SceneManager.rightHanded=this._scene.useRightHandedSystem;var o=[];if(e.SceneManager.parseSceneCameras(this._scene.cameras,this._scene,o),e.SceneManager.parseSceneLights(this._scene.lights,this._scene,o),e.SceneManager.parseSceneMeshes(this._scene.meshes,this._scene,o),null!=this._scene.metadata&&null!=this._scene.metadata.properties){if(this._scene.metadata.properties.controllerPresent){var i=this.findSceneController();if(null!=i&&i instanceof e.SceneController)this.controller=i;else{var s="Failed to locate valid BABYLON.SceneController metadata instance";console&&console.warn(s)}}if(null!=this._scene.metadata.properties.interfaceMode&&(this._gui=this._scene.metadata.properties.interfaceMode,null!=this._scene.metadata.properties.userInterface)){var c=this._scene.metadata.properties.userInterface;window&&c.embedded&&null!=c.base64&&(this._markup=window.atob(c.base64),this._scene.metadata.properties.autoDraw===!0&&null!=this._gui&&""!==this._gui&&"None"!==this._gui&&null!=this._markup&&""!==this._markup&&this.drawSceneMarkup(this._markup))}if(null!=this._scene.metadata.properties.hasTerrainMeshes&&1==this._scene.metadata.properties.hasTerrainMeshes){var u=this._scene.getMeshesByTags("[TERRAIN]");null!=u?u.forEach(function(n){if(n.isVisible=!0,n.visibility=1,n.checkCollisions=!1,null!=n.metadata&&null!=n.metadata.properties&&n.metadata.properties.heightmapBase64){var t=n.metadata.properties.heightmapBase64,a=n.metadata.properties.width,o=n.metadata.properties.length,i=n.metadata.properties.height,s=n.metadata.properties.physicsState,c=n.metadata.properties.physicsMass,u=n.metadata.properties.physicsFriction,l=n.metadata.properties.physicsRestitution,p=n.metadata.properties.physicsImpostor,g=n.metadata.properties.groundTessellation;e.SceneManager.createGroundTerrain(n.name+"_Collider",t,{width:a,height:o,minHeight:0,maxHeight:i,updatable:!1,subdivisions:g,onReady:function(a){a.isVisible=!1,a.visibility=.5,a.checkCollisions=!0,a.position=e.Vector3.Zero(),a.rotation=n.rotation.clone(),a.scaling=n.scaling.clone(),a.parent=n,s&&a.setPhysicsState(p,{mass:c,friction:u,restitution:l}),n.metadata.properties.collisionMeshId=a.id,n.metadata.properties.heightmapBase64=null,t=null}},r._scene)}}):console&&console.warn("Failed to load scene terrain mesh(s)")}if(null!=this._scene.metadata.properties.hasNavigationMesh&&1==this._scene.metadata.properties.hasNavigationMesh)if(this._navmesh=this._scene.getMeshByName("sceneNavigationMesh"),null!=this._navmesh){var l=this.getNavigationTool(),p=l.buildNodes(this._navmesh);null!=p?l.setZoneData(this.getNavigationZone(),p):console&&console.warn("Failed to set scene navigation zone")}else console&&console.warn("Failed to load scene navigation mesh(s)")}o.length>0&&(o.sort(function(e,n){return e.order<n.order?-1:e.order>n.order?1:0}),o.forEach(function(e){e.instance.register()}));var g=this;this._render=function(){null!=g&&(g._input&&e.SceneManager.updateUserInput(),null!=g._scene&&g._scene.render(),null!=g.onrender&&g.onrender())},this._scene.onDispose=function(){null!=g&&g.dispose()}}return n.GetInstance=function(e){return e.manager?e.manager:null},n.CreateScene=function(n,t){var a=new e.Scene(t);return e.SceneManager.parseSceneMetadata("/",n,a),a},n.LoadScene=function(n,t,a,r,o,i){var s=function(a){e.SceneManager.parseSceneMetadata(n,t,a),r&&r(a)};e.SceneLoader.Append(n,t,new e.Scene(a),s,o,i)},n.ImportMesh=function(n,t,a,r,o,i,s){var c=function(n,t,a){e.SceneManager.parseMeshMetadata(n,r),o&&o(n,t,a)};e.SceneLoader.ImportMesh(n,t,a,r,c,i,s)},n.RegisterLoader=function(n){e.SceneManager.loader=n},Object.defineProperty(n.prototype,"ie",{get:function(){return this._ie},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"url",{get:function(){return this._url},enumerable:!0,configurable:!0}),n.prototype.dispose=function(){this.disableUserInput(),this._gui=null,this._render=null,this._markup=null,this._navmesh=null,this._navigation=null,this.onrender=null,this.controller=null;var e=this._scene;e.manager&&(e.manager=null),e=null,this._scene=null},n.prototype.isRunning=function(){return this._running},n.prototype.loadLevel=function(n,t){if(void 0===t&&(t=null),null==e.SceneManager.loader)throw new Error("No scene loader function registered.");var a=null!=t&&""!==t?t:this.getScenePath();this.stop(),this.clearSceneMarkup(),this._scene.dispose(),e.SceneManager.loader(a,n)},n.prototype.toggleDebug=function(){this._scene.debugLayer.isVisible()?this._scene.debugLayer.hide():this._scene.debugLayer.show()},n.prototype.getSceneName=function(){return this._filename},n.prototype.getScenePath=function(){var e="/";if(null!=this.url&&""!==this.url)e=this.url;else if(null!=this._scene.database&&null!=this._scene.database.currentSceneUrl){var n=this._scene.database.currentSceneUrl;e=n.substr(0,n.lastIndexOf("/"))+"/"}return e},n.prototype.getSceneMetadata=function(n){var t=null;if(null!=n.metadata&&n.metadata.api){var a=n.metadata;t=new e.ObjectMetadata(a)}return t},n.prototype.showFullscreen=function(){e.Tools.RequestFullscreen(document.documentElement),document.documentElement.focus()},n.prototype.start=function(){this._running=!0,this._scene.getEngine().runRenderLoop(this._render)},n.prototype.stop=function(){this._running=!1,this._scene.getEngine().stopRenderLoop(this._render)},n.prototype.toggle=function(){this._running?(this.pauseAudio(),this.stop()):(this.resumeAudio(),this.start())},n.prototype.stepFrame=function(){this._running?this.toggle():this._render()},n.prototype.pauseAudio=function(){this._scene.audioEnabled===!0&&(this._scene.audioEnabled=!1)},n.prototype.resumeAudio=function(){this._scene.audioEnabled===!1&&(this._scene.audioEnabled=!0)},n.prototype.getGuiMode=function(){return this._gui},n.prototype.getSceneMarkup=function(){return this._markup},n.prototype.drawSceneMarkup=function(e){if("Html"===this._gui){var n=document.getElementById("gui");if(null==n){var t=document.createElement("div");t.id="gui",t.style.width="100%",t.style.height="100%",t.style.opacity="1",t.style.zIndex="10",t.style.outline="none",t.style.backgroundColor="transparent",document.body.appendChild(t),t.innerHTML=e}else n.innerHTML=e}else{var a="Scene controller gui disabled.";console&&console.warn(a)}},n.prototype.clearSceneMarkup=function(){if("Html"===this._gui){var e=document.getElementById("gui");null!=e&&(e.innerHTML="")}else{var n="Scene controller gui disabled.";console&&console.warn(n)}},n.prototype.hasCollisionMesh=function(e){return null!=e&&null!=e.metadata&&null!=e.metadata.properties&&null!=e.metadata.properties.collisionMeshId&&""!==e.metadata.properties.collisionMeshId},n.prototype.getCollisionMesh=function(e){var n=null;return this.hasCollisionMesh(e)&&(n=this._scene.getMeshByID(e.metadata.properties.collisionMeshId)),null==n&&(n=e),n},n.prototype.addSceneComponent=function(n,t,a,r){void 0===a&&(a=!0),void 0===r&&(r={});var o=null;if(null==n)throw new Error("Null owner scene obejct specified.");if(null==t||""===t)throw new Error("Null scene obejct klass specified.");if(null==n.metadata||!n.metadata.api){var i={api:!0,type:"Babylon",objectName:"Scene Component",objectId:"0",tagName:"Untagged",layerIndex:0,layerName:"Default",areaIndex:-1,navAgent:null,meshLink:null,meshObstacle:null,components:[],properties:{}};n.metadata=i}var s=null;if(null!=n.metadata&&n.metadata.api){null!=n.metadata.disposal&&n.metadata.disposal!==!1||(n.onDispose=function(){e.SceneManager.destroySceneComponents(n)},n.metadata.disposal=!0);var i=n.metadata;if(s=null!=i.components?i.components:[],null!=s){var c=e.SceneManager.createComponentClass(t);if(null!=c)if(o=new c(n,this._scene,a,r),null!=o){var u={order:1e3,name:"BabylonScriptComponent",klass:t,update:a,controller:!1,properties:r,instance:o,tag:{}};s.push(u),o.register()}else console&&console.error("Failed to create component instance");else console&&console.error("Failed to create component class")}else console&&console.error("Failed to parse metadata components")}else console&&console.error("Null owner object metadata");return o},n.prototype.findSceneComponent=function(e,n){var t=null;if(null!=n.metadata&&n.metadata.api){var a=n.metadata;if(null!=a.components&&a.components.length>0)for(var r=0;r<a.components.length;r++){var o=a.components[r];if(null!=o.instance&&o.klass===e){t=o.instance;break}}}return t},n.prototype.findSceneComponents=function(e,n){var t=[];if(null!=n.metadata&&n.metadata.api){var a=n.metadata;if(null!=a.components&&a.components.length>0)for(var r=0;r<a.components.length;r++){var o=a.components[r];null!=o.instance&&o.klass===e&&t.push(o.instance)}}return t},n.prototype.findSceneController=function(){var e=this._scene.meshes,n=null;if(null!=e&&e.length>0)for(var t=0;t<e.length;t++){var a=e[t];if(null!=a.metadata&&a.metadata.api){var r=a.metadata;if(null!=r.components&&r.components.length>0)for(var o=0;o<r.components.length;o++){var i=r.components[o];if(null!=i.instance&&i.controller===!0){n=i.instance;break}}}if(null!=n)break}return n},n.prototype.createSceneController=function(n){if(null!=this.controller)throw new Error("Scene controller already exists.");return this.controller=this.addSceneComponent(new e.Mesh("SceneController",this._scene),n),null!=this.controller&&this.controller.ready(),this.controller},n.prototype.resetUserInput=function(){e.SceneManager.keymap={},e.SceneManager.clientx=0,e.SceneManager.clienty=0,e.SceneManager.mousex=0,e.SceneManager.mousey=0,e.SceneManager.vertical=0,e.SceneManager.horizontal=0,e.SceneManager.x_mousex=0,e.SceneManager.x_mousey=0,e.SceneManager.x_vertical=0,e.SceneManager.x_horizontal=0,e.SceneManager.k_mousex=0,e.SceneManager.k_mousey=0,e.SceneManager.k_vertical=0,e.SceneManager.k_horizontal=0,e.SceneManager.j_mousex=0,e.SceneManager.j_mousey=0,e.SceneManager.j_vertical=0,e.SceneManager.j_horizontal=0,e.SceneManager.g_mousex=0,e.SceneManager.g_mousey=0,e.SceneManager.g_vertical=0,e.SceneManager.g_horizontal=0,e.SceneManager.preventDefault=!1,e.SceneManager.gamepadButtonUp=[],e.SceneManager.gamepadButtonDown=[],e.SceneManager.gamepadButtonPress=[],e.SceneManager.gamepadDpadUp=[],e.SceneManager.gamepadDpadDown=[],e.SceneManager.gamepadDpadPress=[],e.SceneManager.gamepadLeftTrigger=[],e.SceneManager.gamepadRightTrigger=[],e.SceneManager.mouseButtonUp=[],e.SceneManager.mouseButtonDown=[],e.SceneManager.mouseButtonPress=[],e.SceneManager.keyButtonUp=[],e.SceneManager.keyButtonDown=[],e.SceneManager.keyButtonPress=[]},n.prototype.enableUserInput=function(n){void 0===n&&(n=null);var t=!(null==n||!n.preventDefault)&&n.preventDefault,a=!(null==n||!n.useCapture)&&n.useCapture,r=!(null==n||!n.virtualJoystick)&&n.virtualJoystick,o=null!=n&&n.gamepadConnected?n.gamepadConnected:null;this._input||(this.resetUserInput(),document.documentElement.tabIndex=1,document.documentElement.addEventListener("keyup",e.SceneManager.inputKeyUpHandler,a),document.documentElement.addEventListener("keydown",e.SceneManager.inputKeyDownHandler,a),document.documentElement.addEventListener("pointerup",e.SceneManager.inputPointerUpHandler,a),document.documentElement.addEventListener("pointerdown",e.SceneManager.inputPointerDownHandler,a),document.documentElement.addEventListener("pointermove",e.SceneManager.inputPointerMoveHandler,a),e.SceneManager.preventDefault=t,null==e.SceneManager.gamepads&&(e.SceneManager.gamepadConnected=o,e.SceneManager.gamepads=new e.Gamepads(function(n){e.SceneManager.inputGamepadConnected(n)})),r&&(null==e.SceneManager.leftJoystick&&(e.SceneManager.leftJoystick=new e.VirtualJoystick((!0)),e.SceneManager.leftJoystick.setAxisForUpDown(e.JoystickAxis.Z),e.SceneManager.leftJoystick.setAxisForLeftRight(e.JoystickAxis.X),e.SceneManager.leftJoystick.setJoystickSensibility(e.UserInputOptions.JoystickLeftSensibility)),null==e.SceneManager.rightJoystick&&(e.SceneManager.rightJoystick=new e.VirtualJoystick((!1)),e.SceneManager.rightJoystick.setAxisForUpDown(e.JoystickAxis.X),e.SceneManager.rightJoystick.setAxisForLeftRight(e.JoystickAxis.Y),e.SceneManager.rightJoystick.reverseUpDown=!0,e.SceneManager.rightJoystick.setJoystickSensibility(e.UserInputOptions.JoystickRightSensibility),e.SceneManager.rightJoystick.setJoystickColor(e.UserInputOptions.JoystickRightHandleColor))),this._input=!0,document.documentElement.focus())},n.prototype.disableUserInput=function(n){void 0===n&&(n=!1),this._input&&(document.documentElement.removeEventListener("keyup",e.SceneManager.inputKeyUpHandler,n),document.documentElement.removeEventListener("keydown",e.SceneManager.inputKeyDownHandler,n),document.documentElement.removeEventListener("pointerup",e.SceneManager.inputPointerUpHandler,n),document.documentElement.removeEventListener("pointerdown",e.SceneManager.inputPointerDownHandler,n),document.documentElement.removeEventListener("pointermove",e.SceneManager.inputPointerMoveHandler,n),e.SceneManager.preventDefault=!1,this.resetUserInput(),this._input=!1)},n.prototype.getUserInput=function(n){var t=0;if(this._input)switch(n){case e.UserInputAxis.Vertical:case e.UserInputAxis.Horizontal:t=n===e.UserInputAxis.Horizontal?e.SceneManager.horizontal:e.SceneManager.vertical;break;case e.UserInputAxis.MouseX:case e.UserInputAxis.MouseY:t=n===e.UserInputAxis.MouseX?e.SceneManager.mousex:e.SceneManager.mousey;break;case e.UserInputAxis.ClientX:case e.UserInputAxis.ClientY:t=n===e.UserInputAxis.ClientX?e.SceneManager.clientx:e.SceneManager.clienty}return t},n.prototype.onKeyUp=function(n){this._input&&e.SceneManager.keyButtonUp.push(n)},n.prototype.onKeyDown=function(n){this._input&&e.SceneManager.keyButtonDown.push(n)},n.prototype.onKeyPress=function(n,t){this._input&&e.SceneManager.keyButtonPress.push({index:n,action:t})},n.prototype.getKeyInput=function(n){var t=!1;if(this._input){var a="k"+n.toString();null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a])}return t},n.prototype.onPointerUp=function(n){this._input&&e.SceneManager.mouseButtonUp.push(n)},n.prototype.onPointerDown=function(n){this._input&&e.SceneManager.mouseButtonDown.push(n)},n.prototype.onPointerPress=function(n,t){this._input&&e.SceneManager.mouseButtonPress.push({index:n,action:t})},n.prototype.getPointerInput=function(n){var t=!1;if(this._input){var a="p"+n.toString();null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a])}return t},n.prototype.onButtonUp=function(n){this._input&&e.SceneManager.gamepadButtonUp.push(n)},n.prototype.onButtonDown=function(n){this._input&&e.SceneManager.gamepadButtonDown.push(n)},n.prototype.onButtonPress=function(n,t){this._input&&e.SceneManager.gamepadButtonPress.push({index:n,action:t})},n.prototype.getButtonInput=function(n){var t=!1;if(this._input){var a="b"+n.toString();null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a])}return t},n.prototype.onDpadUp=function(n){this._input&&e.SceneManager.gamepadDpadUp.push(n)},n.prototype.onDpadDown=function(n){this._input&&e.SceneManager.gamepadDpadDown.push(n)},n.prototype.onDpadPress=function(n,t){this._input&&e.SceneManager.gamepadDpadPress.push({index:n,action:t})},n.prototype.getDpadInput=function(n){var t=!1;if(this._input){var a="d"+n.toString();null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a])}return t},n.prototype.onTriggerLeft=function(n){this._input&&e.SceneManager.gamepadLeftTrigger.push(n)},n.prototype.onTriggerRight=function(n){this._input&&e.SceneManager.gamepadRightTrigger.push(n)},n.prototype.getTriggerInput=function(n){var t=0;if(this._input){var a="t"+n.toString();null!=e.SceneManager.keymap[a]&&(t=e.SceneManager.keymap[a])}return t},n.prototype.getConnectedGamepad=function(){return this._input?e.SceneManager.gamepad:null},n.prototype.getConnectedGamepadType=function(){return this._input?e.SceneManager.gamepadType:e.GamepadType.None},n.prototype.disposeConnectedGamepad=function(){this._input&&(null!=e.SceneManager.gamepads&&(e.SceneManager.gamepads.dispose(),e.SceneManager.gamepads=null),e.SceneManager.gamepad=null,e.SceneManager.gamepadType=e.GamepadType.None,e.SceneManager.gamepadConnected=null)},n.prototype.getLeftVirtualJoystick=function(){return this._input?e.SceneManager.leftJoystick:null},n.prototype.getRightVirtualJoystick=function(){return this._input?e.SceneManager.rightJoystick:null},n.prototype.disposeVirtualJoysticks=function(){this._input&&(null!=e.SceneManager.leftJoystick&&(e.SceneManager.leftJoystick.releaseCanvas(),e.SceneManager.leftJoystick=null),null!=e.SceneManager.rightJoystick&&(e.SceneManager.rightJoystick.releaseCanvas(),e.SceneManager.rightJoystick=null))},n.prototype.updateCameraPosition=function(n,t,a,r){if(null!=n){var o=n._computeLocalCameraSpeed()*r,i=e.Matrix.RotationYawPitchRoll(n.rotation.y,n.rotation.x,0),s=e.Vector3.TransformCoordinates(new e.Vector3(t*o,0,-a*o),i);n.cameraDirection=n.cameraDirection.add(s)}},n.prototype.updateCameraRotation=function(n,t,a,r){null!=n&&(n.cameraRotation=n.cameraRotation.add(new e.Vector2(a*r,t*r)))},n.prototype.updateCameraUserInput=function(n,t,a){if(null!=n){var r=this.getUserInput(e.UserInputAxis.Horizontal),o=this.getUserInput(e.UserInputAxis.Vertical),i=this.getUserInput(e.UserInputAxis.MouseX),s=this.getUserInput(e.UserInputAxis.MouseY);this.updateCameraPosition(n,r,-o,t),this.updateCameraRotation(n,i,s,a)}},n.prototype.hasNavigationMesh=function(){return null!=this._navmesh},n.prototype.setNavigationMesh=function(e){this._navmesh=e},n.prototype.getNavigationMesh=function(){return this._navmesh},n.prototype.getNavigationTool=function(){return null==this._navigation&&(this._navigation=new Navigation),this._navigation},n.prototype.getNavigationZone=function(){return"scene"},n.prototype.getNavigationPath=function(e,n){if(null==this._navigation||null==this._navmesh)return null;var t=this.getNavigationZone(),a=this._navigation.getGroup(t,e.position);return this._navigation.findPath(e.position,n,t,a)},n.prototype.setNavigationPath=function(n,t,a,r,o){if(t&&t.length>1){for(var i=0,s=[{frame:0,value:n.position}],c=0;c<t.length;c++)i+=e.Vector3.Distance(s[c].value,t[c]),s.push({frame:i,value:t[c]});var u=new e.Animation("Move","position",3,e.Animation.ANIMATIONTYPE_VECTOR3,e.Animation.ANIMATIONLOOPMODE_CONSTANT);u.setKeys(s),n.animations.push(u),this._scene.beginAnimation(n,0,i,r,a,o)}},n.prototype.getNavigationAgent=function(n){return new e.NavigationAgent(n)},n.prototype.getNavigationAgents=function(){return this._scene.getMeshesByTags("[NAVAGENT]")},n.prototype.getNavigationAreaTable=function(){return null!=this._navmesh.metadata&&null!=this._navmesh.metadata.properties&&null!=this._navmesh.metadata.properties.table?this._navmesh.metadata.properties.table:[]},n.prototype.getNavigationAreaIndexes=function(){return null!=this._navmesh.metadata&&null!=this._navmesh.metadata.properties&&null!=this._navmesh.metadata.properties.areas?this._navmesh.metadata.properties.areas:[]},n.prototype.getNavigationAreaName=function(e){var n="";if(null!=this._navmesh.metadata&&null!=this._navmesh.metadata.properties&&null!=this._navmesh.metadata.properties.table){var t=this._navmesh.metadata.properties.table;if(null!=t)for(var a=0;a<t.length;a++)if(t[a].index===e){n=t[a].area;break}}return n},n.prototype.getNavigationAreaCost=function(e){var n=-1;if(null!=this._navmesh.metadata&&null!=this._navmesh.metadata.properties){var t=this._navmesh.metadata.properties.table;if(null!=t)for(var a=0;a<t.length;a++)if(t[a].index===e){n=t[a].cost;break}}return n},n.inputKeyDownHandler=function(n){var t="k"+n.keyCode.toString(),a=!1;switch(null!=e.SceneManager.keymap[t]&&(a=e.SceneManager.keymap[t]),e.SceneManager.keymap[t]=!0,n.keyCode){case 39:case 68:e.SceneManager.k_horizontal=1;break;case 37:case 65:e.SceneManager.k_horizontal=-1;break;case 38:case 87:e.SceneManager.k_vertical=1;break;case 40:case 83:e.SceneManager.k_vertical=-1}return null!=e.SceneManager.keyButtonDown&&e.SceneManager.keyButtonDown.length>0&&e.SceneManager.keyButtonDown.forEach(function(e){e(n.keyCode)}),a||null!=e.SceneManager.keyButtonPress&&e.SceneManager.keyButtonPress.length>0&&e.SceneManager.keyButtonPress.forEach(function(e){e.index===n.keyCode&&e.action()}),e.SceneManager.preventDefault&&n.preventDefault(),!0},n.inputKeyUpHandler=function(n){var t="k"+n.keyCode.toString();switch(e.SceneManager.keymap[t]=!1,n.keyCode){case 39:case 37:case 68:case 65:e.SceneManager.k_horizontal=0;break;case 38:case 40:case 87:case 83:e.SceneManager.k_vertical=0}return null!=e.SceneManager.keyButtonUp&&e.SceneManager.keyButtonUp.length>0&&e.SceneManager.keyButtonUp.forEach(function(e){e(n.keyCode)}),e.SceneManager.preventDefault&&n.preventDefault(),!0},n.inputPointerDownHandler=function(n){0===n.button&&(e.SceneManager.previousPosition={x:n.clientX,y:n.clientY});var t="p"+n.button.toString(),a=!1;return null!=e.SceneManager.keymap[t]&&(a=e.SceneManager.keymap[t]),e.SceneManager.keymap[t]=!0,null!=e.SceneManager.mouseButtonDown&&e.SceneManager.mouseButtonDown.length>0&&e.SceneManager.mouseButtonDown.forEach(function(e){e(n.button)}),a||null!=e.SceneManager.mouseButtonPress&&e.SceneManager.mouseButtonPress.length>0&&e.SceneManager.mouseButtonPress.forEach(function(e){e.index===n.button&&e.action()}),e.SceneManager.preventDefault&&n.preventDefault(),!0},n.inputPointerUpHandler=function(n){0===n.button&&null!=e.SceneManager.previousPosition&&(e.SceneManager.previousPosition=null,e.SceneManager.k_mousex=0,e.SceneManager.k_mousey=0);var t="p"+n.button.toString();return e.SceneManager.keymap[t]=!1,null!=e.SceneManager.mouseButtonUp&&e.SceneManager.mouseButtonUp.length>0&&e.SceneManager.mouseButtonUp.forEach(function(e){e(n.button)}),e.SceneManager.preventDefault&&n.preventDefault(),
- !0},n.inputPointerMoveHandler=function(n){if(null!=e.SceneManager.previousPosition){e.SceneManager.clientx=n.clientX,e.SceneManager.clienty=n.clientY;var t=n.clientX-e.SceneManager.previousPosition.x,a=n.clientY-e.SceneManager.previousPosition.y;e.SceneManager.previousPosition={x:n.clientX,y:n.clientY};var r=t/e.UserInputOptions.PointerAngularSensibility,o=a/e.UserInputOptions.PointerAngularSensibility;0!=r&&(e.SceneManager.k_mousex=r),0!=o&&(e.SceneManager.rightHanded?e.SceneManager.k_mousey=-o:e.SceneManager.k_mousey=o)}return e.SceneManager.preventDefault&&n.preventDefault(),!0},n.inputButtonDownHandler=function(n){if(null!=e.SceneManager.gamepad){var t="b"+n.toString(),a=!1;null!=e.SceneManager.keymap[t]&&(a=e.SceneManager.keymap[t]),e.SceneManager.keymap[t]=!0,null!=e.SceneManager.gamepadButtonDown&&e.SceneManager.gamepadButtonDown.length>0&&e.SceneManager.gamepadButtonDown.forEach(function(e){e(n)}),a||null!=e.SceneManager.gamepadButtonPress&&e.SceneManager.gamepadButtonPress.length>0&&e.SceneManager.gamepadButtonPress.forEach(function(e){e.index===n&&e.action()})}},n.inputButtonUpHandler=function(n){if(null!=e.SceneManager.gamepad){var t="b"+n.toString();e.SceneManager.keymap[t]=!1,null!=e.SceneManager.gamepadButtonUp&&e.SceneManager.gamepadButtonUp.length>0&&e.SceneManager.gamepadButtonUp.forEach(function(e){e(n)})}},n.inputXboxDPadDownHandler=function(n){if(null!=e.SceneManager.gamepad){var t="d"+n.toString(),a=!1;null!=e.SceneManager.keymap[t]&&(a=e.SceneManager.keymap[t]),e.SceneManager.keymap[t]=!0,null!=e.SceneManager.gamepadDpadDown&&e.SceneManager.gamepadDpadDown.length>0&&e.SceneManager.gamepadDpadDown.forEach(function(e){e(n)}),a||null!=e.SceneManager.gamepadDpadPress&&e.SceneManager.gamepadDpadPress.length>0&&e.SceneManager.gamepadDpadPress.forEach(function(e){e.index===n&&e.action()})}},n.inputXboxDPadUpHandler=function(n){if(null!=e.SceneManager.gamepad){var t="d"+n.toString();e.SceneManager.keymap[t]=!1,null!=e.SceneManager.gamepadDpadUp&&e.SceneManager.gamepadDpadUp.length>0&&e.SceneManager.gamepadDpadUp.forEach(function(e){e(n)})}},n.inputXboxLeftTriggerHandler=function(n){null!=e.SceneManager.gamepad&&(e.SceneManager.keymap.t0=n,null!=e.SceneManager.gamepadLeftTrigger&&e.SceneManager.gamepadLeftTrigger.length>0&&e.SceneManager.gamepadLeftTrigger.forEach(function(e){e(n)}))},n.inputXboxRightTriggerHandler=function(n){null!=e.SceneManager.gamepad&&(e.SceneManager.keymap.t1=n,null!=e.SceneManager.gamepadRightTrigger&&e.SceneManager.gamepadRightTrigger.length>0&&e.SceneManager.gamepadRightTrigger.forEach(function(e){e(n)}))},n.inputLeftStickHandler=function(n){if(null!=e.SceneManager.gamepad){var t=n,a=t.x/e.UserInputOptions.GamepadMovementSensibility,r=t.y/e.UserInputOptions.GamepadMovementSensibility;t.x=Math.abs(a)>=e.UserInputOptions.GamepadDeadStickValue?0+a:0,t.y=Math.abs(r)>=e.UserInputOptions.GamepadDeadStickValue?0+r:0,e.SceneManager.g_horizontal=e.UserInputOptions.GamepadLStickXInverted?-t.x:t.x,e.SceneManager.g_vertical=e.UserInputOptions.GamepadLStickYInverted?t.y:-t.y}},n.inputRightStickHandler=function(n){if(null!=e.SceneManager.gamepad){var t=n,a=t.x/e.UserInputOptions.GamepadAngularSensibility,r=t.y/e.UserInputOptions.GamepadAngularSensibility;t.x=Math.abs(a)>=e.UserInputOptions.GamepadDeadStickValue?0+a:0,t.y=Math.abs(r)>=e.UserInputOptions.GamepadDeadStickValue?0+r:0,e.SceneManager.g_mousex=e.UserInputOptions.GamepadRStickXInverted?-t.x:t.x,e.SceneManager.g_mousey=e.UserInputOptions.GamepadRStickYInverted?-t.y:t.y}},n.inputGamepadConnected=function(n){if(0===n.index){if(e.SceneManager.gamepad=n,console.log("[Scene Manager] - Gamepad Connected: "+e.SceneManager.gamepad.id),e.SceneManager.gamepad.id.search("Xbox 360")!==-1||e.SceneManager.gamepad.id.search("Xbox One")!==-1||e.SceneManager.gamepad.id.search("xinput")!==-1){e.SceneManager.gamepadType=e.GamepadType.Xbox360;var t=e.SceneManager.gamepad;t.onbuttonup(e.SceneManager.inputButtonUpHandler),t.onbuttondown(e.SceneManager.inputButtonDownHandler),t.onleftstickchanged(e.SceneManager.inputLeftStickHandler),t.onrightstickchanged(e.SceneManager.inputRightStickHandler),t.ondpadup(e.SceneManager.inputXboxDPadUpHandler),t.ondpaddown(e.SceneManager.inputXboxDPadDownHandler),t.onlefttriggerchanged(e.SceneManager.inputXboxLeftTriggerHandler),t.onrighttriggerchanged(e.SceneManager.inputXboxRightTriggerHandler)}else{e.SceneManager.gamepadType=e.GamepadType.Generic;var a=e.SceneManager.gamepad;a.onbuttonup(e.SceneManager.inputButtonUpHandler),a.onbuttondown(e.SceneManager.inputButtonDownHandler),a.onleftstickchanged(e.SceneManager.inputLeftStickHandler),a.onrightstickchanged(e.SceneManager.inputRightStickHandler)}null!=e.SceneManager.gamepadConnected&&e.SceneManager.gamepadConnected(e.SceneManager.gamepad,e.SceneManager.gamepadType)}},n.inputVirtualJoysticks=function(){if(null!=e.SceneManager.leftJoystick&&null!=e.SceneManager.rightJoystick){var n=e.SceneManager.leftJoystick.deltaPosition,t=e.SceneManager.rightJoystick.deltaPosition;e.SceneManager.leftJoystick.pressed||(n=n.scale(.9)),e.SceneManager.rightJoystick.pressed||(t=t.scale(.9));var a=n.x/e.UserInputOptions.JoystickMovementSensibility,r=n.y/e.UserInputOptions.JoystickMovementSensibility;n.x=Math.abs(a)>=e.UserInputOptions.JoystickDeadStickValue?0+a:0,n.y=Math.abs(r)>=e.UserInputOptions.JoystickDeadStickValue?0+r:0,e.SceneManager.j_horizontal=e.UserInputOptions.JoystickLStickXInverted?-n.x:n.x,e.SceneManager.j_vertical=e.UserInputOptions.JoystickLStickYInverted?n.y:-n.y;var o=t.x/e.UserInputOptions.JoystickAngularSensibility,i=t.y/e.UserInputOptions.JoystickAngularSensibility;t.x=Math.abs(o)>=e.UserInputOptions.JoystickDeadStickValue?0+o:0,t.y=Math.abs(i)>=e.UserInputOptions.JoystickDeadStickValue?0+i:0,e.SceneManager.j_mousex=e.UserInputOptions.JoystickRStickXInverted?-t.x:t.x,e.SceneManager.j_mousey=e.UserInputOptions.JoystickRStickYInverted?-t.y:t.y}},n.updateUserInput=function(){e.SceneManager.inputVirtualJoysticks(),e.SceneManager.x_horizontal=0,e.SceneManager.x_vertical=0,e.SceneManager.x_mousex=0,e.SceneManager.x_mousey=0,0!==e.SceneManager.k_horizontal?e.SceneManager.x_horizontal=e.SceneManager.k_horizontal:0!==e.SceneManager.j_horizontal?e.SceneManager.x_horizontal=e.SceneManager.j_horizontal:0!==e.SceneManager.g_horizontal&&(e.SceneManager.x_horizontal=e.SceneManager.g_horizontal),0!==e.SceneManager.k_vertical?e.SceneManager.x_vertical=e.SceneManager.k_vertical:0!==e.SceneManager.j_vertical?e.SceneManager.x_vertical=e.SceneManager.j_vertical:0!==e.SceneManager.g_vertical&&(e.SceneManager.x_vertical=e.SceneManager.g_vertical),0!==e.SceneManager.k_mousex?e.SceneManager.x_mousex=e.SceneManager.k_mousex:0!==e.SceneManager.j_mousex?e.SceneManager.x_mousex=e.SceneManager.j_mousex:0!==e.SceneManager.g_mousex&&(e.SceneManager.x_mousex=e.SceneManager.g_mousex),0!==e.SceneManager.k_mousey?e.SceneManager.x_mousey=e.SceneManager.k_mousey:0!==e.SceneManager.j_mousey?e.SceneManager.x_mousey=e.SceneManager.j_mousey:0!==e.SceneManager.g_mousey&&(e.SceneManager.x_mousey=e.SceneManager.g_mousey),e.SceneManager.horizontal=e.SceneManager.x_horizontal,e.SceneManager.vertical=e.SceneManager.x_vertical,e.SceneManager.mousex=e.SceneManager.x_mousex,e.SceneManager.mousey=e.SceneManager.x_mousey},n.parseSceneMetadata=function(n,t,a){var r=a;if(null==r.manager){var o=new e.SceneManager(n,t,a);r.manager=o,null!=o.controller&&o.controller.ready()}else console&&console.warn("Scene already has already been parsed.")},n.parseMeshMetadata=function(n,t){var a=t;if(null!=a.manager){var r=(a.manager,[]);e.SceneManager.parseSceneMeshes(n,t,r),r.length>0&&(r.sort(function(e,n){return e.order<n.order?-1:e.order>n.order?1:0}),r.forEach(function(e){e.instance.register()}))}else console&&console.warn("No scene manager detected for current scene")},n.parseSceneCameras=function(n,t,a){null!=n&&n.length>0&&n.forEach(function(n){if(null!=n.metadata&&n.metadata.api){null!=n.metadata.disposal&&n.metadata.disposal!==!1||(n.onDispose=function(){e.SceneManager.destroySceneComponents(n)},n.metadata.disposal=!0);var r=n.metadata;null!=r.components&&r.components.length>0&&r.components.forEach(function(r){if(null!=r.klass&&""!==r.klass&&"BABYLON.ScriptComponent"!==r.klass&&"BABYLON.SceneController"!==r.klass){var o=e.SceneManager.createComponentClass(r.klass);null!=o&&(r.instance=new o(n,t,r.update,r.properties),null!=r.instance&&a.push(r))}})}})},n.parseSceneLights=function(n,t,a){null!=n&&n.length>0&&n.forEach(function(n){if(null!=n.metadata&&n.metadata.api){null!=n.metadata.disposal&&n.metadata.disposal!==!1||(n.onDispose=function(){e.SceneManager.destroySceneComponents(n)},n.metadata.disposal=!0);var r=n.metadata;null!=r.components&&r.components.length>0&&r.components.forEach(function(r){if(null!=r.klass&&""!==r.klass&&"BABYLON.ScriptComponent"!==r.klass&&"BABYLON.SceneController"!==r.klass){var o=e.SceneManager.createComponentClass(r.klass);null!=o&&(r.instance=new o(n,t,r.update,r.properties),null!=r.instance&&a.push(r))}})}})},n.parseSceneMeshes=function(n,t,a){null!=n&&n.length>0&&n.forEach(function(n){if(null!=n.metadata&&n.metadata.api){null!=n.metadata.disposal&&n.metadata.disposal!==!1||(n.onDispose=function(){e.SceneManager.destroySceneComponents(n)},n.metadata.disposal=!0);var r=n.metadata;null!=r.components&&r.components.length>0&&r.components.forEach(function(r){if(null!=r.klass&&""!==r.klass&&"BABYLON.ScriptComponent"!==r.klass&&"BABYLON.SceneController"!==r.klass){var o=e.SceneManager.createComponentClass(r.klass);null!=o&&(r.instance=new o(n,t,r.update,r.properties),null!=r.instance&&a.push(r))}})}})},n.destroySceneComponents=function(e,n){if(void 0===n&&(n=!0),null!=e&&null!=e.metadata&&e.metadata.api){var t=e.metadata;null!=t.components&&t.components.length>0&&(t.components.forEach(function(e){null!=e.instance&&(e.instance.dispose(),e.instance=null)}),n&&(e.metadata.components=null)),n&&(null!=e.metadata.properties&&(e.metadata.properties=null),e.metadata=null)}},n.createGroundTerrain=function(n,t,a,r){var o=a.width||10,i=a.height||10,s=a.subdivisions||1,c=a.minHeight||0,u=a.maxHeight||10,l=a.updatable,p=a.onReady,g=new e.GroundMesh(n,r);g._subdivisionsX=s,g._subdivisionsY=s,g._width=o,g._height=i,g._maxX=g._width/2,g._maxZ=g._height/2,g._minX=-g._maxX,g._minZ=-g._maxZ,g._setReady(!1);var d=function(n){var t=document.createElement("canvas"),a=t.getContext("2d"),r=n.width,d=n.height;t.width=r,t.height=d,a.drawImage(n,0,0);var m=a.getImageData(0,0,r,d).data,h=e.SceneManager.parseTerrainHeightmap({width:o,height:i,subdivisions:s,minHeight:c,maxHeight:u,buffer:m,bufferWidth:r,bufferHeight:d});h.applyToMesh(g,l),g._setReady(!0),p&&p(g)};return e.Tools.LoadImage(t,d,function(){},r.database),g},n.parseTerrainHeightmap=function(n){var t,a,r=[],o=[],i=[],s=[],c=new Float32Array(n.buffer.buffer);for(t=0;t<=n.subdivisions;t++)for(a=0;a<=n.subdivisions;a++){var u=new e.Vector3(a*n.width/n.subdivisions-n.width/2,0,(n.subdivisions-t)*n.height/n.subdivisions-n.height/2),l=(u.x+n.width/2)/n.width*(n.bufferWidth-1)|0,p=(1-(u.z+n.height/2)/n.height)*(n.bufferHeight-1)|0,g=l+p*n.bufferWidth,d=c[g];u.y=n.minHeight+(n.maxHeight-n.minHeight)*d,o.push(u.x,u.y,u.z),i.push(0,0,0),s.push(a/n.subdivisions,1-t/n.subdivisions)}for(t=0;t<n.subdivisions;t++)for(a=0;a<n.subdivisions;a++)r.push(a+1+(t+1)*(n.subdivisions+1)),r.push(a+1+t*(n.subdivisions+1)),r.push(a+t*(n.subdivisions+1)),r.push(a+(t+1)*(n.subdivisions+1)),r.push(a+1+(t+1)*(n.subdivisions+1)),r.push(a+t*(n.subdivisions+1));e.VertexData.ComputeNormals(o,r,i);var m=new e.VertexData;return m.indices=r,m.positions=o,m.normals=i,m.uvs=s,m},n.createComponentClass=function(n){return e.SceneManager.createObjectFromString(n,"function")},n.createObjectFromString=function(e,n){n=n||"object";for(var t=e.split("."),a=window||this,r=0,o=t.length;r<o;r++)try{a=a[t[r]]}catch(i){break}return typeof a!==n&&(a=null,console&&console.warn(n+" not found: "+e)),a},n.keymap={},n.clientx=0,n.clienty=0,n.mousex=0,n.mousey=0,n.vertical=0,n.horizontal=0,n.x_mousex=0,n.x_mousey=0,n.x_vertical=0,n.x_horizontal=0,n.k_mousex=0,n.k_mousey=0,n.k_vertical=0,n.k_horizontal=0,n.j_mousex=0,n.j_mousey=0,n.j_vertical=0,n.j_horizontal=0,n.g_mousex=0,n.g_mousey=0,n.g_vertical=0,n.g_horizontal=0,n.engine=null,n.gamepad=null,n.gamepads=null,n.gamepadType=e.GamepadType.None,n.gamepadConnected=null,n.gamepadButtonPress=[],n.gamepadButtonDown=[],n.gamepadButtonUp=[],n.gamepadDpadPress=[],n.gamepadDpadDown=[],n.gamepadDpadUp=[],n.gamepadLeftTrigger=[],n.gamepadRightTrigger=[],n.mouseButtonPress=[],n.mouseButtonDown=[],n.mouseButtonUp=[],n.keyButtonPress=[],n.keyButtonDown=[],n.keyButtonUp=[],n.leftJoystick=null,n.rightJoystick=null,n.previousPosition=null,n.preventDefault=!1,n.rightHanded=!0,n.loader=null,n}();e.SceneManager=n}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var n=function(){function e(e){if(null==e)throw new Error("Null owner agent mesh specified.");this._mesh=e,this._info=null!=this._mesh.metadata&&null!=this._mesh.metadata.navAgent?this._mesh.metadata.navAgent:null}return Object.defineProperty(e.prototype,"mesh",{get:function(){return this._mesh},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"info",{get:function(){return this._info},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasAgentInfo",{get:function(){return null!=this.info},enumerable:!0,configurable:!0}),e.prototype.setDestination=function(e){this.hasAgentInfo||console&&console.warn("Null navigation agent metadata. Set agent destination ignored.")},e}();e.NavigationAgent=n}(BABYLON||(BABYLON={}));
|