From 8e462a8c2774a4cd55ec6024f9928757c5e7bd06 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Tue, 5 Dec 2017 11:26:54 +0100 Subject: [PATCH] build --- build/game-lib-min.js | 2 +- build/game-lib.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/game-lib-min.js b/build/game-lib-min.js index 5481abc..e6be665 100644 --- a/build/game-lib-min.js +++ b/build/game-lib-min.js @@ -1,4 +1,4 @@ -function GameLib(){}var __DATE__="Tue Dec 05 2017 11:22:05 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.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.PAUSE_ALL_AUDIO=99,GameLib.Event.CONTINUE_ALL_AUDIO=100,GameLib.Event.MUTE_AUDIO=101,GameLib.Event.GAME_STARTED=102,GameLib.Event.GAME_PAUSED=103,GameLib.Event.GAME_RESUMED=104,GameLib.Event.CUSTOM_GAME_START=105,GameLib.Event.AUDIO_MUTED=106,GameLib.Event.AUDIO_UNMUTED=107,GameLib.Event.GetEventName=function(e){switch(e){case 1:return"window_resize";case 2:return"parent_scene_change";case 3:return"parent_entity_change";case 4:return"instance_cloned";case 5:return"load_image";case 6:return"new_entity";case 7:return"material_type_changed";case 8:return"save_component";case 9:return"save_component_error";case 10:return"component_saved";case 11:return"load_component";case 12:return"load_component_error";case 13:return"logged_in";case 14:return"component_created";case 15:return"component_cloned";case 16:return"texture_animated_change";case 17:return"animate_texture_instance";case 18:return"remove_particle_engine";case 19:return"pause";case 20:return"texture_instance_updated";case 21:return"play_audio";case 22:return"material_instance_updated";case 23:return"pause_audio";case 24:return"mesh_instance_updated";case 25:return"stop_audio";case 26:return"light_instance_updated";case 27:return"delete_component";case 28:return"component_download_complete";case 29:return"components_linked";case 30:return"unresolved_dependencies_update";case 31:return"register_update";case 32:return"build_gui";case 33:return"remove_mesh";case 34:return"mesh_selected";case 35:return"mesh_deselected";case 36:return"component_register";case 37:return"image_not_found";case 38:return"blender_data_received";case 39:return"image_upload_complete";case 40:return"remove_component";case 41:return"key_down";case 42:return"key_up";case 43:return"render";case 44:return"event_list";case 45:return"compile_success";case 46:return"compile_failed";case 47:return"image_changed";case 48:return"parent_entity_changed";case 49:return"material_textures_updated";case 50:return"delete_component_error";case 51:return"component_deleted";case 52:return"component_types_updated";case 53:return"audio_ended";case 54:return"component_linked";case 55:return"done_saving";case 56:return"before_render";case 57:return"after_render";case 58:return"array_item_added";case 59:return"instance_created";case 60:return"visualize";case 61:return"stop_visualize";case 62:return"fetch_component_types";case 63:return"fetch_components";case 64:return"get_api_url";case 65:return"get_runtime";case 66:return"parent_world_change";case 67:return"animate";case 68:return"animation_compile_success";case 69:return"animation_compile_failed";case 70:return"saving";case 71:return"game_over";case 72:return"game_start";case 73:return"touch_start";case 74:return"touch_end";case 75:return"touch_move";case 76:return"touch_cancel";case 77:return"get_remote_api_url";case 78:return"component_types_update";case 79:return"delayed_instance_encountered";case 80:return"unused";case 81:return"animation_mesh_added";case 82:return"animation_mesh_removed";case 83:return"get_scene";case 84:return"custom_code_window_resize";case 85:return"load_font";case 86:return"font_not_found";case 87:return"stop_all_audio";case 88:return"register_dependencies";case 89:return"game_loaded";case 90:return"unused";case 91:return"load_progress";case 92:return"entity_loaded";case 93:return"mouse_down";case 94:return"mouse_move";case 95:return"mouse_wheel";case 96:return"mouse_up";case 97:return"particle_instance_updated";case 98:return"game_data";case 99:return"pause_all_audio";case 100:return"continue_all_audio";case 101:return"mute_audio";case 102:return"game_started";case 103:return"game_paused";case 104:return"game_resumed";case 105:return"custom_game_start";case 106:return"audio_muted";case 107:return"audio_unmuted"}throw new error("unknown event id: "+e)},GameLib.Event.prototype.subscribe=function(e,t){return GameLib.Event.Subscribe(e,t.bind(this))},GameLib.Event.prototype.publish=function(e,t,i,n){return GameLib.Event.Emit(e,t,i,n)},GameLib.Event.Emit=function(e,t,i,n){var a=0;return GameLib.Event.Subscriptions.hasOwnProperty(e)?(0===GameLib.Event.Subscriptions[e].length&&(i&&i(),n&&n({message:"No subscriptions for event "+e})),GameLib.Event.Subscriptions[e].map(function(e){e&&(e(t,i,n),a++)})):(i&&i(),n&&n({message:"No subscriptions for event "+e})),a},GameLib.Event.Subscribe=function(e,t){return GameLib.Event.Subscriptions.hasOwnProperty(e)?GameLib.Event.Subscriptions[e].push(t):(GameLib.Event.Subscriptions[e]=[],GameLib.Event.Subscriptions[e].push(t)),{fn:t,remove:function(){var i=GameLib.Event.Subscriptions[e].indexOf(t);if(-1===i)throw new Error("could not remove subscription");GameLib.Event.Subscriptions[e].splice(i,1)}}},GameLib.Utils=function(){},GameLib.Utils.StripImageExtension=function(e){return e.replace(/(\.png$|\.gif$|\.jpeg$|\.jpg$)/,"")},GameLib.Utils.ObjectIdWithNameInArray=function(e,t){return t.reduce(function(t,i){return t||(e===i.name?i.id:null)},null)},GameLib.Utils.LoadIdsFromArrayToIdObject=function(e,t){},GameLib.Utils.LoadIdsFromObjectToIdObject=function(e,t){},GameLib.Utils.GetRandomInt=function(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e))+e},GameLib.Utils.GetRandomIntInclusive=function(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e},GameLib.Utils.InterpolateArray=function(e,t){var i=[],n=Number((e.length-1)/(t-1));i[0]=e[0];for(var a=1;aMath.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;i=e}}},GameLib.Utils.IdArrayOrEmptyArray=function(e){return GameLib.Utils.UndefinedOrNull(e)?[]:e.map(function(e){if(GameLib.Utils.UndefinedOrNull(e.id))throw new Error("No ID found while trying to store IDs to array");return e.id})},GameLib.Utils.Link=function(e,t,i,n){GameLib.Utils.UndefinedOrNull(i[e])||(t.hasOwnProperty(n)||console.warn("Linking failed for object:"+i.name),i[e]=t[n])},GameLib.Utils.RandomId=function(e){return GameLib.Utils.UndefinedOrNull(e)&&(e=10),Math.random().toString(36).substr(2,e)},GameLib.Utils.InvertWindingOrder=function(e){for(var t=0;t0;){var a=i.pop();if(a.triangle.v0index===a.edge.x&&a.triangle.v1index===a.edge.y||a.triangle.v1index===a.edge.x&&a.triangle.v2index===a.edge.y||a.triangle.v2index===a.edge.x&&a.triangle.v0index===a.edge.y){var s=a.triangle.v1index;a.triangle.v1index=a.triangle.v2index,a.triangle.v2index=s;var o=a.triangle.uvs[0][1];a.triangle.uvs[0][1]=a.triangle.uvs[0][2],a.triangle.uvs[0][2]=o}n.push(a);for(var r=[new GameLib.API.Vector2(a.triangle.v0index,a.triangle.v1index),new GameLib.API.Vector2(a.triangle.v1index,a.triangle.v2index),new GameLib.API.Vector2(a.triangle.v2index,a.triangle.v0index)],c=0;c9||console.log("The vertices are not in the right length : "+e.length);for(var i=[],n=new GameLib.API.Quaternion.Points,a=0;ae&&t.splice(0,1);var n=0;for(var a in t)n+=t[a];var s=e;return t.lengthe.length&&(i=t,t=e,e=i),e.filter(function(e){return t.indexOf(e)>-1}).filter(function(e,t,i){return i.indexOf(e)===t})},GameLib.Utils.Difference=function(e,t){var i;return t.length>e.length&&(i=t,t=e,e=i),e.filter(function(e){return-1===t.indexOf(e)}).filter(function(e,t,i){return i.indexOf(e)===t})},GameLib.Utils.PushUnique=function(e,t){-1===e.indexOf(t)&&e.push(t)},GameLib.Utils.IsEmpty=function(e){return 0===Object.keys(e).length&&e.constructor===Object},GameLib.Utils.isString=function(e){return"string"==typeof e},GameLib.Utils.isBoolean=function(e){return!0===e||!1===e},GameLib.Utils.isColor=function(e){return e instanceof GameLib.Color},GameLib.Utils.isNumber=function(e){return"number"==typeof e},GameLib.Utils.isVector2=function(e){return e instanceof GameLib.API.Vector2||e instanceof GameLib.Vector2},GameLib.Utils.isVector3=function(e){return e instanceof GameLib.API.Vector3||e instanceof GameLib.Vector3},GameLib.Utils.isVector4=function(e){return e instanceof GameLib.API.Vector4||e instanceof GameLib.Vector4||e instanceof GameLib.API.Quaternion||e instanceof GameLib.Quaternion},GameLib.Utils.LowerUnderscore=function(e){return e.toLowerCase().replace(/\s+/,"_")},GameLib.Utils.UpperCaseWordsSpaces=function(e){return e.replace(/[-_]/g," ").split(" ").reduce(function(e,t){return(e+=t[0].toUpperCase()+t.substr(1))+" "},"").trim()},GameLib.Utils.UpperCaseUnderscore=function(e){var t="";return e.split("").map(function(e){e==e.toUpperCase()?t+="_"+e:t+=e.toUpperCase()}),t=t.replace(new RegExp("^_"),"")},GameLib.API.Component=function(e,t){this.componentType=e,GameLib.Utils.UndefinedOrNull(t)&&(t=null),this.parentEntity=t},GameLib.API.Component.prototype=Object.create(GameLib.Event.prototype),GameLib.API.Component.prototype.constructor=GameLib.API.Component,GameLib.Component=function(e,t){GameLib.Utils.UndefinedOrNull(e)&&(e={}),this.linkedObjects=e,this.linkedObjects.parentEntity=GameLib.Entity,this.idToObject={},this.selected=!1,this.building=!1,this.loaded=!1,this.linked=!1,this.cloneNumber=0,this.isClone=!1,GameLib.Utils.UndefinedOrNull(t)&&(t=!1),this.delayed=t,this.dependencies=this.getDependencies(),GameLib.Event.Emit(GameLib.Event.COMPONENT_REGISTER,{component:this}),0===this.dependencies.length?this.performInstanceCreation():GameLib.Event.Emit(GameLib.Event.REGISTER_DEPENDENCIES,{component:this})},GameLib.Component.prototype=Object.create(GameLib.API.Component.prototype),GameLib.Component.prototype.constructor=GameLib.Component,GameLib.Component.prototype.performInstanceCreation=function(){var e=!0;if(GameLib.Utils.UndefinedOrNull(this.dependencies)&&(e=!1),this.dependencies&&this.dependencies instanceof Array&&0===this.dependencies.length&&(e=!1),e)throw new Error("performInstanceCreation called while this object still has dependencies");if(delete this.dependencies,this.buildIdToObject(),this.linked)if(this.delayed)GameLib.Event.Emit(GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED,{component:this});else try{this.createInstance()}catch(e){console.error(e)}},GameLib.Component.prototype.createInstance=function(){this.delayed=!1,this.instance&&(this.loaded=!0,GameLib.Event.Emit(GameLib.Event.INSTANCE_CREATED,{component:this})),this instanceof GameLib.Entity&&GameLib.Event.Emit(GameLib.Event.ENTITY_LOADED,{entity:this})},GameLib.Component.prototype.getDependencies=function(){var e=[];for(var t in this.linkedObjects)this.linkedObjects.hasOwnProperty(t)&&0!==t.indexOf("parent")&&this.hasOwnProperty(t)&&("string"==typeof this[t]&&GameLib.Utils.PushUnique(e,this[t]),this[t]instanceof Array&&this[t].map(function(t){"string"==typeof t&&GameLib.Utils.PushUnique(e,t),t&&t instanceof GameLib.Component&&GameLib.Utils.PushUnique(e,t.id)}),this[t]&&this[t]instanceof GameLib.Component&&GameLib.Utils.PushUnique(e,this[t].id));return e},GameLib.Component.prototype.toString=function(){return this.id},GameLib.Component.MATERIAL=2,GameLib.Component.RENDERER=3,GameLib.Component.CAMERA=5,GameLib.Component.MESH=7,GameLib.Component.SPLINE=8,GameLib.Component.LIGHT=9,GameLib.Component.COMPOSER=11,GameLib.Component.RENDER_TARGET=12,GameLib.Component.PASS=13,GameLib.Component.SCENE=14,GameLib.Component.RAYCASTER=15,GameLib.Component.VIEWPORT=18,GameLib.Component.SYSTEM=19,GameLib.Component.GRAPHICS=20,GameLib.Component.HELPER=21,GameLib.Component.CUSTOM_CODE=22,GameLib.Component.MOUSE=23,GameLib.Component.SKELETON=24,GameLib.Component.TEXTURE=25,GameLib.Component.ENTITY_MANAGER=26,GameLib.Component.DOM_ELEMENT=27,GameLib.Component.STATS=29,GameLib.Component.GUI=30,GameLib.Component.IMAGE=31,GameLib.Component.ENTITY=32,GameLib.Component.MESH_SPHERE=33,GameLib.Component.MESH_PLANE=34,GameLib.Component.MESH_CURVE=35,GameLib.Component.PHYSICS_WORLD=36,GameLib.Component.BROADPHASE=37,GameLib.Component.SOLVER=38,GameLib.Component.RIGID_BODY=39,GameLib.Component.SHAPE=40,GameLib.Component.SHAPE_BOX=41,GameLib.Component.SHAPE_SPHERE=42,GameLib.Component.SHAPE_TRI_MESH=43,GameLib.Component.SHAPE_CONVEX_HULL=44,GameLib.Component.SHAPE_CONVEX_HULL_CYLINDER=45,GameLib.Component.SHAPE_HEIGHT_MAP=46,GameLib.Component.SHAPE_PLANE=47,GameLib.Component.CONTROLS=48,GameLib.Component.CONTROLS_EDITOR=49;GameLib.Component.CONTROLS_TOUCH=50,GameLib.Component.FRICTION_MATERIAL=51,GameLib.Component.FRICTION_CONTACT_MATERIAL=52,GameLib.Component.RAYCAST_VEHICLE=53,GameLib.Component.RAYCAST_WHEEL=54,GameLib.Component.CLOCK=55,GameLib.Component.ANIMATION=56,GameLib.Component.CONTROLS_KEYBOARD=57,GameLib.Component.CONTROLS_MOUSE=58,GameLib.Component.MESH_TEXT=59,GameLib.Component.FONT=60,GameLib.Component.CANVAS=61,GameLib.Component.BONE=62,GameLib.Component.MESH_BOX=63,GameLib.Component.MESH_CYLINDER=64,GameLib.Component.SYSTEM_ANIMATION=65,GameLib.Component.SYSTEM_CUSTOM_CODE=66,GameLib.Component.SYSTEM_GUI=67,GameLib.Component.SYSTEM_INPUT=68,GameLib.Component.SYSTEM_LINKING=69,GameLib.Component.SYSTEM_PHYSICS=70,GameLib.Component.SYSTEM_RENDER=71,GameLib.Component.SYSTEM_STORAGE=72,GameLib.Component.SYSTEM_VISUALIZATION=73,GameLib.Component.FOG=80,GameLib.Component.MESH_LINE=81,GameLib.Component.PARTICLE_ENGINE=82,GameLib.Component.SYSTEM_PARTICLE=83,GameLib.Component.PARTICLE=84,GameLib.Component.AUDIO=85,GameLib.Component.SYSTEM_AUDIO=86,GameLib.Component.CAST=87,GameLib.Component.MAX_COMPONENTS=88,GameLib.Component.GRAPHICS_RUNTIME=1,GameLib.Component.PHYSICS_RUNTIME=2,GameLib.Component.SOCKET_RUNTIME=3,GameLib.Component.STATISTICS_RUNTIME=4,GameLib.Component.DEFAULT_RUNTIME=5,GameLib.Component.GUI_RUNTIME=6,GameLib.Component.CODER_RUNTIME=7,GameLib.Component.GetCompentTypes=function(e){GameLib.Component},GameLib.Component.GetComponentInfo=function(e){switch(e){case 1:return null;case 2:return{name:"GameLib.D3.Material",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Material};case 3:return{name:"GameLib.D3.Renderer",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Renderer};case 4:return null;case 5:return{name:"GameLib.D3.Camera",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Camera};case 6:return null;case 7:return{name:"GameLib.D3.Mesh",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh};case 8:return{name:"GameLib.D3.Spline",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Spline};case 9:return{name:"GameLib.D3.Light",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Light};case 10:return null;case 11:return{name:"GameLib.D3.Composer",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Composer};case 12:return{name:"GameLib.D3.RenderTarget",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.RenderTarget};case 13:return{name:"GameLib.D3.Pass",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Pass};case 14:return{name:"GameLib.D3.Scene",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Scene};case 15:return{name:"GameLib.D3.Raycaster",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Raycaster};case 16:case 17:return null;case 18:return{name:"GameLib.D3.Viewport",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Viewport};case 19:return{name:"GameLib.System",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System};case 20:return{name:"GameLib.GraphicsRuntime",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.GraphicsRuntime};case 21:return{name:"GameLib.D3.Helper",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Helper};case 22:return{name:"GameLib.CustomCode",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.CustomCode};case 23:return{name:"GameLib.Mouse",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.Mouse};case 24:return{name:"GameLib.D3.Skeleton",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Skeleton};case 25:return{name:"GameLib.D3.Texture",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Texture};case 26:return{name:"GameLib.EntityManager",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.EntityManager};case 27:return{name:"GameLib.DomElement",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.DomElement};case 28:return null;case 29:return{name:"GameLib.Stats",runtime:GameLib.Component.STATISTICS_RUNTIME,constructor:GameLib.Stats};case 30:return{name:"GameLib.GUI",runtime:GameLib.Component.GUI_RUNTIME,constructor:GameLib.GUI};case 31:return{name:"GameLib.Image",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Image};case 32:return{name:"GameLib.Entity",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Entity};case 33:return{name:"GameLib.D3.Mesh.Sphere",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Sphere};case 34:return{name:"GameLib.D3.Mesh.Plane",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Plane};case 35:return{name:"GameLib.D3.Mesh.Curve",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Curve};case 36:return{name:"GameLib.D3.PhysicsWorld",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.PhysicsWorld};case 37:return{name:"GameLib.D3.Broadphase",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Broadphase};case 38:return{name:"GameLib.D3.Solver",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Solver};case 39:return{name:"GameLib.D3.RigidBody",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.RigidBody};case 40:return{name:"GameLib.D3.Shape",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape};case 41:return{name:"GameLib.D3.Shape.Box",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.Box};case 42:return{name:"GameLib.D3.Shape.Sphere",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.Sphere};case 43:return{name:"GameLib.D3.Shape.TriMesh",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.TriMesh};case 44:return{name:"GameLib.D3.Shape.ConvexHull",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.ConvexHull};case 45:return{name:"GameLib.D3.Shape.ConvexHull.Cylinder",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.ConvexHull.Cylinder};case 46:return{name:"GameLib.D3.Shape.HeightMap",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.D3.Shape.HeightMap};case 47:return{name:"GameLib.D3.Shape.Plane",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.Plane};case 48:return{name:"GameLib.Controls",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Controls};case 49:return{name:"GameLib.Controls.D3.Editor",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.Controls.D3.Editor};case 50:return{name:"GameLib.Controls.Touch",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Controls.Touch};case 51:return{name:"GameLib.D3.FrictionMaterial",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.FrictionMaterial};case 52:return{name:"GameLib.D3.FrictionContactMaterial",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.FrictionContactMaterial};case 53:return{name:"GameLib.D3.RaycastVehicle",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.RaycastVehicle};case 54:return{name:"GameLib.D3.RaycastWheel",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.RaycastWheel};case 55:return{name:"GameLib.Clock",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.Clock};case 56:return{name:"GameLib.D3.Animation",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.D3.Animation};case 57:return{name:"GameLib.Controls.Keyboard",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Controls.Keyboard};case 58:return{name:"GameLib.Controls.Mouse",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Controls.Mouse};case 59:return{name:"GameLib.D3.Mesh.Text",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Text};case 60:return{name:"GameLib.D3.Font",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Font};case 61:return{name:"GameLib.Canvas",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Canvas};case 62:return{name:"GameLib.D3.Bone",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Bone};case 63:return{name:"GameLib.D3.Mesh.Box",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Box};case 64:return{name:"GameLib.D3.Mesh.Cylinder",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Cylinder};case 65:return{name:"GameLib.System.Animation",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Animation};case 66:return{name:"GameLib.System.CustomCode",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.CustomCode};case 67:return{name:"GameLib.System.GUI",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.GUI};case 68:return{name:"GameLib.System.Input",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Input};case 69:return{name:"GameLib.System.Linking",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Linking};case 70:return{name:"GameLib.System.Physics",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Physics};case 71:return{name:"GameLib.System.Render",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Render};case 72:return{name:"GameLib.System.Storage",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Storage};case 73:return{name:"GameLib.System.Visualization",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Visualization};case 80:return{name:"GameLib.D3.Fog",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Fog};case 81:return{name:"GameLib.D3.Mesh.Line",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Line};case 82:return{name:"GameLib.D3.ParticleEngine",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.ParticleEngine};case 83:return{name:"GameLib.System.Particle",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Particle};case 84:return{name:"GameLib.D3.Particle",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Particle};case 85:return{name:"GameLib.D3.Audio",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Audio};case 86:return{name:"GameLib.System.Audio",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Audio};case 87:return{name:"GameLib.Cast",runtime:GameLib.Component.SOCKET_RUNTIME,constructor:GameLib.Cast}}throw new Error("Unknown component type: "+e)},GameLib.Component.GetRuntimeName=function(e){return e===GameLib.Component.GRAPHICS_RUNTIME?"Graphics":e===GameLib.Component.PHYSICS_RUNTIME?"Physics":e===GameLib.Component.GUI_RUNTIME?"GUI":e===GameLib.Component.STATISTICS_RUNTIME?"Statistics":e===GameLib.Component.SOCKET_RUNTIME?"Sockets":e===GameLib.Component.CODER_RUNTIME?"Coder":"Default"},GameLib.Component.GetComponentName=function(e){var t=GameLib.Component.GetComponentInfo(e);return t?t.name:"unused"},GameLib.Component.GetComponentRuntime=function(e){var t=GameLib.Component.GetComponentInfo(e);return t?t.runtime:null},GameLib.Component.GetComponentConstructor=function(e){var t=GameLib.Component.GetComponentInfo(e);return t?t.constructor:null},GameLib.Component.prototype.toApiObject=function(){return this.id},GameLib.Component.prototype.processComponent=function(e){if(e instanceof GameLib.Component){e.buildIdToObject(),e.linked||(this.linked=!1);var t=e.idToObject;for(var i in t)t.hasOwnProperty(i)&&(this.idToObject[i]=t[i]);e.id?this.idToObject[e.id]=e:console.warn("Object with no ID passed: "+e)}else"string"==typeof e?this.linked=!1:console.warn("Unhandled type of object: ",e)},GameLib.Component.prototype.buildIdToObject=function(){if(!this.building){this.building=!0,this.linked=!0,this.idToObject={};for(var e in this.linkedObjects)this.linkedObjects.hasOwnProperty(e)&&this.hasOwnProperty(e)&&this[e]&&0!==e.indexOf("parent")&&(this.linkedObjects[e]instanceof Array?(this[e]=this[e].filter(function(e){return null!==e||(console.log("null object found and removed"),!1)}),this[e].map(function(e){this.processComponent(e)}.bind(this))):this.processComponent(this[e]));this instanceof GameLib.D3.Scene&&(this.storeClones||this.clones.map(function(e){this.idToObject.hasOwnProperty(e.id)&&delete this.idToObject[e.id]}.bind(this))),this.idToObject[this.id]=this,this.building=!1}},GameLib.Component.prototype.generateNewIds=function(){this.buildIdToObject();var e=GameLib.EntityManager.Instance.queryComponents(GameLib.Component.CUSTOM_CODE);for(var t in this.idToObject)if(this.idToObject.hasOwnProperty(t)){var i=this.idToObject[t].id,n=GameLib.Utils.RandomId();this.idToObject[t].id=n,this.idToObject[t].name=this.idToObject[t].name.replace(i,n),e.map(function(e){e.code=e.code.replace(i,n)})}},GameLib.Component.prototype.remove=function(){this.buildIdToObject(),this.getDependencies().map(function(e){var t=this.idToObject[e];t instanceof GameLib.Component&&t.remove()}.bind(this)),GameLib.Event.Emit(GameLib.Event.REMOVE_COMPONENT,{component:this})},GameLib.Component.prototype.clone=function(){var e=this.toApiObject();this.cloneNumber+=1, +function GameLib(){}var __DATE__="Tue Dec 05 2017 11:25:55 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.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.PAUSE_ALL_AUDIO=99,GameLib.Event.CONTINUE_ALL_AUDIO=100,GameLib.Event.MUTE_AUDIO=101,GameLib.Event.GAME_STARTED=102,GameLib.Event.GAME_PAUSED=103,GameLib.Event.GAME_RESUMED=104,GameLib.Event.CUSTOM_GAME_START=105,GameLib.Event.AUDIO_MUTED=106,GameLib.Event.AUDIO_UNMUTED=107,GameLib.Event.GetEventName=function(e){switch(e){case 1:return"window_resize";case 2:return"parent_scene_change";case 3:return"parent_entity_change";case 4:return"instance_cloned";case 5:return"load_image";case 6:return"new_entity";case 7:return"material_type_changed";case 8:return"save_component";case 9:return"save_component_error";case 10:return"component_saved";case 11:return"load_component";case 12:return"load_component_error";case 13:return"logged_in";case 14:return"component_created";case 15:return"component_cloned";case 16:return"texture_animated_change";case 17:return"animate_texture_instance";case 18:return"remove_particle_engine";case 19:return"pause";case 20:return"texture_instance_updated";case 21:return"play_audio";case 22:return"material_instance_updated";case 23:return"pause_audio";case 24:return"mesh_instance_updated";case 25:return"stop_audio";case 26:return"light_instance_updated";case 27:return"delete_component";case 28:return"component_download_complete";case 29:return"components_linked";case 30:return"unresolved_dependencies_update";case 31:return"register_update";case 32:return"build_gui";case 33:return"remove_mesh";case 34:return"mesh_selected";case 35:return"mesh_deselected";case 36:return"component_register";case 37:return"image_not_found";case 38:return"blender_data_received";case 39:return"image_upload_complete";case 40:return"remove_component";case 41:return"key_down";case 42:return"key_up";case 43:return"render";case 44:return"event_list";case 45:return"compile_success";case 46:return"compile_failed";case 47:return"image_changed";case 48:return"parent_entity_changed";case 49:return"material_textures_updated";case 50:return"delete_component_error";case 51:return"component_deleted";case 52:return"component_types_updated";case 53:return"audio_ended";case 54:return"component_linked";case 55:return"done_saving";case 56:return"before_render";case 57:return"after_render";case 58:return"array_item_added";case 59:return"instance_created";case 60:return"visualize";case 61:return"stop_visualize";case 62:return"fetch_component_types";case 63:return"fetch_components";case 64:return"get_api_url";case 65:return"get_runtime";case 66:return"parent_world_change";case 67:return"animate";case 68:return"animation_compile_success";case 69:return"animation_compile_failed";case 70:return"saving";case 71:return"game_over";case 72:return"game_start";case 73:return"touch_start";case 74:return"touch_end";case 75:return"touch_move";case 76:return"touch_cancel";case 77:return"get_remote_api_url";case 78:return"component_types_update";case 79:return"delayed_instance_encountered";case 80:return"unused";case 81:return"animation_mesh_added";case 82:return"animation_mesh_removed";case 83:return"get_scene";case 84:return"custom_code_window_resize";case 85:return"load_font";case 86:return"font_not_found";case 87:return"stop_all_audio";case 88:return"register_dependencies";case 89:return"game_loaded";case 90:return"unused";case 91:return"load_progress";case 92:return"entity_loaded";case 93:return"mouse_down";case 94:return"mouse_move";case 95:return"mouse_wheel";case 96:return"mouse_up";case 97:return"particle_instance_updated";case 98:return"game_data";case 99:return"pause_all_audio";case 100:return"continue_all_audio";case 101:return"mute_audio";case 102:return"game_started";case 103:return"game_paused";case 104:return"game_resumed";case 105:return"custom_game_start";case 106:return"audio_muted";case 107:return"audio_unmuted"}throw new error("unknown event id: "+e)},GameLib.Event.prototype.subscribe=function(e,t){return GameLib.Event.Subscribe(e,t.bind(this))},GameLib.Event.prototype.publish=function(e,t,i,n){return GameLib.Event.Emit(e,t,i,n)},GameLib.Event.Emit=function(e,t,i,n){var a=0;return GameLib.Event.Subscriptions.hasOwnProperty(e)?(0===GameLib.Event.Subscriptions[e].length&&(i&&i(),n&&n({message:"No subscriptions for event "+e})),GameLib.Event.Subscriptions[e].map(function(e){e&&(e(t,i,n),a++)})):(i&&i(),n&&n({message:"No subscriptions for event "+e})),a},GameLib.Event.Subscribe=function(e,t){return GameLib.Event.Subscriptions.hasOwnProperty(e)?GameLib.Event.Subscriptions[e].push(t):(GameLib.Event.Subscriptions[e]=[],GameLib.Event.Subscriptions[e].push(t)),{fn:t,remove:function(){var i=GameLib.Event.Subscriptions[e].indexOf(t);if(-1===i)throw new Error("could not remove subscription");GameLib.Event.Subscriptions[e].splice(i,1)}}},GameLib.Utils=function(){},GameLib.Utils.StripImageExtension=function(e){return e.replace(/(\.png$|\.gif$|\.jpeg$|\.jpg$)/,"")},GameLib.Utils.ObjectIdWithNameInArray=function(e,t){return t.reduce(function(t,i){return t||(e===i.name?i.id:null)},null)},GameLib.Utils.LoadIdsFromArrayToIdObject=function(e,t){},GameLib.Utils.LoadIdsFromObjectToIdObject=function(e,t){},GameLib.Utils.GetRandomInt=function(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e))+e},GameLib.Utils.GetRandomIntInclusive=function(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e},GameLib.Utils.InterpolateArray=function(e,t){var i=[],n=Number((e.length-1)/(t-1));i[0]=e[0];for(var a=1;aMath.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;i=e}}},GameLib.Utils.IdArrayOrEmptyArray=function(e){return GameLib.Utils.UndefinedOrNull(e)?[]:e.map(function(e){if(GameLib.Utils.UndefinedOrNull(e.id))throw new Error("No ID found while trying to store IDs to array");return e.id})},GameLib.Utils.Link=function(e,t,i,n){GameLib.Utils.UndefinedOrNull(i[e])||(t.hasOwnProperty(n)||console.warn("Linking failed for object:"+i.name),i[e]=t[n])},GameLib.Utils.RandomId=function(e){return GameLib.Utils.UndefinedOrNull(e)&&(e=10),Math.random().toString(36).substr(2,e)},GameLib.Utils.InvertWindingOrder=function(e){for(var t=0;t0;){var a=i.pop();if(a.triangle.v0index===a.edge.x&&a.triangle.v1index===a.edge.y||a.triangle.v1index===a.edge.x&&a.triangle.v2index===a.edge.y||a.triangle.v2index===a.edge.x&&a.triangle.v0index===a.edge.y){var s=a.triangle.v1index;a.triangle.v1index=a.triangle.v2index,a.triangle.v2index=s;var o=a.triangle.uvs[0][1];a.triangle.uvs[0][1]=a.triangle.uvs[0][2],a.triangle.uvs[0][2]=o}n.push(a);for(var r=[new GameLib.API.Vector2(a.triangle.v0index,a.triangle.v1index),new GameLib.API.Vector2(a.triangle.v1index,a.triangle.v2index),new GameLib.API.Vector2(a.triangle.v2index,a.triangle.v0index)],c=0;c9||console.log("The vertices are not in the right length : "+e.length);for(var i=[],n=new GameLib.API.Quaternion.Points,a=0;ae&&t.splice(0,1);var n=0;for(var a in t)n+=t[a];var s=e;return t.lengthe.length&&(i=t,t=e,e=i),e.filter(function(e){return t.indexOf(e)>-1}).filter(function(e,t,i){return i.indexOf(e)===t})},GameLib.Utils.Difference=function(e,t){var i;return t.length>e.length&&(i=t,t=e,e=i),e.filter(function(e){return-1===t.indexOf(e)}).filter(function(e,t,i){return i.indexOf(e)===t})},GameLib.Utils.PushUnique=function(e,t){-1===e.indexOf(t)&&e.push(t)},GameLib.Utils.IsEmpty=function(e){return 0===Object.keys(e).length&&e.constructor===Object},GameLib.Utils.isString=function(e){return"string"==typeof e},GameLib.Utils.isBoolean=function(e){return!0===e||!1===e},GameLib.Utils.isColor=function(e){return e instanceof GameLib.Color},GameLib.Utils.isNumber=function(e){return"number"==typeof e},GameLib.Utils.isVector2=function(e){return e instanceof GameLib.API.Vector2||e instanceof GameLib.Vector2},GameLib.Utils.isVector3=function(e){return e instanceof GameLib.API.Vector3||e instanceof GameLib.Vector3},GameLib.Utils.isVector4=function(e){return e instanceof GameLib.API.Vector4||e instanceof GameLib.Vector4||e instanceof GameLib.API.Quaternion||e instanceof GameLib.Quaternion},GameLib.Utils.LowerUnderscore=function(e){return e.toLowerCase().replace(/\s+/,"_")},GameLib.Utils.UpperCaseWordsSpaces=function(e){return e.replace(/[-_]/g," ").split(" ").reduce(function(e,t){return(e+=t[0].toUpperCase()+t.substr(1))+" "},"").trim()},GameLib.Utils.UpperCaseUnderscore=function(e){var t="";return e.split("").map(function(e){e==e.toUpperCase()?t+="_"+e:t+=e.toUpperCase()}),t=t.replace(new RegExp("^_"),"")},GameLib.API.Component=function(e,t){this.componentType=e,GameLib.Utils.UndefinedOrNull(t)&&(t=null),this.parentEntity=t},GameLib.API.Component.prototype=Object.create(GameLib.Event.prototype),GameLib.API.Component.prototype.constructor=GameLib.API.Component,GameLib.Component=function(e,t){GameLib.Utils.UndefinedOrNull(e)&&(e={}),this.linkedObjects=e,this.linkedObjects.parentEntity=GameLib.Entity,this.idToObject={},this.selected=!1,this.building=!1,this.loaded=!1,this.linked=!1,this.cloneNumber=0,this.isClone=!1,GameLib.Utils.UndefinedOrNull(t)&&(t=!1),this.delayed=t,this.dependencies=this.getDependencies(),GameLib.Event.Emit(GameLib.Event.COMPONENT_REGISTER,{component:this}),0===this.dependencies.length?this.performInstanceCreation():GameLib.Event.Emit(GameLib.Event.REGISTER_DEPENDENCIES,{component:this})},GameLib.Component.prototype=Object.create(GameLib.API.Component.prototype),GameLib.Component.prototype.constructor=GameLib.Component,GameLib.Component.prototype.performInstanceCreation=function(){var e=!0;if(GameLib.Utils.UndefinedOrNull(this.dependencies)&&(e=!1),this.dependencies&&this.dependencies instanceof Array&&0===this.dependencies.length&&(e=!1),e)throw new Error("performInstanceCreation called while this object still has dependencies");if(delete this.dependencies,this.buildIdToObject(),this.linked)if(this.delayed)GameLib.Event.Emit(GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED,{component:this});else try{this.createInstance()}catch(e){console.error(e)}},GameLib.Component.prototype.createInstance=function(){this.delayed=!1,this.instance&&(this.loaded=!0,GameLib.Event.Emit(GameLib.Event.INSTANCE_CREATED,{component:this})),this instanceof GameLib.Entity&&GameLib.Event.Emit(GameLib.Event.ENTITY_LOADED,{entity:this})},GameLib.Component.prototype.getDependencies=function(){var e=[];for(var t in this.linkedObjects)this.linkedObjects.hasOwnProperty(t)&&0!==t.indexOf("parent")&&this.hasOwnProperty(t)&&("string"==typeof this[t]&&GameLib.Utils.PushUnique(e,this[t]),this[t]instanceof Array&&this[t].map(function(t){"string"==typeof t&&GameLib.Utils.PushUnique(e,t),t&&t instanceof GameLib.Component&&GameLib.Utils.PushUnique(e,t.id)}),this[t]&&this[t]instanceof GameLib.Component&&GameLib.Utils.PushUnique(e,this[t].id));return e},GameLib.Component.prototype.toString=function(){return this.id},GameLib.Component.MATERIAL=2,GameLib.Component.RENDERER=3,GameLib.Component.CAMERA=5,GameLib.Component.MESH=7,GameLib.Component.SPLINE=8,GameLib.Component.LIGHT=9,GameLib.Component.COMPOSER=11,GameLib.Component.RENDER_TARGET=12,GameLib.Component.PASS=13,GameLib.Component.SCENE=14,GameLib.Component.RAYCASTER=15,GameLib.Component.VIEWPORT=18,GameLib.Component.SYSTEM=19,GameLib.Component.GRAPHICS=20,GameLib.Component.HELPER=21,GameLib.Component.CUSTOM_CODE=22,GameLib.Component.MOUSE=23,GameLib.Component.SKELETON=24,GameLib.Component.TEXTURE=25,GameLib.Component.ENTITY_MANAGER=26,GameLib.Component.DOM_ELEMENT=27,GameLib.Component.STATS=29,GameLib.Component.GUI=30,GameLib.Component.IMAGE=31,GameLib.Component.ENTITY=32,GameLib.Component.MESH_SPHERE=33,GameLib.Component.MESH_PLANE=34,GameLib.Component.MESH_CURVE=35,GameLib.Component.PHYSICS_WORLD=36,GameLib.Component.BROADPHASE=37,GameLib.Component.SOLVER=38,GameLib.Component.RIGID_BODY=39,GameLib.Component.SHAPE=40,GameLib.Component.SHAPE_BOX=41,GameLib.Component.SHAPE_SPHERE=42,GameLib.Component.SHAPE_TRI_MESH=43,GameLib.Component.SHAPE_CONVEX_HULL=44,GameLib.Component.SHAPE_CONVEX_HULL_CYLINDER=45,GameLib.Component.SHAPE_HEIGHT_MAP=46,GameLib.Component.SHAPE_PLANE=47,GameLib.Component.CONTROLS=48,GameLib.Component.CONTROLS_EDITOR=49;GameLib.Component.CONTROLS_TOUCH=50,GameLib.Component.FRICTION_MATERIAL=51,GameLib.Component.FRICTION_CONTACT_MATERIAL=52,GameLib.Component.RAYCAST_VEHICLE=53,GameLib.Component.RAYCAST_WHEEL=54,GameLib.Component.CLOCK=55,GameLib.Component.ANIMATION=56,GameLib.Component.CONTROLS_KEYBOARD=57,GameLib.Component.CONTROLS_MOUSE=58,GameLib.Component.MESH_TEXT=59,GameLib.Component.FONT=60,GameLib.Component.CANVAS=61,GameLib.Component.BONE=62,GameLib.Component.MESH_BOX=63,GameLib.Component.MESH_CYLINDER=64,GameLib.Component.SYSTEM_ANIMATION=65,GameLib.Component.SYSTEM_CUSTOM_CODE=66,GameLib.Component.SYSTEM_GUI=67,GameLib.Component.SYSTEM_INPUT=68,GameLib.Component.SYSTEM_LINKING=69,GameLib.Component.SYSTEM_PHYSICS=70,GameLib.Component.SYSTEM_RENDER=71,GameLib.Component.SYSTEM_STORAGE=72,GameLib.Component.SYSTEM_VISUALIZATION=73,GameLib.Component.FOG=80,GameLib.Component.MESH_LINE=81,GameLib.Component.PARTICLE_ENGINE=82,GameLib.Component.SYSTEM_PARTICLE=83,GameLib.Component.PARTICLE=84,GameLib.Component.AUDIO=85,GameLib.Component.SYSTEM_AUDIO=86,GameLib.Component.CAST=87,GameLib.Component.MAX_COMPONENTS=88,GameLib.Component.GRAPHICS_RUNTIME=1,GameLib.Component.PHYSICS_RUNTIME=2,GameLib.Component.SOCKET_RUNTIME=3,GameLib.Component.STATISTICS_RUNTIME=4,GameLib.Component.DEFAULT_RUNTIME=5,GameLib.Component.GUI_RUNTIME=6,GameLib.Component.CODER_RUNTIME=7,GameLib.Component.GetCompentTypes=function(e){GameLib.Component},GameLib.Component.GetComponentInfo=function(e){switch(e){case 1:return null;case 2:return{name:"GameLib.D3.Material",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Material};case 3:return{name:"GameLib.D3.Renderer",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Renderer};case 4:return null;case 5:return{name:"GameLib.D3.Camera",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Camera};case 6:return null;case 7:return{name:"GameLib.D3.Mesh",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh};case 8:return{name:"GameLib.D3.Spline",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Spline};case 9:return{name:"GameLib.D3.Light",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Light};case 10:return null;case 11:return{name:"GameLib.D3.Composer",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Composer};case 12:return{name:"GameLib.D3.RenderTarget",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.RenderTarget};case 13:return{name:"GameLib.D3.Pass",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Pass};case 14:return{name:"GameLib.D3.Scene",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Scene};case 15:return{name:"GameLib.D3.Raycaster",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Raycaster};case 16:case 17:return null;case 18:return{name:"GameLib.D3.Viewport",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Viewport};case 19:return{name:"GameLib.System",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System};case 20:return{name:"GameLib.GraphicsRuntime",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.GraphicsRuntime};case 21:return{name:"GameLib.D3.Helper",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Helper};case 22:return{name:"GameLib.CustomCode",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.CustomCode};case 23:return{name:"GameLib.Mouse",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.Mouse};case 24:return{name:"GameLib.D3.Skeleton",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Skeleton};case 25:return{name:"GameLib.D3.Texture",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Texture};case 26:return{name:"GameLib.EntityManager",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.EntityManager};case 27:return{name:"GameLib.DomElement",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.DomElement};case 28:return null;case 29:return{name:"GameLib.Stats",runtime:GameLib.Component.STATISTICS_RUNTIME,constructor:GameLib.Stats};case 30:return{name:"GameLib.GUI",runtime:GameLib.Component.GUI_RUNTIME,constructor:GameLib.GUI};case 31:return{name:"GameLib.Image",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Image};case 32:return{name:"GameLib.Entity",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Entity};case 33:return{name:"GameLib.D3.Mesh.Sphere",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Sphere};case 34:return{name:"GameLib.D3.Mesh.Plane",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Plane};case 35:return{name:"GameLib.D3.Mesh.Curve",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Curve};case 36:return{name:"GameLib.D3.PhysicsWorld",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.PhysicsWorld};case 37:return{name:"GameLib.D3.Broadphase",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Broadphase};case 38:return{name:"GameLib.D3.Solver",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Solver};case 39:return{name:"GameLib.D3.RigidBody",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.RigidBody};case 40:return{name:"GameLib.D3.Shape",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape};case 41:return{name:"GameLib.D3.Shape.Box",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.Box};case 42:return{name:"GameLib.D3.Shape.Sphere",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.Sphere};case 43:return{name:"GameLib.D3.Shape.TriMesh",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.TriMesh};case 44:return{name:"GameLib.D3.Shape.ConvexHull",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.ConvexHull};case 45:return{name:"GameLib.D3.Shape.ConvexHull.Cylinder",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.ConvexHull.Cylinder};case 46:return{name:"GameLib.D3.Shape.HeightMap",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.D3.Shape.HeightMap};case 47:return{name:"GameLib.D3.Shape.Plane",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.Shape.Plane};case 48:return{name:"GameLib.Controls",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Controls};case 49:return{name:"GameLib.Controls.D3.Editor",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.Controls.D3.Editor};case 50:return{name:"GameLib.Controls.Touch",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Controls.Touch};case 51:return{name:"GameLib.D3.FrictionMaterial",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.FrictionMaterial};case 52:return{name:"GameLib.D3.FrictionContactMaterial",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.FrictionContactMaterial};case 53:return{name:"GameLib.D3.RaycastVehicle",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.RaycastVehicle};case 54:return{name:"GameLib.D3.RaycastWheel",runtime:GameLib.Component.PHYSICS_RUNTIME,constructor:GameLib.D3.RaycastWheel};case 55:return{name:"GameLib.Clock",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.Clock};case 56:return{name:"GameLib.D3.Animation",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.D3.Animation};case 57:return{name:"GameLib.Controls.Keyboard",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Controls.Keyboard};case 58:return{name:"GameLib.Controls.Mouse",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Controls.Mouse};case 59:return{name:"GameLib.D3.Mesh.Text",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Text};case 60:return{name:"GameLib.D3.Font",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Font};case 61:return{name:"GameLib.Canvas",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.Canvas};case 62:return{name:"GameLib.D3.Bone",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Bone};case 63:return{name:"GameLib.D3.Mesh.Box",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Box};case 64:return{name:"GameLib.D3.Mesh.Cylinder",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Cylinder};case 65:return{name:"GameLib.System.Animation",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Animation};case 66:return{name:"GameLib.System.CustomCode",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.CustomCode};case 67:return{name:"GameLib.System.GUI",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.GUI};case 68:return{name:"GameLib.System.Input",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Input};case 69:return{name:"GameLib.System.Linking",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Linking};case 70:return{name:"GameLib.System.Physics",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Physics};case 71:return{name:"GameLib.System.Render",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Render};case 72:return{name:"GameLib.System.Storage",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Storage};case 73:return{name:"GameLib.System.Visualization",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Visualization};case 80:return{name:"GameLib.D3.Fog",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Fog};case 81:return{name:"GameLib.D3.Mesh.Line",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Mesh.Line};case 82:return{name:"GameLib.D3.ParticleEngine",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.ParticleEngine};case 83:return{name:"GameLib.System.Particle",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Particle};case 84:return{name:"GameLib.D3.Particle",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Particle};case 85:return{name:"GameLib.D3.Audio",runtime:GameLib.Component.GRAPHICS_RUNTIME,constructor:GameLib.D3.Audio};case 86:return{name:"GameLib.System.Audio",runtime:GameLib.Component.DEFAULT_RUNTIME,constructor:GameLib.System.Audio};case 87:return{name:"GameLib.Cast",runtime:GameLib.Component.SOCKET_RUNTIME,constructor:GameLib.Cast}}throw new Error("Unknown component type: "+e)},GameLib.Component.GetRuntimeName=function(e){return e===GameLib.Component.GRAPHICS_RUNTIME?"Graphics":e===GameLib.Component.PHYSICS_RUNTIME?"Physics":e===GameLib.Component.GUI_RUNTIME?"GUI":e===GameLib.Component.STATISTICS_RUNTIME?"Statistics":e===GameLib.Component.SOCKET_RUNTIME?"Sockets":e===GameLib.Component.CODER_RUNTIME?"Coder":"Default"},GameLib.Component.GetComponentName=function(e){var t=GameLib.Component.GetComponentInfo(e);return t?t.name:"unused"},GameLib.Component.GetComponentRuntime=function(e){var t=GameLib.Component.GetComponentInfo(e);return t?t.runtime:null},GameLib.Component.GetComponentConstructor=function(e){var t=GameLib.Component.GetComponentInfo(e);return t?t.constructor:null},GameLib.Component.prototype.toApiObject=function(){return this.id},GameLib.Component.prototype.processComponent=function(e){if(e instanceof GameLib.Component){e.buildIdToObject(),e.linked||(this.linked=!1);var t=e.idToObject;for(var i in t)t.hasOwnProperty(i)&&(this.idToObject[i]=t[i]);e.id?this.idToObject[e.id]=e:console.warn("Object with no ID passed: "+e)}else"string"==typeof e?this.linked=!1:console.warn("Unhandled type of object: ",e)},GameLib.Component.prototype.buildIdToObject=function(){if(!this.building){this.building=!0,this.linked=!0,this.idToObject={};for(var e in this.linkedObjects)this.linkedObjects.hasOwnProperty(e)&&this.hasOwnProperty(e)&&this[e]&&0!==e.indexOf("parent")&&(this.linkedObjects[e]instanceof Array?(this[e]=this[e].filter(function(e){return null!==e||(console.log("null object found and removed"),!1)}),this[e].map(function(e){this.processComponent(e)}.bind(this))):this.processComponent(this[e]));this instanceof GameLib.D3.Scene&&(this.storeClones||this.clones.map(function(e){this.idToObject.hasOwnProperty(e.id)&&delete this.idToObject[e.id]}.bind(this))),this.idToObject[this.id]=this,this.building=!1}},GameLib.Component.prototype.generateNewIds=function(){this.buildIdToObject();var e=GameLib.EntityManager.Instance.queryComponents(GameLib.Component.CUSTOM_CODE);for(var t in this.idToObject)if(this.idToObject.hasOwnProperty(t)){var i=this.idToObject[t].id,n=GameLib.Utils.RandomId();this.idToObject[t].id=n,this.idToObject[t].name=this.idToObject[t].name.replace(i,n),e.map(function(e){e.code=e.code.replace(i,n)})}},GameLib.Component.prototype.remove=function(){this.buildIdToObject(),this.getDependencies().map(function(e){var t=this.idToObject[e];t instanceof GameLib.Component&&t.remove()}.bind(this)),GameLib.Event.Emit(GameLib.Event.REMOVE_COMPONENT,{component:this})},GameLib.Component.prototype.clone=function(){var e=this.toApiObject();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 a in this.idToObject)if(this.idToObject.hasOwnProperty(a)&&this.idToObject[a]instanceof GameLib.Component){var s=this.idToObject[a].toApiObject();t.push(s),this.publish(GameLib.Event.SAVE_COMPONENT,{apiObject:s,remote:e})}},GameLib.Component.Construct=function(e){var t=null,i=GameLib.Component.GetComponentInfo(e.componentType),n=i.constructor,a=n.FromObject,s=null;return GameLib.Event.Emit(GameLib.Event.GET_RUNTIME,null,function(e){s=e}),e.componentType===GameLib.Component.ENTITY?t=a(e,GameLib.EntityManager.Instance):i.runtime===GameLib.Component.GRAPHICS_RUNTIME?(GameLib.Utils.UndefinedOrNull(s.graphics)&&console.warn("no runtime graphics"),t=a(s.graphics,e)):i.runtime===GameLib.Component.PHYSICS_RUNTIME?(GameLib.Utils.UndefinedOrNull(s.physics)&&console.warn("no runtime physics"),t=a(s.physics,e)):i.runtime===GameLib.Component.GUI_RUNTIME?(GameLib.Utils.UndefinedOrNull(s.gui)&&console.warn("no runtime gui"),t=a(s.gui,e)):i.runtime===GameLib.Component.SOCKET_RUNTIME?(GameLib.Utils.UndefinedOrNull(s.sockets)&&console.warn("no runtime sockets"),t=a(s.sockets,e)):i.runtime===GameLib.Component.STATISTICS_RUNTIME?(GameLib.Utils.UndefinedOrNull(s.statistics)&&console.warn("no runtime statistics"),t=a(s.statistics,e)):i.runtime===GameLib.Component.DEFAULT_RUNTIME?t=a(e):(console.log("unknown runtime object found : "+e.name),console.error(e)),t},GameLib.API.Canvas=function(e,t,i,n,a){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,a)},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,a,s,o,r){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="default"),this.roomId=n,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.peer=a,GameLib.Utils.UndefinedOrNull(s)&&(s="127.0.0.1"),this.serverIp=s,GameLib.Utils.UndefinedOrNull(o)&&(o=80),this.port=o,GameLib.API.Component.call(this,GameLib.Component.CAST,r)},GameLib.API.Cast.prototype=Object.create(GameLib.Component.prototype),GameLib.API.Cast.prototype.constructor=GameLib.API.Cast,GameLib.API.Cast.FromObject=function(e){return new GameLib.API.Cast(e.id,e.name,e.castType,e.roomId,e.peer,e.serverIp,e.port,e.parentEntity)},GameLib.API.Clock=function(e,t,i){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Clock ("+this.id+")"),this.name=t,GameLib.API.Component.call(this,GameLib.Component.CLOCK,i)},GameLib.API.Clock.prototype=Object.create(GameLib.Component.prototype),GameLib.API.Clock.prototype.constructor=GameLib.API.Clock,GameLib.API.Clock.FromObject=function(e){return new GameLib.API.Clock(e.id,e.name,e.parentEntity)},GameLib.API.Color=function(e,t,i,n){GameLib.Utils.UndefinedOrNull(e)&&(e=1),this.r=e,GameLib.Utils.UndefinedOrNull(t)&&(t=1),this.g=t,GameLib.Utils.UndefinedOrNull(i)&&(i=1),this.b=i,GameLib.Utils.UndefinedOrNull(n)&&(n=0),this.a=n},GameLib.API.Color.FromObject=function(e){return GameLib.Utils.UndefinedOrNull(e)&&(e={}),new GameLib.API.Color(e.r,e.g,e.b,e.a)},GameLib.API.Color.prototype.toHex=function(){this.r<0&&(this.r=0),this.g<0&&(this.g=0),this.b<0&&(this.b=0),this.r>1&&(this.r=1),this.g>1&&(this.g=1),this.b>1&&(this.b=1);var e=Math.floor(this.r>=1?255:256*this.r).toString(16),t=Math.floor(this.g>=1?255:256*this.g).toString(16),i=Math.floor(this.b>=1?255:256*this.b).toString(16);return e.length<2&&(e="0"+e),t.length<2&&(t="0"+t),i.length<2&&(i="0"+i),"#"+e+t+i},GameLib.API.Color.prototype.fromHex=function(e){var t=e.match(new RegExp("#+(..)(..)(..)"));this.r=parseInt(t[1],16)/255,this.g=parseInt(t[2],16)/255,this.b=parseInt(t[3],16)/255},GameLib.API.Controls=function(e,t,i,n,a){if(GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(this instanceof GameLib.Controls.D3.Editor&&(t=GameLib.Controls.CONTROLS_TYPE_EDITOR),this instanceof GameLib.Controls.Touch&&(t=GameLib.Controls.CONTROLS_TYPE_TOUCH),this instanceof GameLib.Controls.Keyboard&&(t=GameLib.Controls.CONTROLS_TYPE_KEYBOARD),this instanceof GameLib.Controls.Mouse&&(t=GameLib.Controls.CONTROLS_TYPE_MOUSE),GameLib.Utils.UndefinedOrNull(t)))throw new Error("Could not determine controls type from this");this.controlsType=t,GameLib.Utils.UndefinedOrNull(i)&&(t===GameLib.Controls.CONTROLS_TYPE_EDITOR&&(i="Editing Controls"),t===GameLib.Controls.CONTROLS_TYPE_TOUCH&&(i="Touch Controls"),t===GameLib.Controls.CONTROLS_TYPE_KEYBOARD&&(i="Keyboard Controls"),t===GameLib.Controls.CONTROLS_TYPE_MOUSE&&(i="Mouse Controls"),i+=" ("+this.id+")"),this.name=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.domElement=n;var s=GameLib.Component.CONTROLS;this.controlsType===GameLib.Controls.CONTROLS_TYPE_EDITOR&&(s=GameLib.Component.CONTROLS_EDITOR),this.controlsType===GameLib.Controls.CONTROLS_TYPE_TOUCH&&(s=GameLib.Component.CONTROLS_TOUCH),this.controlsType===GameLib.Controls.CONTROLS_TYPE_KEYBOARD&&(s=GameLib.Component.CONTROLS_KEYBOARD),this.controlsType===GameLib.Controls.CONTROLS_TYPE_MOUSE&&(s=GameLib.Component.CONTROLS_MOUSE),GameLib.API.Component.call(this,s,a)},GameLib.API.Controls.prototype=Object.create(GameLib.Component.prototype),GameLib.API.Controls.prototype.constructor=GameLib.API.Controls,GameLib.API.Controls.FromObject=function(e){return new GameLib.API.Controls(e.id,e.controlsType,e.name,e.domElement,e.parentEntity)},GameLib.API.CustomCode=function(e,t,i,n,a){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="CustomCode ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=42),this.eventId=i,GameLib.Utils.UndefinedOrNull(n)&&(n="return null;\n//@ sourceURL="+this.name+".js"),this.code=n,GameLib.API.Component.call(this,GameLib.Component.CUSTOM_CODE,a)},GameLib.API.CustomCode.prototype=Object.create(GameLib.Component.prototype),GameLib.API.CustomCode.prototype.constructor=GameLib.API.CustomCode,GameLib.API.CustomCode.FromObject=function(e){return new GameLib.API.CustomCode(e.id,e.name,e.eventId,e.code,e.parentEntity)},GameLib.API.DomElement=function(e,t,i,n){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="DOM Element ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=""),this.domElementId=i,GameLib.API.Component.call(this,GameLib.Component.DOM_ELEMENT,n)},GameLib.API.DomElement.prototype=Object.create(GameLib.Component.prototype),GameLib.API.DomElement.prototype.constructor=GameLib.API.DomElement,GameLib.API.DomElement.FromObject=function(e){return new GameLib.API.DomElement(e.id,e.name,e.domElementId,e.parentEntity)},GameLib.API.EntityManager=function(e,t,i,n,a,s){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Entity Manager ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=[]),this.entities=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.defaultEntity=n,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.defaultRenderer=a,GameLib.API.Component.call(this,GameLib.Component.ENTITY_MANAGER,s)},GameLib.API.EntityManager.prototype=Object.create(GameLib.Component.prototype),GameLib.API.EntityManager.prototype.constructor=GameLib.API.EntityManager,GameLib.API.EntityManager.FromObject=function(e){var t=e.entities.map(function(e){return GameLib.API.Entity.FromObject(e)});return new GameLib.API.EntityManager(e.id,e.name,t,e.defaultEntity,e.defaultRenderer,e.parentEntity)},GameLib.API.Entity=function(e,t,i,n,a){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Entity ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=[]),this.components=i,GameLib.API.Component.call(this,GameLib.Component.ENTITY,n),GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.parentEntityManager=a,this.activeComponent=null},GameLib.API.Entity.prototype=Object.create(GameLib.Component.prototype),GameLib.API.Entity.prototype.constructor=GameLib.API.Entity,GameLib.API.Entity.FromObject=function(e){return new GameLib.API.Entity(e.id,e.name,e.components,e.parentEntity,e.parentEntityManager)},GameLib.API.GUI=function(e,t,i,n){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="GUI ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=null),this.domElement=i,GameLib.API.Component.call(this,GameLib.Component.GUI,n)},GameLib.API.GUI.prototype=Object.create(GameLib.Component.prototype),GameLib.API.GUI.prototype.constructor=GameLib.API.GUI,GameLib.API.GUI.FromObject=function(e){var t=null;return e.domElement&&(t=e.domElement instanceof Object?GameLib.API.DomElement.FromObject(e.domElement):e.domElement),new GameLib.API.GUI(e.id,e.name,t,e.parentEntity)},GameLib.API.Image=function(e,t,i,n,a,s,o,r){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Image "+e),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=GameLib.Utils.LowerUnderscore(t)),this.fileName=i,GameLib.Utils.UndefinedOrNull(n)&&(n=".unknown"),this.extension=n,GameLib.Utils.UndefinedOrNull(a)&&(a="/"),this.path=a,GameLib.Utils.UndefinedOrNull(s)&&(s="application/octet-stream",this.extension.match(/(png)$/i)&&(s="image/png"),this.extension.match(/(jpg|jpeg)$/i)&&(s="image/jpeg"),this.extension.match(/(gif)$/i)&&(s="image/gif")),this.contentType=s,GameLib.Utils.UndefinedOrNull(o)&&(o=0),this.size=o,GameLib.API.Component.call(this,GameLib.Component.IMAGE,r)},GameLib.API.Image.prototype=Object.create(GameLib.Component.prototype),GameLib.API.Image.prototype.constructor=GameLib.API.Image,GameLib.API.Image.FromObject=function(e){return new GameLib.API.Image(e.id,e.name,e.fileName,e.extension,e.path,e.contentType,e.size,e.parentEntity)},GameLib.API.Matrix4=function(e,t,i,n){this.rows=[],GameLib.Utils.UndefinedOrNull(e)&&(e=new GameLib.API.Vector4(1,0,0,0)),this.rows[0]=e,GameLib.Utils.UndefinedOrNull(t)&&(t=new GameLib.API.Vector4(0,1,0,0)),this.rows[1]=t,GameLib.Utils.UndefinedOrNull(i)&&(i=new GameLib.API.Vector4(0,0,1,0)),this.rows[2]=i,GameLib.Utils.UndefinedOrNull(n)&&(n=new GameLib.API.Vector4(0,0,0,1)),this.rows[3]=n,this.temp=[],this.temp.push(new GameLib.API.Vector4),this.temp.push(new GameLib.API.Vector4),this.temp.push(new GameLib.API.Vector4),this.temp.push(new GameLib.API.Vector4),this.forward=new GameLib.API.Vector4,this.left=new GameLib.API.Vector4,this.up=new GameLib.API.Vector4},GameLib.API.Matrix4.FromObject=function(e){if(e.rows)return new GameLib.API.Matrix4(GameLib.API.Vector4.FromObject(e.rows[0]),GameLib.API.Vector4.FromObject(e.rows[1]),GameLib.API.Vector4.FromObject(e.rows[2]),GameLib.API.Vector4.FromObject(e.rows[3]));if(e instanceof Array)return new GameLib.API.Matrix4(GameLib.API.Vector4.FromObject(e[0]),GameLib.API.Vector4.FromObject(e[1]),GameLib.API.Vector4.FromObject(e[2]),GameLib.API.Vector4.FromObject(e[3]));throw console.warn("Unsupported object matrix type - whats your DB version?"),new Error("Unsupported object matrix type - whats your DB version?")},GameLib.API.Matrix4.prototype.rotationMatrixX=function(e){return this.identity(),this.rows[1]=new GameLib.API.Vector4(0,Math.cos(e),-1*Math.sin(e),0),this.rows[2]=new GameLib.API.Vector4(0,Math.sin(e),Math.cos(e),0),this},GameLib.API.Matrix4.prototype.rotationMatrixY=function(e){return this.identity(),this.rows[0]=new GameLib.API.Vector4(Math.cos(e),0,Math.sin(e),0),this.rows[2]=new GameLib.API.Vector4(-1*Math.sin(e),0,Math.cos(e),0),this},GameLib.API.Matrix4.prototype.rotationMatrixZ=function(e){return this.identity(),this.rows[0]=new GameLib.API.Vector4(Math.cos(e),-1*Math.sin(e),0,0),this.rows[1]=new GameLib.API.Vector4(Math.sin(e),Math.cos(e),0,0),this},GameLib.API.Matrix4.prototype.rotateX=function(e,t){return this.identity(),this.rotationMatrixX(e),this.multiply(t)},GameLib.API.Matrix4.prototype.rotateY=function(e,t){return this.identity(),this.rotationMatrixY(e),this.multiply(t)},GameLib.API.Matrix4.prototype.rotateZ=function(e,t){return this.identity(),this.rotationMatrixZ(e),this.multiply(t)},GameLib.API.Matrix4.prototype.multiply=function(e){return e instanceof GameLib.API.Quaternion||e instanceof GameLib.API.Vector4?new GameLib.API.Quaternion(this.rows[0].x*e.x+this.rows[0].y*e.y+this.rows[0].z*e.z+this.rows[0].w*e.w,this.rows[1].x*e.x+this.rows[1].y*e.y+this.rows[1].z*e.z+this.rows[1].w*e.w,this.rows[2].x*e.x+this.rows[2].y*e.y+this.rows[2].z*e.z+this.rows[2].w*e.w,this.rows[3].x*e.x+this.rows[3].y*e.y+this.rows[3].z*e.z+this.rows[3].w*e.w):e instanceof GameLib.API.Vector3?new GameLib.API.Vector3(this.rows[0].x*e.x+this.rows[0].y*e.y+this.rows[0].z*e.z,this.rows[1].x*e.x+this.rows[1].y*e.y+this.rows[1].z*e.z,this.rows[2].x*e.x+this.rows[2].y*e.y+this.rows[2].z*e.z):void 0},GameLib.API.Matrix4.prototype.identity=function(){this.rows=[new GameLib.API.Vector4(1,0,0,0),new GameLib.API.Vector4(0,1,0,0),new GameLib.API.Vector4(0,0,1,0),new GameLib.API.Vector4(0,0,0,1)]},GameLib.API.Mouse=function(e,t,i,n,a){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Mouse ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=0),this.x=i,GameLib.Utils.UndefinedOrNull(n)&&(n=0),this.y=n,GameLib.API.Component.call(this,GameLib.Component.MOUSE,a)},GameLib.API.Mouse.prototype=Object.create(GameLib.Component.prototype),GameLib.API.Mouse.prototype.constructor=GameLib.API.Mouse,GameLib.API.Mouse.FromObject=function(e){return new GameLib.API.Mouse(e.id,e.name,e.x,e.y,e.parentEntity)},GameLib.API.Quaternion=function(e,t,i,n,a,s){GameLib.Utils.UndefinedOrNull(e)&&(e=0),this.x=e,GameLib.Utils.UndefinedOrNull(t)&&(t=0),this.y=t,GameLib.Utils.UndefinedOrNull(i)&&(i=0),this.z=i,GameLib.Utils.UndefinedOrNull(n)&&(n=1),this.w=n,GameLib.Utils.UndefinedOrNull(a)&&(a=new GameLib.API.Vector3),this.axis=a,GameLib.Utils.UndefinedOrNull(s)&&(s=0),this.angle=s},GameLib.API.Quaternion.prototype.translate=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},GameLib.API.Quaternion.prototype.copy=function(){return new GameLib.API.Quaternion(this.x,this.y,this.z,this.w)},GameLib.API.Quaternion.prototype.normalize=function(){var e=this.x*this.x+this.y*this.y+this.z*this.z;if(e<1e-6)return this;var t=1/Math.sqrt(e);this.x*=t,this.y*=t,this.z*=t},GameLib.API.Quaternion.prototype.multiply=function(e){var t,i,n,a,s=e,o=this;if(e instanceof GameLib.API.Matrix4)return t=s.rows[0].x*o.x+s.rows[0].y*o.y+s.rows[0].z*o.z+s.rows[0].w*o.w,i=s.rows[1].x*o.x+s.rows[1].y*o.y+s.rows[1].z*o.z+s.rows[1].w*o.w,n=s.rows[2].x*o.x+s.rows[2].y*o.y+s.rows[2].z*o.z+s.rows[2].w*o.w,a=s.rows[3].x*o.x+s.rows[3].y*o.y+s.rows[3].z*o.z+s.rows[3].w*o.w,this.x=t,this.y=i,this.z=n,this.w=a,this;if(e instanceof GameLib.API.Quaternion)return t=s.x*o.x-s.y*o.y-s.z*o.z-s.w*s.w,i=s.x*o.y+s.y*o.x-s.z*o.w+s.w*s.z,n=s.x*o.z+s.y*o.w+s.z*o.x-s.w*s.y,a=s.x*o.w-s.y*o.z+s.z*o.y+s.w*s.x,this.x=t,this.y=i,this.z=n,this.w=a,this;throw console.log("This functionality not implemented - please do this"),new Error("This functionality not implemented - please do this")},GameLib.API.Quaternion.prototype.setFromAngle=function(e){return this.instance.setFromAxisAngle(this.axis.instance,e),this.x=this.instance.x,this.y=this.instance.y,this.z=this.instance.z,this.w=this.instance.w,this},GameLib.API.Quaternion.prototype.subtract=function(e){return e instanceof GameLib.API.Vector3&&(this.x-=e.x,this.y-=e.y,this.z-=e.z),e instanceof GameLib.API.Quaternion&&(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w),this},GameLib.API.Quaternion.prototype.magnitude=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},GameLib.API.Quaternion.prototype.normalize=function(){var e=this.magnitude();return e<1e-6?this:(this.x*=e,this.y*=e,this.z*=e,this.w*=e,this)},GameLib.API.Quaternion.prototype.setFromRotationMatrix=function(e){this.instance.setFromRotationMatrix(e.instance),this.x=this.instance.x,this.y=this.instance.y,this.z=this.instance.z,this.w=this.instance.w},GameLib.API.Quaternion.prototype.slerp=function(e,t){return this.updateInstance(),this.instance.slerp(e.instance,t),this.x=this.instance.x,this.y=this.instance.y,this.z=this.instance.z,this.w=this.instance.w,this},GameLib.API.Quaternion.FromObject=function(e){var t=null;return e.axis&&(t=GameLib.API.Vector3.FromObject(e.axis)),new GameLib.API.Quaternion(e.x,e.y,e.z,e.w,t,e.angle)},GameLib.API.Quaternion.Points=function(){this.vectors=[]},GameLib.API.Quaternion.Points.prototype.add=function(e){if(e instanceof GameLib.API.Vector3&&(e=new GameLib.API.Quaternion(e.x,e.y,e.z,1)),!e instanceof GameLib.API.Quaternion)throw console.warn("Vector needs to be of type Quaternion"),new Error("Vector needs to be of type Quaternion");return this.vectors.push(e),this},GameLib.API.Quaternion.Points.prototype.copy=function(){for(var e=[],t=0;ts&&(s=c.x,n=t*e)}this.vectors=a;for(var m=(new GameLib.API.Matrix4).rotationMatrixY(n),h=0;hs&&(s=c.y,n=t*e)}this.vectors=a;for(var m=(new GameLib.API.Matrix4).rotationMatrixX(n),h=0;hn&&(n=this.vectors[o].x),this.vectors[o].y>a&&(a=this.vectors[o].y),this.vectors[o].z>s&&(s=this.vectors[o].z);return new GameLib.API.Vector3(Math.abs(n-e),Math.abs(a-t),Math.abs(a-i))},GameLib.API.Quaternion.Points.prototype.average=function(){for(var e=0,t=0,i=0,n=0;n0},GameLib.API.Vector3.normal=function(e,t,i){var n=t.copy(),a=i.copy();return n.subtract(e).cross(a.subtract(e))},GameLib.API.Vector3.prototype.lookAt=function(e,t){var i=GameLib.API.Matrix4.lookAt(this,e,t);return this.multiply(i)},GameLib.API.Vector3.prototype.translate=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},GameLib.API.Vector3.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},GameLib.API.Vector3.prototype.squared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},GameLib.API.Vector3.prototype.copy=function(){return new GameLib.API.Vector3(this.x,this.y,this.z)},GameLib.API.Vector3.prototype.set=function(e,t,i){this.x=e,this.y=t,this.z=i},GameLib.API.Vector3.prototype.lerp=function(e,t){return new GameLib.API.Vector3(this.x+(e.x-this.x)*t,this.y+(e.y-this.y)*t,this.z+(e.z-this.z)*t)},GameLib.API.Vector3.prototype.distanceTo=function(e){var t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return Math.sqrt(t*t+i*i+n*n)},GameLib.API.Vector3.AngleDirection=function(e,t,i){var n=e.cross(t),a=n.dot(i);return a>0?1:a<0?-1:0},GameLib.API.Vector3.prototype.multiply=function(e,t){var i,n,a,s=e,o=this;if(GameLib.Utils.UndefinedOrNull(t)&&(t=!1),"number"==typeof e)return t?(this.x*=e,this.y*=e,this.z*=e,this):this.x*e+this.y*e+this.z*e;if(e instanceof GameLib.API.Vector3)return t?(i=s.y*o.z-s.z*o.y,n=s.z*o.x-s.x*o.z,a=s.x*o.y-s.y*o.x,this.x=i,this.y=n,this.z=a,this):this.x*e.x+this.y*e.y+this.z*e.z;throw console.log("functionality not implemented - please do this"),new Error("not implemented")},GameLib.API.Vector3.prototype.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z},GameLib.API.Vector3.prototype.normalize=function(){var e=this.squared();if(e<1e-6)return this;var t=1/Math.sqrt(e);return new GameLib.API.Vector3(this.x*t,this.y*t,this.z*t)},GameLib.API.Vector3.prototype.clone=function(){return new GameLib.API.Vector3(this.x,this.y,this.z)},GameLib.API.Vector3.prototype.applyQuaternion=function(e){var t=this.x,i=this.y,n=this.z,a=e.x,s=e.y,o=e.z,r=e.w,c=r*t+s*n-o*i,m=r*i+o*t-a*n,h=r*n+a*i-s*t,l=-a*t-s*i-o*n;return this.x=c*r+l*-a+m*-o-h*-s,this.y=m*r+l*-s+h*-a-c*-o,this.z=h*r+l*-o+c*-s-m*-a,this},GameLib.API.Vector3.prototype.clamp=function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},GameLib.API.Vector3.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},GameLib.API.Vector3.prototype.reflect=function(e){return this.sub(v1.copy(e).multiply(2*this.dot(e)))},GameLib.API.Vector3.prototype.angleTo=function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(exports.Math.clamp(t,-1,1))},GameLib.API.Vector3.FromObject=function(e){return new GameLib.API.Vector3(e.x,e.y,e.z)},GameLib.API.Vector4=function(e,t,i,n){GameLib.Utils.UndefinedOrNull(e)&&(e=0),this.x=e,GameLib.Utils.UndefinedOrNull(t)&&(t=0),this.y=t,GameLib.Utils.UndefinedOrNull(i)&&(i=0),this.z=i,GameLib.Utils.UndefinedOrNull(n)&&(n=1),this.w=n},GameLib.API.Vector4.prototype.equals=function(e){return this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},GameLib.API.Vector4.FromObject=function(e){return new GameLib.API.Vector4(e.x,e.y,e.z,e.w)},GameLib.Canvas=function(e){if(GameLib.Utils.UndefinedOrNull(e)&&(e={}),e instanceof GameLib.Canvas)return e;GameLib.API.Canvas.call(this,e.id,e.name,e.width,e.height,e.parentEntity),GameLib.Component.call(this)},GameLib.Canvas.prototype=Object.create(GameLib.API.Canvas.prototype),GameLib.Canvas.prototype.constructor=GameLib.Canvas,GameLib.Canvas.prototype.createInstance=function(){this.instance=document.createElement("canvas"),this.instance.width=this.width,this.instance.height=this.height,GameLib.Component.prototype.createInstance.call(this)},GameLib.Canvas.prototype.updateInstance=function(e){GameLib.Utils.UndefinedOrNull(e)&&console.warn("unknown property update for Canvas: "+e),"width"===e&&(this.instance.width=this.width),"height"===e&&(this.instance.height=this.height)},GameLib.Canvas.prototype.toApiObject=function(){return new GameLib.API.Canvas(this.id,this.name,this.width,this.height,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.Canvas.FromObject=function(e){return new GameLib.Canvas(GameLib.API.Canvas.FromObject(e))},GameLib.Cast=function(e,t){if(this.socket=e,this.socket.isNotWebSocketThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.Cast)return t;GameLib.API.Cast.call(this,t.id,t.name,t.castType,t.roomId,t.peer,t.serverIp,t.port,t.parentEntity),GameLib.Component.call(this,{peer:GameLib.Component})},GameLib.Cast.prototype=Object.create(GameLib.API.Cast.prototype),GameLib.Cast.prototype.constructor=GameLib.Cast,GameLib.Cast.CAST_TYPE_ROOM=1,GameLib.Cast.CAST_TYPE_PEER=2,GameLib.Cast.CAST_TYPE_ALL=3,GameLib.Cast.CAST_TYPE_ALL_BUT_PEER=4,GameLib.Cast.prototype.createInstance=function(){this.instance=!0,GameLib.Component.prototype.createInstance.call(this)},GameLib.Cast.prototype.updateInstance=function(e){},GameLib.Cast.prototype.remove=function(){},GameLib.Cast.prototype.toApiObject=function(){return new GameLib.API.Cast(this.id,this.name,this.castType,this.roomId,GameLib.Utils.IdOrNull(this.peer),this.serverIp,this.port,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.Cast.FromObject=function(e,t){var i=GameLib.API.Cast.FromObject(t);return new GameLib.Cast(e,i)},GameLib.Clock=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.Clock)return t;GameLib.API.Clock.call(this,t.id,t.name,t.parentEntity),GameLib.Component.call(this)},GameLib.Clock.prototype=Object.create(GameLib.API.Clock.prototype),GameLib.Clock.prototype.constructor=GameLib.Clock;GameLib.Clock.prototype.createInstance=function(){this.instance=new THREE.Clock,GameLib.Component.prototype.createInstance.call(this)},GameLib.Clock.prototype.updateInstance=function(){},GameLib.Clock.prototype.getDelta=function(){var e=this.instance.getDelta();return e>1/30&&(e=1/30),e},GameLib.Clock.prototype.toApiObject=function(){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.createInstance.call(this)},GameLib.Controls.D3.Editor.prototype.updateInstance=function(){console.warn("an update instance was called on editor controls - which, if not called from within a running system at the right time will affect the order of input event handling and cause system instability"),GameLib.Controls.prototype.updateInstance.call(this)},GameLib.Controls.D3.Editor.prototype.toApiObject=function(){var e=GameLib.Controls.prototype.toApiObject.call(this);return e.raycaster=GameLib.Utils.IdOrNull(this.raycaster),e.camera=GameLib.Utils.IdOrNull(this.camera),e},GameLib.Controls.D3.Editor.FromObject=function(e,t){var i=GameLib.API.Controls.FromObject(t);return new GameLib.Controls.D3.Editor(e,i,t.raycaster,t.camera)},GameLib.Controls.Keyboard=function(e){GameLib.Controls.call(this,e)},GameLib.Controls.Keyboard.prototype=Object.create(GameLib.Controls.prototype),GameLib.Controls.Keyboard.prototype.constructor=GameLib.Controls.Keyboard,GameLib.Controls.Keyboard.prototype.createInstance=function(){this.instance=!0,GameLib.Controls.prototype.createInstance.call(this)},GameLib.Controls.Keyboard.prototype.updateInstance=function(){GameLib.Controls.prototype.updateInstance.call(this)},GameLib.Controls.Keyboard.prototype.toApiObject=function(){return GameLib.Controls.prototype.toApiObject.call(this)},GameLib.Controls.Keyboard.FromObject=function(e){var t=GameLib.API.Controls.FromObject(e);return new GameLib.Controls.Keyboard(t)},GameLib.Controls.Mouse=function(e){GameLib.Controls.call(this,e)},GameLib.Controls.Mouse.prototype=Object.create(GameLib.Controls.prototype),GameLib.Controls.Mouse.prototype.constructor=GameLib.Controls.Mouse,GameLib.Controls.Mouse.prototype.createInstance=function(){this.instance=!0,GameLib.Controls.prototype.createInstance.call(this)},GameLib.Controls.Mouse.prototype.updateInstance=function(){GameLib.Controls.prototype.updateInstance.call(this)},GameLib.Controls.Mouse.prototype.toApiObject=function(){return GameLib.Controls.prototype.toApiObject.call(this)},GameLib.Controls.Mouse.FromObject=function(e){var t=GameLib.API.Controls.FromObject(e);return new GameLib.Controls.Mouse(t)},GameLib.Controls.Touch=function(e,t){GameLib.Utils.UndefinedOrNull(t)&&(t=5),this.sensitivity=t,GameLib.Controls.call(this,e)},GameLib.Controls.Touch.prototype=Object.create(GameLib.Controls.prototype),GameLib.Controls.Touch.prototype.constructor=GameLib.Controls.Touch,GameLib.Controls.Touch.prototype.createInstance=function(){this.instance=!0,GameLib.Controls.prototype.createInstance.call(this)},GameLib.Controls.Touch.prototype.updateInstance=function(){GameLib.Controls.prototype.updateInstance.call(this)},GameLib.Controls.Touch.prototype.toApiObject=function(){var e=GameLib.Controls.prototype.toApiObject.call(this);return e.sensitivity=this.sensitivity,e},GameLib.Controls.Touch.FromObject=function(e){var t=GameLib.API.Controls.FromObject(e);return new GameLib.Controls.Touch(t,e.sensitivity)},GameLib.CustomCode=function(e){if(GameLib.Utils.UndefinedOrNull(e)&&(e={}),e instanceof GameLib.CustomCode)return e;GameLib.API.CustomCode.call(this,e.id,e.name,e.eventId,e.code,e.parentEntity),this.editor=null,GameLib.Component.call(this)},GameLib.CustomCode.prototype=Object.create(GameLib.API.CustomCode.prototype),GameLib.CustomCode.prototype.constructor=GameLib.CustomCode,GameLib.CustomCode.prototype.createInstance=function(){try{this.instance=new Function("data",this.code).bind(this)}catch(e){this.instance=new Function("data","console.log('compilation failed for : "+this.name+"');").bind(this)}GameLib.Component.prototype.createInstance.call(this)},GameLib.CustomCode.prototype.updateInstance=function(){try{this.instance=new Function("data",this.code).bind(this),this.publish(GameLib.Event.COMPILE_SUCCESS,{component:this})}catch(e){this.instance=new Function("data","console.log('compilation update failed for : "+this.name+"');").bind(this),this.publish(GameLib.Event.COMPILE_FAILED,{component:this})}},GameLib.CustomCode.prototype.toApiObject=function(){return new GameLib.API.CustomCode(this.id,this.name,this.eventId,this.code,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.CustomCode.FromObject=function(e){var t=GameLib.API.CustomCode.FromObject(e);return new GameLib.CustomCode(t)},GameLib.CustomCode.prototype.launchEditor=function(){GameLib.Event.Emit(GameLib.Event.GET_RUNTIME,null,function(e){this.coder=e.coder,this.coder.isNotCodeMirrorThrow()}.bind(this)),this.editor=this.coder.instance(document.body,{value:this.code,mode:"javascript",lineNumbers:!0,scrollbarStyle:"overlay",indentWithTabs:!0,indentUnit:4}),this.editor.on("change",function(){this.code=this.editor.getValue(),this.updateInstance()}.bind(this))},GameLib.CustomCode.prototype.closeEditor=function(){var e=this.editor.getWrapperElement();e.parentElement.removeChild(e)},GameLib.D3.API.Animation=function(e,t,i,n,a,s,o,r,c,m,h,l){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Animation ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=0),this.rotationSpeed=i,GameLib.Utils.UndefinedOrNull(n)&&(n=0),this.translationSpeed=n,GameLib.Utils.UndefinedOrNull(a)&&(a=0),this.scaleSpeed=a,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.rotationFn=s,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.translationFn=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.scaleFn=r,GameLib.Utils.UndefinedOrNull(c)&&(c={position:!1,rotation:!0,scale:!1}),this.blocking=c,GameLib.Utils.UndefinedOrNull(m)&&(m=!0),this.applyToMeshWhenDone=m,GameLib.Utils.UndefinedOrNull(h)&&(h=[]),this.meshes=h,GameLib.API.Component.call(this,GameLib.Component.ANIMATION,l)},GameLib.D3.API.Animation.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Animation.prototype.constructor=GameLib.D3.API.Animation,GameLib.D3.API.Animation.FromObject=function(e){return new GameLib.D3.API.Animation(e.id,e.name,e.rotationSpeed,e.translationSpeed,e.scaleSpeed,e.rotationFn,e.translationFn,e.scaleFn,e.blocking,e.applyToMeshWhenDone,e.meshes,e.parentEntity)},GameLib.D3.API.Audio=function(e,t,i,n,a,s,o,r,c){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Audio ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=""),this.path=i,GameLib.Utils.UndefinedOrNull(n)&&(n=!1),this.loop=n,GameLib.Utils.UndefinedOrNull(a)&&(a=.5),this.volume=a,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.camera=s,GameLib.Utils.UndefinedOrNull(o)&&(o=!1),this.overplay=o,GameLib.Utils.UndefinedOrNull(r)&&(r=!1),this.paused=r,GameLib.API.Component.call(this,GameLib.Component.AUDIO,c)},GameLib.D3.API.Audio.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Audio.prototype.constructor=GameLib.D3.API.Audio,GameLib.D3.API.Audio.FromObject=function(e){var t=null;return e.camera&&(t=e.camera instanceof Object?GameLib.D3.API.Camera.FromObject(e.camera):e.camera),new GameLib.D3.API.Audio(e.id,e.name,e.path,e.loop,e.volume,t,e.overplay,e.paused,e.parentEntity)},GameLib.D3.API.BoneWeight=function(e,t){this.boneIndex=e,this.weight=t},GameLib.D3.API.BoneWeight.FromObject=function(e){return new GameLib.D3.API.BoneWeight(e.boneIndex,e.weight)},GameLib.D3.API.Bone=function(e,t,i,n,a,s,o,r,c){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Bone ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=[]),this.childBoneIds=i,GameLib.Utils.UndefinedOrNull(n)&&(n=[]),this.parentBoneIds=n,GameLib.Utils.UndefinedOrNull(a)&&(a=new GameLib.API.Vector3),this.position=a,GameLib.Utils.UndefinedOrNull(s)&&(s=new GameLib.API.Quaternion),this.quaternion=s,GameLib.Utils.UndefinedOrNull(o)&&(o=new GameLib.API.Vector3(1,1,1)),this.scale=o,GameLib.Utils.UndefinedOrNull(r)&&(r=new GameLib.API.Vector3(0,1,0)),this.up=r,GameLib.API.Component.call(this,GameLib.Component.BONE,c)},GameLib.D3.API.Bone.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Bone.prototype.constructor=GameLib.D3.API.Bone,GameLib.D3.API.Bone.FromObject=function(e){return new GameLib.D3.API.Bone(e.id,e.name,e.childBoneIds,e.parentBoneIds,GameLib.API.Vector3.FromObject(e.position),GameLib.API.Quaternion.FromObject(e.quaternion),GameLib.API.Vector3.FromObject(e.scale),GameLib.API.Vector3.FromObject(e.up),e.parentEntity)},GameLib.D3.API.Broadphase=function(e,t,i,n){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Broadphase ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE),this.broadphaseType=i,GameLib.API.Component.call(this,GameLib.Component.BROADPHASE,n)},GameLib.D3.API.Broadphase.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Broadphase.prototype.constructor=GameLib.D3.API.Broadphase,GameLib.D3.API.Broadphase.FromObject=function(e){return new GameLib.D3.API.Broadphase(e.id,e.name,e.broadphaseType,e.parentEntity)},GameLib.D3.API.Camera=function(e,t,i,n,a,s,o,r,c,m,h,l,p,u,b,d,L,G,f,E,y){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t=GameLib.D3.Camera.CAMERA_TYPE_PERSPECTIVE),this.cameraType=t,GameLib.Utils.UndefinedOrNull(i)&&(i="Camera ("+this.id+")"),this.name=i,GameLib.Utils.UndefinedOrNull(n)&&(n=75),this.fov=n,GameLib.Utils.UndefinedOrNull(a)&&(a=window.innerWidth/window.innerHeight),this.aspect=a,GameLib.Utils.UndefinedOrNull(s)&&(s=.01),this.near=s,GameLib.Utils.UndefinedOrNull(o)&&(o=1e3),this.far=o,GameLib.Utils.UndefinedOrNull(r)&&(r=new GameLib.API.Vector3(15,15,15)),this.position=r,GameLib.Utils.UndefinedOrNull(G)&&(G=new GameLib.API.Quaternion),this.quaternion=G,GameLib.Utils.UndefinedOrNull(c)&&(c=new GameLib.API.Vector3(0,0,0)),this.lookAt=c,GameLib.Utils.UndefinedOrNull(m)&&(m=-100),this.minX=m,GameLib.Utils.UndefinedOrNull(h)&&(h=100),this.maxX=h,GameLib.Utils.UndefinedOrNull(l)&&(l=-100),this.minY=l,GameLib.Utils.UndefinedOrNull(p)&&(p=100),this.maxY=p,GameLib.Utils.UndefinedOrNull(u)&&(u=-100),this.minZ=u,GameLib.Utils.UndefinedOrNull(b)&&(b=100),this.maxZ=b,GameLib.Utils.UndefinedOrNull(d)&&(d=0),this.offsetX=d,GameLib.Utils.UndefinedOrNull(L)&&(L=0),this.offsetY=L,GameLib.Utils.UndefinedOrNull(f)&&(f=30),this.eyeSeparation=f,GameLib.Utils.UndefinedOrNull(E)&&(E=150),this.focalLength=E,GameLib.API.Component.call(this,GameLib.Component.CAMERA,y)},GameLib.D3.API.Camera.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Camera.prototype.constructor=GameLib.D3.API.Camera,GameLib.D3.API.Camera.FromObject=function(e){return new GameLib.D3.API.Camera(e.id,e.cameraType,e.name,e.fov,e.aspect,e.near,e.far,GameLib.API.Vector3.FromObject(e.position),GameLib.API.Vector3.FromObject(e.lookAt),e.minX,e.maxX,e.minY,e.maxY,e.minZ,e.maxZ,e.offsetX,e.offsetY,GameLib.API.Quaternion.FromObject(e.quaternion),e.eyeSeparation,e.focalLength,e.parentEntity)},GameLib.D3.API.Composer=function(e,t,i,n,a,s){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Composer ("+e+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=null),this.renderer=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.renderTarget=n,GameLib.Utils.UndefinedOrNull(a)&&(a=[]),this.passes=a,GameLib.API.Component.call(this,GameLib.Component.COMPOSER,s)},GameLib.D3.API.Composer.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Composer.prototype.constructor=GameLib.D3.API.Composer,GameLib.D3.API.Composer.FromObject=function(e){return new GameLib.D3.API.Composer(e.id,e.name,e.renderer,e.renderTarget,e.passes,e.parentEntity)},GameLib.D3.API.Face=function(e,t,i,n,a,s,o,r,c,m,h){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Face "+e),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=-1),this.v0index=i,GameLib.Utils.UndefinedOrNull(n)&&(n=-1),this.v1index=n,GameLib.Utils.UndefinedOrNull(a)&&(a=-1),this.v2index=a,GameLib.Utils.UndefinedOrNull(s)&&(s=-1),this.materialIndex=s,GameLib.Utils.UndefinedOrNull(o)&&(o=[[]]),this.uvs=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.color=r,GameLib.Utils.UndefinedOrNull(c)&&(c=[]),this.vertexColors=c,GameLib.Utils.UndefinedOrNull(m)&&(m=[]),this.vertexNormals=m,GameLib.Utils.UndefinedOrNull(h)&&(h=null),this.normal=h},GameLib.D3.API.Face.FromObject=function(e){var t=e.uvs.reduce(function(e,t,i){return e[i]=t.reduce(function(e,t){return e.push(GameLib.API.Vector2.FromObject(t)),e},[]),e},[]),i=e.vertexColors.map(function(e){return GameLib.API.Color.FromObject(e)}),n=null;e.color&&(n=GameLib.API.Color.FromObject(e.color));var a=e.vertexNormals.map(function(e){return GameLib.API.Vector3.FromObject(e)}),s=null;return e.normal&&(s=GameLib.API.Vector3.FromObject(e.normal)),new GameLib.D3.API.Face(e.id,e.name,e.v0index,e.v1index,e.v2index,e.materialIndex,t,n,i,a,s)},GameLib.D3.API.Face.prototype.clone=function(){return new GameLib.D3.API.Face(this.id,this.name,this.v0index,this.v1index,this.v2index,this.materialIndex,this.uvs,this.color,this.vertexColors,this.vertexNormals,this.normal)},GameLib.D3.API.Face.prototype.equals=function(e){return this.v0index===e.v0index&&this.v1index===e.v1index&&this.v2index===e.v2index||this.v0index===e.v0index&&this.v1index===e.v2index&&this.v2index===e.v1index||this.v0index===e.v1index&&this.v1index===e.v0index&&this.v2index===e.v2index||this.v0index===e.v1index&&this.v1index===e.v2index&&this.v2index===e.v0index||this.v0index===e.v2index&&this.v1index===e.v0index&&this.v2index===e.v1index||this.v0index===e.v2index&&this.v1index===e.v1index&&this.v2index===e.v0index},GameLib.D3.API.Fog=function(e,t,i,n,a,s,o,r){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Fog ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=!1),this.exponential=i,GameLib.Utils.UndefinedOrNull(n)&&(n=new GameLib.API.Color(1,1,1,1)),this.color=n,GameLib.Utils.UndefinedOrNull(a)&&(a=1),this.near=a,GameLib.Utils.UndefinedOrNull(s)&&(s=1e3),this.far=s,GameLib.Utils.UndefinedOrNull(o)&&(o=25e-5),this.density=o,GameLib.API.Component.call(this,GameLib.Component.FOG,r)},GameLib.D3.API.Fog.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Fog.prototype.constructor=GameLib.D3.API.Fog,GameLib.D3.API.Fog.FromObject=function(e){return new GameLib.D3.API.Fog(e.id,e.name,e.exponential,e.color,e.near,e.far,e.density,e.parentEntity)},GameLib.D3.API.Font=function(e,t,i,n){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Font ("+e+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i="/apiRelative/path/to/font"),this.url=i,GameLib.API.Component.call(this,GameLib.Component.FONT,n)},GameLib.D3.API.Font.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Font.prototype.constructor=GameLib.D3.API.Font,GameLib.D3.API.Font.FromObject=function(e){return new GameLib.D3.API.Font(e.id,e.name,e.url,e.parentEntity)},GameLib.D3.API.FrictionContactMaterial=function(e,t,i,n,a,s,o,r,c,m){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Friction Material ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=[]),this.materials=i,GameLib.Utils.UndefinedOrNull(n)&&(n=.3),this.friction=n,GameLib.Utils.UndefinedOrNull(a)&&(a=.3),this.restitution=a,GameLib.Utils.UndefinedOrNull(s)&&(s=1e7),this.contactEquationStiffness=s,GameLib.Utils.UndefinedOrNull(o)&&(o=3),this.contactEquationRelaxation=o,GameLib.Utils.UndefinedOrNull(r)&&(r=1e7),this.frictionEquationStiffness=r,GameLib.Utils.UndefinedOrNull(c)&&(c=3),this.frictionEquationRelaxation=c,GameLib.API.Component.call(this,GameLib.Component.FRICTION_CONTACT_MATERIAL,m)},GameLib.D3.API.FrictionContactMaterial.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.FrictionContactMaterial.prototype.constructor=GameLib.D3.API.FrictionContactMaterial,GameLib.D3.API.FrictionContactMaterial.FromObject=function(e){return new GameLib.D3.API.FrictionContactMaterial(e.id,e.name,e.materials,e.friction,e.restitution,e.contactEquationStiffness,e.contactEquationRelaxation,e.frictionEquationStiffness,e.frictionEquationRelaxation,e.parentEntity)},GameLib.D3.API.FrictionMaterial=function(e,t,i,n,a){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Friction Material ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=-1),this.friction=i,GameLib.Utils.UndefinedOrNull(n)&&(n=-1),this.restitution=n,GameLib.API.Component.call(this,GameLib.Component.FRICTION_MATERIAL,a)},GameLib.D3.API.FrictionMaterial.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.FrictionMaterial.prototype.constructor=GameLib.D3.API.FrictionMaterial,GameLib.D3.API.FrictionMaterial.FromObject=function(e){return new GameLib.D3.API.FrictionMaterial(e.id,e.name,e.friction,e.restitution,e.parentEntity)},GameLib.D3.API.Light=function(e,t,i,n,a,s,o,r,c,m,h,l,p,u,b,d,L){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t=GameLib.D3.Light.LIGHT_TYPE_AMBIENT),this.lightType=t,GameLib.Utils.UndefinedOrNull(i)&&(this.lightType===GameLib.D3.Light.LIGHT_TYPE_AMBIENT&&(i="Ambient "),this.lightType===GameLib.D3.Light.LIGHT_TYPE_DIRECTIONAL&&(i="Directional "),this.lightType===GameLib.D3.Light.LIGHT_TYPE_POINT&&(i="Point "),this.lightType===GameLib.D3.Light.LIGHT_TYPE_SPOT&&(i="Spot "),i+="Light ("+e+")"),this.name=i,GameLib.Utils.UndefinedOrNull(n)&&(n=new GameLib.API.Color(1,1,1,1)),this.color=n,GameLib.Utils.UndefinedOrNull(a)&&(a=1),this.intensity=a,GameLib.Utils.UndefinedOrNull(s)&&(s=new GameLib.API.Vector3(10,10,10)),this.position=s,GameLib.Utils.UndefinedOrNull(o)&&(o=new GameLib.API.Vector3(0,0,0)),this.targetPosition=o,GameLib.Utils.UndefinedOrNull(r)&&(r=new GameLib.API.Quaternion),this.quaternion=r,GameLib.Utils.UndefinedOrNull(c)&&(c=new GameLib.API.Vector3(0,0,0)),this.rotation=c,GameLib.Utils.UndefinedOrNull(m)&&(m=new GameLib.API.Vector3(1,1,1)),this.scale=m,GameLib.Utils.UndefinedOrNull(h)&&(h=0),this.distance=h,GameLib.Utils.UndefinedOrNull(l)&&(l=1),this.decay=l,GameLib.Utils.UndefinedOrNull(p)&&(p=4*Math.PI),this.power=p,GameLib.Utils.UndefinedOrNull(u)&&(u=Math.PI/3),this.angle=u,GameLib.Utils.UndefinedOrNull(b)&&(b=0),this.penumbra=b,GameLib.Utils.UndefinedOrNull(d)&&(d=null),this.parentScene=d,GameLib.API.Component.call(this,GameLib.Component.LIGHT,L)},GameLib.D3.API.Light.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Light.prototype.constructor=GameLib.D3.API.Light,GameLib.D3.API.Light.FromObject=function(e){return new GameLib.D3.API.Light(e.id,e.lightType,e.name,GameLib.API.Color.FromObject(e.color),e.intensity,GameLib.API.Vector3.FromObject(e.position),GameLib.API.Vector3.FromObject(e.targetPosition),GameLib.API.Quaternion.FromObject(e.quaternion),GameLib.API.Vector3.FromObject(e.rotation),GameLib.API.Vector3.FromObject(e.scale),e.distance,e.decay,e.power,e.angle,e.penumbra,e.parentScene,e.parentEntity)},GameLib.D3.API.Material=function(e,t,i,n,a,s,o,r,c,m,h,l,p,u,b,d,L,G,f,E,y,I,P,T,A,O,D,S,g,C,U,N,v,M,_,w,R,x,F,Y,j,V,H,z,B,q,k,W,X,Q,K,Z,J,$,ee,te,ie,ne,ae,se,oe,re,ce,me,he,le,pe,ue,be){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t=GameLib.D3.Material.MATERIAL_TYPE_STANDARD),this.materialType=t,GameLib.Utils.UndefinedOrNull(i)&&(i="Material ("+t+")"),this.name=i,GameLib.Utils.UndefinedOrNull(n)&&(n=1),this.opacity=n,GameLib.Utils.UndefinedOrNull(a)&&(a=GameLib.D3.Material.TYPE_FRONT_SIDE),this.side=a,GameLib.Utils.UndefinedOrNull(s)&&(s=!1),this.transparent=s,GameLib.Utils.UndefinedOrNull(o)&&(o=new GameLib.API.Color(.06,.06,.06,.06)),this.specular=o,GameLib.Utils.UndefinedOrNull(r)&&(r=1),this.lightMapIntensity=r,GameLib.Utils.UndefinedOrNull(c)&&(c=1),this.aoMapIntensity=c,GameLib.Utils.UndefinedOrNull(m)&&(m=new GameLib.API.Color(1,1,1,1)),this.color=m,GameLib.Utils.UndefinedOrNull(h)&&(h=new GameLib.API.Color(0,0,0,0)),this.emissive=h,GameLib.Utils.UndefinedOrNull(l)&&(l=1),this.emissiveIntensity=l,GameLib.Utils.UndefinedOrNull(p)&&(p=GameLib.D3.Material.TYPE_MULTIPLY_OPERATION),this.combine=p,GameLib.Utils.UndefinedOrNull(u)&&(u=30),this.shininess=u,GameLib.Utils.UndefinedOrNull(b)&&(b=1),this.reflectivity=b,GameLib.Utils.UndefinedOrNull(d)&&(d=.98),this.refractionRatio=d,GameLib.Utils.UndefinedOrNull(L)&&(L=!0),this.fog=L,GameLib.Utils.UndefinedOrNull(G)&&(G=!1),this.wireframe=G,GameLib.Utils.UndefinedOrNull(f)&&(f=1),this.wireframeLineWidth=f,GameLib.Utils.UndefinedOrNull(E)&&(E="round"),this.wireframeLineCap=E,GameLib.Utils.UndefinedOrNull(y)&&(y="round"),this.wireframeLineJoin=y,GameLib.Utils.UndefinedOrNull(I)&&(I=GameLib.D3.Material.TYPE_NO_COLORS),this.vertexColors=I,GameLib.Utils.UndefinedOrNull(P)&&(P=!1),this.skinning=P,GameLib.Utils.UndefinedOrNull(T)&&(T=!1),this.morphTargets=T,GameLib.Utils.UndefinedOrNull(A)&&(A=!1),this.morphNormals=A,GameLib.Utils.UndefinedOrNull(B)&&(B=0),this.overdraw=B,GameLib.Utils.UndefinedOrNull(O)&&(O=1),this.lineWidth=O,GameLib.Utils.UndefinedOrNull(D)&&(D="round"),this.lineCap=D,GameLib.Utils.UndefinedOrNull(S)&&(S="round"),this.lineJoin=S,GameLib.Utils.UndefinedOrNull(g)&&(g=3),this.dashSize=g,GameLib.Utils.UndefinedOrNull(C)&&(C=1),this.gapWidth=C,GameLib.Utils.UndefinedOrNull(U)&&(U=GameLib.D3.Material.TYPE_NORMAL_BLENDING),this.blending=U,GameLib.Utils.UndefinedOrNull(N)&&(N=GameLib.D3.Material.TYPE_SRC_ALPHA_FACTOR),this.blendSrc=N,GameLib.Utils.UndefinedOrNull(v)&&(v=GameLib.D3.Material.TYPE_ONE_MINUS_SRC_ALPHA_FACTOR),this.blendDst=v,GameLib.Utils.UndefinedOrNull(M)&&(M=GameLib.D3.Material.TYPE_ADD_EQUATION),this.blendEquation=M,GameLib.Utils.UndefinedOrNull(_)&&(_=!0),this.depthTest=_,GameLib.Utils.UndefinedOrNull(w)&&(w=GameLib.D3.Material.TYPE_LESS_EQUAL_DEPTH),this.depthFunc=w,GameLib.Utils.UndefinedOrNull(R)&&(R=!0),this.depthWrite=R,GameLib.Utils.UndefinedOrNull(x)&&(x=!1),this.polygonOffset=x,GameLib.Utils.UndefinedOrNull(F)&&(F=1),this.polygonOffsetFactor=F,GameLib.Utils.UndefinedOrNull(Y)&&(Y=1),this.polygonOffsetUnits=Y,GameLib.Utils.UndefinedOrNull(j)&&(j=0),this.alphaTest=j,GameLib.Utils.UndefinedOrNull(V)&&(V=[]),this.clippingPlanes=V,GameLib.Utils.UndefinedOrNull(H)&&(H=!1),this.clipShadows=H,GameLib.Utils.UndefinedOrNull(z)&&(z=!0),this.visible=z,GameLib.Utils.UndefinedOrNull(q)&&(q=!1),this.flatShading=q,GameLib.Utils.UndefinedOrNull(k)&&(k=1),this.bumpScale=k,GameLib.Utils.UndefinedOrNull(W)&&(W=1),this.normalScale=W,GameLib.Utils.UndefinedOrNull(X)&&(X=1),this.displacementScale=X,GameLib.Utils.UndefinedOrNull(Q)&&(Q=0),this.displacementBias=Q,GameLib.Utils.UndefinedOrNull(K)&&(K=.5),this.roughness=K,GameLib.Utils.UndefinedOrNull(Z)&&(Z=.5),this.metalness=Z,GameLib.Utils.UndefinedOrNull(J)&&(J=1),this.pointSize=J,GameLib.Utils.UndefinedOrNull($)&&($=!0),this.pointSizeAttenuation=$,GameLib.Utils.UndefinedOrNull(ee)&&(ee=0),this.spriteRotation=ee,GameLib.Utils.UndefinedOrNull(te)&&(te=1),this.envMapIntensity=te,GameLib.Utils.UndefinedOrNull(ie)&&(ie=null),this.alphaMap=ie,GameLib.Utils.UndefinedOrNull(ne)&&(ne=null),this.aoMap=ne,GameLib.Utils.UndefinedOrNull(ae)&&(ae=null),this.bumpMap=ae,GameLib.Utils.UndefinedOrNull(se)&&(se=null),this.diffuseMap=se,GameLib.Utils.UndefinedOrNull(oe)&&(oe=null),this.displacementMap=oe,GameLib.Utils.UndefinedOrNull(re)&&(re=null),this.emissiveMap=re,GameLib.Utils.UndefinedOrNull(ce)&&(ce=null),this.environmentMap=ce,GameLib.Utils.UndefinedOrNull(me)&&(me=null),this.lightMap=me,GameLib.Utils.UndefinedOrNull(he)&&(he=null),this.metalnessMap=he,GameLib.Utils.UndefinedOrNull(le)&&(le=null),this.normalMap=le,GameLib.Utils.UndefinedOrNull(pe)&&(pe=null),this.roughnessMap=pe,GameLib.Utils.UndefinedOrNull(ue)&&(ue=null),this.specularMap=ue,GameLib.API.Component.call(this,GameLib.Component.MATERIAL,be),this.needsUpdate=!1},GameLib.D3.API.Material.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Material.prototype.constructor=GameLib.D3.API.Material,GameLib.D3.API.Material.FromObject=function(e){var t=null,i=null,n=null,a=null,s=null,o=null,r=null,c=null,m=null,h=null,l=null,p=null;return e.alphaMap&&(t=e.alphaMap),e.aoMap&&(i=e.aoMap),e.bumpMap&&(n=e.bumpMap),e.diffuseMap&&(a=e.diffuseMap),e.displacementMap&&(s=e.displacementMap),e.emissiveMap&&(o=e.emissiveMap),e.environmentMap&&(r=e.environmentMap),e.lightMap&&(c=e.lightMap),e.metalnessMap&&(m=e.metalnessMap),e.normalMap&&(h=e.normalMap),e.roughnessMap&&(l=e.roughnessMap),e.specularMap&&(p=e.specularMap),new GameLib.D3.API.Material(e.id,e.materialType,e.name,e.opacity,e.side,e.transparent,GameLib.API.Color.FromObject(e.specular),e.lightMapIntensity,e.aoMapIntensity,GameLib.API.Color.FromObject(e.color),GameLib.API.Color.FromObject(e.emissive),e.emissiveIntensity,e.combine,e.shininess,e.reflectivity,e.refractionRatio,e.fog,e.wireframe,e.wireframeLineWidth,e.wireframeLineCap,e.wireframeLineJoin,e.vertexColors,e.skinning,e.morphTargets,e.morphNormals,e.lineWidth,e.lineCap,e.lineJoin,e.dashSize,e.gapWidth,e.blending,e.blendSrc,e.blendDst,e.blendEquation,e.depthTest,e.depthFunc,e.depthWrite,e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits,e.alphaTest,e.clippingPlanes,e.clipShadows,e.visible,e.overdraw,e.flatShading,e.bumpScale,e.normalScale,e.displacementScale,e.displacementBias,e.roughness,e.metalness,e.pointSize,e.pointSizeAttenuation,e.spriteRotation,e.envMapIntensity,t,i,n,a,s,o,r,c,m,h,l,p,e.parentEntity)},GameLib.D3.API.Mesh=function(e,t,i,n,a,s,o,r,c,m,h,l,p,u,b,d,L,G,f,E,y,I){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t=GameLib.D3.API.Mesh.MESH_TYPE_NORMAL),this.meshType=t,GameLib.Utils.UndefinedOrNull(i)&&(i="Mesh ("+e+")"),this.name=i,GameLib.Utils.UndefinedOrNull(n)&&(n=[]),this.vertices=n,GameLib.Utils.UndefinedOrNull(a)&&(a=[]),this.faces=a,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.parentMesh=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.parentScene=r,GameLib.Utils.UndefinedOrNull(c)&&(c=null),this.skeleton=c,GameLib.Utils.UndefinedOrNull(m)&&(m=[]),this.skinIndices=m,GameLib.Utils.UndefinedOrNull(h)&&(h=[]),this.skinWeights=h,(GameLib.Utils.UndefinedOrNull(s)||s instanceof Array&&0===s.length)&&(s=[new GameLib.D3.API.Material(null,GameLib.D3.Material.MATERIAL_TYPE_STANDARD,"Material ("+this.name+")")]),this.materials=s,GameLib.Utils.UndefinedOrNull(l)&&(l=new GameLib.API.Vector3(0,0,0)),this.position=l,GameLib.Utils.UndefinedOrNull(p)&&(p=new GameLib.API.Quaternion),this.quaternion=p,GameLib.Utils.UndefinedOrNull(u)&&(u=new GameLib.API.Vector3(0,0,0)),this.rotation=u,GameLib.Utils.UndefinedOrNull(b)&&(b=new GameLib.API.Vector3(1,1,1)),this.scale=b,GameLib.Utils.UndefinedOrNull(d)&&(d=new GameLib.API.Vector3(0,1,0)),this.up=d,GameLib.Utils.UndefinedOrNull(L)&&(L=new GameLib.API.Matrix4),this.modelMatrix=L,GameLib.Utils.UndefinedOrNull(G)&&(G=0),this.renderOrder=G,GameLib.Utils.UndefinedOrNull(f)&&(f=!1),this.isBufferMesh=f,GameLib.Utils.UndefinedOrNull(E)&&(E=!0),this.useQuaternion=E,GameLib.Utils.UndefinedOrNull(y)&&(y=!0),this.visible=y;var P=GameLib.Component.MESH;this.meshType===GameLib.D3.API.Mesh.MESH_TYPE_PLANE&&(P=GameLib.Component.MESH_PLANE),this.meshType===GameLib.D3.API.Mesh.MESH_TYPE_BOX&&(P=GameLib.Component.MESH_BOX),this.meshType===GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER&&(P=GameLib.Component.MESH_CYLINDER),this.meshType===GameLib.D3.API.Mesh.MESH_TYPE_SPHERE&&(P=GameLib.Component.MESH_SPHERE),this.meshType===GameLib.D3.API.Mesh.MESH_TYPE_LINE&&(P=GameLib.Component.MESH_LINE),this.meshType===GameLib.D3.API.Mesh.MESH_TYPE_TEXT&&(P=GameLib.Component.MESH_TEXT),GameLib.API.Component.call(this,P,I)},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 a=[];e.vertices&&(a=e.vertices.map(function(e){return GameLib.D3.API.Vertex.FromObject(e)}));var s=new GameLib.API.Vector3;e.position&&(s=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,a,t,n,e.parentMesh,e.parentScene,i,e.skinIndices,e.skinWeights,s,r,o,c,m,h,e.renderOrder,e.isBufferMesh,e.useQuaternion,e.visible,e.parentEntity)},GameLib.D3.API.ParticleEngine=function(e,t,i,n,a,s,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(a)&&(a=!1),this.enabled=a,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.templateParticle=s,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 a=null;return e.direction&&(a=GameLib.API.Vector3.FromObject(e.direction)),new GameLib.D3.API.ParticleEngine(e.id,e.name,n,a,e.enabled,t,e.particlesPerSecond,e.frequency,e.elapsed,i,e.pulse,e.parentEntity)},GameLib.D3.API.Particle=function(e,t,i,n,a,s,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(a)&&(a=null),this.mesh=a,GameLib.Utils.UndefinedOrNull(s)&&(s=GameLib.D3.Particle.OPACITY_TYPE_CONSTANT),this.opacityType=s,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.UndefinedOrNull(m)&&(m="//@ sourceURL=positionOffsetFn.js"),this.positionOffsetFn=m,GameLib.Utils.UndefinedOrNull(h)&&(h=GameLib.D3.Particle.DIRECTION_TYPE_CONSTANT),this.directionType=h,GameLib.Utils.UndefinedOrNull(l)&&(l=new GameLib.API.Vector3(0,1,0)),this.direction=l,GameLib.Utils.UndefinedOrNull(p)&&(p="//@ sourceURL=directionFn.js"),this.directionFn=p,GameLib.Utils.UndefinedOrNull(u)&&(u=GameLib.D3.Particle.SPEED_TYPE_CONSTANT),this.speedType=u,GameLib.Utils.UndefinedOrNull(b)&&(b=1),this.speed=b,GameLib.Utils.UndefinedOrNull(d)&&(d=GameLib.D3.Particle.SCALE_TYPE_CONSTANT),this.scaleType=d,GameLib.Utils.UndefinedOrNull(L)&&(L=new GameLib.API.Vector3(1,1,1)),this.scale=L,GameLib.Utils.UndefinedOrNull(G)&&(G="//@ sourceURL=scaleFn.js"),this.scaleFn=G,GameLib.Utils.UndefinedOrNull(f)&&(f=GameLib.D3.Particle.ROTATION_TYPE_CONSTANT),this.rotationType=f,GameLib.Utils.UndefinedOrNull(E)&&(E=new GameLib.API.Vector3(0,0,0)),this.rotation=E,GameLib.Utils.UndefinedOrNull(y)&&(y="//@ sourceURL=rotationFn.js"),this.rotationFn=y,GameLib.Utils.UndefinedOrNull(I)&&(I=null),this.parentEngine=I,GameLib.API.Component.call(this,GameLib.Component.PARTICLE,P)},GameLib.D3.API.Particle.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Particle.prototype.constructor=GameLib.D3.API.Particle,GameLib.D3.API.Particle.FromObject=function(e){var t=null;return e.mesh&&(t=e.mesh instanceof Object?GameLib.D3.API.Mesh.FromObject(e.mesh):e.mesh),new GameLib.D3.API.Particle(e.id,e.name,e.lifeTime,e.elapsed,t,e.opacityType,e.opacityFactor,e.positionOffsetType,GameLib.API.Vector3.FromObject(e.positionOffset),e.positionOffsetFn,e.directionType,GameLib.API.Vector3.FromObject(e.direction),e.directionFn,e.speedType,e.speed,e.scaleType,GameLib.API.Vector3.FromObject(e.scale),e.scaleFn,e.rotationType,GameLib.API.Vector3.FromObject(e.rotation),e.rotationFn,e.parentEngine,e.parentEntity)},GameLib.D3.API.Pass=function(e,t,i,n,a,s,o){if(GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Pass ("+e+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=GameLib.D3.Pass.PASS_TYPE_RENDER),this.passType=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.camera=n,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.scene=a,GameLib.Utils.UndefinedOrNull(s))if(this.passType===GameLib.D3.Pass.PASS_TYPE_RENDER)s=!1;else{if(!GameLib.D3.Pass.PASS_TYPE_COPY_SHADER)throw console.warn("Unsupported Render Pass Type : "+this.passType),new Error("Unsupported Render Pass Type : "+this.passType);s=!0}this.renderToScreen=s,GameLib.API.Component.call(this,GameLib.Component.PASS,o)},GameLib.D3.API.Pass.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Pass.prototype.constructor=GameLib.D3.API.Pass,GameLib.D3.API.Pass.FromObject=function(e){return new GameLib.D3.API.Pass(e.id,e.name,e.passType,e.camera,e.scene,e.renderToScreen,e.parentEntity)},GameLib.D3.API.PhysicsWorld=function(e,t,i,n,a,s,o,r,c,m){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Physics World ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=new GameLib.API.Vector3(0,-9.81,0)),this.gravity=i,GameLib.Utils.UndefinedOrNull(n)&&(n=new GameLib.D3.API.Broadphase(null,"Broadphase (Physics World "+this.id+")")),this.broadphase=n,GameLib.Utils.UndefinedOrNull(a)&&(a=new GameLib.D3.API.Solver(null,"Solver (Physics World "+this.id+")")),this.solver=a,GameLib.Utils.UndefinedOrNull(s)&&(s=[]),this.rigidBodies=s,GameLib.Utils.UndefinedOrNull(o)&&(o=[]),this.contactMaterials=o,GameLib.Utils.UndefinedOrNull(r)&&(r=!0),this.allowSleep=r,GameLib.Utils.UndefinedOrNull(c)&&(c=new GameLib.D3.API.FrictionContactMaterial(null,"Default Contact Material (Physics World "+this.id+")")),this.defaultContactMaterial=c,GameLib.API.Component.call(this,GameLib.Component.PHYSICS_WORLD,m)},GameLib.D3.API.PhysicsWorld.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.PhysicsWorld.prototype.constructor=GameLib.D3.API.PhysicsWorld,GameLib.D3.API.PhysicsWorld.FromObject=function(e){return new GameLib.D3.API.PhysicsWorld(e.id,e.name,GameLib.API.Vector3.FromObject(e.gravity),e.broadphase,e.solver,e.rigidBodies,e.contactMaterials,e.allowSleep,e.defaultContactMaterial,e.parentEntity)},GameLib.D3.API.RaycastVehicle=function(e,t,i,n,a,s,o){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="RaycastVehicle ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=null),this.chassis=i,GameLib.Utils.UndefinedOrNull(n)&&(n=[]),this.wheels=n,GameLib.Utils.UndefinedOrNull(a)&&(a=[]),this.raycastWheels=a,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.parentPhysicsWorld=s,GameLib.API.Component.call(this,GameLib.Component.RAYCAST_VEHICLE,o)},GameLib.D3.API.RaycastVehicle.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.RaycastVehicle.prototype.constructor=GameLib.D3.API.RaycastVehicle,GameLib.D3.API.RaycastVehicle.FromObject=function(e){return new GameLib.D3.API.RaycastVehicle(e.id,e.name,e.chassis,e.wheels,e.raycastWheels,e.parentPhysicsWorld,e.parentEntity)},GameLib.D3.API.RaycastWheel=function(e,t,i,n,a,s,o,r,c,m,h,l,p,u,b,d,L,G){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="RaycastWheel ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=.5),this.radius=i,GameLib.Utils.UndefinedOrNull(n)&&(n=new GameLib.API.Vector3(0,0,-1)),this.directionLocal=n,GameLib.Utils.UndefinedOrNull(a)&&(a=30),this.suspensionStiffness=a,GameLib.Utils.UndefinedOrNull(s)&&(s=.3),this.suspensionRestLength=s,GameLib.Utils.UndefinedOrNull(o)&&(o=5),this.frictionSlip=o,GameLib.Utils.UndefinedOrNull(r)&&(r=2.3),this.dampingRelaxation=r,GameLib.Utils.UndefinedOrNull(c)&&(c=4.4),this.dampingCompression=c,GameLib.Utils.UndefinedOrNull(m)&&(m=1e5),this.maxSuspensionForce=m,GameLib.Utils.UndefinedOrNull(h)&&(h=.01),this.rollInfluence=h,GameLib.Utils.UndefinedOrNull(l)&&(l=new GameLib.API.Vector3(0,1,0)),this.axleLocal=l,GameLib.Utils.UndefinedOrNull(p)&&(p=new GameLib.API.Vector3(1,1,0)),this.chassisConnectionPointLocal=p,GameLib.Utils.UndefinedOrNull(u)&&(u=.3),this.maxSuspensionTravel=u,GameLib.Utils.UndefinedOrNull(b)&&(b=-30),this.customSlidingRotationalSpeed=b,GameLib.Utils.UndefinedOrNull(d)&&(d=!0),this.useCustomSlidingRotationalSpeed=d,GameLib.Utils.UndefinedOrNull(L)&&(L=null),this.parentMesh=L,GameLib.API.Component.call(this,GameLib.Component.RAYCAST_WHEEL,G)},GameLib.D3.API.RaycastWheel.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.RaycastWheel.prototype.constructor=GameLib.D3.API.RaycastWheel,GameLib.D3.API.RaycastWheel.FromObject=function(e){return new GameLib.D3.API.RaycastWheel(e.id,e.name,e.radius,e.directionLocal,e.suspensionStiffness,e.suspensionRestLength,e.frictionSlip,e.dampingRelaxation,e.dampingCompression,e.maxSuspensionForce,e.rollInfluence,e.axleLocal,e.chassisConnectionPointLocal,e.maxSuspensionTravel,e.customSlidingRotationalSpeed,e.useCustomSlidingRotationalSpeed,e.parentMesh,e.parentEntity)},GameLib.D3.API.Raycaster=function(e,t,i,n,a){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Raycaster ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=new GameLib.API.Vector3),this.position=i,GameLib.Utils.UndefinedOrNull(n)&&(n=new GameLib.API.Vector3(0,-1,0)),this.direction=n,GameLib.API.Component.call(this,GameLib.Component.RAYCASTER,a)},GameLib.D3.API.Raycaster.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Raycaster.prototype.constructor=GameLib.D3.API.Raycaster,GameLib.D3.API.Raycaster.FromObject=function(e){return new GameLib.D3.API.Raycaster(e.id,e.name,GameLib.API.Vector3.FromObject(e.position),GameLib.API.Vector3.FromObject(e.direction),e.parentEntity)},GameLib.D3.API.RenderTarget=function(e,t,i,n,a,s,o){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Render Target ("+e+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=800),this.width=i,GameLib.Utils.UndefinedOrNull(n)&&(n=600),this.height=n,GameLib.Utils.UndefinedOrNull(a)&&(a=!1),this.stencilBuffer=a,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.texture=s,GameLib.API.Component.call(this,GameLib.Component.RENDER_TARGET,o)},GameLib.D3.API.RenderTarget.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.RenderTarget.prototype.constructor=GameLib.D3.API.RenderTarget,GameLib.D3.API.RenderTarget.FromObject=function(e){return new GameLib.D3.API.RenderTarget(e.id,e.name,e.width,e.height,e.stencilBuffer,e.texture,e.parentEntity)},GameLib.D3.API.Renderer=function(e,t,i,n,a,s,o,r,c,m,h,l,p,u,b,d,L,G,f){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Renderer ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=!0),this.autoClear=i,GameLib.Utils.UndefinedOrNull(n)&&(n=!1,p&&p.length>0&&(n=!0)),this.localClipping=n,GameLib.Utils.UndefinedOrNull(a)&&(a=800),this.width=a,GameLib.Utils.UndefinedOrNull(s)&&(s=600),this.height=s,GameLib.Utils.UndefinedOrNull(o)&&(o=!1),this.preserveDrawingBuffer=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.domElement=r,GameLib.Utils.UndefinedOrNull(c)&&(c=new GameLib.API.Color(.11,.11,.11)),this.clearColor=c,GameLib.Utils.UndefinedOrNull(m)&&(m=null),this.camera=m,GameLib.Utils.UndefinedOrNull(h)&&(h=[]),this.scenes=h,GameLib.Utils.UndefinedOrNull(l)&&(l=[]),this.viewports=l,GameLib.Utils.UndefinedOrNull(p)&&(p=[]),this.clippingPlanes=p,GameLib.Utils.UndefinedOrNull(u)&&(u=null),this.bufferScene=u,GameLib.Utils.UndefinedOrNull(b)&&(b=m),this.bufferCamera=b,GameLib.Utils.UndefinedOrNull(d)&&(d=null),this.renderTarget=d,GameLib.Utils.UndefinedOrNull(L)&&(L=null),this.defaultScene=L,GameLib.Utils.UndefinedOrNull(G)&&(G=!0),this.sortObjects=G,GameLib.API.Component.call(this,GameLib.Component.RENDERER,f)},GameLib.D3.API.Renderer.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Renderer.prototype.constructor=GameLib.D3.API.Renderer,GameLib.D3.API.Renderer.FromObject=function(e){return new GameLib.D3.API.Renderer(e.id,e.name,e.autoClear,e.localClipping,e.width,e.height,e.preserveDrawingBuffer,e.domElement,e.clearColor,e.camera,e.scenes,e.viewports,e.clippingPlanes,e.bufferScene,e.bufferCamera,e.renderTarget,e.defaultScene,e.sortObjects,e.parentEntity)},GameLib.D3.API.RigidBody=function(e,t,i,n,a,s,o,r,c,m,h,l,p,u,b,d,L,G,f,E,y){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="RigidBody ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=0),this.mass=i,GameLib.Utils.UndefinedOrNull(n)&&(n=5),this.friction=n,GameLib.Utils.UndefinedOrNull(a)&&(a=new GameLib.API.Vector3(0,0,0)),this.position=a,GameLib.Utils.UndefinedOrNull(s)&&(s=new GameLib.API.Quaternion),this.quaternion=s,GameLib.Utils.UndefinedOrNull(o)&&(o=new GameLib.API.Vector3),this.velocity=o,GameLib.Utils.UndefinedOrNull(r)&&(r=new GameLib.API.Vector3),this.angularVelocity=r,GameLib.Utils.UndefinedOrNull(c)&&(c=.01),this.linearDamping=c,GameLib.Utils.UndefinedOrNull(m)&&(m=.01),this.angularDamping=m,GameLib.Utils.UndefinedOrNull(h)&&(h=!0),this.allowSleep=h,GameLib.Utils.UndefinedOrNull(l)&&(l=.1),this.sleepSpeedLimit=l,GameLib.Utils.UndefinedOrNull(p)&&(p=1),this.sleepTimeLimit=p,GameLib.Utils.UndefinedOrNull(u)&&(u=1),this.collisionFilterGroup=u,GameLib.Utils.UndefinedOrNull(b)&&(b=1),this.collisionFilterMask=b,GameLib.Utils.UndefinedOrNull(d)&&(d=!1),this.fixedRotation=d,GameLib.Utils.UndefinedOrNull(L)&&(L=[]),this.shapes=L,GameLib.Utils.UndefinedOrNull(G)&&(G=!1),this.kinematic=G,GameLib.Utils.UndefinedOrNull(f)&&(f=null),this.parentMesh=f,GameLib.Utils.UndefinedOrNull(E)&&(E=null),this.parentPhysicsWorld=E,GameLib.API.Component.call(this,GameLib.Component.RIGID_BODY,y)},GameLib.D3.API.RigidBody.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.RigidBody.prototype.constructor=GameLib.D3.API.RigidBody,GameLib.D3.API.RigidBody.FromObject=function(e){return new GameLib.D3.API.RigidBody(e.id,e.name,e.mass,e.friction,e.position,e.quaternion,e.velocity,e.angularVelocity,e.linearDamping,e.angularDamping,e.allowSleep,e.sleepSpeedLimit,e.sleepTimeLimit,e.collisionFilterGroup,e.collisionFilterMask,e.fixedRotation,e.shapes,e.kinematic,e.parentMesh,e.parentPhysicsWorld,e.parentEntity)},GameLib.D3.API.Scene=function(e,t,i,n,a,s,o,r,c,m,h,l,p,u){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Scene ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=[]),this.meshes=i,GameLib.Utils.UndefinedOrNull(n)&&(n=[]),this.lights=n,GameLib.Utils.UndefinedOrNull(a)&&(a=[]),this.textures=a,GameLib.Utils.UndefinedOrNull(s)&&(s=[]),this.materials=s,GameLib.Utils.UndefinedOrNull(o)&&(o=[]),this.images=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.fog=r,GameLib.Utils.UndefinedOrNull(c)&&(c=null),this.renderCamera=c,GameLib.Utils.UndefinedOrNull(m)&&(m=!0),this.showGrid=m,GameLib.Utils.UndefinedOrNull(h)&&(h=!0),this.showAxis=h,GameLib.Utils.UndefinedOrNull(l)&&(l=10),this.gridSize=l,GameLib.Utils.UndefinedOrNull(p)&&(p=new GameLib.API.Color(.1,.1,.1)),this.gridColor=p,GameLib.API.Component.call(this,GameLib.Component.SCENE,u)},GameLib.D3.API.Scene.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Scene.prototype.constructor=GameLib.D3.API.Scene,GameLib.D3.API.Scene.FromObject=function(e){var t=[],i=[],n=[],a=[],s=[];return e.meshes&&(t=e.meshes.map(function(e){return e instanceof Object?GameLib.D3.API.Mesh.FromObject(e):e})),e.lights&&(i=e.lights.map(function(e){return e instanceof Object?GameLib.D3.API.Light.FromObject(e):e})),e.textures&&(n=e.textures.map(function(e){return e instanceof Object?GameLib.D3.API.Texture.FromObject(e):e})),e.materials&&(a=e.materials.map(function(e){return e instanceof Object?GameLib.D3.API.Material.FromObject(e):e})),e.images&&(s=e.images.map(function(e){return e instanceof Object?GameLib.API.Image.FromObject(e):e})),new GameLib.D3.API.Scene(e.id,e.name,t,i,n,a,s,e.fog,e.renderCamera,e.showGrid,e.showAxis,e.gridSize,GameLib.API.Color.FromObject(e.gridColor),e.parentEntity)},GameLib.D3.API.Shape=function(e,t,i,n,a,s,o,r){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(i)&&(i=GameLib.D3.API.Shape.SHAPE_TYPE_NONE),this.shapeType=i,GameLib.Utils.UndefinedOrNull(t)&&(t="Shape ("+this.id+")",this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_BOX&&(t="Shape Box ("+this.id+")"),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL&&(t="Shape Convex Hull ("+this.id+")"),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL_CYLINDER&&(t="Shape Convex Hull Cylinder ("+this.id+")"),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_HEIGHT_MAP&&(t="Shape HeightMap ("+this.id+")"),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_PLANE&&(t="Shape Plane ("+this.id+")"),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_SPHERE&&(t="Shape Sphere ("+this.id+")"),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_TRIMESH&&(t="Shape TriMesh ("+this.id+")")),this.name=t,GameLib.Utils.UndefinedOrNull(n)&&(n=0),this.boundingSphereRadius=n,GameLib.Utils.UndefinedOrNull(a)&&(a=!0),this.collisionResponse=a,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.frictionMaterial=s,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.parentMesh=o;var c=GameLib.Component.SHAPE;this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_BOX&&(c=GameLib.Component.SHAPE_BOX),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL&&(c=GameLib.Component.SHAPE_CONVEX_HULL),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL_CYLINDER&&(c=GameLib.Component.SHAPE_CONVEX_HULL_CYLINDER),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_HEIGHT_MAP&&(c=GameLib.Component.SHAPE_HEIGHT_MAP),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_PLANE&&(c=GameLib.Component.SHAPE_PLANE),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_SPHERE&&(c=GameLib.Component.SHAPE_SPHERE),this.shapeType===GameLib.D3.API.Shape.SHAPE_TYPE_TRIMESH&&(c=GameLib.Component.SHAPE_TRI_MESH),GameLib.API.Component.call(this,c,r)},GameLib.D3.API.Shape.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Shape.prototype.constructor=GameLib.D3.API.Shape,GameLib.D3.API.Shape.SHAPE_TYPE_NONE=0,GameLib.D3.API.Shape.SHAPE_TYPE_BOX=1,GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL=2,GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL_CYLINDER=3,GameLib.D3.API.Shape.SHAPE_TYPE_HEIGHT_MAP=4,GameLib.D3.API.Shape.SHAPE_TYPE_PLANE=5,GameLib.D3.API.Shape.SHAPE_TYPE_SPHERE=6,GameLib.D3.API.Shape.SHAPE_TYPE_TRIMESH=7,GameLib.D3.API.Shape.FromObject=function(e){return new GameLib.D3.API.Shape(e.id,e.name,e.shapeType,e.boundingSphereRadius,e.collisionResponse,e.frictionMaterial,e.parentMesh,e.parentEntity)},GameLib.D3.API.Skeleton=function(e,t,i,n,a,s,o,r,c,m){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Skeleton"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=[]),this.bones=i,GameLib.Utils.UndefinedOrNull(n)&&(n=[]),this.boneInverses=n,GameLib.Utils.UndefinedOrNull(a)&&(a=!1),this.useVertexTexture=a,a&&console.warn("support for vertex texture bones is not supported yet - something could break somewhere"),GameLib.Utils.UndefinedOrNull(s)&&(s=0),this.boneTextureWidth=s,GameLib.Utils.UndefinedOrNull(o)&&(o=0),this.boneTextureHeight=o,GameLib.Utils.UndefinedOrNull(r)&&(r=[]),this.boneMatrices=r,GameLib.Utils.UndefinedOrNull(c)&&(c=null),this.boneTexture=c,GameLib.API.Component.call(this,GameLib.Component.SKELETON,m)},GameLib.D3.API.Skeleton.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Skeleton.prototype.constructor=GameLib.D3.API.Skeleton,GameLib.D3.API.Skeleton.FromObject=function(e){return new GameLib.D3.API.Skeleton(e.id,e.name,e.bones.map(function(e){return GameLib.D3.API.Bone.FromObject(e)}),e.boneInverses.map(function(e){return GameLib.D3.API.Matrix4.FromObject(e)}),e.useVertexTexture,e.boneTextureWidth,e.boneTextureHeight,e.boneMatrices.map(function(e){return GameLib.D3.API.Matrix4.FromObject(e)}),e.boneTexture,e.parentEntity)},GameLib.D3.API.Solver=function(e,t,i,n,a,s){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Solver ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=GameLib.D3.API.Solver.GS_SOLVER),this.solverType=i,GameLib.Utils.UndefinedOrNull(n)&&(n=10),this.iterations=n,GameLib.Utils.UndefinedOrNull(a)&&(a=1e-7),this.tolerance=a,GameLib.API.Component.call(this,GameLib.Component.SOLVER,s)},GameLib.D3.API.Solver.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Solver.prototype.constructor=GameLib.D3.API.Solver,GameLib.D3.API.Solver.GS_SOLVER=1,GameLib.D3.API.Solver.SPLIT_SOLVER=2,GameLib.D3.API.Solver.FromObject=function(e){return new GameLib.D3.API.Solver(e.id,e.name,e.solverType,e.iterations,e.tolerance,e.parentEntity)},GameLib.D3.API.Spline=function(e,t,i,n){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Spline ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=[]),this.vertices=i,GameLib.API.Component.call(this,GameLib.Component.SPLINE,n)},GameLib.D3.API.Spline.prototype=Object.create(GameLib.Component.prototype);GameLib.D3.API.Spline.prototype.constructor=GameLib.D3.API.Spline,GameLib.D3.API.Spline.FromObject=function(e){return new GameLib.D3.API.Spline(e.id,e.name,e.vertices.map(function(e){return GameLib.API.Vector3.FromObject(e)}),e.parentEntity)},GameLib.D3.API.Texture=function(e,t,i,n,a,s,o,r,c,m,h,l,p,u,b,d,L,G,f,E,y,I,P,T,A,O,D){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t=GameLib.D3.API.Texture.TEXTURE_TYPE_NORMAL),this.textureType=t,GameLib.Utils.UndefinedOrNull(i)&&(i="Texture ("+e+")"),this.name=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.image=n,GameLib.Utils.UndefinedOrNull(a)&&(a=[]),this.images=a,GameLib.Utils.UndefinedOrNull(s)&&(s=GameLib.D3.API.Texture.TYPE_REPEAT_WRAPPING),this.wrapS=s,GameLib.Utils.UndefinedOrNull(o)&&(o=GameLib.D3.API.Texture.TYPE_REPEAT_WRAPPING),this.wrapT=o,GameLib.Utils.UndefinedOrNull(r)&&(r=new GameLib.API.Vector2(1,1)),this.repeat=r,GameLib.Utils.UndefinedOrNull(c)&&(c=null),this.data=c,GameLib.Utils.UndefinedOrNull(m)&&(m=GameLib.D3.API.Texture.TYPE_RGBA_FORMAT),this.format=m,GameLib.Utils.UndefinedOrNull(h)&&(h=GameLib.D3.API.Texture.TYPE_UV_MAPPING),this.mapping=h,GameLib.Utils.UndefinedOrNull(l)&&(l=GameLib.D3.API.Texture.TYPE_LINEAR_FILTER),this.magFilter=l,GameLib.Utils.UndefinedOrNull(p)&&(p=GameLib.D3.API.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER),this.minFilter=p,GameLib.Utils.UndefinedOrNull(u)&&(u=GameLib.D3.API.Texture.TYPE_UNSIGNED_BYTE),this.storageType=u,GameLib.Utils.UndefinedOrNull(b)&&(b=1),this.anisotropy=b,GameLib.Utils.UndefinedOrNull(d)&&(d=new GameLib.API.Vector2(0,0)),this.offset=d,GameLib.Utils.UndefinedOrNull(L)&&(L=!0),this.generateMipmaps=L,GameLib.Utils.UndefinedOrNull(G)&&(G=!0),this.flipY=G,GameLib.Utils.UndefinedOrNull(f)&&(f=[]),this.mipmaps=f,GameLib.Utils.UndefinedOrNull(E)&&(E=4),this.unpackAlignment=E,GameLib.Utils.UndefinedOrNull(y)&&(y=!1),this.premultiplyAlpha=y,GameLib.Utils.UndefinedOrNull(I)&&(I=GameLib.D3.API.Texture.TYPE_LINEAR_ENCODING),this.encoding=I,GameLib.Utils.UndefinedOrNull(P)&&(P=null),this.canvas=P,GameLib.Utils.UndefinedOrNull(T)&&(T=!1),this.animated=T,GameLib.Utils.UndefinedOrNull(A)&&(A=!1),this.reverseAnimation=A,GameLib.Utils.UndefinedOrNull(O)&&(O=!0),this.forward=O,this.needsUpdate=!1,GameLib.API.Component.call(this,GameLib.Component.TEXTURE,D)},GameLib.D3.API.Texture.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Texture.prototype.constructor=GameLib.D3.API.Texture,GameLib.D3.API.Texture.TYPE_ALPHA_FORMAT=1019,GameLib.D3.API.Texture.TYPE_RGB_FORMAT=1020,GameLib.D3.API.Texture.TYPE_RGBA_FORMAT=1021,GameLib.D3.API.Texture.TYPE_LUMINANCE_FORMAT=1022,GameLib.D3.API.Texture.TYPE_LUMINANCE_ALPHA_FORMAT=1023,GameLib.D3.API.Texture.TYPE_DEPTH_FORMAT=1026,GameLib.D3.API.Texture.TYPE_UV_MAPPING=300,GameLib.D3.API.Texture.TYPE_CUBE_REFLECTION_MAPPING=301,GameLib.D3.API.Texture.TYPE_CUBE_REFRACTION_MAPPING=302,GameLib.D3.API.Texture.TYPE_EQUI_RECTANGULAR_REFLECTION_MAPPING=303,GameLib.D3.API.Texture.TYPE_EQUI_RECTANGULAR_REFRACTION_MAPPING=304,GameLib.D3.API.Texture.TYPE_SPHERICAL_REFLECTION_MAPPING=305,GameLib.D3.API.Texture.TYPE_CUBE_UV_REFLECTION_MAPPING=306,GameLib.D3.API.Texture.TYPE_CUBE_UV_REFRACTION_MAPPING=307,GameLib.D3.API.Texture.TYPE_REPEAT_WRAPPING=1e3,GameLib.D3.API.Texture.TYPE_CLAMP_TO_EDGE_WRAPPING=1001,GameLib.D3.API.Texture.TYPE_MIRRORED_REPEAT_WRAPPING=1002,GameLib.D3.API.Texture.TYPE_NEAREST_FILTER=1003,GameLib.D3.API.Texture.TYPE_NEAREST_MIPMAP_NEAREST_FILTER=1004,GameLib.D3.API.Texture.TYPE_NEAREST_MIPMAP_LINEAR_FILTER=1005,GameLib.D3.API.Texture.TYPE_LINEAR_FILTER=1006,GameLib.D3.API.Texture.TYPE_LINEAR_MIPMAP_NEAREST_FILTER=1007,GameLib.D3.API.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER=1008,GameLib.D3.API.Texture.TYPE_UNSIGNED_BYTE=1009,GameLib.D3.API.Texture.TYPE_BYTE=1010,GameLib.D3.API.Texture.TYPE_SHORT=1011,GameLib.D3.API.Texture.TYPE_UNSIGNED_SHORT=1012,GameLib.D3.API.Texture.TYPE_INT=1013,GameLib.D3.API.Texture.TYPE_UNSIGNED_INT=1014,GameLib.D3.API.Texture.TYPE_FLOAT=1015,GameLib.D3.API.Texture.TYPE_HALF_FLOAT=1025,GameLib.D3.API.Texture.TYPE_LINEAR_ENCODING=3e3,GameLib.D3.API.Texture.TYPE_SRGB_ENCODING=3001,GameLib.D3.API.Texture.TYPE_GAMMA_ENCODING=3007,GameLib.D3.API.Texture.TYPE_RGBE_ENCODING=3002,GameLib.D3.API.Texture.TYPE_LOG_LUV_ENCODING=3003,GameLib.D3.API.Texture.TYPE_RGBM7_ENCODING=3004,GameLib.D3.API.Texture.TYPE_RGBM16_ENCODING=3005,GameLib.D3.API.Texture.TYPE_RGBD_ENCODING=3006,GameLib.D3.API.Texture.TEXTURE_TYPE_NORMAL=1,GameLib.D3.API.Texture.TEXTURE_TYPE_CUBE=2,GameLib.D3.API.Texture.TEXTURE_TYPE_CANVAS=3,GameLib.D3.API.Texture.FromObject=function(e){return new GameLib.D3.API.Texture(e.id,e.typeId||e.textureType,e.name,e.image,e.images,e.wrapS,e.wrapT,GameLib.API.Vector2.FromObject(e.repeat),e.data,e.format,e.mapping,e.magFilter,e.minFilter,e.storageType,e.anisotropy,GameLib.API.Vector2.FromObject(e.offset),e.generateMipmaps,e.flipY,e.mipmaps,e.unpackAlignment,e.premultiplyAlpha,e.encoding,e.canvas,e.animated,e.reverseAnimation,e.forward,e.parentEntity)},GameLib.D3.API.Vertex=function(e,t){GameLib.Utils.UndefinedOrNull(e)&&(e=new GameLib.API.Vector3),this.position=e,GameLib.Utils.UndefinedOrNull(t)&&(t=[]),this.boneWeights=t},GameLib.D3.API.Vertex.FromObject=function(e){return new GameLib.D3.API.Vertex(GameLib.API.Vector3.FromObject(e.position),e.boneWeights.map(function(e){return GameLib.D3.API.BoneWeight.FromObject(e)}))},GameLib.D3.API.Viewport=function(e,t,i,n,a,s,o){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Viewport ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=800),this.width=i,GameLib.Utils.UndefinedOrNull(n)&&(n=600),this.height=n,GameLib.Utils.UndefinedOrNull(a)&&(a=0),this.x=a,GameLib.Utils.UndefinedOrNull(s)&&(s=0),this.y=s,GameLib.API.Component.call(this,GameLib.Component.VIEWPORT,o)},GameLib.D3.API.Viewport.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Viewport.prototype.constructor=GameLib.D3.API.Viewport,GameLib.D3.API.Viewport.FromObject=function(e){return new GameLib.D3.API.Viewport(e.id,e.name,e.width,e.height,e.x,e.y,e.parentEntity)},GameLib.D3.Animation=function(e){if(GameLib.Utils.UndefinedOrNull(e)&&(e={}),e instanceof GameLib.D3.Animation)return e;GameLib.D3.API.Animation.call(this,e.id,e.name,e.rotationSpeed,e.translationSpeed,e.scaleSpeed,e.rotationFn,e.translationFn,e.scaleFn,e.blocking,e.applyToMeshWhenDone,e.meshes,e.parentEntity),this.functionType=GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_ROTATION,this.editor=null,this.inProcess=!1,GameLib.Component.call(this,{meshes:[GameLib.D3.Mesh]})},GameLib.D3.Animation.prototype=Object.create(GameLib.D3.API.Animation.prototype),GameLib.D3.Animation.prototype.constructor=GameLib.D3.Animation,GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_ROTATION=1,GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_TRANSLATION=2,GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_SCALE=3,GameLib.D3.Animation.prototype.createInstance=function(){this.instance={rotation:null,translation:null,scale:null};try{this.rotationFn&&(this.instance.rotation=new Function("data",this.rotationFn).bind(this)),this.translationFn&&(this.instance.translation=new Function("data",this.translationFn).bind(this)),this.scaleFn&&(this.instance.scale=new Function("data",this.scaleFn).bind(this))}catch(e){console.error(e),this.publish(GameLib.Event.ANIMATION_COMPILE_FAILED,{component:this})}GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Animation.prototype.updateInstance=function(){try{this.rotationFn&&(this.instance.rotation=new Function("data",this.rotationFn).bind(this),this.publish(GameLib.Event.ANIMATION_COMPILE_SUCCESS,{component:this,type:GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_ROTATION})),this.translationFn&&(this.instance.translation=new Function("data",this.translationFn).bind(this),this.publish(GameLib.Event.ANIMATION_COMPILE_SUCCESS,{component:this,type:GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_TRANSLATION})),this.scaleFn&&(this.instance.scale=new Function("data",this.scaleFn).bind(this),this.publish(GameLib.Event.ANIMATION_COMPILE_SUCCESS,{component:this,type:GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_SCALE}))}catch(e){console.error(e),this.publish(GameLib.Event.ANIMATION_COMPILE_FAILED,{component:this})}},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, diff --git a/build/game-lib.js b/build/game-lib.js index 5b41ab9..0fb3776 100644 --- a/build/game-lib.js +++ b/build/game-lib.js @@ -1,5 +1,5 @@ // COMPILE TIME DEFINITIONS (Generated via gulp) -var __DATE__ = "Tue Dec 05 2017 11:22:05 GMT+0100 (CET)"; +var __DATE__ = "Tue Dec 05 2017 11:25:55 GMT+0100 (CET)"; // END COMPILE TIME DEFINITIONS /**