r3-legacy/build/game-lib-min.js

14 lines
414 KiB
JavaScript
Raw Normal View History

2017-12-05 17:03:24 +01:00
function GameLib(){}var __DATE__="Tue Dec 05 2017 17:00:21 GMT+0100 (CET)";if(void 0===GameLib.D3&&(GameLib.D3=function(){}),void 0===GameLib.D3.API&&(GameLib.D3.API=function(){}),void 0===GameLib.API&&(GameLib.API=function(){}),void 0===GameLib.D3.Runtime&&(GameLib.D3.Runtime=function(){}),void 0===Q){if("undefined"==typeof require)throw console.warn("You need the Q promise library for the GameLib.D3"),new Error("You need the Q promise library for the GameLib.D3");var Q=require("q")}if(void 0===_){if("undefined"==typeof require)throw console.warn("You need the lodash library for the GameLib.D3"),new Error("You need the lodash library for the GameLib.D3");var _=require("lodash")}console.log("Loading GameLib compiled at: "+__DATE__),GameLib.Event=function(){},GameLib.Event.Subscriptions={},GameLib.Event.OnceSubscriptions={},GameLib.Event.WINDOW_RESIZE=1,GameLib.Event.PARENT_SCENE_CHANGE=2,GameLib.Event.PARENT_ENTITY_CHANGE=3,GameLib.Event.INSTANCE_CLONED=4,GameLib.Event.LOAD_IMAGE=5,GameLib.Event.NEW_ENTITY=6,GameLib.Event.MATERIAL_TYPE_CHANGED=7,GameLib.Event.SAVE_COMPONENT=8,GameLib.Event.SAVE_COMPONENT_ERROR=9,GameLib.Event.COMPONENT_SAVED=10,GameLib.Event.LOAD_COMPONENT=11,GameLib.Event.LOAD_COMPONENT_ERROR=12,GameLib.Event.LOGGED_IN=13,GameLib.Event.COMPONENT_CREATED=14,GameLib.Event.COMPONENT_CLONED=15,GameLib.Event.TEXTURE_ANIMATED_CHANGE=16,GameLib.Event.ANIMATE_TEXTURE_INSTANCE=17,GameLib.Event.REMOVE_PARTICLE_ENGINE=18,GameLib.Event.GAME_PAUSE=19,GameLib.Event.TEXTURE_INSTANCE_UPDATED=20,GameLib.Event.PLAY_AUDIO=21,GameLib.Event.MATERIAL_INSTANCE_UPDATED=22,GameLib.Event.PAUSE_AUDIO=23,GameLib.Event.MESH_INSTANCE_UPDATED=24,GameLib.Event.STOP_AUDIO=25,GameLib.Event.LIGHT_INSTANCE_UPDATED=26,GameLib.Event.DELETE_COMPONENT=27,GameLib.Event.COMPONENT_DOWNLOAD_COMPLETE=28,GameLib.Event.COMPONENTS_LINKED=29,GameLib.Event.UNRESOLVED_DEPENDENCIES_UPDATE=30,GameLib.Event.REGISTER_UPDATE=31,GameLib.Event.BUILD_GUI=32,GameLib.Event.REMOVE_MESH=33,GameLib.Event.MESH_SELECTED=34,GameLib.Event.MESH_DESELECTED=35,GameLib.Event.COMPONENT_REGISTER=36,GameLib.Event.IMAGE_NOT_FOUND=37,GameLib.Event.BLENDER_DATA_RECEIVED=38,GameLib.Event.IMAGE_UPLOAD_COMPLETE=39,GameLib.Event.REMOVE_COMPONENT=40,GameLib.Event.KEY_DOWN=41,GameLib.Event.KEY_UP=42,GameLib.Event.RENDER=43,GameLib.Event.EVENT_LIST=44,GameLib.Event.COMPILE_SUCCESS=45,GameLib.Event.COMPILE_FAILED=46,GameLib.Event.IMAGE_CHANGED=47,GameLib.Event.PARENT_ENTITY_CHANGED=48,GameLib.Event.MATERIAL_TEXTURES_UPDATED=49,GameLib.Event.DELETE_COMPONENT_ERROR=50,GameLib.Event.COMPONENT_DELETED=51,GameLib.Event.COMPONENT_TYPES_FETCHED=52,GameLib.Event.AUDIO_ENDED=53,GameLib.Event.COMPONENT_LINKED=54,GameLib.Event.DONE_SAVING=55,GameLib.Event.BEFORE_RENDER=56,GameLib.Event.AFTER_RENDER=57,GameLib.Event.ARRAY_ITEM_ADDED=58,GameLib.Event.INSTANCE_CREATED=59,GameLib.Event.VISUALIZE=60,GameLib.Event.STOP_VISUALIZE=61,GameLib.Event.FETCH_COMPONENT_TYPES=62,GameLib.Event.FETCH_COMPONENTS=63,GameLib.Event.GET_API_URL=64,GameLib.Event.GET_RUNTIME=65,GameLib.Event.PARENT_WORLD_CHANGE=66,GameLib.Event.ANIMATE=67,GameLib.Event.ANIMATION_COMPILE_SUCCESS=68,GameLib.Event.ANIMATION_COMPILE_FAILED=69,GameLib.Event.SAVING=70,GameLib.Event.GAME_OVER=71,GameLib.Event.GAME_START=72,GameLib.Event.TOUCH_START=73,GameLib.Event.TOUCH_END=74,GameLib.Event.TOUCH_MOVE=75,GameLib.Event.TOUCH_CANCEL=76,GameLib.Event.GET_REMOTE_API_URL=77,GameLib.Event.COMPONENT_TYPES_UPDATE=78,GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED=79,GameLib.Event.CAST_SOURCE_CHANGED=80,GameLib.Event.ANIMATION_MESH_ADDED=81,GameLib.Event.ANIMATION_MESH_REMOVED=82,GameLib.Event.GET_SCENE=83,GameLib.Event.CUSTOM_CODE_WINDOW_RESIZE=84,GameLib.Event.LOAD_FONT=85,GameLib.Event.FONT_NOT_FOUND=86,GameLib.Event.STOP_ALL_AUDIO=87,GameLib.Event.REGISTER_DEPENDENCIES=88,GameLib.Event.GAME_LOADED=89,GameLib.Event.LOAD_PROGRESS=91,GameLib.Event.ENTITY_LOADED=92,GameLib.Event.MOUSE_DOWN=93,GameLib.Event.MOUSE_MOVE=94,GameLib.Event.MOUSE_WHEEL=95,GameLib.Event.MOUSE_UP=96,GameLib.Event.PARTICLE_INSTANCE_UPDATED=97,GameLib.Event.GAME_DATA=98,GameLib.Event.
;this.cloneNumber+=1,e.id=GameLib.Utils.RandomId(),e.name=this.name+" Clone ("+this.cloneNumber+")";var t=GameLib.Component.Construct(e);return t.isClone=!0,GameLib.Event.Emit(GameLib.Event.COMPONENT_CLONED,{parent:this,component:t}),t.parentEntity=null,t},GameLib.Component.prototype.cloneInstance=function(){var e=null;return this.instance&&this.instance.clone&&(this.instance.clone,!0)&&(e=this.instance.clone(),GameLib.Event.Emit(GameLib.Event.INSTANCE_CLONED,{component:this,instance:e})),e},GameLib.Component.prototype.saveToRemoteAPI=function(){this.save(!0)},GameLib.Component.prototype.save=function(e){var t=[],i=[],n=[];if(this.buildIdToObject(),this.saveSubscription||this.saveErrorSubscription)return void console.warn("another save is in progress");GameLib.Event.Emit(GameLib.Event.SAVING,{component:this}),this.saveSubscription=GameLib.Event.Subscribe(GameLib.Event.COMPONENT_SAVED,function(e){i.push(e.component),n.length+i.length===t.length&&(this.saveSubscription.remove(),this.saveSubscription=null,this.saveErrorSubscription.remove(),this.saveErrorSubscription=null,GameLib.Event.Emit(GameLib.Event.DONE_SAVING,{failed:n,saved:i}))}.bind(this)),this.saveErrorSubscription=GameLib.Event.Subscribe(GameLib.Event.SAVE_COMPONENT_ERROR,function(e){n.push(e.component),n.length+i.length===t.length&&(this.saveSubscription.remove(),this.saveSubscription=null,this.saveErrorSubscription.remove(),this.saveErrorSubscription=null,GameLib.Event.Emit(GameLib.Event.DONE_SAVING,{failed:n,saved:i}))}.bind(this));for(var s in this.idToObject)if(this.idToObject.hasOwnProperty(s)&&this.idToObject[s]instanceof GameLib.Component){var a=this.idToObject[s].toApiObject();t.push(a),this.publish(GameLib.Event.SAVE_COMPONENT,{apiObject:a,remote:e})}},GameLib.Component.Construct=function(e){var t=null,i=GameLib.Component.GetComponentInfo(e.componentType),n=i.constructor,s=n.FromObject,a=null;return GameLib.Event.Emit(GameLib.Event.GET_RUNTIME,null,function(e){a=e}),e.componentType===GameLib.Component.ENTITY?t=s(e,GameLib.EntityManager.Instance):i.runtime===GameLib.Component.GRAPHICS_RUNTIME?(GameLib.Utils.UndefinedOrNull(a.graphics)&&console.warn("no runtime graphics"),t=s(a.graphics,e)):i.runtime===GameLib.Component.PHYSICS_RUNTIME?(GameLib.Utils.UndefinedOrNull(a.physics)&&console.warn("no runtime physics"),t=s(a.physics,e)):i.runtime===GameLib.Component.GUI_RUNTIME?(GameLib.Utils.UndefinedOrNull(a.gui)&&console.warn("no runtime gui"),t=s(a.gui,e)):i.runtime===GameLib.Component.SOCKET_RUNTIME?(GameLib.Utils.UndefinedOrNull(a.sockets)&&console.warn("no runtime sockets"),t=s(a.sockets,e)):i.runtime===GameLib.Component.STATISTICS_RUNTIME?(GameLib.Utils.UndefinedOrNull(a.statistics)&&console.warn("no runtime statistics"),t=s(a.statistics,e)):i.runtime===GameLib.Component.DEFAULT_RUNTIME?t=s(e):(console.log("unknown runtime object found : "+e.name),console.error(e)),t},GameLib.API.Canvas=function(e,t,i,n,s){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Canvas ("+e+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=512),this.width=i,GameLib.Utils.UndefinedOrNull(n)&&(n=512),this.height=n,GameLib.API.Component.call(this,GameLib.Component.CANVAS,s)},GameLib.API.Canvas.prototype=Object.create(GameLib.Component.prototype),GameLib.API.Canvas.prototype.constructor=GameLib.API.Canvas,GameLib.API.Canvas.FromObject=function(e){return new GameLib.API.Canvas(e.id,e.name,e.width,e.height,e.parentEntity)},GameLib.API.Cast=function(e,t,i,n,s,a,o,r,c,m){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Cast ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=GameLib.Cast.CAST_TYPE_ROOM),this.castType=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.source=n,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.sourceProperties=s,GameLib.Utils.UndefinedOrNull(a)&&(a="default"),this.roomId=a,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.peer=o,GameLib.Utils.UndefinedOrNull(r)&&(r="127.0.0.1"),this.serverIp=r,GameLib.Utils.UndefinedOrN
return new GameLib.API.Clock(this.id,this.name,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.Clock.FromObject=function(e,t){var i=GameLib.API.Clock.FromObject(t);return new GameLib.Clock(e,i)},GameLib.CoderRuntime=function(e,t,i){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Coder ("+e+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=GameLib.CoderRuntime.TYPE_CODE_MIRROR),this.coderType=i,this.createInstance()},GameLib.CoderRuntime.TYPE_CODE_MIRROR=1,GameLib.CoderRuntime.prototype.createInstance=function(){this.coderType===GameLib.CoderRuntime.TYPE_CODE_MIRROR?this.instance=CodeMirror:this.instance=null},GameLib.CoderRuntime.prototype.updateInstance=function(e){"coderType"===e&&this.createInstance()},GameLib.CoderRuntime.prototype.isNotCodeMirrorThrow=function(){if(this.instance!==CodeMirror)throw console.error("Only CodeMirror supported"),new Error("Only CodeMirror supported")},GameLib.Color=function(e,t,i,n){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.Color)return t;GameLib.API.Color.call(this,t.r,t.g,t.b,t.a),GameLib.Utils.UndefinedOrNull(i)&&(i=null),this.parentObject=i,GameLib.Utils.UndefinedOrNull(n)&&(n=.001),this.grain=n,this.createInstance()},GameLib.Color.prototype=Object.create(GameLib.API.Color.prototype),GameLib.Color.prototype.constructor=GameLib.Color,GameLib.Color.prototype.createInstance=function(){this.instance=new THREE.Color(this.r,this.g,this.b)},GameLib.Color.prototype.updateInstance=function(e){this.instance.r=this.r,this.instance.g=this.g,this.instance.b=this.b,this.parentObject&&this.parentObject.updateInstance&&this.parentObject.updateInstance(e)},GameLib.Color.prototype.toApiObject=function(){return new GameLib.API.Color(this.r,this.g,this.b,this.a)},GameLib.Controls=function(e){if(GameLib.Utils.UndefinedOrNull(e)&&(e={}),e instanceof GameLib.Controls)return e;GameLib.API.Controls.call(this,e.id,e.controlsType,e.name,e.domElement,e.parentEntity);var t={domElement:GameLib.DomElement},i=!1;this.controlsType===GameLib.Controls.CONTROLS_TYPE_EDITOR&&(t.raycaster=GameLib.D3.Raycaster,t.camera=GameLib.D3.Camera,i=!0),GameLib.Component.call(this,t,i)},GameLib.Controls.prototype=Object.create(GameLib.API.Controls.prototype),GameLib.Controls.prototype.constructor=GameLib.Controls,GameLib.Controls.D3=function(){},GameLib.Controls.CONTROLS_TYPE_EDITOR=0,GameLib.Controls.CONTROLS_TYPE_TOUCH=1,GameLib.Controls.CONTROLS_TYPE_KEYBOARD=2,GameLib.Controls.CONTROLS_TYPE_MOUSE=3,GameLib.Controls.prototype.createInstance=function(){GameLib.Component.prototype.createInstance.call(this)},GameLib.Controls.prototype.updateInstance=function(){console.log("default controls update instance")},GameLib.Controls.prototype.toApiObject=function(){return new GameLib.API.Controls(this.id,this.controlsType,this.name,GameLib.Utils.IdOrNull(this.domElement),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.Controls.FromObject=function(e){var t=GameLib.API.Controls.FromObject(e);return new GameLib.Controls(t)},GameLib.Controls.D3.Editor=function(e,t,i,n){this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(i)&&(i=null),this.raycaster=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.camera=n,this.raycaster instanceof GameLib.D3.API.Raycaster&&(this.raycaster=new GameLib.D3.Raycaster(this.graphics,this.raycaster)),this.camera instanceof GameLib.D3.API.Camera&&(this.camera=new GameLib.D3.Camera(this.graphics,this.camera)),GameLib.Controls.call(this,t)},GameLib.Controls.D3.Editor.prototype=Object.create(GameLib.Controls.prototype),GameLib.Controls.D3.Editor.prototype.constructor=GameLib.Controls.D3.Editor,GameLib.Controls.D3.Editor.prototype.createInstance=function(){if(!this.camera||!this.camera.instance)throw new Error("No camera at time of instance");if(!this.domElement||!this.domElement.instance)throw new Error("No dom element at time of instance");this.instance=new THREE.EditorControls(this.camera.instance,this.domElement.instance),GameLib.Controls.prototype.c
GameLib.D3.API.Mesh.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Mesh.prototype.constructor=GameLib.D3.API.Mesh,GameLib.D3.API.Mesh.MESH_TYPE_NORMAL=0,GameLib.D3.API.Mesh.MESH_TYPE_SKINNED=1,GameLib.D3.API.Mesh.MESH_TYPE_CURVE=2,GameLib.D3.API.Mesh.MESH_TYPE_SPHERE=3,GameLib.D3.API.Mesh.MESH_TYPE_PLANE=4,GameLib.D3.API.Mesh.MESH_TYPE_BOX=5,GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER=6,GameLib.D3.API.Mesh.MESH_TYPE_TEXT=7,GameLib.D3.API.Mesh.MESH_TYPE_LINE=8,GameLib.D3.API.Mesh.FromObject=function(e){var t=[];e.faces&&(t=e.faces.map(function(e){return GameLib.D3.API.Face.FromObject(e)}));var i=null;e.skeleton&&(i=GameLib.D3.API.Skeleton.FromObject(e.skeleton));var n=[];e.materials&&(n=e.materials.map(function(e){return e instanceof Object?GameLib.D3.API.Material.FromObject(e):e}));var s=[];e.vertices&&(s=e.vertices.map(function(e){return GameLib.D3.API.Vertex.FromObject(e)}));var a=new GameLib.API.Vector3;e.position&&(a=GameLib.API.Vector3.FromObject(e.position));var o=new GameLib.API.Vector3;e.rotation&&(o=GameLib.API.Vector3.FromObject(e.rotation));var r=new GameLib.API.Quaternion;e.quaternion&&(r=GameLib.API.Quaternion.FromObject(e.quaternion));var c=new GameLib.API.Vector3(1,1,1);e.scale&&(c=GameLib.API.Vector3.FromObject(e.scale));var m=new GameLib.API.Vector3(0,1,0);e.up&&(m=GameLib.API.Vector3.FromObject(e.up));var h=new GameLib.API.Matrix4;return e.modelMatrix&&(h=GameLib.API.Matrix4.FromObject(e.modelMatrix)),new GameLib.D3.API.Mesh(e.id,e.meshType,e.name,s,t,n,e.parentMesh,e.parentScene,i,e.skinIndices,e.skinWeights,a,r,o,c,m,h,e.renderOrder,e.isBufferMesh,e.useQuaternion,e.visible,e.parentEntity)},GameLib.D3.API.ParticleEngine=function(e,t,i,n,s,a,o,r,c,m,h,l){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="ParticleEngine ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=new GameLib.API.Vector3(0,0,0)),this.position=i,GameLib.Utils.UndefinedOrNull(n)&&(n=new GameLib.API.Vector3(0,1,0)),this.direction=n,GameLib.Utils.UndefinedOrNull(s)&&(s=!1),this.enabled=s,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.templateParticle=a,GameLib.Utils.UndefinedOrNull(o)&&(o=1),this.particlesPerSecond=o,GameLib.Utils.UndefinedOrNull(r)&&(r=Number(1/Number(this.particlesPerSecond))),this.frequency=r,GameLib.Utils.UndefinedOrNull(c)&&(c=0),this.elapsed=c,GameLib.Utils.UndefinedOrNull(m)&&(m=null),this.camera=m,GameLib.Utils.UndefinedOrNull(h)&&(h=!1),this.pulse=h,GameLib.API.Component.call(this,GameLib.Component.PARTICLE_ENGINE,l)},GameLib.D3.API.ParticleEngine.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.ParticleEngine.prototype.constructor=GameLib.D3.API.ParticleEngine,GameLib.D3.API.ParticleEngine.FromObject=function(e){var t=null;e.templateParticle&&(t=e.templateParticle instanceof Object?GameLib.D3.API.Particle.FromObject(e.templateParticle):e.templateParticle);var i=null;e.camera&&(i=e.camera instanceof Object?GameLib.D3.API.Camera.FromObject(e.camera):e.camera);var n=null;e.position&&(n=GameLib.API.Vector3.FromObject(e.position));var s=null;return e.direction&&(s=GameLib.API.Vector3.FromObject(e.direction)),new GameLib.D3.API.ParticleEngine(e.id,e.name,n,s,e.enabled,t,e.particlesPerSecond,e.frequency,e.elapsed,i,e.pulse,e.parentEntity)},GameLib.D3.API.Particle=function(e,t,i,n,s,a,o,r,c,m,h,l,p,u,b,d,L,G,f,E,y,I,P){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Particle ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=10),this.lifeTime=i,GameLib.Utils.UndefinedOrNull(n)&&(n=0),this.elapsed=n,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.mesh=s,GameLib.Utils.UndefinedOrNull(a)&&(a=GameLib.D3.Particle.OPACITY_TYPE_CONSTANT),this.opacityType=a,GameLib.Utils.UndefinedOrNull(o)&&(o=.01),this.opacityFactor=o,GameLib.Utils.UndefinedOrNull(r)&&(r=GameLib.D3.Particle.POSITION_OFFSET_TYPE_CONSTANT),this.positionOffsetType=r,GameLib.Utils.UndefinedOrNull(c)&&(c=new GameLib.API.Vector3(0,0,0)),this.positionOffset=c,GameLib.Utils.Undefi
GameLib.D3.Animation.prototype.toApiObject=function(){return new GameLib.D3.API.Animation(this.id,this.name,this.rotationSpeed,this.translationSpeed,this.scaleSpeed,this.rotationFn,this.translationFn,this.scaleFn,this.blocking,this.applyToMeshWhenDone,this.meshes.map(function(e){return GameLib.Utils.IdOrNull(e)}),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Animation.FromObject=function(e){var t=GameLib.D3.API.Animation.FromObject(e);return new GameLib.D3.Animation(t)},GameLib.D3.Animation.prototype.launchEditor=function(){GameLib.Event.Emit(GameLib.Event.GET_RUNTIME,null,function(e){this.coder=e.coder,this.coder.isNotCodeMirrorThrow()}.bind(this));var e=null;this.functionType===GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_ROTATION&&(this.rotationFn="//when the animation is complete, return true\nreturn true;",e="rotationFn"),this.functionType===GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_TRANSLATION&&(this.translationFn="//when the animation is complete, return true\nreturn true;",e="translationFn"),this.functionType===GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_SCALE&&(this.scaleFn="//when the animation is complete, return true\nreturn true;",e="scaleFn"),e?(this.editor=this.coder.instance(document.body,{value:this[e],mode:"javascript",lineNumbers:!0,scrollbarStyle:"overlay"}),this.editor.on("change",function(){this[e]=this.editor.getValue(),this.updateInstance()}.bind(this))):console.warn("invalid function type selected")},GameLib.D3.Animation.prototype.closeEditor=function(){var e=this.editor.getWrapperElement();e.parentElement.removeChild(e)},GameLib.D3.Animation.prototype.addMesh=function(e){GameLib.Utils.PushUnique(this.meshes,e),GameLib.Event.Emit(GameLib.Event.ANIMATION_MESH_ADDED,{animation:this,mesh:e})},GameLib.D3.Animation.prototype.removeMesh=function(e){var t=this.meshes.indexOf(e);this.meshes.splice(t,1),GameLib.Event.Emit(GameLib.Event.ANIMATION_MESH_REMOVED,{animation:this,mesh:e})},GameLib.D3.Audio=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Audio)return t;GameLib.D3.API.Audio.call(this,t.id,t.name,t.path,t.loop,t.volume,t.camera,t.overplay,t.pause,t.parentEntity),this.camera instanceof GameLib.D3.API.Camera&&(this.camera=new GameLib.D3.Camera(this.graphics,this.camera)),GameLib.Component.call(this,{camera:GameLib.D3.Camera})},GameLib.D3.Audio.prototype=Object.create(GameLib.D3.API.Audio.prototype),GameLib.D3.Audio.prototype.constructor=GameLib.D3.Audio,GameLib.D3.Audio.prototype.createInstance=function(){if(GameLib.Utils.UndefinedOrNull(this.camera)||GameLib.Utils.UndefinedOrNull(this.camera.instance))return void console.log("audio not ready to create instance");GameLib.Event.Emit(GameLib.Event.GET_API_URL,null,function(e){this.apiUrl=e.apiUrl}.bind(this));var e=new THREE.AudioListener;this.camera.instance.add(e),this.instance=new THREE.Audio(e),(new THREE.AudioLoader).load(this.apiUrl+this.path+"?ts="+Date.now(),function(e){this.instance.setBuffer(e),this.instance.setLoop(this.loop),this.instance.setVolume(this.volume),GameLib.Component.prototype.createInstance.call(this)}.bind(this))},GameLib.D3.Audio.prototype.updateInstance=function(e){"loop"===e&&this.instance.setLoop(this.loop),"volume"===e&&this.instance.setVolume(this.volume),"paused"===e&&(this.paused?this.instance.pause():this.instance.play())},GameLib.D3.Audio.prototype.toApiObject=function(){return new GameLib.D3.API.Audio(this.id,this.name,this.path,this.loop,this.volume,GameLib.Utils.IdOrNull(this.camera),this.overplay,this.paused,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Audio.FromObject=function(e,t){var i=GameLib.D3.API.Audio.FromObject(t);return new GameLib.D3.Audio(e,i)},GameLib.D3.Audio.prototype.play=function(){this.instance.play()},GameLib.D3.BoneWeight=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.BoneWeight)return t;GameLib.D3.API.BoneWeight.call(this,t.boneIndex,t.weight)},GameLib.D3.BoneWeight.prototype=Object.create(GameLib.D3.API.B
this.aoMap&&this.aoMap instanceof GameLib.D3.API.Texture&&(this.aoMap=new GameLib.D3.Texture(this.graphics,this.aoMap)),this.bumpMap&&this.bumpMap instanceof GameLib.D3.API.Texture&&(this.bumpMap=new GameLib.D3.Texture(this.graphics,this.bumpMap)),this.diffuseMap&&this.diffuseMap instanceof GameLib.D3.API.Texture&&(this.diffuseMap=new GameLib.D3.Texture(this.graphics,this.diffuseMap)),this.displacementMap&&this.displacementMap instanceof GameLib.D3.API.Texture&&(this.displacementMap=new GameLib.D3.Texture(this.graphics,this.displacementMap)),this.emissiveMap&&this.emissiveMap instanceof GameLib.D3.API.Texture&&(this.emissiveMap=new GameLib.D3.Texture(this.graphics,this.emissiveMap)),this.environmentMap&&this.environmentMap instanceof GameLib.D3.API.Texture&&(this.environmentMap=new GameLib.D3.Texture(this.graphics,this.environmentMap)),this.lightMap&&this.lightMap instanceof GameLib.D3.API.Texture&&(this.lightMap=new GameLib.D3.Texture(this.graphics,this.lightMap)),this.metalnessMap&&this.metalnessMap instanceof GameLib.D3.API.Texture&&(this.metalnessMap=new GameLib.D3.Texture(this.graphics,this.metalnessMap)),this.normalMap&&this.normalMap instanceof GameLib.D3.API.Texture&&(this.normalMap=new GameLib.D3.Texture(this.graphics,this.normalMap)),this.roughnessMap&&this.roughnessMap instanceof GameLib.D3.API.Texture&&(this.roughnessMap=new GameLib.D3.Texture(this.graphics,this.roughnessMap)),this.specularMap&&this.specularMap instanceof GameLib.D3.API.Texture&&(this.specularMap=new GameLib.D3.Texture(this.graphics,this.specularMap)),GameLib.Component.call(this,{alphaMap:GameLib.D3.Texture,aoMap:GameLib.D3.Texture,bumpMap:GameLib.D3.Texture,diffuseMap:GameLib.D3.Texture,displacementMap:GameLib.D3.Texture,emissiveMap:GameLib.D3.Texture,environmentMap:GameLib.D3.Texture,lightMap:GameLib.D3.Texture,metalnessMap:GameLib.D3.Texture,normalMap:GameLib.D3.Texture,roughnessMap:GameLib.D3.Texture,specularMap:GameLib.D3.Texture})},GameLib.D3.Material.prototype=Object.create(GameLib.D3.API.Material.prototype),GameLib.D3.Material.prototype.constructor=GameLib.D3.Material,GameLib.D3.Material.TYPE_MULTIPLY_OPERATION=0,GameLib.D3.Material.TYPE_MIX_OPERATION=1,GameLib.D3.Material.TYPE_ADD_OPERATION=2,GameLib.D3.Material.TYPE_NO_COLORS=0,GameLib.D3.Material.TYPE_FACE_COLORS=1,GameLib.D3.Material.TYPE_VERTEX_COLORS=2,GameLib.D3.Material.TYPE_NO_BLENDING=0,GameLib.D3.Material.TYPE_NORMAL_BLENDING=1,GameLib.D3.Material.TYPE_ADDITIVE_BLENDING=2,GameLib.D3.Material.TYPE_SUBTRACTIVE_BLENDING=3,GameLib.D3.Material.TYPE_MULTIPLY_BLENDING=4,GameLib.D3.Material.TYPE_CUSTOM_BLENDING=5,GameLib.D3.Material.TYPE_ZERO_FACTOR=200,GameLib.D3.Material.TYPE_ONE_FACTOR=201,GameLib.D3.Material.TYPE_SRC_COLOR_FACTOR=202,GameLib.D3.Material.TYPE_ONE_MINUS_SRC_COLOR_FACTOR=203,GameLib.D3.Material.TYPE_SRC_ALPHA_FACTOR=204,GameLib.D3.Material.TYPE_ONE_MINUS_SRC_ALPHA_FACTOR=205,GameLib.D3.Material.TYPE_DST_ALPHA_FACTOR=206,GameLib.D3.Material.TYPE_ONE_MINUS_DST_ALPHA_FACTOR=207,GameLib.D3.Material.TYPE_DST_COLOR_FACTOR=208,GameLib.D3.Material.TYPE_ONE_MINUS_DST_COLOR_FACTOR=209,GameLib.D3.Material.TYPE_SRC_ALPHA_SATURATE_FACTOR=210;GameLib.D3.Material.TYPE_ADD_EQUATION=100,GameLib.D3.Material.TYPE_SUBTRACT_EQUATION=101,GameLib.D3.Material.TYPE_REVERSE_SUBTRACT_EQUATION=102,GameLib.D3.Material.TYPE_MIN_EQUATION=103,GameLib.D3.Material.TYPE_MAX_EQUATION=104,GameLib.D3.Material.TYPE_NEVER_DEPTH=0,GameLib.D3.Material.TYPE_ALWAYS_DEPTH=1,GameLib.D3.Material.TYPE_LESS_DEPTH=2,GameLib.D3.Material.TYPE_LESS_EQUAL_DEPTH=3,GameLib.D3.Material.TYPE_EQUAL_DEPTH=4,GameLib.D3.Material.TYPE_GREATER_EQUAL_DEPTH=5,GameLib.D3.Material.TYPE_GREATER_DEPTH=6,GameLib.D3.Material.TYPE_NOT_EQUAL_DEPTH=7,GameLib.D3.Material.TYPE_FRONT_SIDE=0,GameLib.D3.Material.TYPE_BACK_SIDE=1,GameLib.D3.Material.TYPE_DOUBLE_SIDE=2,GameLib.D3.Material.TYPE_FLAT_SHADING=1,GameLib.D3.Material.TYPE_SMOOTH_SHADING=2,GameLib.D3.Material.MATERIAL_TYPE_LINE_BASIC=1,GameLib.D3.Material.MATERIAL_TYPE_LINE_DASHED=2,GameLib.D3.Material.MATERIAL_TYPE_BASIC=3,GameLib.D3.Material.MATERIAL_TYPE_DEPTH=4,GameLib.D3.Materia
;var l=this.vertices.reduce(function(e,t,i){return t.position.equals(m.position)&&(e=i),e},-1),p=l;-1===l&&(this.vertices.push(m),p=this.vertices.length-1),o.push(p),3===o.length&&(this.faces.push(new GameLib.D3.Face(this.graphics,new GameLib.D3.API.Face(null,null,o[0],o[1],o[2],n,[[r[0],r[1],r[2]]]))),r=[],o=[])}}.bind(this)),console.log("todo : update vertices from buffer geometry")}else{var n=0;e.faces.map(function(t,i){n++,n%100==0&&console.log("processed "+n+" faces"),this.faces.push(new GameLib.D3.Face(this.graphics,new GameLib.D3.API.Face(null,null,t.a,t.b,t.c,t.materialIndex,[[new GameLib.API.Vector2(e.faceVertexUvs[0][i][0].x,e.faceVertexUvs[0][i][0].y),new GameLib.API.Vector2(e.faceVertexUvs[0][i][1].x,e.faceVertexUvs[0][i][1].y),new GameLib.API.Vector2(e.faceVertexUvs[0][i][2].x,e.faceVertexUvs[0][i][2].y)]],new GameLib.Color(this.graphics,new GameLib.API.Color(t.color.r,t.color.g,t.color.b)),t.vertexColors.map(function(e){return new GameLib.Color(this.graphics,new GameLib.API.Color(e.r,e.g,e.b))}.bind(this)),t.vertexNormals.map(function(e){return new GameLib.Vector3(this.graphics,new GameLib.API.Vector3(e.x,e.y,e.z))}.bind(this)),new GameLib.Vector3(this.graphics,new GameLib.API.Vector3(t.normal.x,t.normal.y,t.normal.z)))))}.bind(this)),n=0,e.vertices.map(function(e){n++,n%100==0&&console.log("processed "+n+" vertices"),this.vertices.push(new GameLib.D3.Vertex(this.graphics,new GameLib.D3.API.Vertex(new GameLib.Vector3(this.graphics,new GameLib.API.Vector3(e.x,e.y,e.z)))))}.bind(this))}},GameLib.D3.Mesh.prototype.applyBones=function(e){this.skinIndices.map(function(t){e.skinIndices.push(new THREE.Vector4(t.x,t.y,t.z,t.w))}),this.skinWeights.map(function(t){e.skinWeights.push(new THREE.Vector4(t.x,t.y,t.z,t.w))})},GameLib.D3.Mesh.prototype.addChild=function(e,t){if(!this.instance)throw new Error("mesh instance not loaded yet : "+this.name);if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no child mesh instance");if(GameLib.Utils.UndefinedOrNull(t))throw new Error("no child mesh");this.instance.add(e),e.parent=this.instance,t.parentMesh=this},GameLib.D3.Mesh.prototype.setParentMesh=function(e){if(GameLib.Utils.UndefinedOrNull(e)){if(!(this.instance&&this.instance.parent&&this.parentScene.instance))throw new Error("Not enough information to detach");this.instance.parent.updateMatrixWorld();var t=new THREE.Vector3;t.setFromMatrixPosition(this.instance.matrixWorld),THREE.SceneUtils.detach(this.instance,this.instance.parent,this.parentScene.instance),this.parentMesh=null,this.position.x=t.x,this.position.y=t.y,this.position.z=t.z,this.updateInstancePosition()}else{if(!this.instance)throw new Error("No valid instance at time of adding to parent for mesh "+this.name);if(!(e instanceof GameLib.D3.Mesh))throw new Error("Not a valid parent mesh");this.parentMesh=e,this.parentMesh.addChild(this.instance,this)}},GameLib.D3.Mesh.prototype.toApiObject=function(){var e=null;this.skeleton&&(e=this.skeleton.id);var t=null;this.materials&&(t=this.materials.map(function(e){return e.id}));var i=this.faces.map(function(e){return e.toApiObject()});return new GameLib.D3.API.Mesh(this.id,this.meshType,this.name,this.vertices.map(function(e){return e.toApiObject()}),i,t,GameLib.Utils.IdOrNull(this.parentMesh),GameLib.Utils.IdOrNull(this.parentScene),e,this.skinIndices,this.skinWeights,this.position.toApiObject(),this.quaternion.toApiObject(),this.rotation.toApiObject(),this.scale.toApiObject(),this.up.toApiObject(),this.modelMatrix.toApiObject(),this.renderOrder,this.isBufferMesh,this.useQuaternion,this.visible,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Mesh.FromObject=function(e,t){var i=GameLib.D3.API.Mesh.FromObject(t);return new GameLib.D3.Mesh(e,i)},GameLib.D3.Mesh.prototype.centerAroundOrigin=function(){var e=this.instance.geometry.center();this.instance.position.set(0,0,0),this.instance.updateMatrix();for(var t=0;t<this.instance.geometry.vertices.length;t++)this.vertices[t].position.x=this.instance.geometry.vertices[t].x,this.vertices[t].position.y=this.instance.geometry.vertices[t].y,this.vertices[t].position.
GameLib.D3.ParticleEngine.prototype.createNewParticle=function(e){},GameLib.D3.ParticleEngine.prototype.toApiObject=function(){return new GameLib.D3.API.ParticleEngine(this.id,this.name,this.position.toApiObject(),this.direction.toApiObject(),this.enabled,GameLib.Utils.IdOrNull(this.templateParticle),this.particlesPerSecond,this.frequency,this.elapsed,GameLib.Utils.IdOrNull(this.camera),this.pulse,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.ParticleEngine.FromObject=function(e,t){var i=GameLib.D3.API.ParticleEngine.FromObject(t);return new GameLib.D3.ParticleEngine(e,i)},GameLib.D3.Particle=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Particle)return t;if(GameLib.D3.API.Particle.call(this,t.id,t.name,t.lifeTime,t.elapsed,t.mesh,t.opacityType,t.opacityFactor,t.positionOffsetType,t.positionOffset,t.positionOffsetFn,t.directionType,t.direction,t.directionFn,t.speedType,t.speed,t.scaleType,t.scale,t.scaleFn,t.rotationType,t.rotation,t.rotationFn,t.parentEngine,t.parentEntity),this.mesh instanceof GameLib.D3.API.Mesh&&(this.mesh=new GameLib.D3.Mesh(e,this.mesh)),!(this.positionOffset instanceof GameLib.API.Vector3))throw console.warn("positionOffset not instance of API.Vector3"),new Error("positionOffset not instance of API.Vector3");if(this.positionOffset=new GameLib.Vector3(e,this.positionOffset,this),!(this.direction instanceof GameLib.API.Vector3))throw console.warn("direction not instance of API.Vector3"),new Error("direction not instance of API.Vector3");if(this.direction=new GameLib.Vector3(e,this.direction,this),!(this.scale instanceof GameLib.API.Vector3))throw console.warn("scale not instance of API.Vector3"),new Error("scale not instance of API.Vector3");if(this.scale=new GameLib.Vector3(e,this.scale,this),!(this.rotation instanceof GameLib.API.Vector3))throw console.warn("rotation not instance of API.Vector3"),new Error("rotation not instance of API.Vector3");this.rotation=new GameLib.Vector3(e,this.rotation,this),GameLib.Component.call(this,{mesh:GameLib.D3.Mesh,parentEngine:GameLib.D3.ParticleEngine})},GameLib.D3.Particle.prototype=Object.create(GameLib.D3.API.Particle.prototype),GameLib.D3.Particle.prototype.constructor=GameLib.D3.Particle,GameLib.D3.Particle.OPACITY_TYPE_CONSTANT=1,GameLib.D3.Particle.OPACITY_TYPE_DECREASE_LINEAR=2,GameLib.D3.Particle.OPACITY_TYPE_INCREASE_LINEAR=3,GameLib.D3.Particle.POSITION_OFFSET_TYPE_CONSTANT=1,GameLib.D3.Particle.POSITION_OFFSET_TYPE_RANDOM=2,GameLib.D3.Particle.POSITION_OFFSET_TYPE_FUNCTION=3,GameLib.D3.Particle.DIRECTION_TYPE_CONSTANT=1,GameLib.D3.Particle.DIRECTION_TYPE_RANDOM=2,GameLib.D3.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED=3,GameLib.D3.Particle.DIRECTION_TYPE_FUNCTION=4,GameLib.D3.Particle.SCALE_TYPE_CONSTANT=1,GameLib.D3.Particle.SCALE_TYPE_LINEAR=2,GameLib.D3.Particle.SCALE_TYPE_EXPONENTIAL=3,GameLib.D3.Particle.SCALE_TYPE_RANDOM=4,GameLib.D3.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y=6,GameLib.D3.Particle.SCALE_TYPE_FUNCTION=7,GameLib.D3.Particle.SPEED_TYPE_CONSTANT=1,GameLib.D3.Particle.SPEED_TYPE_LINEAR=2,GameLib.D3.Particle.SPEED_TYPE_EXPONENTIAL=3,GameLib.D3.Particle.SPEED_TYPE_LOGARITHMIC=4,GameLib.D3.Particle.SPEED_TYPE_ONE_OVER_LOG=5,GameLib.D3.Particle.SPEED_TYPE_EXP=6,GameLib.D3.Particle.SPEED_TYPE_ONE_OVER_EXP=7,GameLib.D3.Particle.ROTATION_TYPE_CONSTANT=1,GameLib.D3.Particle.ROTATION_TYPE_RANDOM=2,GameLib.D3.Particle.ROTATION_TYPE_FUNCTION=3,GameLib.D3.Particle.prototype.createInstance=function(){if(!this.mesh)return void console.warn("no mesh to clone from - failed dependency check?");this.instance=this.mesh.instance,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Particle.prototype.updateInstance=function(e){"positionOffset"===e&&(this.positionOffset.instance.x=this.positionOffset.x,this.positionOffset.instance.y=this.positionOffset.y,this.positionOffset.instance.z=this.positionOffset.z),"direction"===e&&(this.direction.instance.x=this.direction.x,this.direction.instance.y=this.direction.y,this.direction.instance.z=this.direction.z),"sc
}),GameLib.Utils.IdOrNull(this.bufferScene),GameLib.Utils.IdOrNull(this.bufferCamera),GameLib.Utils.IdOrNull(this.renderTarget),GameLib.Utils.IdOrNull(this.defaultScene),this.sortObjects,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Renderer.FromObject=function(e,t){var i=GameLib.D3.API.Renderer.FromObject(t);return new GameLib.D3.Renderer(e,i)},GameLib.D3.Renderer.prototype.render=function(e,t){this.instance&&(GameLib.Utils.UndefinedOrNull(t)&&(t=this.scenes),this.viewports.length>1&&(this.instance.autoClear=!1),t.length>1&&(this.instance.autoClear=!1),this.instance.clear(),this.bufferScene&&this.bufferScene.instance&&this.bufferCamera&&this.bufferCamera.instance&&this.renderTarget&&this.renderTarget.instance&&this.instance.render(this.bufferScene.instance,this.bufferCamera.instance,this.renderTarget.instance),this.viewports.map(function(e){this.instance.setViewport(e.x*this.width,e.y*this.height,e.width*this.width,e.height*this.height),t.map(function(e){e.instance&&(this.camera.instance||e.renderCamera||e.renderCamera.instance)&&(e.renderCamera&&e.renderCamera.instance?this.instance.render(e.instance,e.renderCamera.instance):this.instance.render(e.instance,this.camera.instance))}.bind(this))}.bind(this)))},GameLib.D3.Renderer.prototype.setSize=function(e,t){this.width=e,this.height=t,this.instance?this.instance.setSize(this.width,this.height):console.log("renderer not ready to set size")},GameLib.D3.RigidBody=function(e,t){if(this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.RigidBody)return t;GameLib.D3.API.RigidBody.call(this,t.id,t.name,t.mass,t.friction,t.position,t.quaternion,t.velocity,t.angularVelocity,t.linearDamping,t.angularDamping,t.allowSleep,t.sleepSpeedLimit,t.sleepTimeLimit,t.collisionFilterGroup,t.collisionFilterMask,t.fixedRotation,t.shapes,t.kinematic,t.parentMesh,t.parentPhysicsWorld,t.parentEntity),this.position=new GameLib.Vector3(this.physics,this.position,this),this.quaternion=new GameLib.Quaternion(this.physics,this.quaternion,this),this.velocity=new GameLib.Vector3(this.physics,this.velocity,this),this.angularVelocity=new GameLib.Vector3(this.physics,this.angularVelocity,this),this.force=new GameLib.Vector3(this.physics),this.forcePoint=new GameLib.Vector3(this.physics),GameLib.Component.call(this,{shapes:[GameLib.D3.Shape],parentMesh:GameLib.D3.Mesh,parentPhysicsWorld:GameLib.D3.PhysicsWorld})},GameLib.D3.RigidBody.prototype=Object.create(GameLib.D3.API.RigidBody.prototype),GameLib.D3.RigidBody.prototype.constructor=GameLib.D3.RigidBody,GameLib.D3.RigidBody.prototype.createInstance=function(){this.instance=new CANNON.Body({mass:this.mass,friction:this.friction,position:this.position.instance,quaternion:this.quaternion.instance,velocity:this.velocity.instance,angularVelocity:this.angularVelocity.instance,linearDamping:this.linearDamping,angularDamping:this.angularDamping,allowSleep:this.allowSleep,sleepSpeedLimit:this.sleepSpeedLimit,sleepTimeLimit:this.sleepTimeLimit,collisionFilterGroup:this.collisionFilterGroup,collisionFilterMask:this.collisionFilterMask,fixedRotation:this.fixedRotation,kinematic:this.kinematic}),this.instance.addEventListener("sleepy",function(){console.log(this.name+" is feeling sleepy...")}.bind(this)),this.instance.addEventListener("sleep",function(){console.log(this.name+" fell asleep!")}.bind(this)),this.instance.addEventListener("wakeup",function(){console.log(this.name+" woke up!")}.bind(this)),this.shapes.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no shape");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no shape instance");this.instance.addShape(e.instance)}.bind(this)),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.RigidBody.prototype.updateInstance=function(){this.instance.mass=this.mass,this.instance.friction=this.friction,this.instance.position.x=this.position.x,this.instance.position.y=this.position.y,this.instance.position.z=this.position.z,this.quaternion.axis.instance.x=this.quaternion.axis.x,this.quaternion.axis.instance.y=th
this.solverType===GameLib.D3.API.Solver.SPLIT_SOLVER&&(this.instance instanceof CANNON.SplitSolver||(this.instance=new CANNON.SplitSolver)),this.instance.iterations=this.iterations,this.instance.tolerance=this.tolerance},GameLib.D3.Solver.prototype.toApiObject=function(){return new GameLib.D3.API.Solver(this.id,this.name,this.solverType,this.iterations,this.tolerance,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Solver.FromObject=function(e,t){var i=GameLib.D3.API.Solver.FromObject(t);return new GameLib.D3.Solver(e,i)},GameLib.D3.Spline=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Spline)return t;GameLib.D3.API.Spline.call(this,t.id,t.name,t.vertices,t.parentEntity),this.vertices=this.vertices.map(function(t){return new GameLib.Vector3(e,t,this)}),GameLib.Component.call(this)},GameLib.D3.Spline.prototype=Object.create(GameLib.D3.API.Spline.prototype),GameLib.D3.Spline.prototype.constructor=GameLib.D3.Spline,GameLib.D3.Spline.prototype.createInstance=function(){var e=this.vertices.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no vertex");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no vertex instance");return e.instance});this.instance=THREE.CatmullRomCurve3(e),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Spline.prototype.updateInstance=function(){var e=this.vertices.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no vertex");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no vertex instance");return e.instance});this.instance=new THREE.CatmullRomCurve3(e)},GameLib.D3.Spline.prototype.toApiObject=function(){return new GameLib.D3.API.Spline(this.id,this.name,this.vertices.map(function(e){return e.toApiObject()}),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Spline.FromObject=function(e,t){var i=GameLib.D3.API.Spline.FromObject(t);return new GameLib.D3.Spline(e,i)},GameLib.D3.Spline.prototype.getPointAt=function(e){var t=this.instance.getPointAt(e);return new GameLib.Vector3(this.graphics,new GameLib.API.Vector3(t.x,t.y,t.z),this,.1)},GameLib.D3.Texture=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Texture)return t;GameLib.D3.API.Texture.call(this,t.id,t.textureType,t.name,t.image,t.images,t.wrapS,t.wrapT,t.repeat,t.data,t.format,t.mapping,t.magFilter,t.minFilter,t.storageType,t.anisotropy,t.offset,t.generateMipmaps,t.flipY,t.mipmaps,t.unpackAlignment,t.premultiplyAlpha,t.encoding,t.canvas,t.animated,t.reverseAnimation,t.forward,t.parentEntity),this.offset=new GameLib.Vector2(this.graphics,this.offset,this),this.repeat=new GameLib.Vector2(this.graphics,this.repeat,this),this.image instanceof GameLib.API.Image&&(this.image=new GameLib.Image(this.graphics,this.image)),this.images=this.images.map(function(e){return e instanceof GameLib.API.Image?new GameLib.Image(this.graphics,e):e}.bind(this)),this.canvas instanceof GameLib.API.Canvas&&(this.canvas=new GameLib.Canvas(this.graphics,this.canvas)),GameLib.Component.call(this,{image:GameLib.Image,images:[GameLib.Image],canvas:GameLib.Canvas})},GameLib.D3.Texture.prototype=Object.create(GameLib.D3.API.Texture.prototype),GameLib.D3.Texture.prototype.constructor=GameLib.D3.Texture,GameLib.D3.Texture.prototype.createInstance=function(){if(this.textureType===GameLib.D3.API.Texture.TEXTURE_TYPE_CUBE){if(6!==this.images.length)throw new Error("not enough images for cube texture");var e=this.images.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no image");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no image instance");return e.instance});this.instance=new THREE.CubeTexture(e)}else if(this.textureType===GameLib.D3.API.Texture.TEXTURE_TYPE_NORMAL)GameLib.Utils.UndefinedOrNull(this.image)||GameLib.Utils.UndefinedOrNull(this.image.instance)?this.instance=new THREE.Texture:this.instance=new THREE.Texture(this.image.instance);else if(this.textureType===GameLib.D3.API.Texture.
new Error("Only stats supported")},GameLib.Stats=function(e,t){if(this.stats=e,this.stats.isNotStatsThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.Stats)return t;GameLib.API.Stats.call(this,t.id,t.name,t.domElement,t.parentEntity),GameLib.Component.call(this,{domElement:GameLib.DomElement})},GameLib.Stats.prototype=Object.create(GameLib.Component.prototype),GameLib.Stats.prototype.constructor=GameLib.Stats,GameLib.Stats.prototype.createInstance=function(){this.instance=this.stats.instance(),this.resize(),this.domElement.instance.parentElement.appendChild(this.instance.dom),GameLib.Component.prototype.createInstance.call(this)},GameLib.Stats.prototype.updateInstance=function(){this.instance=new this.stats},GameLib.Stats.prototype.toApiObject=function(){return new GameLib.API.Stats(this.id,this.name,GameLib.Utils.IdOrNull(this.domElement),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.Stats.FromObject=function(e,t){var i=GameLib.API.Stats.FromObject(t);return new GameLib.Stats(e,i)},GameLib.Stats.prototype.resize=function(){console.log("override stats resize per implementation")},GameLib.Stats.prototype.start=function(){this.instance.begin()},GameLib.Stats.prototype.end=function(){this.instance.end()},GameLib.System=function(e){if(GameLib.Utils.UndefinedOrNull(e)&&(e={}),e instanceof GameLib.System)return e;GameLib.API.System.call(this,e.id,e.name,e.systemType,e.parentEntity),this.started=!1,this.paused=!1;var t={};e.systemType===GameLib.System.SYSTEM_TYPE_INPUT&&(t.mouseControls=[GameLib.Controls.Mouse],t.keyboardControls=[GameLib.Controls.Keyboard],t.touchControls=[GameLib.Controls.Touch],t.editorControls=[GameLib.Controls.D3.Editor]),e.systemType===GameLib.System.SYSTEM_TYPE_AUDIO&&(t.audioComponents=[GameLib.D3.Audio]),GameLib.Component.call(this,t)},GameLib.System.prototype=Object.create(GameLib.API.System.prototype),GameLib.System.prototype.constructor=GameLib.System,GameLib.System.SYSTEM_TYPE_NONE=0,GameLib.System.SYSTEM_TYPE_RENDER=1,GameLib.System.SYSTEM_TYPE_ANIMATION=2,GameLib.System.SYSTEM_TYPE_INPUT=4,GameLib.System.SYSTEM_TYPE_STORAGE=8,GameLib.System.SYSTEM_TYPE_GUI=16,GameLib.System.SYSTEM_TYPE_PHYSICS=32,GameLib.System.SYSTEM_TYPE_LINKING=64,GameLib.System.SYSTEM_TYPE_CUSTOM=128,GameLib.System.SYSTEM_TYPE_VISUALIZATION=256,GameLib.System.SYSTEM_TYPE_PARTICLE=512,GameLib.System.SYSTEM_TYPE_AUDIO=1024,GameLib.System.SYSTEM_TYPE_SOCKET=2048,GameLib.System.SYSTEM_TYPE_ALL=65535,GameLib.System.prototype.createInstance=function(){this.instance=!0,GameLib.Component.prototype.createInstance.call(this)},GameLib.System.prototype.start=function(){this.started=!0,console.log("starting "+this.name)},GameLib.System.prototype.stop=function(){this.started=!1,console.log("stopping "+this.name)},GameLib.System.prototype.toApiObject=function(){return new GameLib.API.System(this.id,this.name,this.systemType,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.System.prototype.restart=function(){console.log("restarting system : "+this.name),this.stop(),this.start()},GameLib.System.Animation=function(e){GameLib.System.call(this,e),this.animations={},this.latest={},this.textures={},this.textureIds=[],this.animationMeshAddedSubscription=null,this.animationMeshRemovedSubscription=null,this.instanceCreatedSubscription=null,this.removeComponentSubscription=null,this.textureAnimatedSubscription=null,this.animateTextureInstanceSubscription=null},GameLib.System.Animation.prototype=Object.create(GameLib.System.prototype),GameLib.System.Animation.prototype.constructor=GameLib.System.Animation,GameLib.System.Animation.prototype.start=function(){GameLib.System.prototype.start.call(this),this.beforeRenderSubscription=GameLib.Event.Subscribe(GameLib.Event.BEFORE_RENDER,this.beforeRender.bind(this)),GameLib.EntityManager.Instance.queryComponents(GameLib.Component.ANIMATION).map(function(e){e.meshes.map(function(t){this.attachAnimation(e,t)}.bind(this))}.bind(this)),this.animationMeshAddedSubscription=GameLib.Event.Subscribe(GameLib.Event.ANIMATION_MESH_ADDED,function(e){this.attachAnimation(e.animation,e.mesh)}.bin
increase:GameLib.D3.Particle.OPACITY_TYPE_INCREASE_LINEAR}));else if("positionOffsetType"===i)o.push(e.add(n,i,{constant:GameLib.D3.Particle.POSITION_OFFSET_TYPE_CONSTANT,random:GameLib.D3.Particle.POSITION_OFFSET_TYPE_RANDOM,function:GameLib.D3.Particle.POSITION_OFFSET_TYPE_FUNCTION}));else if("directionType"===i)o.push(e.add(n,i,{constant:GameLib.D3.Particle.DIRECTION_TYPE_CONSTANT,random:GameLib.D3.Particle.DIRECTION_TYPE_RANDOM,"random normalized":GameLib.D3.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED,function:GameLib.D3.Particle.DIRECTION_TYPE_FUNCTION}));else if("speedType"===i)o.push(e.add(n,i,{constant:GameLib.D3.Particle.SPEED_TYPE_CONSTANT,linear:GameLib.D3.Particle.SPEED_TYPE_LINEAR,exponential:GameLib.D3.Particle.SPEED_TYPE_EXPONENTIAL,logarithmic:GameLib.D3.Particle.SPEED_TYPE_LOGARITHMIC,"1 / log":GameLib.D3.Particle.SPEED_TYPE_ONE_OVER_LOG,exp:GameLib.D3.Particle.SPEED_TYPE_EXP,"1 / exp":GameLib.D3.Particle.SPEED_TYPE_ONE_OVER_EXP}));else if("scaleType"===i)o.push(e.add(n,i,{constant:GameLib.D3.Particle.SCALE_TYPE_CONSTANT,linear:GameLib.D3.Particle.SCALE_TYPE_LINEAR,exponential:GameLib.D3.Particle.SCALE_TYPE_EXPONENTIAL,random:GameLib.D3.Particle.SCALE_TYPE_RANDOM,"random (x = y)":GameLib.D3.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y,function:GameLib.D3.Particle.SCALE_TYPE_FUNCTION}));else if("rotationType"===i)o.push(e.add(n,i,{constant:GameLib.D3.Particle.ROTATION_TYPE_CONSTANT,random:GameLib.D3.Particle.ROTATION_TYPE_RANDOM,function:GameLib.D3.Particle.ROTATION_TYPE_FUNCTION}));else if("broadphaseType"===i)o.push(e.add(n,i,{naive:GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE,grid:GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID,sap:GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP}));else if("solverType"===i)o.push(e.add(n,i,{gs:GameLib.D3.API.Solver.GS_SOLVER,split:GameLib.D3.API.Solver.SPLIT_SOLVER}));else if("meshType"===i)o.push(e.add(n,i,{normal:GameLib.D3.API.Mesh.MESH_TYPE_NORMAL,curve:GameLib.D3.API.Mesh.MESH_TYPE_CURVE,skinned:GameLib.D3.API.Mesh.MESH_TYPE_SKINNED,plane:GameLib.D3.API.Mesh.MESH_TYPE_PLANE,sphere:GameLib.D3.API.Mesh.MESH_TYPE_SPHERE,box:GameLib.D3.API.Mesh.MESH_TYPE_BOX,cylinder:GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER,text:GameLib.D3.API.Mesh.MESH_TYPE_TEXT}));else if("cameraType"===i)o.push(e.add(n,i,{perspective:GameLib.D3.Camera.CAMERA_TYPE_PERSPECTIVE,orthographic:GameLib.D3.Camera.CAMERA_TYPE_ORTHOGONAL}));else if("materialType"===i)o.push(e.add(n,i,{standard:GameLib.D3.Material.MATERIAL_TYPE_STANDARD,basic:GameLib.D3.Material.MATERIAL_TYPE_BASIC,phong:GameLib.D3.Material.MATERIAL_TYPE_PHONG,points:GameLib.D3.Material.MATERIAL_TYPE_POINTS,toon:GameLib.D3.Material.MATERIAL_TYPE_TOON,"line basic":GameLib.D3.Material.MATERIAL_TYPE_LINE_BASIC}));else if("side"===i)o.push(e.add(n,i,{double:GameLib.D3.Material.TYPE_DOUBLE_SIDE,front:GameLib.D3.Material.TYPE_FRONT_SIDE,back:GameLib.D3.Material.TYPE_BACK_SIDE}));else if("combine"===i)o.push(e.add(n,i,{multiply:GameLib.D3.Material.TYPE_MULTIPLY_OPERATION,mix:GameLib.D3.Material.TYPE_MIX_OPERATION,add:GameLib.D3.Material.TYPE_ADD_OPERATION}));else if("vertexColors"===i)o.push(e.add(n,i,{none:GameLib.D3.Material.TYPE_NO_COLORS,face:GameLib.D3.Material.TYPE_FACE_COLORS,vertex:GameLib.D3.Material.TYPE_VERTEX_COLORS}));else if("blending"===i)o.push(e.add(n,i,{none:GameLib.D3.Material.TYPE_NO_BLENDING,normal:GameLib.D3.Material.TYPE_NORMAL_BLENDING,additive:GameLib.D3.Material.TYPE_ADDITIVE_BLENDING,subtractive:GameLib.D3.Material.TYPE_SUBTRACTIVE_BLENDING,multiply:GameLib.D3.Material.TYPE_MULTIPLY_BLENDING,custom:GameLib.D3.Material.TYPE_CUSTOM_BLENDING}));else if("blendSrc"===i)o.push(e.add(n,i,{zero:GameLib.D3.Material.TYPE_ZERO_FACTOR,one:GameLib.D3.Material.TYPE_ONE_FACTOR,"source color":GameLib.D3.Material.TYPE_SRC_COLOR_FACTOR,"one minus source color":GameLib.D3.Material.TYPE_ONE_MINUS_SRC_COLOR_FACTOR,"source alpha":GameLib.D3.Material.TYPE_SRC_ALPHA_FACTOR,"one minus source alpha":GameLib.D3.Material.TYPE_ONE_MINUS_SRC_ALPHA_FACTOR,"destination alpha":GameLib.D3.Material.TYPE_DST_ALPHA_FACTOR,"one minus destination alpha":GameLib.D3.Material.TYPE_ONE_
GameLib.System.Linking.prototype=Object.create(GameLib.System.prototype),GameLib.System.Linking.prototype.constructor=GameLib.System.Linking,GameLib.System.Linking.prototype.start=function(){GameLib.System.prototype.start.call(this),this.componentCreatedSubscription=this.subscribe(GameLib.Event.COMPONENT_CREATED,this.componentCreated.bind(this)),this.componentClonedSubscription=this.subscribe(GameLib.Event.COMPONENT_CLONED,this.componentCloned.bind(this)),this.registerDependenciesSubscription=this.subscribe(GameLib.Event.REGISTER_DEPENDENCIES,this.registerDependenciesDirect),this.componentRemoveSubscription=this.subscribe(GameLib.Event.REMOVE_COMPONENT,this.removeComponent),this.parentSceneChangeSubscription=this.subscribe(GameLib.Event.PARENT_SCENE_CHANGE,this.onParentSceneChange),this.parentPhysicsWorldChangeSubscription=this.subscribe(GameLib.Event.PARENT_WORLD_CHANGE,this.onParentWorldChange),this.parentEntityChangeSubscription=this.subscribe(GameLib.Event.PARENT_ENTITY_CHANGE,this.onParentEntityChange),this.instanceCreatedSubscription=this.subscribe(GameLib.Event.INSTANCE_CREATED,this.instanceCreated),this.instanceClonedSubscription=this.subscribe(GameLib.Event.INSTANCE_CLONED,this.instanceCloned),this.removeMeshSubscription=this.subscribe(GameLib.Event.REMOVE_MESH,this.removeMesh),this.imageChangedSubscription=this.subscribe(GameLib.Event.IMAGE_CHANGED,this.imageChanged),this.materialTypeChangedSubscription=this.subscribe(GameLib.Event.MATERIAL_TYPE_CHANGED,this.materialTypeChanged),this.arrayItemAddedSubscription=this.subscribe(GameLib.Event.ARRAY_ITEM_ADDED,this.arrayItemAdded)},GameLib.System.Linking.prototype.link=function(e,t){for(var i in e.linkedObjects)if(e.linkedObjects.hasOwnProperty(i))if(e.linkedObjects[i]instanceof Array){var n=[];e[i]=e[i].map(function(s){return s===t.component.id?(n.push({parent:e,property:i,child:t.component}),t.component):s}),n.map(function(e){GameLib.Event.Emit(GameLib.Event.COMPONENT_LINKED,e)})}else e[i]&&e[i]===t.component.id&&(e[i]=t.component,GameLib.Event.Emit(GameLib.Event.COMPONENT_LINKED,{parent:e,property:i,child:t.component}))},GameLib.System.Linking.prototype.resolveDependencies=function(e){if(!e.loaded)return!1;var t=this.dependencies[e.id];if(GameLib.Utils.UndefinedOrNull(t))return!1;t.map(function(t){if(this.link(t,{component:e}),GameLib.Utils.PushUnique(this.resolved,e),GameLib.Utils.UndefinedOrNull(t.dependencies)||t.dependencies instanceof Array&&0===t.dependencies.length){if(!t.loaded||GameLib.Utils.UndefinedOrNull(t.instance))try{t.performInstanceCreation()}catch(e){console.error(e)}}else{var i=t.dependencies.indexOf(e.id);-1!==i&&t.dependencies.splice(i,1),0===t.dependencies.length&&t.performInstanceCreation()}}.bind(this)),delete this.dependencies[e.id],GameLib.Event.Emit(GameLib.Event.UNRESOLVED_DEPENDENCIES_UPDATE,{dependencies:this.dependencies}),GameLib.Utils.IsEmpty(this.dependencies)&&(GameLib.Event.Emit(GameLib.Event.COMPONENTS_LINKED,{components:this.resolved.map(function(e){return e})}),this.resolved=[])},GameLib.System.Linking.prototype.registerDependencies=function(e){e.dependencies&&e.dependencies.length>0&&(e.dependencies=e.dependencies.reduce(function(t,i){var n=GameLib.EntityManager.Instance.findComponentById(i);return n&&n.loaded?(this.link(e,{component:n}),GameLib.Utils.PushUnique(this.resolved,n)):(GameLib.Utils.UndefinedOrNull(this.dependencies[i])&&(this.dependencies[i]=[]),-1===this.dependencies[i].indexOf(e)&&(this.dependencies[i].push(e),GameLib.Event.Emit(GameLib.Event.UNRESOLVED_DEPENDENCIES_UPDATE,{dependencies:this.dependencies})),t.push(i)),t}.bind(this),[]),0===e.dependencies.length&&e.performInstanceCreation())},GameLib.System.Linking.prototype.componentCreated=function(e){var t=e.component;this.registerDependencies(t),this.resolveDependencies(t)},GameLib.System.Linking.prototype.componentCloned=function(e){if(this.componentCreated(e),e.component instanceof GameLib.D3.Mesh){if(!(e.parent instanceof GameLib.D3.Mesh))throw new Error("no scene parent");e.parent.parentScene&&e.parent.parentScene.addClone(e.component)}},GameLib.Syste
this.deleteSubscription.remove(),this.fetchComponentTypesSubscription.remove(),this.fetchComponentsSubscription.remove()},GameLib.System.Visualization=function(e,t,i){GameLib.System.call(this,e),GameLib.Utils.UndefinedOrNull(t)&&GameLib.Event.Emit(GameLib.Event.GET_GRAPHICS_RUNTIME,null,function(e){t=e}.bind(this),function(){t=null}.bind(this)),this.graphics=t,GameLib.Utils.UndefinedOrNull(i)&&GameLib.Event.Emit(GameLib.Event.GET_PHYSICS_RUNTIME,null,function(e){i=e}.bind(this),function(){i=null}.bind(this)),this.physics=i,this.visualizationSubscription=null,this.stopVisualizationSubscription=null},GameLib.System.Visualization.prototype=Object.create(GameLib.System.prototype),GameLib.System.Visualization.prototype.constructor=GameLib.System.Visualization,GameLib.System.Visualization.prototype.start=function(){GameLib.System.prototype.start.call(this),this.visualizationSubscription=this.subscribe(GameLib.Event.VISUALIZE,this.visualize),this.stopVisualizationSubscription=this.subscribe(GameLib.Event.STOP_VISUALIZE,this.stopVisualize)},GameLib.System.Visualization.prototype.visualize=function(e){var t=e.shape;t.parentMesh;t.setFromMesh();var i=new GameLib.D3.API.Mesh;if(i.name="Visualization Mesh for Shape "+t.name,t instanceof GameLib.D3.Shape.HeightMap)for(var n=new CANNON.Vec3,s=new CANNON.Vec3,a=new CANNON.Vec3,o=0;o<t.heightData.length-1;o++)for(var r=0;r<t.heightData[o].length-1;r++)for(var c=0;c<2;c++){t.instance.getConvexTrianglePillar(o,r,0===c),n.copy(t.instance.pillarConvex.vertices[0]),s.copy(t.instance.pillarConvex.vertices[1]),a.copy(t.instance.pillarConvex.vertices[2]),n.vadd(t.instance.pillarOffset,n),s.vadd(t.instance.pillarOffset,s),a.vadd(t.instance.pillarOffset,a),i.vertices.push(new GameLib.D3.API.Vertex(new GameLib.API.Vector3(n.x,n.y,n.z)),new GameLib.D3.API.Vertex(new GameLib.API.Vector3(s.x,s.y,s.z)),new GameLib.D3.API.Vertex(new GameLib.API.Vector3(a.x,a.y,a.z)));var m=i.vertices.length-3;i.faces.push(new GameLib.D3.API.Face(null,null,m,m+1,m+2))}new GameLib.D3.Mesh(this.graphics,i)},GameLib.System.Visualization.prototype.stopVisualize=function(e){},GameLib.System.Visualization.prototype.stop=function(){GameLib.System.prototype.stop.call(this),this.visualizationSubscription&&this.visualizationSubscription.remove(),this.stopVisualizationSubscription&&this.stopVisualizationSubscription.remove()},GameLib.Vector2=function(e,t,i,n){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={},t={}),t instanceof GameLib.Vector2)return t;GameLib.API.Vector2.call(this,t.x,t.y),GameLib.Utils.UndefinedOrNull(i)&&(i=null),this.parentObject=i,GameLib.Utils.UndefinedOrNull(n)&&(n=.001),this.grain=n,this.createInstance()},GameLib.Vector2.prototype=Object.create(GameLib.API.Vector2.prototype),GameLib.Vector2.prototype.constructor=GameLib.Vector2,GameLib.Vector2.prototype.createInstance=function(){this.instance=new THREE.Vector2(this.x,this.y)},GameLib.Vector2.prototype.updateInstance=function(e){this.instance.x=this.x,this.instance.y=this.y,this.parentObject&&this.parentObject.updateInstance&&this.parentObject.updateInstance(e)},GameLib.Vector2.prototype.toApiObject=function(){return new GameLib.API.Vector2(this.x,this.y)},GameLib.Vector2.prototype.copy=function(e){return GameLib.Utils.UndefinedOrNull(e)?new GameLib.Vector2(this.graphics,new GameLib.API.Vector2(this.x,this.y),this.parentObject,this.grain):(this.x=e.x,this.y=e.y,this)},GameLib.Vector2.prototype.equals=function(e){return this.x==e.x&&this.y==e.y},GameLib.Vector2.prototype.add=function(e){if(!(e instanceof GameLib.API.Vector2||e instanceof GameLib.API.Vector3||e instanceof GameLib.API.Vector4||e instanceof GameLib.API.Quaternion))throw console.warn("Could not add Vector2"),new Error("Could not add Vector2");this.x+=e.x,this.y+=e.y},GameLib.Vector2.prototype.subtract=function(e){if(!(e instanceof GameLib.API.Vector2||e instanceof GameLib.API.Vector3||e instanceof GameLib.API.Vector4||e instanceof GameLib.API.Quaternion))throw console.warn("Could not subtract Vector2"),new Error("Could not subtract Vector2");this.x-=e.x,t