From 011ae97d3e0b0427514f145a97afd63de438f845 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Wed, 29 Nov 2017 22:26:42 +0100 Subject: [PATCH] new float array --- build/game-lib-min.js | 4 ++-- build/game-lib.js | 8 ++++---- src/game-lib-d3-mesh-0.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build/game-lib-min.js b/build/game-lib-min.js index 4f35c43..53054e5 100644 --- a/build/game-lib-min.js +++ b/build/game-lib-min.js @@ -1,9 +1,9 @@ -function GameLib(){}var __DATE__="Wed Nov 29 2017 22:24:30 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_UPDATED=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_PHYSICS_IMPLEMENTATION=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.GET_GRAPHICS_IMPLEMENTATION=78,GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED=79,GameLib.Event.GET_CODER_IMPLEMENTATION=80,GameLib.Event.ANIMATION_MESH_ADDED=81,GameLib.Event.ANIMATION_MESH_REMOVED=82,GameLib.Event.GET_SCENE=83,GameLib.Event.CUSTOM_CODE_WINDOW_RESIZE=84,GameLib.Event.LOAD_FONT=85,GameLib.Event.FONT_NOT_FOUND=86,GameLib.Event.STOP_ALL_AUDIO=87,GameLib.Event.REGISTER_DEPENDENCIES=88,GameLib.Event.GAME_LOADED=89,GameLib.Event.LOAD_PROGRESS=91,GameLib.Event.ENTITY_LOADED=92,GameLib.Event.MOUSE_DOWN=93,GameLib.Event.MOUSE_MOVE=94,GameLib.Event.MOUSE_WHEEL=95,GameLib.Event.MOUSE_UP=96,GameLib.Event.PARTICLE_INSTANCE_UPDATED=97,GameLib.Event.GAME_DATA=98,GameLib.Event.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_physics_implementation";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"get_graphics_implementation";case 79:return"delayed_instance_encountered";case 80:return"get_coder_implementation";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 s=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),s++)})):(i&&i(),n&&n({message:"No subscriptions for event "+e})),s},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 s=1;sMath.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 s=i.pop();if(s.triangle.v0index===s.edge.x&&s.triangle.v1index===s.edge.y||s.triangle.v1index===s.edge.x&&s.triangle.v2index===s.edge.y||s.triangle.v2index===s.edge.x&&s.triangle.v0index===s.edge.y){var a=s.triangle.v1index;s.triangle.v1index=s.triangle.v2index,s.triangle.v2index=a;var o=s.triangle.uvs[0][1];s.triangle.uvs[0][1]=s.triangle.uvs[0][2],s.triangle.uvs[0][2]=o}n.push(s);for(var r=[new GameLib.API.Vector2(s.triangle.v0index,s.triangle.v1index),new GameLib.API.Vector2(s.triangle.v1index,s.triangle.v2index),new GameLib.API.Vector2(s.triangle.v2index,s.triangle.v0index)],h=0;h9||console.log("The vertices are not in the right length : "+e.length);for(var i=[],n=new GameLib.API.Quaternion.Points,s=0;se&&t.splice(0,1);var n=0;for(var s in t)n+=t[s];var a=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.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,i){GameLib.Utils.UndefinedOrNull(t)&&(t={}),this.linkedObjects=t,this.linkedObjects.parentEntity=GameLib.Entity,GameLib.API.Component.call(this,e,this.parentEntity),this.idToObject={},this.selected=!1,this.building=!1,this.loaded=!1,this.linked=!1,this.cloneNumber=0,this.isClone=!1,GameLib.Utils.UndefinedOrNull(i)&&(i=!1),this.delayed=i,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.COMPONENT_PATH_FOLLOWING=1,GameLib.Component.COMPONENT_MATERIAL=2,GameLib.Component.COMPONENT_RENDERER=3,GameLib.Component.COMPONENT_LOOK_AT=4,GameLib.Component.COMPONENT_CAMERA=5,GameLib.Component.COMPONENT_FOLLOW=6,GameLib.Component.COMPONENT_MESH=7,GameLib.Component.COMPONENT_SPLINE=8,GameLib.Component.COMPONENT_LIGHT=9,GameLib.Component.COMPONENT_INPUT_DRIVE=10,GameLib.Component.COMPONENT_COMPOSER=11,GameLib.Component.COMPONENT_RENDER_TARGET=12,GameLib.Component.COMPONENT_PASS=13,GameLib.Component.COMPONENT_SCENE=14,GameLib.Component.COMPONENT_RAYCASTER=15,GameLib.Component.COMPONENT_INPUT_EDITOR=16,GameLib.Component.COMPONENT_EDITOR=17,GameLib.Component.COMPONENT_VIEWPORT=18,GameLib.Component.COMPONENT_SYSTEM=19,GameLib.Component.COMPONENT_GRAPHICS=20,GameLib.Component.COMPONENT_HELPER=21,GameLib.Component.COMPONENT_CUSTOM_CODE=22,GameLib.Component.COMPONENT_MOUSE=23,GameLib.Component.COMPONENT_SKELETON=24,GameLib.Component.COMPONENT_TEXTURE=25,GameLib.Component.COMPONENT_ENTITY_MANAGER=26,GameLib.Component.COMPONENT_DOM_ELEMENT=27,GameLib.Component.COMPONENT_IMAGE_FACTORY=28,GameLib.Component.COMPONENT_STATS=29,GameLib.Component.COMPONENT_GUI=30,GameLib.Component.COMPONENT_IMAGE=31,GameLib.Component.COMPONENT_ENTITY=32,GameLib.Component.COMPONENT_MESH_SPHERE=33,GameLib.Component.COMPONENT_MESH_PLANE=34,GameLib.Component.COMPONENT_MESH_CURVE=35,GameLib.Component.COMPONENT_PHYSICS_WORLD=36,GameLib.Component.COMPONENT_BROADPHASE=37,GameLib.Component.COMPONENT_SOLVER=38,GameLib.Component.COMPONENT_RIGID_BODY=39,GameLib.Component.COMPONENT_SHAPE=40,GameLib.Component.COMPONENT_SHAPE_BOX=41,GameLib.Component.COMPONENT_SHAPE_SPHERE=42;GameLib.Component.COMPONENT_SHAPE_TRI_MESH=43,GameLib.Component.COMPONENT_SHAPE_CONVEX_HULL=44,GameLib.Component.COMPONENT_SHAPE_CONVEX_HULL_CYLINDER=45,GameLib.Component.COMPONENT_SHAPE_HEIGHT_MAP=46,GameLib.Component.COMPONENT_SHAPE_PLANE=47,GameLib.Component.COMPONENT_CONTROLS=48,GameLib.Component.COMPONENT_CONTROLS_EDITOR=49,GameLib.Component.COMPONENT_CONTROLS_TOUCH=50,GameLib.Component.COMPONENT_FRICTION_MATERIAL=51,GameLib.Component.COMPONENT_FRICTION_CONTACT_MATERIAL=52,GameLib.Component.COMPONENT_RAYCAST_VEHICLE=53,GameLib.Component.COMPONENT_RAYCAST_WHEEL=54,GameLib.Component.COMPONENT_CLOCK=55,GameLib.Component.COMPONENT_ANIMATION=56,GameLib.Component.COMPONENT_CONTROLS_KEYBOARD=57,GameLib.Component.COMPONENT_CONTROLS_MOUSE=58,GameLib.Component.COMPONENT_MESH_TEXT=59,GameLib.Component.COMPONENT_FONT=60,GameLib.Component.COMPONENT_CANVAS=61,GameLib.Component.COMPONENT_BONE=62,GameLib.Component.COMPONENT_MESH_BOX=63,GameLib.Component.COMPONENT_MESH_CYLINDER=64,GameLib.Component.COMPONENT_SYSTEM_ANIMATION=65,GameLib.Component.COMPONENT_SYSTEM_CUSTOM_CODE=66,GameLib.Component.COMPONENT_SYSTEM_GUI=67,GameLib.Component.COMPONENT_SYSTEM_INPUT=68,GameLib.Component.COMPONENT_SYSTEM_LINKING=69,GameLib.Component.COMPONENT_SYSTEM_PHYSICS=70,GameLib.Component.COMPONENT_SYSTEM_RENDER=71,GameLib.Component.COMPONENT_SYSTEM_STORAGE=72,GameLib.Component.COMPONENT_SYSTEM_VISUALIZATION=73,GameLib.Component.COMPONENT_FOG=80,GameLib.Component.COMPONENT_MESH_LINE=81,GameLib.Component.COMPONENT_PARTICLE_ENGINE=82,GameLib.Component.COMPONENT_SYSTEM_PARTICLE=83,GameLib.Component.COMPONENT_PARTICLE=84,GameLib.Component.COMPONENT_AUDIO=85,GameLib.Component.COMPONENT_SYSTEM_AUDIO=86,GameLib.Component.GetComponentName=function(e){switch(e){case 1:return"GameLib.D3.PathFollowing";case 2:return"GameLib.D3.Material";case 3:return"GameLib.D3.Renderer";case 4:return"GameLib.D3.LookAt";case 5:return"GameLib.D3.Camera";case 6:return"GameLib.D3.Follow";case 7:return"GameLib.D3.Mesh";case 8:return"GameLib.D3.Spline";case 9:return"GameLib.D3.Light";case 10:return"GameLib.D3.InputDrive";case 11:return"GameLib.D3.Composer";case 12:return"GameLib.D3.RenderTarget";case 13:return"GameLib.D3.Pass";case 14:return"GameLib.D3.Scene";case 15:return"GameLib.D3.Raycaster";case 16:return"GameLib.D3.InputEditor";case 17:return"GameLib.D3.Editor";case 18:return"GameLib.D3.Viewport";case 19:return"GameLib.System";case 20:return"GameLib.D3.Graphics";case 21:return"GameLib.D3.Helper";case 22:return"GameLib.D3.CustomCode";case 23:return"GameLib.Mouse";case 24:return"GameLib.D3.Skeleton";case 25:return"GameLib.D3.Texture";case 26:return"GameLib.EntityManager";case 27:return"GameLib.DomElement";case 28:return"GameLib.D3.ImageFactory";case 29:return"GameLib.D3.Stats";case 30:return"GameLib.GUI";case 31:return"GameLib.D3.Image";case 32:return"GameLib.Entity";case 33:return"GameLib.D3.Mesh.Sphere";case 34:return"GameLib.D3.Mesh.Plane";case 35:return"GameLib.D3.Mesh.Curve";case 36:return"GameLib.D3.PhysicsWorld";case 37:return"GameLib.D3.Broadphase";case 38:return"GameLib.D3.Solver";case 39:return"GameLib.D3.RigidBody";case 40:return"GameLib.D3.Shape";case 41:return"GameLib.D3.Shape.Box";case 42:return"GameLib.D3.Shape.Sphere";case 43:return"GameLib.D3.Shape.TriMesh";case 44:return"GameLib.D3.Shape.ConvexHull";case 45:return"GameLib.D3.Shape.ConvexHull.Cylinder";case 46:return"GameLib.D3.Shape.HeightMap";case 47:return"GameLib.D3.Shape.Plane";case 48:return"GameLib.D3.Controls";case 49:return"GameLib.D3.Controls.Editor";case 50:return"GameLib.D3.Controls.Touch";case 51:return"GameLib.D3.FrictionMaterial";case 52:return"GameLib.D3.FrictionContactMaterial";case 53:return"GameLib.D3.RaycastVehicle";case 54:return"GameLib.D3.RaycastWheel";case 55:return"GameLib.Clock";case 56:return"GameLib.D3.Animation";case 57:return"GameLib.D3.Controls.Keyboard";case 58:return"GameLib.D3.Controls.Mouse";case 59:return"GameLib.D3.Mesh.Text";case 60:return"GameLib.D3.Font";case 61:return"GameLib.D3.Canvas";case 62:return"GameLib.D3.Bone";case 63:return"GameLib.D3.Mesh.Box";case 64:return"GameLib.D3.Mesh.Cylinder";case 65:return"GameLib.D3.System.Animation";case 66:return"GameLib.D3.System.CustomCode";case 67:return"GameLib.D3.System.GUI";case 68:return"GameLib.D3.System.Input";case 69:return"GameLib.D3.System.Linking";case 70:return"GameLib.D3.System.Physics";case 71:return"GameLib.D3.System.Render";case 72:return"GameLib.D3.System.Storage";case 73:return"GameLib.D3.System.Visualization";case 80:return"GameLib.D3.Fog";case 81:return"GameLib.D3.Mesh.Line";case 82:return"GameLib.D3.ParticleEngine";case 83:return"GameLib.D3.System.Particle";case 84:return"GameLib.D3.Particle";case 85:return"GameLib.D3.Audio";case 86:return"GameLib.D3.System.Audio"}throw new Error("Unknown component type: "+e)},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.D3.CustomCode);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=null;try{t=new this.constructor(this.graphics,e)}catch(i){console.log(i);try{t=new this.constructor(this.physics,e)}catch(i){console.log(i);try{t=new this.constructor(this.coder,e)}catch(e){return console.log(e),void console.log("failed to construct a runtime component")}}}return t.isClone=!0,GameLib.Event.Emit(GameLib.Event.COMPONENT_CLONED,{parent:this,component:t}),t.parentEntity=null,t},GameLib.Component.prototype.cloneInstance=function(){var e=null;return this.instance&&this.instance.clone&&(this.instance.clone,!0)&&(e=this.instance.clone(),GameLib.Event.Emit(GameLib.Event.INSTANCE_CLONED,{component:this,instance:e})),e},GameLib.Component.prototype.saveToRemoteAPI=function(){this.save(!0)},GameLib.Component.prototype.save=function(e){var t=[],i=[],n=[];if(this.buildIdToObject(),this.saveSubscription||this.saveErrorSubscription)return void console.warn("another save is in progress");GameLib.Event.Emit(GameLib.Event.SAVING,{component:this}),this.saveSubscription=GameLib.Event.Subscribe(GameLib.Event.COMPONENT_SAVED,function(e){i.push(e.component),n.length+i.length===t.length&&(this.saveSubscription.remove(),this.saveSubscription=null,this.saveErrorSubscription.remove(),this.saveErrorSubscription=null,GameLib.Event.Emit(GameLib.Event.DONE_SAVING,{failed:n,saved:i}))}.bind(this)),this.saveErrorSubscription=GameLib.Event.Subscribe(GameLib.Event.SAVE_COMPONENT_ERROR,function(e){n.push(e.component),n.length+i.length===t.length&&(this.saveSubscription.remove(),this.saveSubscription=null,this.saveErrorSubscription.remove(),this.saveErrorSubscription=null,GameLib.Event.Emit(GameLib.Event.DONE_SAVING,{failed:n,saved:i}))}.bind(this));for(var s in this.idToObject)if(this.idToObject.hasOwnProperty(s)&&this.idToObject[s]instanceof GameLib.Component){var a=this.idToObject[s].toApiObject();a.componentType=this.idToObject[s].componentType,t.push(a),this.publish(GameLib.Event.SAVE_COMPONENT,{apiObject:a,remote:e})}},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.Utils.UndefinedOrNull(i)&&(i=null),this.parentEntity=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.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.Utils.UndefinedOrNull(n)&&(n=null),this.parentEntity=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,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(s)&&(s=null),this.defaultRenderer=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)},GameLib.API.Entity=function(e,t,i,n,s){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.Utils.UndefinedOrNull(n)&&(n=null),this.parentEntity=n,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.parentEntityManager=s,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.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), +function GameLib(){}var __DATE__="Wed Nov 29 2017 22:26:34 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_UPDATED=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_PHYSICS_IMPLEMENTATION=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.GET_GRAPHICS_IMPLEMENTATION=78,GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED=79,GameLib.Event.GET_CODER_IMPLEMENTATION=80,GameLib.Event.ANIMATION_MESH_ADDED=81,GameLib.Event.ANIMATION_MESH_REMOVED=82,GameLib.Event.GET_SCENE=83,GameLib.Event.CUSTOM_CODE_WINDOW_RESIZE=84,GameLib.Event.LOAD_FONT=85,GameLib.Event.FONT_NOT_FOUND=86,GameLib.Event.STOP_ALL_AUDIO=87,GameLib.Event.REGISTER_DEPENDENCIES=88,GameLib.Event.GAME_LOADED=89,GameLib.Event.LOAD_PROGRESS=91,GameLib.Event.ENTITY_LOADED=92,GameLib.Event.MOUSE_DOWN=93,GameLib.Event.MOUSE_MOVE=94,GameLib.Event.MOUSE_WHEEL=95,GameLib.Event.MOUSE_UP=96,GameLib.Event.PARTICLE_INSTANCE_UPDATED=97,GameLib.Event.GAME_DATA=98,GameLib.Event.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_physics_implementation";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"get_graphics_implementation";case 79:return"delayed_instance_encountered";case 80:return"get_coder_implementation";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 s=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),s++)})):(i&&i(),n&&n({message:"No subscriptions for event "+e})),s},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 s=1;sMath.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 s=i.pop();if(s.triangle.v0index===s.edge.x&&s.triangle.v1index===s.edge.y||s.triangle.v1index===s.edge.x&&s.triangle.v2index===s.edge.y||s.triangle.v2index===s.edge.x&&s.triangle.v0index===s.edge.y){var a=s.triangle.v1index;s.triangle.v1index=s.triangle.v2index,s.triangle.v2index=a;var o=s.triangle.uvs[0][1];s.triangle.uvs[0][1]=s.triangle.uvs[0][2],s.triangle.uvs[0][2]=o}n.push(s);for(var r=[new GameLib.API.Vector2(s.triangle.v0index,s.triangle.v1index),new GameLib.API.Vector2(s.triangle.v1index,s.triangle.v2index),new GameLib.API.Vector2(s.triangle.v2index,s.triangle.v0index)],h=0;h9||console.log("The vertices are not in the right length : "+e.length);for(var i=[],n=new GameLib.API.Quaternion.Points,s=0;se&&t.splice(0,1);var n=0;for(var s in t)n+=t[s];var a=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.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,i){GameLib.Utils.UndefinedOrNull(t)&&(t={}),this.linkedObjects=t,this.linkedObjects.parentEntity=GameLib.Entity,GameLib.API.Component.call(this,e,this.parentEntity),this.idToObject={},this.selected=!1,this.building=!1,this.loaded=!1,this.linked=!1,this.cloneNumber=0,this.isClone=!1,GameLib.Utils.UndefinedOrNull(i)&&(i=!1),this.delayed=i,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.COMPONENT_PATH_FOLLOWING=1,GameLib.Component.COMPONENT_MATERIAL=2,GameLib.Component.COMPONENT_RENDERER=3,GameLib.Component.COMPONENT_LOOK_AT=4,GameLib.Component.COMPONENT_CAMERA=5,GameLib.Component.COMPONENT_FOLLOW=6,GameLib.Component.COMPONENT_MESH=7,GameLib.Component.COMPONENT_SPLINE=8,GameLib.Component.COMPONENT_LIGHT=9,GameLib.Component.COMPONENT_INPUT_DRIVE=10,GameLib.Component.COMPONENT_COMPOSER=11,GameLib.Component.COMPONENT_RENDER_TARGET=12,GameLib.Component.COMPONENT_PASS=13,GameLib.Component.COMPONENT_SCENE=14,GameLib.Component.COMPONENT_RAYCASTER=15,GameLib.Component.COMPONENT_INPUT_EDITOR=16,GameLib.Component.COMPONENT_EDITOR=17,GameLib.Component.COMPONENT_VIEWPORT=18,GameLib.Component.COMPONENT_SYSTEM=19,GameLib.Component.COMPONENT_GRAPHICS=20,GameLib.Component.COMPONENT_HELPER=21,GameLib.Component.COMPONENT_CUSTOM_CODE=22,GameLib.Component.COMPONENT_MOUSE=23,GameLib.Component.COMPONENT_SKELETON=24,GameLib.Component.COMPONENT_TEXTURE=25,GameLib.Component.COMPONENT_ENTITY_MANAGER=26,GameLib.Component.COMPONENT_DOM_ELEMENT=27,GameLib.Component.COMPONENT_IMAGE_FACTORY=28,GameLib.Component.COMPONENT_STATS=29,GameLib.Component.COMPONENT_GUI=30,GameLib.Component.COMPONENT_IMAGE=31,GameLib.Component.COMPONENT_ENTITY=32,GameLib.Component.COMPONENT_MESH_SPHERE=33,GameLib.Component.COMPONENT_MESH_PLANE=34,GameLib.Component.COMPONENT_MESH_CURVE=35,GameLib.Component.COMPONENT_PHYSICS_WORLD=36,GameLib.Component.COMPONENT_BROADPHASE=37,GameLib.Component.COMPONENT_SOLVER=38,GameLib.Component.COMPONENT_RIGID_BODY=39,GameLib.Component.COMPONENT_SHAPE=40,GameLib.Component.COMPONENT_SHAPE_BOX=41,GameLib.Component.COMPONENT_SHAPE_SPHERE=42;GameLib.Component.COMPONENT_SHAPE_TRI_MESH=43,GameLib.Component.COMPONENT_SHAPE_CONVEX_HULL=44,GameLib.Component.COMPONENT_SHAPE_CONVEX_HULL_CYLINDER=45,GameLib.Component.COMPONENT_SHAPE_HEIGHT_MAP=46,GameLib.Component.COMPONENT_SHAPE_PLANE=47,GameLib.Component.COMPONENT_CONTROLS=48,GameLib.Component.COMPONENT_CONTROLS_EDITOR=49,GameLib.Component.COMPONENT_CONTROLS_TOUCH=50,GameLib.Component.COMPONENT_FRICTION_MATERIAL=51,GameLib.Component.COMPONENT_FRICTION_CONTACT_MATERIAL=52,GameLib.Component.COMPONENT_RAYCAST_VEHICLE=53,GameLib.Component.COMPONENT_RAYCAST_WHEEL=54,GameLib.Component.COMPONENT_CLOCK=55,GameLib.Component.COMPONENT_ANIMATION=56,GameLib.Component.COMPONENT_CONTROLS_KEYBOARD=57,GameLib.Component.COMPONENT_CONTROLS_MOUSE=58,GameLib.Component.COMPONENT_MESH_TEXT=59,GameLib.Component.COMPONENT_FONT=60,GameLib.Component.COMPONENT_CANVAS=61,GameLib.Component.COMPONENT_BONE=62,GameLib.Component.COMPONENT_MESH_BOX=63,GameLib.Component.COMPONENT_MESH_CYLINDER=64,GameLib.Component.COMPONENT_SYSTEM_ANIMATION=65,GameLib.Component.COMPONENT_SYSTEM_CUSTOM_CODE=66,GameLib.Component.COMPONENT_SYSTEM_GUI=67,GameLib.Component.COMPONENT_SYSTEM_INPUT=68,GameLib.Component.COMPONENT_SYSTEM_LINKING=69,GameLib.Component.COMPONENT_SYSTEM_PHYSICS=70,GameLib.Component.COMPONENT_SYSTEM_RENDER=71,GameLib.Component.COMPONENT_SYSTEM_STORAGE=72,GameLib.Component.COMPONENT_SYSTEM_VISUALIZATION=73,GameLib.Component.COMPONENT_FOG=80,GameLib.Component.COMPONENT_MESH_LINE=81,GameLib.Component.COMPONENT_PARTICLE_ENGINE=82,GameLib.Component.COMPONENT_SYSTEM_PARTICLE=83,GameLib.Component.COMPONENT_PARTICLE=84,GameLib.Component.COMPONENT_AUDIO=85,GameLib.Component.COMPONENT_SYSTEM_AUDIO=86,GameLib.Component.GetComponentName=function(e){switch(e){case 1:return"GameLib.D3.PathFollowing";case 2:return"GameLib.D3.Material";case 3:return"GameLib.D3.Renderer";case 4:return"GameLib.D3.LookAt";case 5:return"GameLib.D3.Camera";case 6:return"GameLib.D3.Follow";case 7:return"GameLib.D3.Mesh";case 8:return"GameLib.D3.Spline";case 9:return"GameLib.D3.Light";case 10:return"GameLib.D3.InputDrive";case 11:return"GameLib.D3.Composer";case 12:return"GameLib.D3.RenderTarget";case 13:return"GameLib.D3.Pass";case 14:return"GameLib.D3.Scene";case 15:return"GameLib.D3.Raycaster";case 16:return"GameLib.D3.InputEditor";case 17:return"GameLib.D3.Editor";case 18:return"GameLib.D3.Viewport";case 19:return"GameLib.System";case 20:return"GameLib.D3.Graphics";case 21:return"GameLib.D3.Helper";case 22:return"GameLib.D3.CustomCode";case 23:return"GameLib.Mouse";case 24:return"GameLib.D3.Skeleton";case 25:return"GameLib.D3.Texture";case 26:return"GameLib.EntityManager";case 27:return"GameLib.DomElement";case 28:return"GameLib.D3.ImageFactory";case 29:return"GameLib.D3.Stats";case 30:return"GameLib.GUI";case 31:return"GameLib.D3.Image";case 32:return"GameLib.Entity";case 33:return"GameLib.D3.Mesh.Sphere";case 34:return"GameLib.D3.Mesh.Plane";case 35:return"GameLib.D3.Mesh.Curve";case 36:return"GameLib.D3.PhysicsWorld";case 37:return"GameLib.D3.Broadphase";case 38:return"GameLib.D3.Solver";case 39:return"GameLib.D3.RigidBody";case 40:return"GameLib.D3.Shape";case 41:return"GameLib.D3.Shape.Box";case 42:return"GameLib.D3.Shape.Sphere";case 43:return"GameLib.D3.Shape.TriMesh";case 44:return"GameLib.D3.Shape.ConvexHull";case 45:return"GameLib.D3.Shape.ConvexHull.Cylinder";case 46:return"GameLib.D3.Shape.HeightMap";case 47:return"GameLib.D3.Shape.Plane";case 48:return"GameLib.D3.Controls";case 49:return"GameLib.D3.Controls.Editor";case 50:return"GameLib.D3.Controls.Touch";case 51:return"GameLib.D3.FrictionMaterial";case 52:return"GameLib.D3.FrictionContactMaterial";case 53:return"GameLib.D3.RaycastVehicle";case 54:return"GameLib.D3.RaycastWheel";case 55:return"GameLib.Clock";case 56:return"GameLib.D3.Animation";case 57:return"GameLib.D3.Controls.Keyboard";case 58:return"GameLib.D3.Controls.Mouse";case 59:return"GameLib.D3.Mesh.Text";case 60:return"GameLib.D3.Font";case 61:return"GameLib.D3.Canvas";case 62:return"GameLib.D3.Bone";case 63:return"GameLib.D3.Mesh.Box";case 64:return"GameLib.D3.Mesh.Cylinder";case 65:return"GameLib.D3.System.Animation";case 66:return"GameLib.D3.System.CustomCode";case 67:return"GameLib.D3.System.GUI";case 68:return"GameLib.D3.System.Input";case 69:return"GameLib.D3.System.Linking";case 70:return"GameLib.D3.System.Physics";case 71:return"GameLib.D3.System.Render";case 72:return"GameLib.D3.System.Storage";case 73:return"GameLib.D3.System.Visualization";case 80:return"GameLib.D3.Fog";case 81:return"GameLib.D3.Mesh.Line";case 82:return"GameLib.D3.ParticleEngine";case 83:return"GameLib.D3.System.Particle";case 84:return"GameLib.D3.Particle";case 85:return"GameLib.D3.Audio";case 86:return"GameLib.D3.System.Audio"}throw new Error("Unknown component type: "+e)},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.D3.CustomCode);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=null;try{t=new this.constructor(this.graphics,e)}catch(i){console.log(i);try{t=new this.constructor(this.physics,e)}catch(i){console.log(i);try{t=new this.constructor(this.coder,e)}catch(e){return console.log(e),void console.log("failed to construct a runtime component")}}}return t.isClone=!0,GameLib.Event.Emit(GameLib.Event.COMPONENT_CLONED,{parent:this,component:t}),t.parentEntity=null,t},GameLib.Component.prototype.cloneInstance=function(){var e=null;return this.instance&&this.instance.clone&&(this.instance.clone,!0)&&(e=this.instance.clone(),GameLib.Event.Emit(GameLib.Event.INSTANCE_CLONED,{component:this,instance:e})),e},GameLib.Component.prototype.saveToRemoteAPI=function(){this.save(!0)},GameLib.Component.prototype.save=function(e){var t=[],i=[],n=[];if(this.buildIdToObject(),this.saveSubscription||this.saveErrorSubscription)return void console.warn("another save is in progress");GameLib.Event.Emit(GameLib.Event.SAVING,{component:this}),this.saveSubscription=GameLib.Event.Subscribe(GameLib.Event.COMPONENT_SAVED,function(e){i.push(e.component),n.length+i.length===t.length&&(this.saveSubscription.remove(),this.saveSubscription=null,this.saveErrorSubscription.remove(),this.saveErrorSubscription=null,GameLib.Event.Emit(GameLib.Event.DONE_SAVING,{failed:n,saved:i}))}.bind(this)),this.saveErrorSubscription=GameLib.Event.Subscribe(GameLib.Event.SAVE_COMPONENT_ERROR,function(e){n.push(e.component),n.length+i.length===t.length&&(this.saveSubscription.remove(),this.saveSubscription=null,this.saveErrorSubscription.remove(),this.saveErrorSubscription=null,GameLib.Event.Emit(GameLib.Event.DONE_SAVING,{failed:n,saved:i}))}.bind(this));for(var s in this.idToObject)if(this.idToObject.hasOwnProperty(s)&&this.idToObject[s]instanceof GameLib.Component){var a=this.idToObject[s].toApiObject();a.componentType=this.idToObject[s].componentType,t.push(a),this.publish(GameLib.Event.SAVE_COMPONENT,{apiObject:a,remote:e})}},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.Utils.UndefinedOrNull(i)&&(i=null),this.parentEntity=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.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.Utils.UndefinedOrNull(n)&&(n=null),this.parentEntity=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,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(s)&&(s=null),this.defaultRenderer=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)},GameLib.API.Entity=function(e,t,i,n,s){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.Utils.UndefinedOrNull(n)&&(n=null),this.parentEntity=n,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.parentEntityManager=s,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.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,s){GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.parentEntity=s,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.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,s,a){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(s)&&(s=new GameLib.API.Vector3),this.axis=s,GameLib.Utils.UndefinedOrNull(a)&&(a=0),this.angle=a},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,s,a=e,o=this;if(e instanceof GameLib.API.Matrix4)return t=a.rows[0].x*o.x+a.rows[0].y*o.y+a.rows[0].z*o.z+a.rows[0].w*o.w,i=a.rows[1].x*o.x+a.rows[1].y*o.y+a.rows[1].z*o.z+a.rows[1].w*o.w,n=a.rows[2].x*o.x+a.rows[2].y*o.y+a.rows[2].z*o.z+a.rows[2].w*o.w,s=a.rows[3].x*o.x+a.rows[3].y*o.y+a.rows[3].z*o.z+a.rows[3].w*o.w,this.x=t,this.y=i,this.z=n,this.w=s,this;if(e instanceof GameLib.API.Quaternion)return t=a.x*o.x-a.y*o.y-a.z*o.z-a.w*a.w,i=a.x*o.y+a.y*o.x-a.z*o.w+a.w*a.z,n=a.x*o.z+a.y*o.w+a.z*o.x-a.w*a.y,s=a.x*o.w-a.y*o.z+a.z*o.y+a.w*a.x,this.x=t,this.y=i,this.z=n,this.w=s,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;ta&&(a=h.x,n=t*e)}this.vectors=s;for(var c=(new GameLib.API.Matrix4).rotationMatrixY(n),m=0;ma&&(a=h.y,n=t*e)}this.vectors=s;for(var c=(new GameLib.API.Matrix4).rotationMatrixX(n),m=0;mn&&(n=this.vectors[o].x),this.vectors[o].y>s&&(s=this.vectors[o].y),this.vectors[o].z>a&&(a=this.vectors[o].z);return new GameLib.API.Vector3(Math.abs(n-e),Math.abs(s-t),Math.abs(s-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(),s=i.copy();return n.subtract(e).cross(s.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),s=n.dot(i);return s>0?1:s<0?-1:0},GameLib.API.Vector3.prototype.multiply=function(e,t){var i,n,s,a=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=a.y*o.z-a.z*o.y,n=a.z*o.x-a.x*o.z,s=a.x*o.y-a.y*o.x,this.x=i,this.y=n,this.z=s,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,s=e.x,a=e.y,o=e.z,r=e.w,h=r*t+a*n-o*i,c=r*i+o*t-s*n,m=r*n+s*i-a*t,l=-s*t-a*i-o*n;return this.x=h*r+l*-s+c*-o-m*-a,this.y=c*r+l*-a+m*-s-h*-o,this.z=m*r+l*-o+h*-a-c*-s,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.Clock=function(e,t){if(this.implementation=e,this.implementation.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.Component.COMPONENT_CLOCK)},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.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.D3.API.Animation=function(e,t,i,n,s,a,o,r,h,c,m,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(s)&&(s=0),this.scaleSpeed=s,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.rotationFn=a,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.translationFn=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.scaleFn=r,GameLib.Utils.UndefinedOrNull(h)&&(h={position:!1,rotation:!0,scale:!1}),this.blocking=h,GameLib.Utils.UndefinedOrNull(c)&&(c=!0),this.applyToMeshWhenDone=c,GameLib.Utils.UndefinedOrNull(m)&&(m=[]),this.meshes=m,GameLib.Utils.UndefinedOrNull(l)&&(l=null),this.parentEntity=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,s,a,o,r,h){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(s)&&(s=.5),this.volume=s,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.camera=a,GameLib.Utils.UndefinedOrNull(o)&&(o=!1),this.overplay=o,GameLib.Utils.UndefinedOrNull(r)&&(r=!1),this.paused=r,GameLib.Utils.UndefinedOrNull(h)&&(h=null),this.parentEntity=h},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,s,a,o,r){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(s)&&(s=new GameLib.API.Vector3),this.position=s,GameLib.Utils.UndefinedOrNull(a)&&(a=new GameLib.API.Quaternion),this.quaternion=a,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.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))},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.Utils.UndefinedOrNull(n)&&(n=null),this.parentEntity=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,s,a,o,r,h,c,m,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(s)&&(s=window.innerWidth/window.innerHeight),this.aspect=s,GameLib.Utils.UndefinedOrNull(a)&&(a=.01),this.near=a,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(h)&&(h=new GameLib.API.Vector3(0,0,0)),this.lookAt=h,GameLib.Utils.UndefinedOrNull(c)&&(c=-100),this.minX=c,GameLib.Utils.UndefinedOrNull(m)&&(m=100),this.maxX=m,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(E)&&(E=30),this.eyeSeparation=E,GameLib.Utils.UndefinedOrNull(y)&&(y=150),this.focalLength=y,GameLib.Utils.UndefinedOrNull(f)&&(f=null),this.parentEntity=f},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.parentEntity,e.eyeSeparation,e.focalLength)},GameLib.D3.API.Canvas=function(e,t,i,n,s){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Canvas ("+e+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=512),this.width=i,GameLib.Utils.UndefinedOrNull(n)&&(n=512),this.height=n,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.parentEntity=s},GameLib.D3.API.Canvas.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Canvas.prototype.constructor=GameLib.D3.API.Canvas,GameLib.D3.API.Canvas.FromObject=function(e){return new GameLib.D3.API.Canvas(e.id,e.name,e.width,e.height,e.parentEntity)},GameLib.D3.API.Composer=function(e,t,i,n,s,a){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(s)&&(s=[]),this.passes=s,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.parentEntity=a},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.Controls=function(e,t,i,n,s){if(GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(this instanceof GameLib.D3.Controls.Editor&&(t=GameLib.D3.Controls.CONTROLS_TYPE_EDITOR),this instanceof GameLib.D3.Controls.Touch&&(t=GameLib.D3.Controls.CONTROLS_TYPE_TOUCH),this instanceof GameLib.D3.Controls.Keyboard&&(t=GameLib.D3.Controls.CONTROLS_TYPE_KEYBOARD),this instanceof GameLib.D3.Controls.Mouse&&(t=GameLib.D3.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.D3.Controls.CONTROLS_TYPE_EDITOR&&(i="Editing Controls"),t===GameLib.D3.Controls.CONTROLS_TYPE_TOUCH&&(i="Touch Controls"),t===GameLib.D3.Controls.CONTROLS_TYPE_KEYBOARD&&(i="Keyboard Controls"),t===GameLib.D3.Controls.CONTROLS_TYPE_MOUSE&&(i="Mouse Controls"),i+=" ("+this.id+")"),this.name=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.domElement=n,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.parentEntity=s},GameLib.D3.API.Controls.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Controls.prototype.constructor=GameLib.D3.API.Controls,GameLib.D3.API.Controls.FromObject=function(e){return new GameLib.D3.API.Controls(e.id,e.controlsType,e.name,e.domElement,e.parentEntity)},GameLib.D3.API.CustomCode=function(e,t,i,n,s){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.Utils.UndefinedOrNull(s)&&(s=null),this.parentEntity=s},GameLib.D3.API.CustomCode.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.CustomCode.prototype.constructor=GameLib.D3.API.CustomCode,GameLib.D3.API.CustomCode.FromObject=function(e){return new GameLib.D3.API.CustomCode(e.id,e.name,e.eventId,e.code,e.parentEntity)},GameLib.D3.API.Face=function(e,t,i,n,s,a,o,r,h,c,m){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(s)&&(s=-1),this.v2index=s,GameLib.Utils.UndefinedOrNull(a)&&(a=-1),this.materialIndex=a,GameLib.Utils.UndefinedOrNull(o)&&(o=[[]]),this.uvs=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.color=r,GameLib.Utils.UndefinedOrNull(h)&&(h=[]),this.vertexColors=h,GameLib.Utils.UndefinedOrNull(c)&&(c=[]),this.vertexNormals=c,GameLib.Utils.UndefinedOrNull(m)&&(m=null),this.normal=m},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 s=e.vertexNormals.map(function(e){return GameLib.API.Vector3.FromObject(e)}),a=null;return e.normal&&(a=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,s,a)},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,s,a,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(s)&&(s=1),this.near=s,GameLib.Utils.UndefinedOrNull(a)&&(a=1e3),this.far=a,GameLib.Utils.UndefinedOrNull(o)&&(o=25e-5),this.density=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.parentEntity=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.Utils.UndefinedOrNull(n)&&(n=null),this.parentEntity=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,s,a,o,r,h,c){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(s)&&(s=.3),this.restitution=s,GameLib.Utils.UndefinedOrNull(a)&&(a=1e7),this.contactEquationStiffness=a,GameLib.Utils.UndefinedOrNull(o)&&(o=3),this.contactEquationRelaxation=o,GameLib.Utils.UndefinedOrNull(r)&&(r=1e7),this.frictionEquationStiffness=r,GameLib.Utils.UndefinedOrNull(h)&&(h=3),this.frictionEquationRelaxation=h,GameLib.Utils.UndefinedOrNull(c)&&(c=null),this.parentEntity=c},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,s){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.Utils.UndefinedOrNull(s)&&(s=null),this.parentEntity=s},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.ImageFactory=function(e,t,i,n){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="ImageFactory ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i="",console.warn("No baseURL defined for image factory")),this.baseUrl=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.parentEntity=n},GameLib.D3.API.ImageFactory.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.ImageFactory.prototype.constructor=GameLib.D3.API.ImageFactory,GameLib.D3.API.ImageFactory.FromObject=function(e){return new GameLib.D3.API.ImageFactory(e.id,e.name,e.baseUrl,e.parentEntity)},GameLib.D3.API.Image=function(e,t,i,n,s,a,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(s)&&(s="/"),this.path=s,GameLib.Utils.UndefinedOrNull(a)&&(a="application/octet-stream", this.extension.match(/(png)$/i)&&(a="image/png"),this.extension.match(/(jpg|jpeg)$/i)&&(a="image/jpeg"),this.extension.match(/(gif)$/i)&&(a="image/gif")),this.contentType=a,GameLib.Utils.UndefinedOrNull(o)&&(o=0),this.size=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.parentEntity=r},GameLib.D3.API.Image.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Image.prototype.constructor=GameLib.D3.API.Image,GameLib.D3.API.Image.FromObject=function(e){return new GameLib.D3.API.Image(e.id,e.name,e.fileName,e.extension,e.path,e.contentType,e.size,e.parentEntity)},GameLib.D3.API.Light=function(e,t,i,n,s,a,o,r,h,c,m,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(s)&&(s=1),this.intensity=s,GameLib.Utils.UndefinedOrNull(a)&&(a=new GameLib.API.Vector3(10,10,10)),this.position=a,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(h)&&(h=new GameLib.API.Vector3(0,0,0)),this.rotation=h,GameLib.Utils.UndefinedOrNull(c)&&(c=new GameLib.API.Vector3(1,1,1)),this.scale=c,GameLib.Utils.UndefinedOrNull(m)&&(m=0),this.distance=m,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.Utils.UndefinedOrNull(L)&&(L=null),this.parentEntity=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.LookAt=function(e,t,i,n,s,a,o){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t=this.constructor.name),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=null),this.currentComponent=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.targetComponent=n,GameLib.Utils.UndefinedOrNull(s)&&(s=new GameLib.API.Vector3(0,0,0)),this.targetPositionOffset=s,GameLib.Utils.UndefinedOrNull(a)&&(a=22),this.rotationSpeed=a,this.lookAtMatrix=new GameLib.API.Matrix4,this.up=new GameLib.API.Vector3(0,1,0),this.currentRotation=new GameLib.API.Quaternion,this.targetPosition=new GameLib.API.Vector3,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.parentEntity=o},GameLib.D3.API.LookAt.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.LookAt.prototype.constructor=GameLib.D3.API.LookAt,GameLib.D3.API.LookAt.FromObject=function(e){return new GameLib.D3.API.LookAt(e.id,e.name,e.currentComponent,e.targetComponent,GameLib.API.Vector3.FromObject(e.targetPositionOffset),e.rotationSpeed,e.parentEntity)},GameLib.D3.API.Material=function(e,t,i,n,s,a,o,r,h,c,m,l,p,u,b,d,L,G,f,E,y,O,D,P,T,I,g,A,N,S,C,U,v,M,_,w,x,R,F,j,V,Y,H,z,q,B,k,W,Q,X,K,Z,J,$,ee,te,ie,ne,se,ae,oe,re,he,ce,me,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(s)&&(s=GameLib.D3.Material.TYPE_FRONT_SIDE),this.side=s,GameLib.Utils.UndefinedOrNull(a)&&(a=!1),this.transparent=a,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(h)&&(h=1),this.aoMapIntensity=h,GameLib.Utils.UndefinedOrNull(c)&&(c=new GameLib.API.Color(1,1,1,1)),this.color=c,GameLib.Utils.UndefinedOrNull(m)&&(m=new GameLib.API.Color(0,0,0,0)),this.emissive=m,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(O)&&(O=GameLib.D3.Material.TYPE_NO_COLORS),this.vertexColors=O,GameLib.Utils.UndefinedOrNull(D)&&(D=!1),this.skinning=D,GameLib.Utils.UndefinedOrNull(P)&&(P=!1),this.morphTargets=P,GameLib.Utils.UndefinedOrNull(T)&&(T=!1),this.morphNormals=T,GameLib.Utils.UndefinedOrNull(q)&&(q=0),this.overdraw=q,GameLib.Utils.UndefinedOrNull(I)&&(I=1),this.lineWidth=I,GameLib.Utils.UndefinedOrNull(g)&&(g="round"),this.lineCap=g,GameLib.Utils.UndefinedOrNull(A)&&(A="round"),this.lineJoin=A,GameLib.Utils.UndefinedOrNull(N)&&(N=3),this.dashSize=N,GameLib.Utils.UndefinedOrNull(S)&&(S=1),this.gapWidth=S,GameLib.Utils.UndefinedOrNull(C)&&(C=GameLib.D3.Material.TYPE_NORMAL_BLENDING),this.blending=C,GameLib.Utils.UndefinedOrNull(U)&&(U=GameLib.D3.Material.TYPE_SRC_ALPHA_FACTOR),this.blendSrc=U,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(x)&&(x=!0),this.depthWrite=x,GameLib.Utils.UndefinedOrNull(R)&&(R=!1),this.polygonOffset=R,GameLib.Utils.UndefinedOrNull(F)&&(F=1),this.polygonOffsetFactor=F,GameLib.Utils.UndefinedOrNull(j)&&(j=1),this.polygonOffsetUnits=j,GameLib.Utils.UndefinedOrNull(V)&&(V=0),this.alphaTest=V,GameLib.Utils.UndefinedOrNull(Y)&&(Y=[]),this.clippingPlanes=Y,GameLib.Utils.UndefinedOrNull(H)&&(H=!1),this.clipShadows=H,GameLib.Utils.UndefinedOrNull(z)&&(z=!0),this.visible=z,GameLib.Utils.UndefinedOrNull(B)&&(B=!1),this.flatShading=B,GameLib.Utils.UndefinedOrNull(k)&&(k=1),this.bumpScale=k,GameLib.Utils.UndefinedOrNull(W)&&(W=1),this.normalScale=W,GameLib.Utils.UndefinedOrNull(Q)&&(Q=1),this.displacementScale=Q,GameLib.Utils.UndefinedOrNull(X)&&(X=0),this.displacementBias=X,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(se)&&(se=null),this.bumpMap=se,GameLib.Utils.UndefinedOrNull(ae)&&(ae=null),this.diffuseMap=ae,GameLib.Utils.UndefinedOrNull(oe)&&(oe=null),this.displacementMap=oe,GameLib.Utils.UndefinedOrNull(re)&&(re=null),this.emissiveMap=re,GameLib.Utils.UndefinedOrNull(he)&&(he=null),this.environmentMap=he,GameLib.Utils.UndefinedOrNull(ce)&&(ce=null),this.lightMap=ce,GameLib.Utils.UndefinedOrNull(me)&&(me=null),this.metalnessMap=me,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.Utils.UndefinedOrNull(be)&&(be=null),this.parentEntity=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,s=null,a=null,o=null,r=null,h=null,c=null,m=null,l=null,p=null;return e.alphaMap&&(t=e.alphaMap),e.aoMap&&(i=e.aoMap),e.bumpMap&&(n=e.bumpMap),e.diffuseMap&&(s=e.diffuseMap),e.displacementMap&&(a=e.displacementMap),e.emissiveMap&&(o=e.emissiveMap),e.environmentMap&&(r=e.environmentMap),e.lightMap&&(h=e.lightMap),e.metalnessMap&&(c=e.metalnessMap),e.normalMap&&(m=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,s,a,o,r,h,c,m,l,p,e.parentEntity)},GameLib.D3.API.Mesh=function(e,t,i,n,s,a,o,r,h,c,m,l,p,u,b,d,L,G,f,E,y,O){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t=GameLib.D3.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(s)&&(s=[]),this.faces=s,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.parentMesh=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.parentScene=r,GameLib.Utils.UndefinedOrNull(h)&&(h=null),this.skeleton=h,GameLib.Utils.UndefinedOrNull(c)&&(c=[]),this.skinIndices=c,GameLib.Utils.UndefinedOrNull(m)&&(m=[]),this.skinWeights=m,(GameLib.Utils.UndefinedOrNull(a)||a instanceof Array&&0===a.length)&&(a=[new GameLib.D3.API.Material(null,GameLib.D3.Material.MATERIAL_TYPE_STANDARD,"Material ("+this.name+")")]),this.materials=a,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(f)&&(f=0),this.renderOrder=f,GameLib.Utils.UndefinedOrNull(G)&&(G=null),this.parentEntity=G,GameLib.Utils.UndefinedOrNull(E)&&(E=!1),this.isBufferMesh=E,GameLib.Utils.UndefinedOrNull(y)&&(y=!0),this.useQuaternion=y,GameLib.Utils.UndefinedOrNull(O)&&(O=!0),this.visible=O},GameLib.D3.API.Mesh.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Mesh.prototype.constructor=GameLib.D3.API.Mesh,GameLib.D3.API.Mesh.FromObject=function(e){var t=[];e.faces&&(t=e.faces.map(function(e){return GameLib.D3.API.Face.FromObject(e)}));var i=null;e.skeleton&&(i=GameLib.D3.API.Skeleton.FromObject(e.skeleton));var n=[];e.materials&&(n=e.materials.map(function(e){return e instanceof Object?GameLib.D3.API.Material.FromObject(e):e}));var s=[];e.vertices&&(s=e.vertices.map(function(e){return GameLib.D3.API.Vertex.FromObject(e)}));var a=new GameLib.API.Vector3;e.position&&(a=GameLib.API.Vector3.FromObject(e.position));var o=new GameLib.API.Vector3;e.rotation&&(o=GameLib.API.Vector3.FromObject(e.rotation));var r=new GameLib.API.Quaternion;e.quaternion&&(r=GameLib.API.Quaternion.FromObject(e.quaternion));var h=new GameLib.API.Vector3(1,1,1);e.scale&&(h=GameLib.API.Vector3.FromObject(e.scale));var c=new GameLib.API.Vector3(0,1,0);e.up&&(c=GameLib.API.Vector3.FromObject(e.up));var m=new GameLib.API.Matrix4;return e.modelMatrix&&(m=GameLib.API.Matrix4.FromObject(e.modelMatrix)),new GameLib.D3.API.Mesh(e.id,e.meshType,e.name,s,t,n,e.parentMesh,e.parentScene,i,e.skinIndices,e.skinWeights,a,r,o,h,c,m,e.parentEntity,e.renderOrder,e.isBufferMesh,e.useQuaternion,e.visible)},GameLib.D3.API.ParticleEngine=function(e,t,i,n,s,a,o,r,h,c,m,l){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="ParticleEngine ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=new GameLib.API.Vector3(0,0,0)),this.position=i,GameLib.Utils.UndefinedOrNull(n)&&(n=new GameLib.API.Vector3(0,1,0)),this.direction=n,GameLib.Utils.UndefinedOrNull(s)&&(s=!1),this.enabled=s,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.templateParticle=a,GameLib.Utils.UndefinedOrNull(o)&&(o=1),this.particlesPerSecond=o,GameLib.Utils.UndefinedOrNull(r)&&(r=Number(1/Number(this.particlesPerSecond))),this.frequency=r,GameLib.Utils.UndefinedOrNull(h)&&(h=0),this.elapsed=h,GameLib.Utils.UndefinedOrNull(c)&&(c=null),this.camera=c,GameLib.Utils.UndefinedOrNull(m)&&(m=!1),this.pulse=m,GameLib.Utils.UndefinedOrNull(l)&&(l=null),this.parentEntity=l},GameLib.D3.API.ParticleEngine.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.ParticleEngine.prototype.constructor=GameLib.D3.API.ParticleEngine,GameLib.D3.API.ParticleEngine.FromObject=function(e){var t=null;e.templateParticle&&(t=e.templateParticle instanceof Object?GameLib.D3.API.Particle.FromObject(e.templateParticle):e.templateParticle);var i=null;e.camera&&(i=e.camera instanceof Object?GameLib.D3.API.Camera.FromObject(e.camera):e.camera);var n=null;e.position&&(n=GameLib.API.Vector3.FromObject(e.position));var s=null;return e.direction&&(s=GameLib.API.Vector3.FromObject(e.direction)),new GameLib.D3.API.ParticleEngine(e.id,e.name,n,s,e.enabled,t,e.particlesPerSecond,e.frequency,e.elapsed,i,e.pulse,e.parentEntity)},GameLib.D3.API.Particle=function(e,t,i,n,s,a,o,r,h,c,m,l,p,u,b,d,L,G,f,E,y,O,D){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Particle ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=10),this.lifeTime=i,GameLib.Utils.UndefinedOrNull(n)&&(n=0),this.elapsed=n,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.mesh=s,GameLib.Utils.UndefinedOrNull(a)&&(a=GameLib.D3.Particle.OPACITY_TYPE_CONSTANT),this.opacityType=a,GameLib.Utils.UndefinedOrNull(o)&&(o=.01),this.opacityFactor=o,GameLib.Utils.UndefinedOrNull(r)&&(r=GameLib.D3.Particle.POSITION_OFFSET_TYPE_CONSTANT),this.positionOffsetType=r,GameLib.Utils.UndefinedOrNull(h)&&(h=new GameLib.API.Vector3(0,0,0)),this.positionOffset=h,GameLib.Utils.UndefinedOrNull(c)&&(c="//@ sourceURL=positionOffsetFn.js"),this.positionOffsetFn=c,GameLib.Utils.UndefinedOrNull(m)&&(m=GameLib.D3.Particle.DIRECTION_TYPE_CONSTANT),this.directionType=m,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(O)&&(O=null),this.parentEngine=O,GameLib.Utils.UndefinedOrNull(D)&&(D=null),this.parentEntity=D},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,s,a,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(s)&&(s=null),this.scene=s,GameLib.Utils.UndefinedOrNull(a))if(this.passType===GameLib.D3.Pass.PASS_TYPE_RENDER)a=!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);a=!0}this.renderToScreen=a,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.parentEntity=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.PathFollowing=function(e,t,i,n,s,a,o,r,h,c,m,l,p,u,b,d,L,G,f,E,y,O){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t=this.constructor.name),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=null),this.spline=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.mesh=n,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.raytraceMesh=s,GameLib.Utils.UndefinedOrNull(o)&&(o=.03),this.maxSpeed=o,GameLib.Utils.UndefinedOrNull(a)&&(a=.1),this.accelleration=a,GameLib.Utils.UndefinedOrNull(r)&&(r=new GameLib.API.Vector3),this.baseOffset=r,GameLib.Utils.UndefinedOrNull(h)&&(h=new GameLib.API.Vector3),this.maxOffset=h,GameLib.Utils.UndefinedOrNull(c)&&(c=1),this.steeringSpeed=c,GameLib.Utils.UndefinedOrNull(m)&&(m=new GameLib.API.Vector3),this.targetOffset=m,GameLib.Utils.UndefinedOrNull(l)&&(l=new GameLib.API.Vector3),this.currentOffset=l,GameLib.Utils.UndefinedOrNull(p)&&(p=0),this.currentPathValue=p,GameLib.Utils.UndefinedOrNull(u)&&(u=0),this.currentSpeed=u,GameLib.Utils.UndefinedOrNull(b)&&(b=1),this.direction=b,GameLib.Utils.UndefinedOrNull(d)&&(d=new GameLib.D3.API.Raycaster),this.raycaster=d,GameLib.Utils.UndefinedOrNull(L)&&(L=new GameLib.API.Vector3),this.currentPosition=L,GameLib.Utils.UndefinedOrNull(G)&&(G=new GameLib.API.Vector3),this.futurePosition=G,GameLib.Utils.UndefinedOrNull(f)&&(f=new GameLib.API.Vector3(0,1,0)),this.up=f,GameLib.Utils.UndefinedOrNull(E)&&(E=new GameLib.API.Matrix4),this.rotationMatrix=E,GameLib.Utils.UndefinedOrNull(y)&&(y=new GameLib.API.Quaternion),this.rotationVector=y,GameLib.Utils.UndefinedOrNull(O)&&(O=null),this.parentEntity=O},GameLib.D3.API.PathFollowing.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.PathFollowing.prototype.constructor=GameLib.D3.API.PathFollowing,GameLib.D3.API.PathFollowing.FromObject=function(e){var t=null;return e.raycaster&&(t=GameLib.D3.API.Raycaster.FromObject(e.raycaster)),new GameLib.D3.API.PathFollowing(e.id,e.name,e.spline,e.mesh,e.raytraceMesh,e.accelleration,e.maxSpeed,GameLib.API.Vector3.FromObject(e.baseOffset),GameLib.API.Vector3.FromObject(e.maxOffset),e.steeringSpeed,GameLib.API.Vector3.FromObject(e.targetOffset),GameLib.API.Vector3.FromObject(e.currentOffset),e.currentPathValue,e.currentSpeed,e.direction,t,GameLib.API.Vector3.FromObject(e.currentPosition),GameLib.API.Vector3.FromObject(e.futurePosition),GameLib.API.Vector3.FromObject(e.up),GameLib.API.Matrix4.FromObject(e.rotationMatrix),GameLib.API.Quaternion.FromObject(e.rotationVector),e.parentEntity)},GameLib.D3.API.PhysicsWorld=function(e,t,i,n,s,a,o,r,h,c){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(s)&&(s=new GameLib.D3.API.Solver(null,"Solver (Physics World "+this.id+")")),this.solver=s,GameLib.Utils.UndefinedOrNull(a)&&(a=[]),this.rigidBodies=a,GameLib.Utils.UndefinedOrNull(o)&&(o=[]),this.contactMaterials=o,GameLib.Utils.UndefinedOrNull(r)&&(r=!0),this.allowSleep=r,GameLib.Utils.UndefinedOrNull(h)&&(h=new GameLib.D3.API.FrictionContactMaterial(null,"Default Contact Material (Physics World "+this.id+")")),this.defaultContactMaterial=h,GameLib.Utils.UndefinedOrNull(c)&&(c=null),this.parentEntity=c},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,s,a,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(s)&&(s=[]),this.raycastWheels=s,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.parentWorld=a,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.parentEntity=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.parentWorld,e.parentEntity)},GameLib.D3.API.RaycastWheel=function(e,t,i,n,s,a,o,r,h,c,m,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(s)&&(s=30),this.suspensionStiffness=s,GameLib.Utils.UndefinedOrNull(a)&&(a=.3),this.suspensionRestLength=a,GameLib.Utils.UndefinedOrNull(o)&&(o=5),this.frictionSlip=o,GameLib.Utils.UndefinedOrNull(r)&&(r=2.3),this.dampingRelaxation=r,GameLib.Utils.UndefinedOrNull(h)&&(h=4.4),this.dampingCompression=h,GameLib.Utils.UndefinedOrNull(c)&&(c=1e5),this.maxSuspensionForce=c,GameLib.Utils.UndefinedOrNull(m)&&(m=.01),this.rollInfluence=m,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.parentEntity=L,GameLib.Utils.UndefinedOrNull(G)&&(G=null),this.parentMesh=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.parentEntity,e.parentMesh)},GameLib.D3.API.Raycaster=function(e,t,i,n){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.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))},GameLib.D3.API.RenderTarget=function(e,t,i,n,s,a,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(s)&&(s=!1),this.stencilBuffer=s,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.texture=a,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.parentEntity=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,s,a,o,r,h,c,m,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(s)&&(s=800),this.width=s,GameLib.Utils.UndefinedOrNull(a)&&(a=600),this.height=a,GameLib.Utils.UndefinedOrNull(o)&&(o=!1),this.preserveDrawingBuffer=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.domElement=r,GameLib.Utils.UndefinedOrNull(h)&&(h=new GameLib.API.Color(.11,.11,.11)),this.clearColor=h,GameLib.Utils.UndefinedOrNull(c)&&(c=null),this.camera=c,GameLib.Utils.UndefinedOrNull(m)&&(m=[]),this.scenes=m,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=c),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.Utils.UndefinedOrNull(f)&&(f=null),this.parentEntity=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,s,a,o,r,h,c,m,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(s)&&(s=new GameLib.API.Vector3(0,0,0)),this.position=s,GameLib.Utils.UndefinedOrNull(a)&&(a=new GameLib.API.Quaternion),this.quaternion=a,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(h)&&(h=.01),this.linearDamping=h,GameLib.Utils.UndefinedOrNull(c)&&(c=.01),this.angularDamping=c,GameLib.Utils.UndefinedOrNull(m)&&(m=!0),this.allowSleep=m,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.parentWorld=E,GameLib.Utils.UndefinedOrNull(y)&&(y=null),this.parentEntity=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.parentWorld,e.parentEntity)},GameLib.D3.API.Scene=function(e,t,i,n,s,a,o,r,h,c,m,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(s)&&(s=[]),this.textures=s,GameLib.Utils.UndefinedOrNull(a)&&(a=[]),this.materials=a,GameLib.Utils.UndefinedOrNull(o)&&(o=[]),this.images=o,GameLib.Utils.UndefinedOrNull(r)&&(r=null),this.fog=r,GameLib.Utils.UndefinedOrNull(h)&&(h=null),this.renderCamera=h,GameLib.Utils.UndefinedOrNull(c)&&(c=!0),this.showGrid=c,GameLib.Utils.UndefinedOrNull(m)&&(m=!0),this.showAxis=m,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.Utils.UndefinedOrNull(u)&&(u=null),this.parentEntity=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=[],s=[],a=[];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&&(s=e.materials.map(function(e){return e instanceof Object?GameLib.D3.API.Material.FromObject(e):e})),e.images&&(a=e.images.map(function(e){return e instanceof Object?GameLib.D3.API.Image.FromObject(e):e})),new GameLib.D3.API.Scene(e.id,e.name,t,i,n,s,a,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,s,a,o){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Shape ("+this.id+")",this instanceof GameLib.D3.Shape.ConvexHull&&(t="Shape Convex Hull ("+this.id+")"),this instanceof GameLib.D3.Shape.ConvexHull.Cylinder&&(t="Shape Convex Hull Cylinder ("+this.id+")"),this instanceof GameLib.D3.Shape.HeightMap&&(t="Shape Heightmap ("+this.id+")"),this instanceof GameLib.D3.Shape.Box&&(t="Shape Box ("+this.id+")"),this instanceof GameLib.D3.Shape.Plane&&(t="Shape Plane ("+this.id+")"),this instanceof GameLib.D3.Shape.Sphere&&(t="Shape Sphere ("+this.id+")"),this instanceof GameLib.D3.Shape.TriMesh&&(t="Shape TriMesh ("+this.id+")")),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=0),this.boundingSphereRadius=i,GameLib.Utils.UndefinedOrNull(n)&&(n=!0),this.collisionResponse=n,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.frictionMaterial=s,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.parentMesh=a,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.parentEntity=o},GameLib.D3.API.Shape.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Shape.prototype.constructor=GameLib.D3.API.Shape,GameLib.D3.API.Shape.FromObject=function(e){return new GameLib.D3.API.Shape(e.id,e.name,e.boundingSphereRadius,e.collisionResponse,e.frictionMaterial,e.parentMesh,e.parentEntity)},GameLib.D3.API.Skeleton=function(e,t,i,n,s,a,o,r,h,c){GameLib.Utils.UndefinedOrNull(c)&&(c=null),this.parentEntity=c,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(s)&&(s=!1),this.useVertexTexture=s,s&&console.warn("support for vertex texture bones is not supported yet - something could break somewhere"),GameLib.Utils.UndefinedOrNull(a)&&(a=0),this.boneTextureWidth=a,GameLib.Utils.UndefinedOrNull(o)&&(o=0),this.boneTextureHeight=o,GameLib.Utils.UndefinedOrNull(r)&&(r=[]),this.boneMatrices=r,GameLib.Utils.UndefinedOrNull(h)&&(h=null),this.boneTexture=h},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,s,a){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.Solver.GS_SOLVER),this.solverType=i,GameLib.Utils.UndefinedOrNull(n)&&(n=10),this.iterations=n,GameLib.Utils.UndefinedOrNull(s)&&(s=1e-7),this.tolerance=s,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.parentEntity=a},GameLib.D3.API.Solver.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Solver.prototype.constructor=GameLib.D3.API.Solver,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 (unknown)"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=[]),this.vertices=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.parentEntity=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,s,a,o,r,h,c,m,l,p,u,b,d,L,G,f,E,y,O,D,P,T,I,g){GameLib.Utils.UndefinedOrNull(g)&&(g=null),this.parentEntity=g,GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t=GameLib.D3.Texture.TEXTURE_TYPE_NORMAL),this.typeId=t,GameLib.Utils.UndefinedOrNull(i)&&(i="Texture ("+e+")"),this.name=i,GameLib.Utils.UndefinedOrNull(n)&&(n=null),this.image=n,GameLib.Utils.UndefinedOrNull(s)&&(s=[]),this.images=s,GameLib.Utils.UndefinedOrNull(a)&&(a=GameLib.D3.Texture.TYPE_REPEAT_WRAPPING),this.wrapS=a,GameLib.Utils.UndefinedOrNull(o)&&(o=GameLib.D3.Texture.TYPE_REPEAT_WRAPPING),this.wrapT=o,GameLib.Utils.UndefinedOrNull(r)&&(r=new GameLib.API.Vector2(1,1)),this.repeat=r,GameLib.Utils.UndefinedOrNull(h)&&(h=null),this.data=h,GameLib.Utils.UndefinedOrNull(c)&&(c=GameLib.D3.Texture.TYPE_RGBA_FORMAT),this.format=c,GameLib.Utils.UndefinedOrNull(m)&&(m=GameLib.D3.Texture.TYPE_UV_MAPPING),this.mapping=m,GameLib.Utils.UndefinedOrNull(l)&&(l=GameLib.D3.Texture.TYPE_LINEAR_FILTER),this.magFilter=l,GameLib.Utils.UndefinedOrNull(p)&&(p=GameLib.D3.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER),this.minFilter=p,GameLib.Utils.UndefinedOrNull(u)&&(u=GameLib.D3.Texture.TYPE_UNSIGNED_BYTE),this.textureType=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(O)&&(O=GameLib.D3.Texture.TYPE_LINEAR_ENCODING),this.encoding=O,GameLib.Utils.UndefinedOrNull(D)&&(D=null),this.canvas=D,GameLib.Utils.UndefinedOrNull(P)&&(P=!1),this.animated=P,GameLib.Utils.UndefinedOrNull(T)&&(T=!1),this.reverseAnimation=T,GameLib.Utils.UndefinedOrNull(I)&&(I=!0),this.forward=I,this.needsUpdate=!1},GameLib.D3.API.Texture.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.API.Texture.prototype.constructor=GameLib.D3.API.Texture,GameLib.D3.API.Texture.FromObject=function(e){return new GameLib.D3.API.Texture(e.id,e.typeId,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.textureType,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,s,a,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(s)&&(s=0),this.x=s,GameLib.Utils.UndefinedOrNull(a)&&(a=0),this.y=a,GameLib.Utils.UndefinedOrNull(o)&&(o=null),this.parentEntity=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,GameLib.Component.COMPONENT_ANIMATION,{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_CODER_IMPLEMENTATION,null,function(e){this.coder=e,this.coder.isNotCodeMirrorThrow()}.bind(this));var e=null;this.functionType===GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_ROTATION&&(this.rotationFn="//when the animation is complete, return true\nreturn true;",e="rotationFn"),this.functionType===GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_TRANSLATION&&(this.translationFn="//when the animation is complete, return true\nreturn true;",e="translationFn"),this.functionType===GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_SCALE&&(this.scaleFn="//when the animation is complete, return true\nreturn true;",e="scaleFn"),e?(this.editor=this.coder.instance(document.body,{value:this[e],mode:"javascript",lineNumbers:!0,scrollbarStyle:"overlay"}),this.editor.on("change",function(){this[e]=this.editor.getValue(),this.updateInstance()}.bind(this))):console.warn("invalid function type selected")},GameLib.D3.Animation.prototype.closeEditor=function(){var e=this.editor.getWrapperElement();e.parentElement.removeChild(e)},GameLib.D3.Animation.prototype.addMesh=function(e){GameLib.Utils.PushUnique(this.meshes,e),GameLib.Event.Emit(GameLib.Event.ANIMATION_MESH_ADDED,{animation:this,mesh:e})},GameLib.D3.Animation.prototype.removeMesh=function(e){var t=this.meshes.indexOf(e);this.meshes.splice(t,1),GameLib.Event.Emit(GameLib.Event.ANIMATION_MESH_REMOVED,{animation:this,mesh:e})},GameLib.D3.Audio=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Audio)return t;GameLib.D3.API.Audio.call(this,t.id,t.name,t.path,t.loop,t.volume,t.camera,t.overplay,t.pause,t.parentEntity),this.camera instanceof GameLib.D3.API.Camera&&(this.camera=new GameLib.D3.Camera(this.graphics,this.camera)),GameLib.Component.call(this,GameLib.Component.COMPONENT_AUDIO,{camera:GameLib.D3.Camera})},GameLib.D3.Audio.prototype=Object.create(GameLib.D3.API.Audio.prototype),GameLib.D3.Audio.prototype.constructor=GameLib.D3.Audio,GameLib.D3.Audio.prototype.createInstance=function(){if(GameLib.Utils.UndefinedOrNull(this.camera)||GameLib.Utils.UndefinedOrNull(this.camera.instance))return void console.log("audio not ready to create instance");GameLib.Event.Emit(GameLib.Event.GET_API_URL,null,function(e){this.apiUrl=e.apiUrl}.bind(this));var e=new THREE.AudioListener;this.camera.instance.add(e),this.instance=new THREE.Audio(e),(new THREE.AudioLoader).load(this.apiUrl+this.path+"?ts="+Date.now(),function(e){this.instance.setBuffer(e),this.instance.setLoop(this.loop),this.instance.setVolume(this.volume),GameLib.Component.prototype.createInstance.call(this)}.bind(this))},GameLib.D3.Audio.prototype.updateInstance=function(e){"loop"===e&&this.instance.setLoop(this.loop),"volume"===e&&this.instance.setVolume(this.volume),"paused"===e&&(this.paused?this.instance.pause():this.instance.play())},GameLib.D3.Audio.prototype.toApiObject=function(){return new GameLib.D3.API.Audio(this.id,this.name,this.path,this.loop,this.volume,GameLib.Utils.IdOrNull(this.camera),this.overplay,this.paused,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Audio.FromObject=function(e,t){var i=GameLib.D3.API.Audio.FromObject(t);return new GameLib.D3.Audio(e,i)},GameLib.D3.Audio.prototype.play=function(){this.instance.play()},GameLib.D3.BoneWeight=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.BoneWeight)return t;GameLib.D3.API.BoneWeight.call(this,t.boneIndex,t.weight)},GameLib.D3.BoneWeight.prototype=Object.create(GameLib.D3.API.BoneWeight.prototype),GameLib.D3.BoneWeight.prototype.constructor=GameLib.D3.BoneWeight,GameLib.D3.BoneWeight.prototype.toApiObject=function(){return new GameLib.D3.API.BoneWeight(this.boneIndex,this.weight)},GameLib.D3.BoneWeight.FromObject=function(e,t){var i=GameLib.D3.API.BoneWeight.FromObject(t);return new GameLib.D3.BoneWeight(e,i)},GameLib.D3.Bone=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Bone)return t;GameLib.D3.API.Bone.call(this,t.id,t.name,t.childBoneIds,t.parentBoneIds,t.position,t.quaternion,t.scale,t.up),this.position=new GameLib.Vector3(e,this.position,this),this.quaternion=new GameLib.Quaternion(e,this.quaternion,this),this.scale=new GameLib.Vector3(e,this.scale,this),this.up=new GameLib.Vector3(e,this.up,this),GameLib.Component.call(this,GameLib.Component.COMPONENT_BONE)},GameLib.D3.Bone.prototype=Object.create(GameLib.D3.API.Bone.prototype),GameLib.D3.Bone.prototype.constructor=GameLib.D3.Bone,GameLib.D3.Bone.prototype.createInstance=function(){this.instance=new THREE.Bone,this.instance.name=this.name,this.instance.position.x=this.position.x,this.instance.position.y=this.position.y,this.instance.position.z=this.position.z,this.instance.quaternion.x=this.quaternion.x,this.instance.quaternion.y=this.quaternion.y,this.instance.quaternion.z=this.quaternion.z,this.instance.quaternion.w=this.quaternion.w,this.instance.scale.x=this.scale.x,this.instance.scale.y=this.scale.y,this.instance.scale.z=this.scale.z,this.instance.up.x=this.up.x,this.instance.up.y=this.up.y,this.instance.up.z=this.up.z,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Bone.prototype.updateInstance=function(){this.instance.name=this.name,this.instance.position.x=this.position.x,this.instance.position.y=this.position.y,this.instance.position.z=this.position.z,this.instance.quaternion.x=this.quaternion.x,this.instance.quaternion.y=this.quaternion.y,this.instance.quaternion.z=this.quaternion.z,this.instance.quaternion.w=this.quaternion.w,this.instance.scale.x=this.scale.x,this.instance.scale.y=this.scale.y,this.instance.scale.z=this.scale.z,this.instance.up.x=this.up.x,this.instance.up.y=this.up.y,this.instance.up.z=this.up.z},GameLib.D3.Bone.prototype.toApiObject=function(){return new GameLib.D3.API.Bone(this.id,this.name,this.childBoneIds,this.parentBoneIds,this.position.toApiObject(),this.quaternion.toApiObject(),this.scale.toApiObject(),this.up.toApiObject())},GameLib.D3.Bone.FromObject=function(e,t){var i=GameLib.D3.API.Bone.FromObject(t);return GameLib.D3.Bone(e,i)},GameLib.D3.Broadphase=function(e,t){if(this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Broadphase)return t;GameLib.D3.API.Broadphase.call(this,t.id,t.name,t.broadphaseType,t.parentEntity),GameLib.Component.call(this,GameLib.Component.COMPONENT_BROADPHASE)},GameLib.D3.Broadphase.prototype=Object.create(GameLib.D3.API.Broadphase.prototype),GameLib.D3.Broadphase.prototype.constructor=GameLib.D3.Broadphase,GameLib.D3.Broadphase.prototype.createInstance=function(){if(this.broadphaseType===GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE)this.instance=new CANNON.NaiveBroadphase;else if(this.broadphaseType===GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID)this.instance=new CANNON.GridBroadphase;else{if(this.broadphaseType!==GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP)throw console.warn("Unsupported broadphase type: "+this.broadphaseType),new Error("Unsupported broadphase type: "+this.broadphaseType);this.instance=new CANNON.SAPBroadphase}GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Broadphase.prototype.updateInstance=function(){this.broadphaseType===GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE&&(this.instance instanceof CANNON.NaiveBroadphase||this.createInstance()),this.broadphaseType===GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID&&(this.instance instanceof CANNON.GridBroadphase||this.createInstance()),this.broadphaseType===GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP&&(this.instance instanceof CANNON.SAPBroadphase||this.createInstance())},GameLib.D3.Broadphase.prototype.toApiObject=function(){return new GameLib.D3.API.Broadphase(this.id,this.name,this.broadphaseType,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Broadphase.FromObject=function(e,t){var i=GameLib.D3.API.Broadphase.FromObject(t);return new GameLib.D3.Broadphase(e,i)},GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE=1,GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID=2,GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP=3,GameLib.D3.Camera=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Camera)return t;if(GameLib.D3.API.Camera.call(this,t.id,t.cameraType,t.name,t.fov,t.aspect,t.near,t.far,t.position,t.lookAt,t.minX,t.maxX,t.minY,t.maxY,t.minZ,t.maxZ,t.offsetX,t.offsetY,t.quaternion,t.parentEntity,t.eyeSeparation,t.focalLength),!(this.position instanceof GameLib.API.Vector3))throw console.warn("position not instance of API.Vector3"),new Error("position not instance of API.Vector3");if(this.position=new GameLib.Vector3(e,this.position,this),!(this.quaternion instanceof GameLib.API.Quaternion))throw console.warn("quaternion not instance of API.Quaternion"),new Error("quaternion not instance of API.Quaternion");if(this.quaternion=new GameLib.Quaternion(e,this.quaternion,this),!(this.lookAt instanceof GameLib.API.Vector3))throw console.warn("lookAt not instance of API.Vector3"),new Error("lookAt not instance of API.Vector3");this.lookAt=new GameLib.Vector3(e,this.lookAt,this),GameLib.Component.call(this,GameLib.Component.COMPONENT_CAMERA)},GameLib.D3.Camera.prototype=Object.create(GameLib.D3.API.Camera.prototype),GameLib.D3.Camera.prototype.constructor=GameLib.D3.Camera,GameLib.D3.Camera.CAMERA_TYPE_PERSPECTIVE=1,GameLib.D3.Camera.CAMERA_TYPE_ORTHOGONAL=2,GameLib.D3.Camera.CAMERA_TYPE_STEREO=3,GameLib.D3.Camera.prototype.createInstance=function(){if(this.cameraType===GameLib.D3.Camera.CAMERA_TYPE_PERSPECTIVE)this.instance=new THREE.PerspectiveCamera(this.fov,this.aspect,this.near,this.far);else if(this.cameraType===GameLib.D3.Camera.CAMERA_TYPE_ORTHOGONAL)this.instance=new THREE.OrthographicCamera(this.minX+this.offsetX,this.maxX+this.offsetX,this.maxY,this.minY,this.minZ,this.maxZ);else{if(this.cameraType!==GameLib.D3.Camera.CAMERA_TYPE_STEREO)throw new Error("unsupported camera type : "+this.cameraType);this.instance=new THREE.StereoCamera}this.instance.position.x=this.position.x,this.instance.position.y=this.position.y,this.instance.position.z=this.position.z,this.instance.quaternion.x=this.quaternion.x,this.instance.quaternion.y=this.quaternion.y,this.instance.quaternion.z=this.quaternion.z,this.instance.quaternion.w=this.quaternion.w,this.instance.lookAt(this.lookAt.instance),this.instance.updateProjectionMatrix(),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Camera.prototype.updateInstance=function(e){GameLib.Utils.UndefinedOrNull(e)&&console.warn("no camera property specified for : "+this.name),"cameraType"===e&&(this.cameraType!==GameLib.D3.Camera.CAMERA_TYPE_ORTHOGONAL||this.instance instanceof THREE.OrthographicCamera||this.createInstance(),this.cameraType!==GameLib.D3.Camera.CAMERA_TYPE_PERSPECTIVE||this.instance instanceof THREE.PerspectiveCamera||this.createInstance()),"aspect"!==e&&"minX"!==e&&"maxX"!==e&&"minY"!==e&&"maxY"!==e&&"minZ"!==e&&"maxZ"!==e&&"offsetX"!==e&&"offsetY"!==e&&"fov"!==e&&"near"!==e&&"far"!==e&&"eyeSeparation"!==e&&"focalLength"!==e||(this.cameraType===GameLib.D3.Camera.CAMERA_TYPE_ORTHOGONAL&&(this.minX=this.aspect*this.minY,this.maxX=this.aspect*this.maxY,this.instance.left=this.minX+this.offsetX,this.instance.right=this.maxX+this.offsetX,this.instance.bottom=this.minY+this.offsetY,this.instance.top=this.maxY+this.offsetY,this.instance.near=this.minZ,this.instance.far=this.maxZ),this.cameraType!==GameLib.D3.Camera.CAMERA_TYPE_PERSPECTIVE&&this.cameraType!==GameLib.D3.Camera.CAMERA_TYPE_STEREO||(this.instance.fov=this.fov,this.instance.aspect=this.aspect,this.instance.near=this.near,this.instance.far=this.far),this.cameraType===GameLib.D3.Camera.CAMERA_TYPE_STEREO&&(this.instance.eyeSeparation=this.eyeSeparation,this.instance.focalLength=this.focalLength,this.instance.update(this.instance))),"position"===e&&(this.instance.position.x=this.position.x,this.instance.position.y=this.position.y,this.instance.position.z=this.position.z),"quaternion"===e&&(this.instance.quaternion.x=this.quaternion.x,this.instance.quaternion.y=this.quaternion.y,this.instance.quaternion.z=this.quaternion.z,this.instance.quaternion.w=this.quaternion.w),"lookAt"===e&&(this.lookAt.instance.x=this.lookAt.x,this.lookAt.instance.y=this.lookAt.y,this.lookAt.instance.z=this.lookAt.z,this.instance.lookAt(this.lookAt.instance)),this.instance.updateProjectionMatrix()},GameLib.D3.Camera.prototype.resize=function(e,t){camera.aspect=e/t,camera.updateInstance()},GameLib.D3.Camera.prototype.toApiObject=function(){return new GameLib.D3.API.Camera(this.id,this.cameraType,this.name,this.fov,this.aspect,this.near,this.far,this.position.toApiObject(),this.lookAt.toApiObject(),this.minX,this.maxX,this.minY,this.maxY,this.minZ,this.maxZ,this.offsetX,this.offsetY,this.quaternion.toApiObject(),GameLib.Utils.IdOrNull(this.parentEntity),this.eyeSeparation,this.focalLength)},GameLib.D3.Camera.FromObject=function(e,t){var i=GameLib.D3.API.Camera.FromObject(t);return new GameLib.D3.Camera(e,i)},GameLib.D3.Canvas=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Canvas)return t;GameLib.D3.API.Canvas.call(this,t.id,t.name,t.width,t.height,t.parentEntity),GameLib.Component.call(this,GameLib.Component.COMPONENT_CANVAS)},GameLib.D3.Canvas.prototype=Object.create(GameLib.D3.API.Canvas.prototype),GameLib.D3.Canvas.prototype.constructor=GameLib.D3.Canvas,GameLib.D3.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.D3.Canvas.prototype.updateInstance=function(){GameLib.Utils.UndefinedOrNull(this.instance)&&this.createInstance(),this.instance.width=this.width,this.instance.height=this.height},GameLib.D3.Canvas.prototype.toApiObject=function(){return new GameLib.D3.API.Canvas(this.id,this.name,this.width,this.height,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Canvas.FromObject=function(e,t){return new GameLib.D3.Canvas(e,GameLib.D3.API.Canvas.FromObject(t))},GameLib.D3.Coder=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.D3.Coder.CODER_TYPE_CODE_MIRROR),this.coderType=i,this.createInstance()},GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR=1,GameLib.D3.Coder.prototype.createInstance=function(){this.instance=CodeMirror},GameLib.D3.Coder.prototype.updateInstance=function(){},GameLib.D3.Coder.prototype.isCodeMirror=function(){return this.coderType===GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR},GameLib.D3.Coder.prototype.isNotCodeMirrorThrow=function(){if(this.coderType!==GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR)throw console.warn("Only CodeMirror supported for this function"),new Error("Only CodeMirror supported for this function")},GameLib.D3.Composer=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Composer)return t;GameLib.D3.API.Composer.call(this,t.id,t.name,t.renderer,t.renderTarget,t.passes,t.parentEntity),GameLib.Component.call(this,GameLib.Component.COMPONENT_COMPOSER,{renderer:GameLib.D3.Renderer,renderTarget:GameLib.D3.RenderTarget,passes:[GameLib.D3.Pass]})},GameLib.D3.Composer.prototype=Object.create(GameLib.D3.API.Composer.prototype),GameLib.D3.Composer.prototype.constructor=GameLib.D3.Composer,GameLib.D3.Composer.prototype.createInstance=function(){console.log("GameLib.D3.Composer.prototype.createInstance() - fix me"),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Composer.prototype.updateInstance=function(){console.log("GameLib.D3.Composer.prototype.updateInstance() - fix me")},GameLib.D3.Composer.prototype.toApiObject=function(){return new GameLib.D3.API.Composer(this.id,this.name,GameLib.Utils.IdOrNull(this.renderer),GameLib.Utils.IdOrNull(this.renderTarget),this.passes.map(function(e){return GameLib.Utils.IdOrNull(e)}),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Composer.FromObject=function(e,t){var i=GameLib.D3.API.Composer.FromObject(t);return new GameLib.D3.Composer(e,i)},GameLib.D3.Controls=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Controls)return t;GameLib.D3.API.Controls.call(this,t.id,t.controlsType,t.name,t.domElement,t.parentEntity);var i=GameLib.Component.COMPONENT_CONTROLS,n={domElement:GameLib.DomElement},s=!1;this.controlsType===GameLib.D3.Controls.CONTROLS_TYPE_EDITOR&&(i=GameLib.Component.COMPONENT_CONTROLS_EDITOR,n.raycaster=GameLib.D3.Raycaster,n.camera=GameLib.D3.Camera,s=!0),this.controlsType===GameLib.D3.Controls.CONTROLS_TYPE_TOUCH&&(i=GameLib.Component.COMPONENT_CONTROLS_TOUCH),this.controlsType===GameLib.D3.Controls.CONTROLS_TYPE_KEYBOARD&&(i=GameLib.Component.COMPONENT_CONTROLS_KEYBOARD),this.controlsType===GameLib.D3.Controls.CONTROLS_TYPE_MOUSE&&(i=GameLib.Component.COMPONENT_CONTROLS_MOUSE),GameLib.Component.call(this,i,n,s)},GameLib.D3.Controls.prototype=Object.create(GameLib.D3.API.Controls.prototype),GameLib.D3.Controls.prototype.constructor=GameLib.D3.Controls,GameLib.D3.Controls.CONTROLS_TYPE_EDITOR=0,GameLib.D3.Controls.CONTROLS_TYPE_TOUCH=1,GameLib.D3.Controls.CONTROLS_TYPE_KEYBOARD=2,GameLib.D3.Controls.CONTROLS_TYPE_MOUSE=3,GameLib.D3.Controls.prototype.createInstance=function(){GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Controls.prototype.updateInstance=function(){console.log("default controls update instance")},GameLib.D3.Controls.prototype.toApiObject=function(){return new GameLib.D3.API.Controls(this.id,this.controlsType,this.name,GameLib.Utils.IdOrNull(this.domElement),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Controls.FromObject=function(e,t){var i=GameLib.D3.API.Controls.FromObject(t);return new GameLib.D3.Controls(e,i)},GameLib.D3.Controls.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.D3.Controls.call(this,this.graphics,t)},GameLib.D3.Controls.Editor.prototype=Object.create(GameLib.D3.Controls.prototype),GameLib.D3.Controls.Editor.prototype.constructor=GameLib.D3.Controls.Editor,GameLib.D3.Controls.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.D3.Controls.prototype.createInstance.call(this)};GameLib.D3.Controls.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.D3.Controls.prototype.updateInstance.call(this)},GameLib.D3.Controls.Editor.prototype.toApiObject=function(){var e=GameLib.D3.Controls.prototype.toApiObject.call(this);return e.raycaster=GameLib.Utils.IdOrNull(this.raycaster),e.camera=GameLib.Utils.IdOrNull(this.camera),e},GameLib.D3.Controls.Editor.FromObject=function(e,t){var i=GameLib.D3.API.Controls.FromObject(t);return new GameLib.D3.Controls.Editor(e,i,t.raycaster,t.camera)},GameLib.D3.Controls.Keyboard=function(e,t){this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.D3.Controls.call(this,this.graphics,t)},GameLib.D3.Controls.Keyboard.prototype=Object.create(GameLib.D3.Controls.prototype),GameLib.D3.Controls.Keyboard.prototype.constructor=GameLib.D3.Controls.Keyboard,GameLib.D3.Controls.Keyboard.prototype.createInstance=function(){this.instance=!0,GameLib.D3.Controls.prototype.createInstance.call(this)},GameLib.D3.Controls.Keyboard.prototype.updateInstance=function(){GameLib.D3.Controls.prototype.updateInstance.call(this)},GameLib.D3.Controls.Keyboard.prototype.toApiObject=function(){return GameLib.D3.Controls.prototype.toApiObject.call(this)},GameLib.D3.Controls.Keyboard.FromObject=function(e,t){var i=GameLib.D3.API.Controls.FromObject(t);return new GameLib.D3.Controls.Keyboard(e,i)},GameLib.D3.Controls.Mouse=function(e,t){this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.D3.Controls.call(this,this.graphics,t)}, GameLib.D3.Controls.Mouse.prototype=Object.create(GameLib.D3.Controls.prototype),GameLib.D3.Controls.Mouse.prototype.constructor=GameLib.D3.Controls.Mouse,GameLib.D3.Controls.Mouse.prototype.createInstance=function(){this.instance=!0,GameLib.D3.Controls.prototype.createInstance.call(this)},GameLib.D3.Controls.Mouse.prototype.updateInstance=function(){GameLib.D3.Controls.prototype.updateInstance.call(this)},GameLib.D3.Controls.Mouse.prototype.toApiObject=function(){return GameLib.D3.Controls.prototype.toApiObject.call(this)},GameLib.D3.Controls.Mouse.FromObject=function(e,t){var i=GameLib.D3.API.Controls.FromObject(t);return new GameLib.D3.Controls.Mouse(e,i)},GameLib.D3.Controls.Touch=function(e,t,i){this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(i)&&(i=5),this.sensitivity=i,GameLib.D3.Controls.call(this,this.graphics,t)},GameLib.D3.Controls.Touch.prototype=Object.create(GameLib.D3.Controls.prototype),GameLib.D3.Controls.Touch.prototype.constructor=GameLib.D3.Controls.Touch,GameLib.D3.Controls.Touch.prototype.createInstance=function(){this.instance=!0,GameLib.D3.Controls.prototype.createInstance.call(this)},GameLib.D3.Controls.Touch.prototype.updateInstance=function(){GameLib.D3.Controls.prototype.updateInstance.call(this)},GameLib.D3.Controls.Touch.prototype.toApiObject=function(){var e=GameLib.D3.Controls.prototype.toApiObject.call(this);return e.sensitivity=this.sensitivity,e},GameLib.D3.Controls.Touch.FromObject=function(e,t){var i=GameLib.D3.API.Controls.FromObject(t);return new GameLib.D3.Controls.Touch(e,i,t.sensitivity)},GameLib.D3.CustomCode=function(e){if(GameLib.Utils.UndefinedOrNull(e)&&(e={}),e instanceof GameLib.D3.CustomCode)return e;GameLib.D3.API.CustomCode.call(this,e.id,e.name,e.eventId,e.code,e.parentEntity),this.editor=null,GameLib.Component.call(this,GameLib.Component.COMPONENT_CUSTOM_CODE)},GameLib.D3.CustomCode.prototype=Object.create(GameLib.D3.API.CustomCode.prototype),GameLib.D3.CustomCode.prototype.constructor=GameLib.D3.CustomCode,GameLib.D3.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.D3.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.D3.CustomCode.prototype.toApiObject=function(){return new GameLib.D3.API.CustomCode(this.id,this.name,this.eventId,this.code,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.CustomCode.FromObject=function(e){var t=GameLib.D3.API.CustomCode.FromObject(e);return new GameLib.D3.CustomCode(t)},GameLib.D3.CustomCode.prototype.launchEditor=function(){GameLib.Event.Emit(GameLib.Event.GET_CODER_IMPLEMENTATION,null,function(e){this.coder=e,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.D3.CustomCode.prototype.closeEditor=function(){var e=this.editor.getWrapperElement();e.parentElement.removeChild(e)},GameLib.D3.Face=function(e,t){if(this.implementation=e,e instanceof GameLib.D3.Graphics)this.implementation.isNotThreeThrow();else{if(!(e instanceof GameLib.D3.Physics))throw new Error("Unhandled implementation : "+e);this.implementation.isNotCannonThrow()}if(GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Face)return t;GameLib.D3.API.Face.call(this,t.id,t.name,t.v0index,t.v1index,t.v2index,t.materialIndex,t.uvs,t.color,t.vertexColors,t.vertexNormals,t.normal),this.implementation instanceof GameLib.D3.Graphics&&(this.color=new GameLib.Color(this.implementation,this.color,this),this.vertexColors=this.vertexColors.map(function(e){return e instanceof GameLib.Color?e:e instanceof GameLib.API.Color?new GameLib.Color(this.implementation,e,this):void console.warn("unknown vertex color type",e)}.bind(this))),this.vertexNormals=this.vertexNormals.map(function(e){return e instanceof GameLib.Vector3?e:e instanceof GameLib.API.Vector3?new GameLib.Vector3(this.implementation,e,this):void console.warn("unknown vertex normal type",e)}.bind(this)),this.uvs=this.uvs.reduce(function(e,t,i){return e[i]=t.reduce(function(e,t){return t instanceof GameLib.API.Vector2?e.push(new GameLib.Vector2(this.implementation,t,this)):console.warn("unknown uv type"),e}.bind(this),[]),e}.bind(this),[]),this.normal=new GameLib.Vector3(this.implementation,this.normal,this)},GameLib.D3.Face.prototype=Object.create(GameLib.D3.API.Face.prototype),GameLib.D3.Face.prototype.constructor=GameLib.D3.Face,GameLib.D3.Face.prototype.createInstance=function(){},GameLib.D3.Face.prototype.updateInstance=function(){},GameLib.D3.Face.prototype.toApiObject=function(){return new GameLib.D3.API.Face(this.id,this.name,this.v0index,this.v1index,this.v2index,this.materialIndex,this.uvs.reduce(function(e,t,i){return e[i]=t.reduce(function(e,t){return t instanceof GameLib.Vector2?e.push(t.toApiObject()):console.warn("unknown uv type - cannot commit to API"),e}.bind(this),[]),e}.bind(this),[]),this.color.toApiObject(),this.vertexColors.map(function(e){return e.toApiObject()}),this.vertexNormals.map(function(e){return e.toApiObject()}),this.normal.toApiObject())},GameLib.D3.Face.FromObject=function(e,t){return new GameLib.D3.Face(e,GameLib.D3.API.Face.FromObject(t))},GameLib.D3.Fog=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Fog)return t;GameLib.D3.API.Fog.call(this,t.id,t.name,t.exponential,t.color,t.near,t.far,t.density,t.parentEntity),this.color=new GameLib.Color(this.graphics,this.color,this),GameLib.Component.call(this,GameLib.Component.COMPONENT_FOG)},GameLib.D3.Fog.prototype=Object.create(GameLib.D3.API.Fog.prototype),GameLib.D3.Fog.prototype.constructor=GameLib.D3.Fog,GameLib.D3.Fog.prototype.createInstance=function(){this.exponential?this.instance=new THREE.FogExp2(this.color.instance,this.density):this.instance=new THREE.Fog(this.color.instance,this.near,this.far),this.instance.name=this.name,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Fog.prototype.updateInstance=function(e){if("exponential"===e){if(this.exponential&&!(this.instance instanceof THREE.FogExp2))return void this.createInstance();if(!(this.exponential||this.instance instanceof THREE.Fog))return void this.createInstance()}"color"===e&&(this.color.instance.setRGB(this.color.r,this.color.g,this.color.b),this.instance.color=this.color.instance),"near"!==e&&"far"!==e||this.instance instanceof THREE.Fog&&(this.instance.near=this.near,this.instance.far=this.far),"density"===e&&this.instance instanceof THREE.FogExp2&&(this.instance.density=this.density)},GameLib.D3.Fog.prototype.toApiObject=function(){return new GameLib.D3.API.Fog(this.id,this.name,this.exponential,this.color.toApiObject(),this.near,this.far,this.density,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Fog.FromObject=function(e,t){var i=GameLib.D3.API.Fog.FromObject(t);return new GameLib.D3.Fog(e,i)},GameLib.D3.Font=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Font)return t;GameLib.D3.API.Font.call(this,t.id,t.name,t.url,t.parentEntity),GameLib.Component.call(this,GameLib.Component.COMPONENT_FONT)},GameLib.D3.Font.prototype=Object.create(GameLib.D3.API.Font.prototype),GameLib.D3.Font.prototype.constructor=GameLib.D3.Font,GameLib.D3.Font.prototype.createInstance=function(){GameLib.Event.Emit(GameLib.Event.LOAD_FONT,{font:this},function(e){this.instance=e,GameLib.Component.prototype.createInstance.call(this)}.bind(this),function(e){console.error(e),this.instance=null,GameLib.Component.prototype.createInstance.call(this)}.bind(this))},GameLib.D3.Font.prototype.updateInstance=function(){GameLib.Event.Emit(GameLib.Event.LOAD_FONT,{font:this})},GameLib.D3.Font.prototype.toApiObject=function(){return new GameLib.D3.API.Font(this.id,this.name,this.url,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Font.FromObject=function(e,t){return new GameLib.D3.Font(e,GameLib.D3.API.Font.FromObject(t))},GameLib.D3.FrictionContactMaterial=function(e,t){if(this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.FrictionContactMaterial)return t;GameLib.D3.API.FrictionContactMaterial.call(this,t.id,t.name,t.materials,t.friction,t.restitution,t.contactEquationStiffness,t.contactEquationRelaxation,t.frictionEquationStiffness,t.frictionEquationRelaxation,t.parentEntity),GameLib.Component.call(this,GameLib.Component.COMPONENT_FRICTION_CONTACT_MATERIAL,{materials:[GameLib.D3.FrictionMaterial]})},GameLib.D3.FrictionContactMaterial.prototype=Object.create(GameLib.D3.API.FrictionContactMaterial.prototype),GameLib.D3.FrictionContactMaterial.prototype.constructor=GameLib.D3.FrictionContactMaterial,GameLib.D3.FrictionContactMaterial.prototype.createInstance=function(){this.instance=new CANNON.ContactMaterial(null,null,{friction:this.friction,restitution:this.restitution,contactEquationStiffness:this.contactEquationStiffness}),this.instance.materials=this.materials.map(function(e){return e.instance}),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.FrictionContactMaterial.prototype.updateInstance=function(){this.instance.materials=this.materials.map(function(e){return e.instance}),this.instance.friction=this.friction,this.instance.restitution=this.restitution,this.instance.contactEquationStiffness=this.contactEquationStiffness,this.instance.contactEquationRelaxation=this.contactEquationRelaxation,this.instance.frictionEquationStiffness=this.frictionEquationStiffness,this.instance.frictionEquationRelaxation=this.frictionEquationRelaxation},GameLib.D3.FrictionContactMaterial.prototype.toApiObject=function(){return new GameLib.D3.API.FrictionContactMaterial(this.id,this.name,this.materials.map(function(e){return GameLib.Utils.IdOrNull(e)}),this.friction,this.restitution,this.contactEquationStiffness,this.contactEquationRelaxation,this.frictionEquationStiffness,this.frictionEquationRelaxation,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.FrictionContactMaterial.FromObject=function(e,t){var i=GameLib.D3.API.FrictionContactMaterial.FromObject(t);return new GameLib.D3.FrictionContactMaterial(e,i)},GameLib.D3.FrictionMaterial=function(e,t){if(this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.FrictionMaterial)return t;GameLib.D3.API.FrictionMaterial.call(this,t.id,t.name,t.friction,t.restitution,t.parentEntity),GameLib.Component.call(this,GameLib.Component.COMPONENT_FRICTION_MATERIAL)},GameLib.D3.FrictionMaterial.prototype=Object.create(GameLib.D3.API.FrictionMaterial.prototype),GameLib.D3.FrictionMaterial.prototype.constructor=GameLib.D3.FrictionMaterial,GameLib.D3.FrictionMaterial.prototype.createInstance=function(){this.instance=new CANNON.Material(this.name),this.instance.friction=this.friction,this.instance.restitution=this.restitution,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.FrictionMaterial.prototype.updateInstance=function(){this.instance.friction=this.friction,this.instance.restitution=this.restitution,this.instance.name=this.name},GameLib.D3.FrictionMaterial.prototype.toApiObject=function(){return new GameLib.D3.API.FrictionMaterial(this.id,this.name,this.friction,this.restitution,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.FrictionMaterial.FromObject=function(e,t){var i=GameLib.D3.API.FrictionMaterial.FromObject(t);return new GameLib.D3.FrictionMaterial(e,i)},GameLib.D3.Graphics=function(e,t,i){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Graphics ("+e+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=GameLib.D3.Graphics.GRAPHICS_TYPE_THREE),this.graphicsType=i,this.createInstance()},GameLib.D3.Graphics.GRAPHICS_TYPE_THREE=1,GameLib.D3.Graphics.prototype.createInstance=function(){this.instance=THREE},GameLib.D3.Graphics.prototype.updateInstance=function(){},GameLib.D3.Graphics.prototype.isThree=function(){return this.graphicsType===GameLib.D3.Graphics.GRAPHICS_TYPE_THREE},GameLib.D3.Graphics.prototype.isNotThreeThrow=function(){if(this.graphicsType!==GameLib.D3.Graphics.GRAPHICS_TYPE_THREE)throw console.warn("Only THREE supported for this function"),new Error("Only THREE supported for this function")},GameLib.D3.Helper=function(e,t,i,n,s,a){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t=GameLib.Utils.RandomId()),this.id=t,GameLib.Utils.UndefinedOrNull(i)&&(i="Helper ("+t+")"),this.name=i,GameLib.Utils.UndefinedOrNull(n))throw console.warn("Cannot create a helper for an Object which does not exist"),new Error("Cannot create a helper for an Object which does not exist");this.object=n,GameLib.Utils.UndefinedOrNull(s)&&(s=GameLib.D3.Helper.HELPER_TYPE_NONE,n instanceof GameLib.D3.Mesh&&n.meshType!==GameLib.D3.Mesh.MESH_TYPE_CURVE&&(s=GameLib.D3.Helper.HELPER_TYPE_EDGES),n instanceof GameLib.D3.Light&&(n.lightType===GameLib.D3.Light.LIGHT_TYPE_DIRECTIONAL&&(s=GameLib.D3.Helper.HELPER_TYPE_DIRECTIONAL_LIGHT),n.lightType===GameLib.D3.Light.LIGHT_TYPE_POINT&&(s=GameLib.D3.Helper.HELPER_TYPE_POINT_LIGHT),n.lightType===GameLib.D3.Light.LIGHT_TYPE_SPOT&&(s=GameLib.D3.Helper.HELPER_TYPE_SPOT_LIGHT)),n instanceof GameLib.D3.Skeleton&&(s=GameLib.D3.Helper.HELPER_TYPE_SKELETON)),this.helperType=s,GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.parentEntity=a,this.createInstance()},GameLib.D3.Helper.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.Helper.prototype.constructor=GameLib.D3.Helper,GameLib.D3.Helper.HELPER_TYPE_NONE=0,GameLib.D3.Helper.HELPER_TYPE_EDGES=1,GameLib.D3.Helper.HELPER_TYPE_DIRECTIONAL_LIGHT=2,GameLib.D3.Helper.HELPER_TYPE_SPOT_LIGHT=3,GameLib.D3.Helper.HELPER_TYPE_POINT_LIGHT=4,GameLib.D3.Helper.HELPER_TYPE_WIREFRAME=5,GameLib.D3.Helper.HELPER_TYPE_SKELETON=6,GameLib.D3.Helper.prototype.createInstance=function(){this.helperType===GameLib.D3.Helper.HELPER_TYPE_EDGES&&(this.instance=new THREE.LineSegments(new THREE.EdgesGeometry(this.object.instance.geometry),new THREE.LineBasicMaterial({color:65280,linewidth:2}))),this.helperType===GameLib.D3.Helper.HELPER_TYPE_DIRECTIONAL_LIGHT&&(this.instance=new THREE.DirectionalLightHelper(this.object.instance)),this.helperType===GameLib.D3.Helper.HELPER_TYPE_POINT_LIGHT&&(this.instance=new THREE.PointLightHelper(this.object.instance,1)),this.helperType===GameLib.D3.Helper.HELPER_TYPE_SPOT_LIGHT&&(this.instance=new THREE.SpotLightHelper(this.object.instance)),this.helperType===GameLib.D3.Helper.HELPER_TYPE_WIREFRAME&&(this.instance=new THREE.WireframeGeometry(this.object.instance,65280)),this.helperType===GameLib.D3.Helper.HELPER_TYPE_SKELETON&&(this.instance=new THREE.SkeletonHelper(this.object.instance))},GameLib.D3.Helper.prototype.updateInstance=function(){this.instance.position.copy(this.object.instance.position),this.object.instance.parentMesh&&this.object.instance.parentMesh.instance&&this.instance.position.add(this.object.instance.parentMesh.instance.position),this.instance.scale.copy(this.object.instance.scale),this.instance.quaternion.copy(this.object.instance.quaternion)},GameLib.D3.Image=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Image)return t;GameLib.D3.API.Image.call(this,t.id,t.name,t.fileName,t.extension,t.path,t.contentType,t.size,t.parentEntity),GameLib.Component.call(this,GameLib.Component.COMPONENT_IMAGE,null,!0),GameLib.Event.Emit(GameLib.Event.LOAD_IMAGE,{image:this})},GameLib.D3.Image.prototype=Object.create(GameLib.D3.API.Image.prototype),GameLib.D3.Image.prototype.constructor=GameLib.D3.Image,GameLib.D3.Image.prototype.createInstance=function(){GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Image.prototype.updateInstance=function(){this.createInstance()},GameLib.D3.Image.prototype.toApiObject=function(){return new GameLib.D3.API.Image(this.id,this.name,this.fileName,this.extension,this.path,this.contentType,this.size,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Image.FromObject=function(e,t){return new GameLib.D3.Image(e,GameLib.D3.API.Image.FromObject(t))},GameLib.D3.Light=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Light)return t;GameLib.D3.API.Light.call(this,t.id,t.lightType,t.name,t.color,t.intensity,t.position,t.targetPosition,t.quaternion,t.rotation,t.scale,t.distance,t.decay,t.power,t.angle,t.penumbra,t.parentScene,t.parentEntity),this.color=new GameLib.Color(e,this.color,this),this.position=new GameLib.Vector3(e,this.position,this),this.targetPosition=new GameLib.Vector3(e,this.targetPosition,this),this.scale=new GameLib.Vector3(e,this.scale,this),this.quaternion=new GameLib.Quaternion(e,this.quaternion,this),this.rotation=new GameLib.Vector3(e,this.rotation,this),GameLib.Component.call(this,GameLib.Component.COMPONENT_LIGHT,{parentScene:GameLib.D3.Scene})},GameLib.D3.Light.prototype=Object.create(GameLib.D3.API.Light.prototype),GameLib.D3.Light.prototype.constructor=GameLib.D3.Light,GameLib.D3.Light.LIGHT_TYPE_AMBIENT=1,GameLib.D3.Light.LIGHT_TYPE_DIRECTIONAL=2,GameLib.D3.Light.LIGHT_TYPE_POINT=3,GameLib.D3.Light.LIGHT_TYPE_SPOT=4,GameLib.D3.Light.prototype.createInstance=function(){if(this.lightType===GameLib.D3.Light.LIGHT_TYPE_AMBIENT||"AmbientLight"===this.lightType)this.instance=new THREE.AmbientLight(this.color.instance,this.intensity);else if(this.lightType===GameLib.D3.Light.LIGHT_TYPE_DIRECTIONAL||"DirectionalLight"===this.lightType)this.instance=new THREE.DirectionalLight(this.color.instance,this.intensity);else if(this.lightType===GameLib.D3.Light.LIGHT_TYPE_POINT||"PointLight"===this.lightType)this.instance=new THREE.PointLight(this.color.instance,this.intensity),this.instance.distance=this.distance,this.instance.decay=this.decay;else{if(this.lightType!==GameLib.D3.Light.LIGHT_TYPE_SPOT&&"SpotLight"!==this.lightType)return void console.warn("unsupported light type: "+this.lightType);this.instance=new THREE.SpotLight(this.color.instance,this.intensity),this.instance.distance=this.distance,this.instance.angle=this.angle,this.instance.penumbra=this.penumbra,this.instance.decay=this.decay}this.instance.name=this.name,this.instance.position.x=this.position.x,this.instance.position.y=this.position.y,this.instance.position.z=this.position.z,this.instance.scale.x=this.scale.x,this.instance.scale.y=this.scale.y,this.instance.scale.z=this.scale.z,this.instance.target&&(this.instance.target.position.x=this.targetPosition.x,this.instance.target.position.y=this.targetPosition.y,this.instance.target.position.z=this.targetPosition.z),this.instance.quaternion.x=this.quaternion.x,this.instance.quaternion.y=this.quaternion.y,this.instance.quaternion.z=this.quaternion.z,this.instance.quaternion.w=this.quaternion.w,this.instance.intensity=this.intensity,this.instance.color.set(this.color.toHex()),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Light.prototype.updateInstance=function(e){GameLib.Utils.UndefinedOrNull(e)&&console.warn("no property for light: "+this.name),"lightType"===e&&(this.parentScene.instance.remove(this.instance),this.createInstance(),this.parentScene.instance.add(this.instance)),"name"===e&&(this.instance.name=this.name),"position"===e&&(this.instance.position.x=this.position.x,this.instance.position.y=this.position.y,this.instance.position.z=this.position.z),"scale"===e&&(this.instance.scale.x=this.scale.x,this.instance.scale.y=this.scale.y,this.instance.scale.z=this.scale.z),"target"===e&&this.instance.target&&(this.instance.target.position.x=this.targetPosition.x,this.instance.target.position.y=this.targetPosition.y,this.instance.target.position.z=this.targetPosition.z),"quaternion"===e&&(this.instance.quaternion.x=this.quaternion.x,this.instance.quaternion.y=this.quaternion.y,this.instance.quaternion.z=this.quaternion.z,this.instance.quaternion.w=this.quaternion.w),"intensity"===e&&(this.instance.intensity=this.intensity),"color"===e&&this.instance.color.set(this.color.toHex())},GameLib.D3.Light.prototype.toApiObject=function(){return new GameLib.D3.API.Light(this.id,this.lightType,this.name,this.color.toApiObject(),this.intensity,this.position.toApiObject(),this.targetPosition.toApiObject(),this.quaternion.toApiObject(),this.rotation.toApiObject(),this.scale.toApiObject(),this.distance,this.decay,this.power,this.angle,this.penumbra,GameLib.Utils.IdOrNull(this.parentScene),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Light.FromObject=function(e,t){return new GameLib.D3.Light(e,GameLib.D3.API.Light.FromObject(t))},GameLib.D3.LookAt=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.LookAt)return t;GameLib.D3.API.LookAt.call(this,t.id,t.name,t.currentComponent,t.targetComponent,t.targetPositionOffset,t.rotationSpeed,t.parentEntity),this.targetPositionOffset=new GameLib.Vector3(this.graphics,this.targetPositionOffset,this),this.lookAtMatrix=new GameLib.Matrix4(this.graphics,this.lookAtMatrix,this),this.up=new GameLib.Vector3(this.graphics,this.up,this),this.currentRotation=new GameLib.Quaternion(this.graphics,this.currentRotation,this),this.targetPosition=new GameLib.Vector3(this.graphics,this.targetPosition,this),GameLib.Component.call(this,GameLib.Component.COMPONENT_LOOK_AT,{currentComponent:GameLib.Component,targetComponent:GameLib.Component})},GameLib.D3.LookAt.prototype=Object.create(GameLib.D3.API.LookAt.prototype),GameLib.D3.LookAt.prototype.constructor=GameLib.D3.LookAt,GameLib.D3.LookAt.prototype.createInstance=function(){this.instance=!0,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.LookAt.prototype.updateInstance=function(){},GameLib.D3.LookAt.prototype.toApiObject=function(){return new GameLib.D3.API.LookAt(this.id,this.name,GameLib.Utils.IdOrNull(this.currentComponent),GameLib.Utils.IdOrNull(this.targetComponent),this.targetPositionOffset.toApiObject(),this.rotationSpeed,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.LookAt.FromObject=function(e,t){var i=GameLib.D3.API.LookAt.FromObject(t);return new GameLib.D3.LookAt(e,i)},GameLib.D3.LookAt.prototype.update=function(e){this.currentComponent&&this.targetComponent&&(this.targetPosition.x=this.targetComponent.position.x+this.targetPositionOffset.x,this.targetPosition.y=this.targetComponent.position.y+this.targetPositionOffset.y,this.targetPosition.z=this.targetComponent.position.z+this.targetPositionOffset.z,this.targetPosition.updateInstance(),this.currentComponent.lookAt.x=this.targetPosition.x,this.currentComponent.lookAt.y=this.targetPosition.y,this.currentComponent.lookAt.z=this.targetPosition.z,this.currentComponent.lookAt.updateInstance())},GameLib.D3.Material=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Material)return t;GameLib.D3.API.Material.call(this,t.id,t.materialType,t.name,t.opacity,t.side,t.transparent,t.specular,t.lightMapIntensity,t.aoMapIntensity,t.color,t.emissive,t.emissiveIntensity,t.combine,t.shininess,t.reflectivity,t.refractionRatio,t.fog,t.wireframe,t.wireframeLineWidth,t.wireframeLineCap,t.wireframeLineJoin,t.vertexColors,t.skinning,t.morphTargets,t.morphNormals,t.lineWidth,t.lineCap,t.lineJoin,t.dashSize,t.gapWidth,t.blending,t.blendSrc,t.blendDst,t.blendEquation,t.depthTest,t.depthFunc,t.depthWrite,t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits,t.alphaTest,t.clippingPlanes,t.clipShadows,t.visible,t.overdraw,t.flatShading,t.bumpScale,t.normalScale,t.displacementScale,t.displacementBias,t.roughness,t.metalness,t.pointSize,t.pointSizeAttenuation,t.spriteRotation,t.envMapIntensity,t.alphaMap,t.aoMap,t.bumpMap,t.diffuseMap,t.displacementMap,t.emissiveMap,t.environmentMap,t.lightMap,t.metalnessMap,t.normalMap,t.roughnessMap,t.specularMap,t.parentEntity),this.specular=new GameLib.Color(e,this.specular,this),this.color=new GameLib.Color(e,this.color,this),this.emissive=new GameLib.Color(e,this.emissive,this),this.alphaMap&&this.alphaMap instanceof GameLib.D3.API.Texture&&(this.alphaMap=new GameLib.D3.Texture(this.graphics,this.alphaMap)),this.aoMap&&this.aoMap instanceof GameLib.D3.API.Texture&&(this.aoMap=new GameLib.D3.Texture(this.graphics,this.aoMap)),this.bumpMap&&this.bumpMap instanceof GameLib.D3.API.Texture&&(this.bumpMap=new GameLib.D3.Texture(this.graphics,this.bumpMap)),this.diffuseMap&&this.diffuseMap instanceof GameLib.D3.API.Texture&&(this.diffuseMap=new GameLib.D3.Texture(this.graphics,this.diffuseMap)),this.displacementMap&&this.displacementMap instanceof GameLib.D3.API.Texture&&(this.displacementMap=new GameLib.D3.Texture(this.graphics,this.displacementMap)),this.emissiveMap&&this.emissiveMap instanceof GameLib.D3.API.Texture&&(this.emissiveMap=new GameLib.D3.Texture(this.graphics,this.emissiveMap)),this.environmentMap&&this.environmentMap instanceof GameLib.D3.API.Texture&&(this.environmentMap=new GameLib.D3.Texture(this.graphics,this.environmentMap)),this.lightMap&&this.lightMap instanceof GameLib.D3.API.Texture&&(this.lightMap=new GameLib.D3.Texture(this.graphics,this.lightMap)),this.metalnessMap&&this.metalnessMap instanceof GameLib.D3.API.Texture&&(this.metalnessMap=new GameLib.D3.Texture(this.graphics,this.metalnessMap)),this.normalMap&&this.normalMap instanceof GameLib.D3.API.Texture&&(this.normalMap=new GameLib.D3.Texture(this.graphics,this.normalMap)),this.roughnessMap&&this.roughnessMap instanceof GameLib.D3.API.Texture&&(this.roughnessMap=new GameLib.D3.Texture(this.graphics,this.roughnessMap)),this.specularMap&&this.specularMap instanceof GameLib.D3.API.Texture&&(this.specularMap=new GameLib.D3.Texture(this.graphics,this.specularMap)),GameLib.Component.call(this,GameLib.Component.COMPONENT_MATERIAL,{alphaMap:GameLib.D3.Texture,aoMap:GameLib.D3.Texture,bumpMap:GameLib.D3.Texture,diffuseMap:GameLib.D3.Texture,displacementMap:GameLib.D3.Texture,emissiveMap:GameLib.D3.Texture,environmentMap:GameLib.D3.Texture,lightMap:GameLib.D3.Texture,metalnessMap:GameLib.D3.Texture,normalMap:GameLib.D3.Texture,roughnessMap:GameLib.D3.Texture,specularMap:GameLib.D3.Texture})},GameLib.D3.Material.prototype=Object.create(GameLib.D3.API.Material.prototype),GameLib.D3.Material.prototype.constructor=GameLib.D3.Material,GameLib.D3.Material.TYPE_MULTIPLY_OPERATION=0,GameLib.D3.Material.TYPE_MIX_OPERATION=1,GameLib.D3.Material.TYPE_ADD_OPERATION=2,GameLib.D3.Material.TYPE_NO_COLORS=0,GameLib.D3.Material.TYPE_FACE_COLORS=1,GameLib.D3.Material.TYPE_VERTEX_COLORS=2,GameLib.D3.Material.TYPE_NO_BLENDING=0,GameLib.D3.Material.TYPE_NORMAL_BLENDING=1,GameLib.D3.Material.TYPE_ADDITIVE_BLENDING=2,GameLib.D3.Material.TYPE_SUBTRACTIVE_BLENDING=3,GameLib.D3.Material.TYPE_MULTIPLY_BLENDING=4,GameLib.D3.Material.TYPE_CUSTOM_BLENDING=5,GameLib.D3.Material.TYPE_ZERO_FACTOR=200,GameLib.D3.Material.TYPE_ONE_FACTOR=201,GameLib.D3.Material.TYPE_SRC_COLOR_FACTOR=202,GameLib.D3.Material.TYPE_ONE_MINUS_SRC_COLOR_FACTOR=203,GameLib.D3.Material.TYPE_SRC_ALPHA_FACTOR=204,GameLib.D3.Material.TYPE_ONE_MINUS_SRC_ALPHA_FACTOR=205,GameLib.D3.Material.TYPE_DST_ALPHA_FACTOR=206,GameLib.D3.Material.TYPE_ONE_MINUS_DST_ALPHA_FACTOR=207,GameLib.D3.Material.TYPE_DST_COLOR_FACTOR=208,GameLib.D3.Material.TYPE_ONE_MINUS_DST_COLOR_FACTOR=209,GameLib.D3.Material.TYPE_SRC_ALPHA_SATURATE_FACTOR=210,GameLib.D3.Material.TYPE_ADD_EQUATION=100,GameLib.D3.Material.TYPE_SUBTRACT_EQUATION=101,GameLib.D3.Material.TYPE_REVERSE_SUBTRACT_EQUATION=102,GameLib.D3.Material.TYPE_MIN_EQUATION=103,GameLib.D3.Material.TYPE_MAX_EQUATION=104,GameLib.D3.Material.TYPE_NEVER_DEPTH=0,GameLib.D3.Material.TYPE_ALWAYS_DEPTH=1,GameLib.D3.Material.TYPE_LESS_DEPTH=2,GameLib.D3.Material.TYPE_LESS_EQUAL_DEPTH=3,GameLib.D3.Material.TYPE_EQUAL_DEPTH=4,GameLib.D3.Material.TYPE_GREATER_EQUAL_DEPTH=5,GameLib.D3.Material.TYPE_GREATER_DEPTH=6,GameLib.D3.Material.TYPE_NOT_EQUAL_DEPTH=7,GameLib.D3.Material.TYPE_FRONT_SIDE=0,GameLib.D3.Material.TYPE_BACK_SIDE=1,GameLib.D3.Material.TYPE_DOUBLE_SIDE=2,GameLib.D3.Material.TYPE_FLAT_SHADING=1,GameLib.D3.Material.TYPE_SMOOTH_SHADING=2,GameLib.D3.Material.MATERIAL_TYPE_LINE_BASIC=1,GameLib.D3.Material.MATERIAL_TYPE_LINE_DASHED=2,GameLib.D3.Material.MATERIAL_TYPE_BASIC=3,GameLib.D3.Material.MATERIAL_TYPE_DEPTH=4,GameLib.D3.Material.MATERIAL_TYPE_LAMBERT=5,GameLib.D3.Material.MATERIAL_TYPE_NORMAL=6,GameLib.D3.Material.MATERIAL_TYPE_PHONG=7,GameLib.D3.Material.MATERIAL_TYPE_STANDARD=8,GameLib.D3.Material.MATERIAL_TYPE_POINTS=9,GameLib.D3.Material.MATERIAL_TYPE_SPRITE=10,GameLib.D3.Material.MATERIAL_TYPE_TOON=11,GameLib.D3.Material.LINE_CAP_BUTT=1,GameLib.D3.Material.LINE_CAP_ROUND=2,GameLib.D3.Material.LINE_CAP_SQUARE=3,GameLib.D3.Material.LINE_JOIN_ROUND=1,GameLib.D3.Material.LINE_JOIN_BEVEL=2,GameLib.D3.Material.LINE_JOIN_MITER=3,GameLib.D3.Material.prototype.createToonMaterialInstance=function(){return new THREE.MeshToonMaterial({name:this.name,opacity:this.opacity,transparent:this.transparent,blending:this.blending,blendSrc:this.blendSrc,blendDst:this.blendDst,blendEquation:this.blendEquation,depthTest:this.depthTest,depthFunc:this.depthFunc,depthWrite:this.depthWrite,polygonOffset:this.polygonOffset,polygonOffsetFactor:this.polygonOffsetFactor,polygonOffsetUnits:this.polygonOffsetUnits,alphaTest:this.alphaTest,clippingPlanes:this.clippingPlanes,clipShadows:this.clipShadows,overdraw:this.overdraw,visible:this.visible,side:this.side,color:this.color.instance,roughness:this.roughness,metalness:this.metalness,lightMapIntensity:this.lightMapIntensity,aoMapIntensity:this.aoMapIntensity,emissive:this.emissive.instance,emissiveIntensity:this.emissiveIntensity,bumpScale:this.bumpScale,normalScale:this.normalScale,displacementScale:this.displacementScale,refractionRatio:this.refractionRatio,fog:this.fog,flatShading:this.flatShading,wireframe:this.wireframe,wireframeLinewidth:this.wireframeLineWidth,wireframeLinecap:this.wireframeLineCap,wireframeLinejoin:this.wireframeLineJoin,vertexColors:GameLib.D3.Material.TYPE_VERTEX_COLORS,skinning:this.skinning,morphTargets:this.morphTargets,morphNormals:this.morphNormals})},GameLib.D3.Material.prototype.createStandardMaterialInstance=function(){return new THREE.MeshStandardMaterial({name:this.name,opacity:this.opacity,transparent:this.transparent,blending:this.blending,blendSrc:this.blendSrc,blendDst:this.blendDst,blendEquation:this.blendEquation,depthTest:this.depthTest,depthFunc:this.depthFunc,depthWrite:this.depthWrite,polygonOffset:this.polygonOffset,polygonOffsetFactor:this.polygonOffsetFactor,polygonOffsetUnits:this.polygonOffsetUnits,alphaTest:this.alphaTest,clippingPlanes:this.clippingPlanes,clipShadows:this.clipShadows,overdraw:this.overdraw,visible:this.visible,side:this.side,color:this.color.instance,roughness:this.roughness,metalness:this.metalness,lightMapIntensity:this.lightMapIntensity,aoMapIntensity:this.aoMapIntensity,emissive:this.emissive.instance,emissiveIntensity:this.emissiveIntensity,bumpScale:this.bumpScale,normalScale:this.normalScale,displacementScale:this.displacementScale,refractionRatio:this.refractionRatio,fog:this.fog,flatShading:this.flatShading,wireframe:this.wireframe,wireframeLinewidth:this.wireframeLineWidth,wireframeLinecap:this.wireframeLineCap,wireframeLinejoin:this.wireframeLineJoin, -vertexColors:GameLib.D3.Material.TYPE_VERTEX_COLORS,skinning:this.skinning,morphTargets:this.morphTargets,morphNormals:this.morphNormals})},GameLib.D3.Material.prototype.createPointsMaterialInstance=function(){return new THREE.PointsMaterial({name:this.name,opacity:this.opacity,transparent:this.transparent,depthTest:this.depthTest,depthFunc:this.depthFunc,depthWrite:this.depthWrite,visible:this.visible,side:this.side,color:this.color.instance,size:this.pointSize,sizeAttenuation:this.pointSizeAttenuation})},GameLib.D3.Material.prototype.createLineBasicMaterialInstance=function(){var e="round";this.lineCap===GameLib.D3.Material.LINE_CAP_BUTT&&(e="butt"),this.lineCap===GameLib.D3.Material.LINE_CAP_SQUARE&&(e="square");var t="round";return this.lineJoin===GameLib.D3.Material.LINE_JOIN_BEVEL&&(t="bevel"),this.lineJoin===GameLib.D3.Material.LINE_JOIN_MITER&&(t="miter"),new THREE.LineBasicMaterial({name:this.name,opacity:this.opacity,transparent:this.transparent,depthTest:this.depthTest,depthFunc:this.depthFunc,depthWrite:this.depthWrite,visible:this.visible,side:this.side,color:this.color.instance,linewidth:this.lineWidth,linecap:e,linejoin:t})},GameLib.D3.Material.prototype.createPhongMaterialInstance=function(){return new THREE.MeshPhongMaterial({name:this.name,opacity:this.opacity,transparent:this.transparent,blending:this.blending,blendSrc:this.blendSrc,blendDst:this.blendDst,blendEquation:this.blendEquation,depthTest:this.depthTest,depthFunc:this.depthFunc,depthWrite:this.depthWrite,polygonOffset:this.polygonOffset,polygonOffsetFactor:this.polygonOffsetFactor,polygonOffsetUnits:this.polygonOffsetUnits,alphaTest:this.alphaTest,clippingPlanes:this.clippingPlanes,clipShadows:this.clipShadows,overdraw:this.overdraw,visible:this.visible,side:this.side,color:this.color.instance,specular:this.specular.instance,shininess:this.shininess,lightMapIntensity:this.lightMapIntensity,aoMapIntensity:this.aoMapIntensity,emissive:this.emissive.instance,emissiveIntensity:this.emissiveIntensity,bumpScale:this.bumpScale,normalScale:this.normalScale,displacementScale:this.displacementScale,combine:this.combine,refractionRatio:this.refractionRatio,fog:this.fog,flatShading:this.flatShading,wireframe:this.wireframe,wireframeLinewidth:this.wireframeLineWidth,wireframeLinecap:this.wireframeLineCap,wireframeLinejoin:this.wireframeLineJoin,vertexColors:GameLib.D3.Material.TYPE_VERTEX_COLORS,skinning:this.skinning,morphTargets:this.morphTargets,morphNormals:this.morphNormals})},GameLib.D3.Material.prototype.createMeshBasicMaterialInstance=function(){return new THREE.MeshBasicMaterial({name:this.name,opacity:this.opacity,transparent:this.transparent,blending:this.blending,blendSrc:this.blendSrc,blendDst:this.blendDst,blendEquation:this.blendEquation,depthTest:this.depthTest,depthFunc:this.depthFunc,depthWrite:this.depthWrite,polygonOffset:this.polygonOffset,polygonOffsetFactor:this.polygonOffsetFactor,polygonOffsetUnits:this.polygonOffsetUnits,alphaTest:this.alphaTest,clippingPlanes:this.clippingPlanes,clipShadows:this.clipShadows,overdraw:this.overdraw,visible:this.visible,side:this.side,color:this.color.instance,vertexColors:GameLib.D3.Material.TYPE_VERTEX_COLORS,fog:this.fog})},GameLib.D3.Material.prototype.checkTexture=function(e,t){var i=!1;return this[e]&&this[e].instance?this.instance[t]!==this[e].instance&&(this.instance[t]=this[e].instance,i=!0):null!==this.instance[t]&&(this.instance[t]=null,i=!0),i},GameLib.D3.Material.prototype.updateTextures=function(){var e=!1;return this.checkTexture("alphaMap","alphaMap")&&(e=!0),this.checkTexture("aoMap","aoMap")&&(e=!0),this.checkTexture("bumpMap","bumpMap")&&(e=!0),this.checkTexture("diffuseMap","map")&&(e=!0),this.checkTexture("displacementMap","displacementMap")&&(e=!0),this.checkTexture("emissiveMap","emissiveMap")&&(e=!0),this.checkTexture("environmentMap","envMap")&&(e=!0),this.checkTexture("lightMap","lightMap")&&(e=!0),this.checkTexture("metalnessMap","metalnessMap")&&(e=!0),this.checkTexture("normalMap","normalMap")&&(e=!0),this.checkTexture("roughnessMap","roughnessMap")&&(e=!0),this.checkTexture("specularMap","specularMap")&&(e=!0),e&&this.publish(GameLib.Event.MATERIAL_TEXTURES_UPDATED,{material:this}),e},GameLib.D3.Material.prototype.updateToonMaterialInstance=function(e){this.instance.name=this.name,this.instance.opacity=this.opacity,this.instance.transparent=this.transparent,this.instance.blending=this.blending,this.instance.blendSrc=this.blendSrc,this.instance.blendDst=this.blendDst,this.instance.blendEquation=this.blendEquation,this.instance.depthTest=this.depthTest,this.instance.depthFunc=this.depthFunc,this.instance.depthWrite=this.depthWrite,this.instance.polygonOffset=this.polygonOffset,this.instance.polygonOffsetFactor=this.polygonOffsetFactor,this.instance.polygonOffsetUnits=this.polygonOffsetUnits,this.instance.alphaTest=this.alphaTest,this.instance.clippingPlanes=this.clippingPlanes,this.instance.clipShadows=this.clipShadows,this.instance.overdraw=this.overdraw,this.instance.visible=this.visible,this.instance.side=this.side,this.instance.color=this.color.instance,this.instance.envMapIntensity=this.envMapIntensity,this.instance.roughness=this.roughness,this.instance.metalness=this.metalness,this.instance.lightMapIntensity=this.lightMapIntensity,this.instance.aoMapIntensity=this.aoMapIntensity,this.instance.emissive=this.emissive.instance,this.instance.emissiveIntensity=this.emissiveIntensity,this.instance.bumpScale=this.bumpScale,this.instance.normalScale=this.normalScale,this.instance.displacementScale=this.displacementScale,this.instance.refractionRatio=this.refractionRatio,this.instance.fog=this.fog,this.instance.flatShading=this.flatShading,this.instance.wireframe=this.wireframe,this.instance.wireframeLinewidth=this.wireframeLineWidth,this.instance.wireframeLinecap=this.wireframeLineCap,this.instance.wireframeLinejoin=this.wireframeLineJoin,this.instance.vertexColors=GameLib.D3.Material.TYPE_VERTEX_COLORS,this.instance.skinning=this.skinning,this.instance.morphTargets=this.morphTargets,this.instance.morphNormals=this.morphNormals},GameLib.D3.Material.prototype.updateStandardMaterialInstance=function(e){this.instance.name=this.name,this.instance.opacity=this.opacity,this.instance.transparent=this.transparent,this.instance.blending=this.blending,this.instance.blendSrc=this.blendSrc,this.instance.blendDst=this.blendDst,this.instance.blendEquation=this.blendEquation,this.instance.depthTest=this.depthTest,this.instance.depthFunc=this.depthFunc,this.instance.depthWrite=this.depthWrite,this.instance.polygonOffset=this.polygonOffset,this.instance.polygonOffsetFactor=this.polygonOffsetFactor,this.instance.polygonOffsetUnits=this.polygonOffsetUnits,this.instance.alphaTest=this.alphaTest,this.instance.clippingPlanes=this.clippingPlanes,this.instance.clipShadows=this.clipShadows,this.instance.overdraw=this.overdraw,this.instance.visible=this.visible,this.instance.side=this.side,this.instance.color=this.color.instance,this.instance.envMapIntensity=this.envMapIntensity,this.instance.roughness=this.roughness,this.instance.metalness=this.metalness,this.instance.lightMapIntensity=this.lightMapIntensity,this.instance.aoMapIntensity=this.aoMapIntensity,this.instance.emissive=this.emissive.instance,this.instance.emissiveIntensity=this.emissiveIntensity,this.instance.bumpScale=this.bumpScale,this.instance.normalScale=this.normalScale,this.instance.displacementScale=this.displacementScale,this.instance.refractionRatio=this.refractionRatio,this.instance.fog=this.fog,this.instance.flatShading=this.flatShading,this.instance.wireframe=this.wireframe,this.instance.wireframeLinewidth=this.wireframeLineWidth,this.instance.wireframeLinecap=this.wireframeLineCap,this.instance.wireframeLinejoin=this.wireframeLineJoin,this.instance.vertexColors=GameLib.D3.Material.TYPE_VERTEX_COLORS,this.instance.skinning=this.skinning,this.instance.morphTargets=this.morphTargets,this.instance.morphNormals=this.morphNormals},GameLib.D3.Material.prototype.updatePointsMaterialInstance=function(e){this.instance.name=this.name,this.instance.opacity=this.opacity,this.instance.transparent=this.transparent,this.instance.depthFunc=this.depthFunc,this.instance.depthWrite=this.depthWrite,this.instance.visible=this.visible,this.instance.side=this.side,this.instance.color=this.color.instance,this.instance.size=this.pointSize,this.instance.sizeAttenuation=this.pointSizeAttenuation},GameLib.D3.Material.prototype.updateLineBasicMaterialInstance=function(e){var t="round";this.lineCap===GameLib.D3.Material.LINE_CAP_BUTT&&(t="butt"),this.lineCap===GameLib.D3.Material.LINE_CAP_SQUARE&&(t="square");var i="round";this.lineJoin===GameLib.D3.Material.LINE_JOIN_BEVEL&&(i="bevel"),this.lineJoin===GameLib.D3.Material.LINE_JOIN_MITER&&(i="miter"),this.instance.name=this.name,this.instance.opacity=this.opacity,this.instance.transparent=this.transparent,this.instance.depthFunc=this.depthFunc,this.instance.depthWrite=this.depthWrite,this.instance.visible=this.visible,this.instance.side=this.side,this.instance.color=this.color.instance,this.instance.linewidth=this.lineWidth,this.instance.linecap=t,this.instance.linejoin=i},GameLib.D3.Material.prototype.updatePhongMaterialInstance=function(e){this.instance.name=this.name,this.instance.opacity=this.opacity,this.instance.transparent=this.transparent,this.instance.blending=this.blending,this.instance.blendSrc=this.blendSrc,this.instance.blendDst=this.blendDst,this.instance.blendEquation=this.blendEquation,this.instance.depthTest=this.depthTest,this.instance.depthFunc=this.depthFunc,this.instance.depthWrite=this.depthWrite,this.instance.polygonOffset=this.polygonOffset,this.instance.polygonOffsetFactor=this.polygonOffsetFactor,this.instance.polygonOffsetUnits=this.polygonOffsetUnits,this.instance.alphaTest=this.alphaTest,this.instance.clippingPlanes=this.clippingPlanes,this.instance.clipShadows=this.clipShadows,this.instance.overdraw=this.overdraw,this.instance.visible=this.visible,this.instance.side=this.side,this.instance.color=this.color.instance,this.instance.specular=this.specular.instance,this.instance.shininess=this.shininess,this.instance.lightMapIntensity=this.lightMapIntensity,this.instance.aoMapIntensity=this.aoMapIntensity,this.instance.emissive=this.emissive.instance,this.instance.emissiveIntensity=this.emissiveIntensity,this.instance.envMapIntensity=this.envMapIntensity,this.instance.bumpScale=this.bumpScale,this.instance.normalScale=this.normalScale,this.instance.displacementScale=this.displacementScale,this.instance.combine=this.combine,this.instance.refractionRatio=this.refractionRatio,this.instance.fog=this.fog,this.instance.flatShading=this.flatShading,this.instance.wireframe=this.wireframe,this.instance.wireframeLinewidth=this.wireframeLineWidth,this.instance.wireframeLinecap=this.wireframeLineCap,this.instance.wireframeLinejoin=this.wireframeLineJoin,this.instance.vertexColors=GameLib.D3.Material.TYPE_VERTEX_COLORS,this.instance.skinning=this.skinning,this.instance.morphTargets=this.morphTargets,this.instance.morphNormals=this.morphNormals},GameLib.D3.Material.prototype.updateMeshBasicMaterialInstance=function(e){this.instance.name=this.name,this.instance.opacity=this.opacity,this.instance.transparent=this.transparent,this.instance.blending=this.blending,this.instance.blendSrc=this.blendSrc,this.instance.blendDst=this.blendDst,this.instance.blendEquation=this.blendEquation,this.instance.depthTest=this.depthTest,this.instance.depthFunc=this.depthFunc,this.instance.depthWrite=this.depthWrite,this.instance.polygonOffset=this.polygonOffset,this.instance.polygonOffsetFactor=this.polygonOffsetFactor,this.instance.polygonOffsetUnits=this.polygonOffsetUnits,this.instance.alphaTest=this.alphaTest,this.instance.clippingPlanes=this.clippingPlanes,this.instance.clipShadows=this.clipShadows,this.instance.overdraw=this.overdraw,this.instance.visible=this.visible,this.instance.side=this.side,this.instance.color=this.color.instance,this.instance.vertexColors=GameLib.D3.Material.TYPE_VERTEX_COLORS,this.instance.fog=this.fog},GameLib.D3.Material.prototype.createInstance=function(){this.materialType===GameLib.D3.Material.MATERIAL_TYPE_STANDARD?this.instance=this.createStandardMaterialInstance():this.materialType===GameLib.D3.Material.MATERIAL_TYPE_POINTS?this.instance=this.createPointsMaterialInstance():this.materialType===GameLib.D3.Material.MATERIAL_TYPE_PHONG?this.instance=this.createPhongMaterialInstance():this.materialType===GameLib.D3.Material.MATERIAL_TYPE_BASIC?this.instance=this.createMeshBasicMaterialInstance():this.materialType===GameLib.D3.Material.MATERIAL_TYPE_LINE_BASIC?this.instance=this.createLineBasicMaterialInstance():this.materialType===GameLib.D3.Material.MATERIAL_TYPE_TOON?this.instance=this.createToonMaterialInstance():console.warn("material type is not implemented yet: "+this.materialType),this.instance.needsUpdate=!0,this.updateTextures(),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Material.prototype.updateInstance=function(e){return this.instance?"materialType"===e?(this.createInstance(),void this.publish(GameLib.Event.MATERIAL_TYPE_CHANGED,{material:this})):("alphaMap"!==e&&"aoMap"!==e&&"bumpMap"!==e&&"diffuseMap"!==e&&"displacementMap"!==e&&"emissiveMap"!==e&&"environmentMap"!==e&&"lightMap"!==e&&"metalnessMap"!==e&&"normalMap"!==e&&"roughnessMap"!==e&&"specularMap"!==e||this.updateTextures(),this.materialType===GameLib.D3.Material.MATERIAL_TYPE_STANDARD?this.updateStandardMaterialInstance(e):this.materialType===GameLib.D3.Material.MATERIAL_TYPE_POINTS?this.updatePointsMaterialInstance(e):this.materialType===GameLib.D3.Material.MATERIAL_TYPE_PHONG?this.updatePhongMaterialInstance(e):this.materialType===GameLib.D3.Material.MATERIAL_TYPE_BASIC?this.updateMeshBasicMaterialInstance(e):this.materialType===GameLib.D3.Material.MATERIAL_TYPE_LINE_BASIC?this.updateLineBasicMaterialInstance(e):this.materialType===GameLib.D3.Material.MATERIAL_TYPE_TOON?this.updateToonMaterialInstance(e):console.warn("not yet implemented (material type = "+this.materialType+")"),void(this.instance.needsUpdate=!0)):void console.warn("Attempt to update a non-existent instance")},GameLib.D3.Material.prototype.toApiObject=function(e){GameLib.Utils.UndefinedOrNull(e)&&(e=!1);var t=null;this.alphaMap&&(e&&this.alphaMap.save(),t=this.alphaMap.id);var i=null;this.aoMap&&(e&&this.aoMap.save(),i=this.aoMap.id);var n=null;this.bumpMap&&(e&&this.bumpMap.save(),n=this.bumpMap.id);var s=null;this.diffuseMap&&(e&&this.diffuseMap.save(),s=this.diffuseMap.id);var a=null;this.displacementMap&&(e&&this.displacementMap.save(),a=this.displacementMap.id);var o=null;this.emissiveMap&&(e&&this.emissiveMap.save(),o=this.emissiveMap.id);var r=null;this.environmentMap&&(e&&this.environmentMap.save(),r=this.environmentMap.id);var h=null;this.lightMap&&(e&&this.lightMap.save(),h=this.lightMap.id);var c=null;this.metalnessMap&&(e&&this.metalnessMap.save(),c=this.metalnessMap.id);var m=null;this.normalMap&&(this.normalMap.save(),m=this.normalMap.id);var l=null;this.roughnessMap&&(e&&this.roughnessMap.save(),l=this.roughnessMap.id);var p=null;return this.specularMap&&(e&&this.specularMap.save(),p=this.specularMap.id),new GameLib.D3.API.Material(this.id,this.materialType,this.name,this.opacity,this.side,this.transparent,this.specular.toApiObject(),this.lightMapIntensity,this.aoMapIntensity,this.color.toApiObject(),this.emissive.toApiObject(),this.emissiveIntensity,this.combine,this.shininess,this.reflectivity,this.refractionRatio,this.fog,this.wireframe,this.wireframeLineWidth,this.wireframeLineCap,this.wireframeLineJoin,this.vertexColors,this.skinning,this.morphTargets,this.morphNormals,this.lineWidth,this.lineCap,this.lineJoin,this.dashSize,this.gapWidth,this.blending,this.blendSrc,this.blendDst,this.blendEquation,this.depthTest,this.depthFunc,this.depthWrite,this.polygonOffset,this.polygonOffsetFactor,this.polygonOffsetUnits,this.alphaTest,this.clippingPlanes,this.clipShadows,this.visible,this.overdraw,this.flatShading,this.bumpScale,this.normalScale,this.displacementScale,this.displacementBias,this.roughness,this.metalness,this.pointSize,this.pointSizeAttenuation,this.spriteRotation,this.envMapIntensity,t,i,n,s,a,o,r,h,c,m,l,p,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Material.prototype.getTextures=function(){var e=[];return this.alphaMap&&e.push(this.alphaMap),this.aoMap&&e.push(this.aoMap),this.bumpMap&&e.push(this.bumpMap),this.diffuseMap&&e.push(this.diffuseMap),this.displacementMap&&e.push(this.displacementMap),this.emissiveMap&&e.push(this.emissiveMap),this.environmentMap&&e.push(this.environmentMap),this.lightMap&&e.push(this.lightMap),this.metalnessMap&&e.push(this.metalnessMap),this.normalMap&&e.push(this.normalMap),this.roughnessMap&&e.push(this.roughnessMap),this.specularMap&&e.push(this.specularMap),e},GameLib.D3.Material.FromObject=function(e,t){return new GameLib.D3.Material(e,GameLib.D3.API.Material.FromObject(t))},GameLib.D3.Mesh=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Mesh)return t;GameLib.D3.API.Mesh.call(this,t.id,t.meshType,t.name,t.vertices,t.faces,t.materials,t.parentMesh,t.parentScene,t.skeleton,t.skinIndices,t.skinWeights,t.position,t.quaternion,t.rotation,t.scale,t.up,t.modelMatrix,t.parentEntity,t.renderOrder,t.isBufferMesh,t.useQuaternion,t.visible),this.faces=this.faces.map(function(e){return e instanceof GameLib.D3.API.Face?new GameLib.D3.Face(this.graphics,e):e}.bind(this)),this.materials=this.materials.map(function(e){return e instanceof GameLib.D3.API.Material?new GameLib.D3.Material(this.graphics,e):e}.bind(this)),this.skeleton&&(this.skeleton=new GameLib.D3.Skeleton(this.graphics,this.skeleton)),this.vertices=this.vertices.map(function(e){return new GameLib.D3.Vertex(this.graphics,e)}.bind(this)),this.position=new GameLib.Vector3(this.graphics,this.position,this),this.quaternion=new GameLib.Quaternion(this.graphics,this.quaternion,this),this.rotation=new GameLib.Vector3(this.graphics,this.rotation,this),this.scale=new GameLib.Vector3(this.graphics,this.scale,this),this.up=new GameLib.Vector3(this.graphics,this.up,this),this.modelMatrix=new GameLib.Matrix4(this.graphics,this.modelMatrix,this),this.dimensions=new GameLib.Vector3(this.graphics,new GameLib.API.Vector3,this);var i={parentMesh:GameLib.D3.Mesh,parentScene:GameLib.D3.Scene,materials:[GameLib.D3.Material],skeleton:GameLib.D3.Skeleton},n=GameLib.Component.COMPONENT_MESH;this.meshType===GameLib.D3.Mesh.MESH_TYPE_PLANE&&(n=GameLib.Component.COMPONENT_MESH_PLANE),this.meshType===GameLib.D3.Mesh.MESH_TYPE_BOX&&(n=GameLib.Component.COMPONENT_MESH_BOX),this.meshType===GameLib.D3.Mesh.MESH_TYPE_CYLINDER&&(n=GameLib.Component.COMPONENT_MESH_CYLINDER),this.meshType===GameLib.D3.Mesh.MESH_TYPE_SPHERE&&(n=GameLib.Component.COMPONENT_MESH_SPHERE),this.meshType===GameLib.D3.Mesh.MESH_TYPE_LINE&&(n=GameLib.Component.COMPONENT_MESH_LINE),this.meshType===GameLib.D3.Mesh.MESH_TYPE_TEXT&&(n=GameLib.Component.COMPONENT_MESH_TEXT,i.font=GameLib.D3.Font),this.helper=null,this.updateRotationFromAxisAngle=!0,GameLib.Component.call(this,n,i)},GameLib.D3.Mesh.prototype=Object.create(GameLib.D3.API.Mesh.prototype),GameLib.D3.Mesh.prototype.constructor=GameLib.D3.Mesh,GameLib.D3.Mesh.MESH_TYPE_NORMAL=0,GameLib.D3.Mesh.MESH_TYPE_SKINNED=1,GameLib.D3.Mesh.MESH_TYPE_CURVE=2,GameLib.D3.Mesh.MESH_TYPE_SPHERE=3,GameLib.D3.Mesh.MESH_TYPE_PLANE=4;GameLib.D3.Mesh.MESH_TYPE_BOX=5,GameLib.D3.Mesh.MESH_TYPE_CYLINDER=6,GameLib.D3.Mesh.MESH_TYPE_TEXT=7,GameLib.D3.Mesh.MESH_TYPE_LINE=8,GameLib.D3.Mesh.prototype.lookAt=function(e){this.instance.lookAt(new THREE.Vector3(e.x,e.y,e.z)),this.rotation.x=this.instance.rotation.x,this.rotation.y=this.instance.rotation.y,this.rotation.z=this.instance.rotation.z,this.quaternion.x=this.instance.quaternion.x,this.quaternion.y=this.instance.quaternion.y,this.quaternion.z=this.instance.quaternion.z,this.quaternion.w=this.instance.quaternion.w},GameLib.D3.Mesh.prototype.createInstanceGeometry=function(e){if(e instanceof THREE.Geometry&&(this.computeBoundingBox(e),this.isBufferMesh))return(new THREE.BufferGeometry).fromGeometry(e);this.faces.sort(function(e,t){return e.materialIndext.materialIndex?1:0});var t=new Float32Array(this.faces.reduce(function(e,t){return e.push(this.vertices[t.v0index].position.x),e.push(this.vertices[t.v0index].position.y),e.push(this.vertices[t.v0index].position.z),e.push(this.vertices[t.v1index].position.x),e.push(this.vertices[t.v1index].position.y),e.push(this.vertices[t.v1index].position.z),e.push(this.vertices[t.v2index].position.x),e.push(this.vertices[t.v2index].position.y),e.push(this.vertices[t.v2index].position.z),e}.bind(this),[])),i=null;if(this.isBufferMesh){i=new THREE.BufferGeometry,i.addAttribute("position",new THREE.BufferAttribute(t,3));var n=Float32Array.from(this.faces.reduce(function(e,t){return e.push(1,1,1,1,1,1,1,1,1),e}.bind(this),[]));i.addAttribute("color",new THREE.BufferAttribute(n,3,!0));var s=Float32Array.from(this.faces.reduce(function(e,t){return t.uvs[0].map(function(t){e.push(t.x),e.push(t.y)}),e},[]));i.addAttribute("uv",new THREE.BufferAttribute(s,2));var a=Float32Array.from(this.faces.reduce(function(e,t){return e.push(t.normal.x,t.normal.y,t.normal.z),e.push(t.normal.x,t.normal.y,t.normal.z),e.push(t.normal.x,t.normal.y,t.normal.z),e},[]));i.addAttribute("normal",new THREE.BufferAttribute(a,3)),i.computeFaceNormals();this.faces.reduce(function(e,t){var i=e.pop();return i.index!==t.materialIndex?(e.push(i),e.push({index:t.materialIndex,count:3})):(i.count+=3,e.push(i)),e},[{index:0,count:0}]).reduce(function(e,t){return i.addGroup(e,t.count,t.index),e+t.count},0)}else{i=new THREE.Geometry;var o=[];i.faces=this.faces.map(function(e){e.uvs[0].length>0&&o.push(e.uvs[0].map(function(e){return new THREE.Vector2(e.x,e.y)}));var t=new THREE.Face3(e.v0index,e.v1index,e.v2index);return e.normal&&(t.normal=new THREE.Vector3(e.normal.x,e.normal.y,e.normal.z)),e.color&&(t.color=new THREE.Color(e.color.r,e.color.g,e.color.b)),t.materialIndex=e.materialIndex,t}),i.vertices=this.vertices.map(function(e){return new THREE.Vector3(e.position.x,e.position.y,e.position.z)}),i.verticesNeedUpdate=!0,o.length>0&&(i.faceVertexUvs=[o]),i.computeFaceNormals(),i.computeVertexNormals()}return this.computeBoundingBox(i),i},GameLib.D3.Mesh.prototype.createInstance=function(){var e=this.createInstanceGeometry();this.skeleton?(1===this.materials.length?this.instance=new THREE.SkinnedMesh(e,this.materials[0].instance):this.instance=new THREE.SkinnedMesh(e,this.materials.map(function(e){return e.instance})),this.instance.add(this.skeleton.rootBoneInstance),this.instance.bind(this.skeleton.instance)):1===this.materials.length?this.instance=new THREE.Mesh(e,this.materials[0].instance):this.instance=new THREE.Mesh(e,this.materials.map(function(e){return e.instance})),this.instance.name=this.name,this.parentMesh&&this.parentMesh.instance&&this.parentMesh.add(this.instance,this),this.instance.position.x=this.position.x,this.instance.position.y=this.position.y,this.instance.position.z=this.position.z,this.useQuaternion?(this.instance.quaternion.x=this.quaternion.x,this.instance.quaternion.y=this.quaternion.y,this.instance.quaternion.z=this.quaternion.z,this.instance.quaternion.w=this.quaternion.w,this.instance.quaternion.setFromAxisAngle(new THREE.Vector3(this.quaternion.axis.x,this.quaternion.axis.y,this.quaternion.axis.z),this.quaternion.angle)):(this.instance.rotation.x=this.rotation.x,this.instance.rotation.y=this.rotation.y,this.instance.rotation.z=this.rotation.z),this.instance.scale.x=this.scale.x,this.instance.scale.y=this.scale.y,this.instance.scale.z=this.scale.z,this.instance.up.x=this.up.x,this.instance.up.y=this.up.y,this.instance.up.z=this.up.z,this.instance.renderOrder=this.renderOrder,this.instance.visible=this.visible,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Mesh.prototype.updateInstance=function(e){GameLib.Utils.UndefinedOrNull(e)&&console.warn("unknown mesh property update"),"isBufferMesh"===e&&(this.isBufferMesh&&!(this.instance.geometry instanceof THREE.BufferGeometry)||!this.isBufferMesh&&this.instance.geometry instanceof THREE.BufferGeometry)&&(this.instance.geometry=this.createInstanceGeometry(this.instance.geometry)),"rotation"!==e&&"quaternion"!==e&&"useQuaternion"!==e||this.updateInstanceRotation(),"parentMesh"===e&&this.parentMesh&&this.parentMesh.instance&&this.instance.parent!==this.parentMesh.instance&&(this.instance.parent=this.parentMesh.instance),"scale"===e&&this.updateInstanceScale(),"position"===e&&this.updateInstancePosition(),"up"===e&&(this.instance.up.x=this.up.x,this.instance.up.y=this.up.y,this.instance.up.z=this.up.z),"name"===e&&(this.instance.name=this.name),"materials"===e&&1===this.materials.length&&this.materials[0].instance&&(this.instance.material=this.materials[0].instance),"renderOrder"===e&&(this.instance.renderOrder=this.renderOrder),"visible"===e&&(this.instance.visible=this.visible),this.helper&&(this.removeHelper(),this.createHelper())},GameLib.D3.Mesh.prototype.updateVerticesFromGeometryInstance=function(e){if(this.vertices=[],this.faces=[],e instanceof THREE.BufferGeometry){var t=e.getAttribute("position").array,i=e.getAttribute("uv").array;e.groups.map(function(e){for(var n=e.materialIndex,s=e.start,a=e.count,o=[],r=[],h=s;ht.materialIndex?1:0});var t=new Float32Array(this.faces.reduce(function(e,t){return e.push(this.vertices[t.v0index].position.x),e.push(this.vertices[t.v0index].position.y),e.push(this.vertices[t.v0index].position.z),e.push(this.vertices[t.v1index].position.x),e.push(this.vertices[t.v1index].position.y),e.push(this.vertices[t.v1index].position.z),e.push(this.vertices[t.v2index].position.x),e.push(this.vertices[t.v2index].position.y),e.push(this.vertices[t.v2index].position.z),e}.bind(this),[])),i=null;if(this.isBufferMesh){i=new THREE.BufferGeometry,i.addAttribute("position",new THREE.BufferAttribute(t,3));var n=new Float32Array(this.faces.reduce(function(e,t){return e.push(1,1,1,1,1,1,1,1,1),e}.bind(this),[]));i.addAttribute("color",new THREE.BufferAttribute(n,3,!0));var s=new Float32Array(this.faces.reduce(function(e,t){return t.uvs[0].map(function(t){e.push(t.x),e.push(t.y)}),e},[]));i.addAttribute("uv",new THREE.BufferAttribute(s,2));var a=new Float32Array(this.faces.reduce(function(e,t){return e.push(t.normal.x,t.normal.y,t.normal.z),e.push(t.normal.x,t.normal.y,t.normal.z),e.push(t.normal.x,t.normal.y,t.normal.z),e},[]));i.addAttribute("normal",new THREE.BufferAttribute(a,3)),i.computeFaceNormals();this.faces.reduce(function(e,t){var i=e.pop();return i.index!==t.materialIndex?(e.push(i),e.push({index:t.materialIndex,count:3})):(i.count+=3,e.push(i)),e},[{index:0,count:0}]).reduce(function(e,t){return i.addGroup(e,t.count,t.index),e+t.count},0)}else{i=new THREE.Geometry;var o=[];i.faces=this.faces.map(function(e){e.uvs[0].length>0&&o.push(e.uvs[0].map(function(e){return new THREE.Vector2(e.x,e.y)}));var t=new THREE.Face3(e.v0index,e.v1index,e.v2index);return e.normal&&(t.normal=new THREE.Vector3(e.normal.x,e.normal.y,e.normal.z)),e.color&&(t.color=new THREE.Color(e.color.r,e.color.g,e.color.b)),t.materialIndex=e.materialIndex,t}),i.vertices=this.vertices.map(function(e){return new THREE.Vector3(e.position.x,e.position.y,e.position.z)}),i.verticesNeedUpdate=!0,o.length>0&&(i.faceVertexUvs=[o]),i.computeFaceNormals(),i.computeVertexNormals()}return this.computeBoundingBox(i),i},GameLib.D3.Mesh.prototype.createInstance=function(){var e=this.createInstanceGeometry();this.skeleton?(1===this.materials.length?this.instance=new THREE.SkinnedMesh(e,this.materials[0].instance):this.instance=new THREE.SkinnedMesh(e,this.materials.map(function(e){return e.instance})),this.instance.add(this.skeleton.rootBoneInstance),this.instance.bind(this.skeleton.instance)):1===this.materials.length?this.instance=new THREE.Mesh(e,this.materials[0].instance):this.instance=new THREE.Mesh(e,this.materials.map(function(e){return e.instance})),this.instance.name=this.name,this.parentMesh&&this.parentMesh.instance&&this.parentMesh.add(this.instance,this),this.instance.position.x=this.position.x,this.instance.position.y=this.position.y,this.instance.position.z=this.position.z,this.useQuaternion?(this.instance.quaternion.x=this.quaternion.x,this.instance.quaternion.y=this.quaternion.y,this.instance.quaternion.z=this.quaternion.z,this.instance.quaternion.w=this.quaternion.w,this.instance.quaternion.setFromAxisAngle(new THREE.Vector3(this.quaternion.axis.x,this.quaternion.axis.y,this.quaternion.axis.z),this.quaternion.angle)):(this.instance.rotation.x=this.rotation.x,this.instance.rotation.y=this.rotation.y,this.instance.rotation.z=this.rotation.z),this.instance.scale.x=this.scale.x,this.instance.scale.y=this.scale.y,this.instance.scale.z=this.scale.z,this.instance.up.x=this.up.x,this.instance.up.y=this.up.y,this.instance.up.z=this.up.z,this.instance.renderOrder=this.renderOrder,this.instance.visible=this.visible,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Mesh.prototype.updateInstance=function(e){GameLib.Utils.UndefinedOrNull(e)&&console.warn("unknown mesh property update"),"isBufferMesh"===e&&(this.isBufferMesh&&!(this.instance.geometry instanceof THREE.BufferGeometry)||!this.isBufferMesh&&this.instance.geometry instanceof THREE.BufferGeometry)&&(this.instance.geometry=this.createInstanceGeometry(this.instance.geometry)),"rotation"!==e&&"quaternion"!==e&&"useQuaternion"!==e||this.updateInstanceRotation(),"parentMesh"===e&&this.parentMesh&&this.parentMesh.instance&&this.instance.parent!==this.parentMesh.instance&&(this.instance.parent=this.parentMesh.instance),"scale"===e&&this.updateInstanceScale(),"position"===e&&this.updateInstancePosition(),"up"===e&&(this.instance.up.x=this.up.x,this.instance.up.y=this.up.y,this.instance.up.z=this.up.z),"name"===e&&(this.instance.name=this.name),"materials"===e&&1===this.materials.length&&this.materials[0].instance&&(this.instance.material=this.materials[0].instance),"renderOrder"===e&&(this.instance.renderOrder=this.renderOrder),"visible"===e&&(this.instance.visible=this.visible),this.helper&&(this.removeHelper(),this.createHelper())},GameLib.D3.Mesh.prototype.updateVerticesFromGeometryInstance=function(e){if(this.vertices=[],this.faces=[],e instanceof THREE.BufferGeometry){var t=e.getAttribute("position").array,i=e.getAttribute("uv").array;e.groups.map(function(e){for(var n=e.materialIndex,s=e.start,a=e.count,o=[],r=[],h=s;hthis.maxSpeed&&(this.currentSpeed=this.maxSpeed),this.grain=this.currentSpeed/100;var t=this.spline.getPointAt(this.currentPathValue);this.currentPosition.x=t.x,this.currentPosition.y=t.y,this.currentPosition.z=t.z,this.currentPathValue+=this.grain,this.currentPathValue>=1&&(this.currentPathValue=this.currentPathValue-1),this.currentPathValue<0&&(this.currentPathValue=0);var i=this.spline.getPointAt(this.currentPathValue);this.futurePosition.x=i.x,this.futurePosition.y=i.y,this.futurePosition.z=i.z,this.raycaster.setPosition(this.currentPosition),this.raycaster.setDirection({x:-this.up.x,y:-this.up.y,z:-this.up.z});var n=this.raycaster.getFaceNormal(this.raytraceMesh);n&&(this.up.x=this.mx(n.x),this.up.y=this.my(n.y),this.up.z=this.mz(n.z)),this.rotationMatrix.lookAt(this.currentPosition,this.futurePosition,this.up),this.rotationVector.setFromRotationMatrix(this.rotationMatrix),this.mesh.position.x=this.futurePosition.x,this.mesh.position.y=this.futurePosition.y,this.mesh.position.z=this.futurePosition.z,this.mesh.quaternion.x=this.rotationVector.x,this.mesh.quaternion.y=this.rotationVector.y,this.mesh.quaternion.z=this.rotationVector.z,this.mesh.quaternion.w=this.rotationVector.w}},GameLib.D3.PhysicsWorld=function(e,t){if(this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.PhysicsWorld)return t;GameLib.D3.API.PhysicsWorld.call(this,t.id,t.name,t.gravity,t.broadphase,t.solver,t.rigidBodies,t.contactMaterials,t.allowSleep,t.defaultContactMaterial,t.parentEntity),this.gravity instanceof GameLib.API.Vector3&&(this.gravity=new GameLib.Vector3(this.physics,this.gravity,this)),this.broadphase instanceof GameLib.D3.API.Broadphase&&(this.broadphase=new GameLib.D3.Broadphase(this.physics,this.broadphase)),this.solver instanceof GameLib.D3.API.Solver&&(this.solver=new GameLib.D3.Solver(this.physics,this.solver)),this.rigidBodies=this.rigidBodies.map(function(e){return e instanceof GameLib.D3.API.RigidBody?new GameLib.D3.RigidBody(this.physics,e):e}.bind(this)),this.contactMaterials=this.contactMaterials.map(function(e){return e instanceof GameLib.D3.API.FrictionContactMaterial?new GameLib.D3.FrictionContactMaterial(this.physics,e):e}.bind(this)),this.defaultContactMaterial instanceof GameLib.D3.API.FrictionContactMaterial&&(this.defaultContactMaterial=new GameLib.D3.FrictionContactMaterial(this.physics,this.defaultContactMaterial)),GameLib.Component.call(this,GameLib.Component.COMPONENT_PHYSICS_WORLD,{broadphase:GameLib.D3.Broadphase,solver:GameLib.D3.Solver,rigidBodies:[GameLib.D3.RigidBody],contactMaterials:[GameLib.D3.FrictionContactMaterial],defaultContactMaterial:GameLib.D3.FrictionContactMaterial})},GameLib.D3.PhysicsWorld.prototype=Object.create(GameLib.D3.API.PhysicsWorld.prototype),GameLib.D3.PhysicsWorld.prototype.constructor=GameLib.D3.PhysicsWorld,GameLib.D3.PhysicsWorld.prototype.createInstance=function(){if(GameLib.Utils.UndefinedOrNull(this.broadphase))throw new Error("no broadphase");if(GameLib.Utils.UndefinedOrNull(this.broadphase.instance))throw new Error("no broadphase instance");if(GameLib.Utils.UndefinedOrNull(this.solver))throw new Error("no solver");if(GameLib.Utils.UndefinedOrNull(this.solver.instance))throw new Error("no solver instance");this.instance=new CANNON.World,this.instance.broadphase=this.broadphase.instance,this.instance.solver=this.solver.instance,this.instance.gravity=this.gravity.instance,this.instance.allowSleep=this.allowSleep,this.contactMaterials.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no contact material");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no contact material instance");this.instance.addContactMaterial(e.instance)}.bind(this)),this.rigidBodies.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no rigidbody");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no rigidbody instance");e.parentWorld=this,this.instance.add(e.instance)}.bind(this)),this.instance.defaultContactMaterial.friction=this.defaultContactMaterial.friction,this.instance.defaultContactMaterial.restitution=this.defaultContactMaterial.restitution,this.instance.defaultContactMaterial.contactEquationStiffness=this.defaultContactMaterial.contactEquationStiffness,this.instance.defaultContactMaterial.contactEquationRelaxation=this.defaultContactMaterial.contactEquationRelaxation,this.instance.defaultContactMaterial.frictionEquationStiffness=this.defaultContactMaterial.frictionEquationStiffness,this.instance.defaultContactMaterial.frictionEquationRelaxation=this.defaultContactMaterial.frictionEquationRelaxation,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.PhysicsWorld.prototype.addRigidBody=function(e){e&&e.instance?(this.instance.add(e.instance),e.parentWorld=this,GameLib.Utils.PushUnique(this.rigidBodies,e)):console.warn("Attempt to add rigidBody "+e.name+" without an instance")},GameLib.D3.PhysicsWorld.prototype.removeRigidBody=function(e){if(!e instanceof GameLib.D3.RigidBody)return void console.warn("not a rigid body");e.instance?this.instance.remove(e.instance):console.warn("Attempt to remove rigidBody "+e.name+" without an instance"),e.parentWorld=null;var t=this.rigidBodies.indexOf(e);-1!==t?this.rigidBodies.splice(t,1):console.warn("could not remove a rigidbody from an array where it should have existed")},GameLib.D3.PhysicsWorld.prototype.updateInstance=function(){if(!this.instance)return void console.log("no world instance");this.instance.broadphase=this.broadphase.instance,this.instance.solver=this.solver.instance,this.instance.gravity=this.gravity.instance,this.instance.allowSleep=this.allowSleep,this.instance.defaultContactMaterial.friction=this.defaultContactMaterial.friction,this.instance.defaultContactMaterial.restitution=this.defaultContactMaterial.restitution,this.instance.defaultContactMaterial.contactEquationStiffness=this.defaultContactMaterial.contactEquationStiffness,this.instance.defaultContactMaterial.contactEquationRelaxation=this.defaultContactMaterial.contactEquationRelaxation,this.instance.defaultContactMaterial.frictionEquationStiffness=this.defaultContactMaterial.frictionEquationStiffness,this.instance.defaultContactMaterial.frictionEquationRelaxation=this.defaultContactMaterial.frictionEquationRelaxation},GameLib.D3.PhysicsWorld.prototype.toApiObject=function(){return new GameLib.D3.API.PhysicsWorld(this.id,this.name,this.gravity.toApiObject(),GameLib.Utils.IdOrNull(this.broadphase),GameLib.Utils.IdOrNull(this.solver),this.rigidBodies.map(function(e){return GameLib.Utils.IdOrNull(e)}),this.contactMaterials.map(function(e){return GameLib.Utils.IdOrNull(e)}),this.allowSleep,GameLib.Utils.IdOrNull(this.defaultContactMaterial),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.PhysicsWorld.FromObject=function(e,t){var i=GameLib.D3.API.PhysicsWorld.FromObject(t);return new GameLib.D3.PhysicsWorld(e,i)},GameLib.D3.Physics=function(e,t,i){GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Physics ("+e+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=GameLib.D3.Physics.PHYSICS_TYPE_CANNON),this.physicsType=i,this.createInstance()},GameLib.D3.Physics.PHYSICS_TYPE_CANNON=1,GameLib.D3.Physics.prototype.createInstance=function(){this.instance=CANNON},GameLib.D3.Physics.prototype.updateInstance=function(){},GameLib.D3.Physics.prototype.isNotCannonThrow=function(){if(this.physicsType!==GameLib.D3.Physics.PHYSICS_TYPE_CANNON)throw console.warn("Only CANNON supported for this function"),new Error("Only CANNON supported for this function")},GameLib.D3.PolyVertex=function(e,t,i,n,s){this.localIndex=e,this.mvertIndex=t,this.uv=i,this.materialIndex=n,this.edgeIndex=s},GameLib.D3.PolyVertex.prototype.clone=function(){return new GameLib.D3.PolyVertex(this.localIndex,this.mvertIndex,this.uv.copy(),this.materialIndex,this.edgeIndex)},GameLib.D3.RaycastVehicle=function(e,t){if(this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.RaycastVehicle)return t;GameLib.D3.API.RaycastVehicle.call(this,t.id,t.name,t.chassis,t.wheels,t.raycastWheels,t.parentWorld,t.parentEntity),this.chassis instanceof GameLib.D3.API.RaycastVehicle&&(this.chassis=new GameLib.D3.RaycastVehicle(this.physics,this.chassis)),this.wheels=this.wheels.map(function(e){return e instanceof GameLib.D3.API.RigidBody?new GameLib.D3.RigidBody(this.physics,e):e}.bind(this)),this.raycastWheels=this.raycastWheels.map(function(e){return e instanceof GameLib.D3.API.RaycastWheel?new GameLib.D3.RaycastWheel(this.physics,e):e}.bind(this)),GameLib.Component.call(this,GameLib.Component.COMPONENT_RAYCAST_VEHICLE,{chassis:GameLib.D3.RigidBody,wheels:[GameLib.D3.RigidBody],raycastWheels:[GameLib.D3.RaycastWheel],parentWorld:GameLib.D3.PhysicsWorld})},GameLib.D3.RaycastVehicle.prototype=Object.create(GameLib.D3.API.RaycastVehicle.prototype),GameLib.D3.RaycastVehicle.prototype.constructor=GameLib.D3.RaycastVehicle,GameLib.D3.RaycastVehicle.prototype.createInstance=function(){if(GameLib.Utils.UndefinedOrNull(this.chassis))throw new Error("no chassis");if(GameLib.Utils.UndefinedOrNull(this.chassis.instance))throw new Error("no chassis instance");if(GameLib.Utils.UndefinedOrNull(this.parentWorld))throw new Error("no parent world");if(GameLib.Utils.UndefinedOrNull(this.parentWorld.instance))throw new Error("no parent world instance");this.instance=new CANNON.RaycastVehicle({chassisBody:this.chassis.instance}),this.raycastWheels.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no wheel");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no wheel instance");this.instance.addWheel(e.instance)}.bind(this)),this.instance.addToWorld(this.parentWorld.instance),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.RaycastVehicle.prototype.updateInstance=function(){console.log("TODO: update raycast vehicle instance")},GameLib.D3.RaycastVehicle.prototype.toApiObject=function(){return new GameLib.D3.API.RaycastVehicle(this.id,this.name,GameLib.Utils.IdOrNull(this.chassis),this.wheels.map(function(e){return GameLib.Utils.IdOrNull(e)}),this.raycastWheels.map(function(e){return GameLib.Utils.IdOrNull(e)}),GameLib.Utils.IdOrNull(this.parentWorld),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.RaycastVehicle.FromObject=function(e,t){var i=GameLib.D3.API.RaycastVehicle.FromObject(t);return new GameLib.D3.RaycastVehicle(e,i)},GameLib.D3.RaycastWheel=function(e,t){if(this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.RaycastWheel)return t;GameLib.D3.API.RaycastWheel.call(this,t.id,t.name,t.radius,t.directionLocal,t.suspensionStiffness,t.suspensionRestLength,t.frictionSlip,t.dampingRelaxation,t.dampingCompression,t.maxSuspensionForce,t.rollInfluence,t.axleLocal,t.chassisConnectionPointLocal,t.maxSuspensionTravel,t.customSlidingRotationalSpeed,t.useCustomSlidingRotationalSpeed,t.parentEntity,t.parentMesh),this.directionLocal=new GameLib.Vector3(this.physics,this.directionLocal,this),this.axleLocal=new GameLib.Vector3(this.physics,this.axleLocal,this),this.chassisConnectionPointLocal=new GameLib.Vector3(this.physics,this.chassisConnectionPointLocal,this),GameLib.Component.call(this,GameLib.Component.COMPONENT_RAYCAST_WHEEL,{parentMesh:GameLib.D3.Mesh})},GameLib.D3.RaycastWheel.prototype=Object.create(GameLib.D3.API.RaycastWheel.prototype),GameLib.D3.RaycastWheel.prototype.constructor=GameLib.D3.RaycastWheel,GameLib.D3.RaycastWheel.prototype.createInstance=function(){this.instance={radius:this.radius,directionLocal:this.directionLocal.instance,suspensionStiffness:this.suspensionStiffness,suspensionRestLength:this.suspensionRestLength,frictionSlip:this.frictionSlip,dampingRelaxation:this.dampingRelaxation,dampingCompression:this.dampingCompression,maxSuspensionForce:this.maxSuspensionForce,rollInfluence:this.rollInfluence,axleLocal:this.axleLocal.instance,chassisConnectionPointLocal:this.chassisConnectionPointLocal.instance,maxSuspensionTravel:this.maxSuspensionTravel,customSlidingRotationalSpeed:this.customSlidingRotationalSpeed,useCustomSlidingRotationalSpeed:this.useCustomSlidingRotationalSpeed},GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.RaycastWheel.prototype.updateInstance=function(){this.instance.radius=this.radius,this.instance.directionLocal=this.directionLocal.instance,this.instance.suspensionStiffness=this.suspensionStiffness,this.instance.suspensionRestLength=this.suspensionRestLength,this.instance.frictionSlip=this.frictionSlip,this.instance.dampingRelaxation=this.dampingRelaxation,this.instance.dampingCompression=this.dampingCompression,this.instance.maxSuspensionForce=this.maxSuspensionForce,this.instance.rollInfluence=this.rollInfluence,this.instance.axleLocal=this.axleLocal.instance,this.instance.chassisConnectionPointLocal=this.chassisConnectionPointLocal.instance,this.instance.maxSuspensionTravel=this.maxSuspensionTravel,this.instance.customSlidingRotationalSpeed=this.customSlidingRotationalSpeed,this.instance.useCustomSlidingRotationalSpeed=this.useCustomSlidingRotationalSpeed},GameLib.D3.RaycastWheel.prototype.toApiObject=function(){return new GameLib.D3.API.RaycastWheel(this.id,this.name,this.radius,this.directionLocal.toApiObject(),this.suspensionStiffness,this.suspensionRestLength,this.frictionSlip,this.dampingRelaxation,this.dampingCompression,this.maxSuspensionForce,this.rollInfluence,this.axleLocal.toApiObject(),this.chassisConnectionPointLocal.toApiObject(),this.maxSuspensionTravel,this.customSlidingRotationalSpeed,this.useCustomSlidingRotationalSpeed,GameLib.Utils.IdOrNull(this.parentEntity),GameLib.Utils.IdOrNull(this.parentMesh))},GameLib.D3.RaycastWheel.FromObject=function(e,t){var i=GameLib.D3.API.RaycastWheel.FromObject(t);return new GameLib.D3.RaycastWheel(e,i)},GameLib.D3.RaycastWheel.prototype.setChassisLocalConnectionPoint=function(){this.parentMesh||console.log("you need to set the parent mesh first"),this.chassisConnectionPointLocal.x=this.parentMesh.position.x,this.chassisConnectionPointLocal.y=this.parentMesh.position.y,this.chassisConnectionPointLocal.z=this.parentMesh.position.z},GameLib.D3.Raycaster=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Raycaster)return t;GameLib.D3.API.Raycaster.call(this,t.id,t.name,t.position,t.direction),this.position=new GameLib.Vector3(this.graphics,this.position,this),this.direction=new GameLib.Vector3(this.graphics,this.direction,this),GameLib.Component.call(this,GameLib.Component.COMPONENT_RAYCASTER)},GameLib.D3.Raycaster.prototype=Object.create(GameLib.D3.API.Raycaster.prototype),GameLib.D3.Raycaster.prototype.constructor=GameLib.D3.Raycaster,GameLib.D3.Raycaster.prototype.createInstance=function(){this.instance=new THREE.Raycaster,this.instance.set(this.position.instance,this.direction.instance),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Raycaster.prototype.updateInstance=function(){this.position.instance.x=this.position.x,this.position.instance.y=this.position.y,this.position.instance.z=this.position.z,this.direction.instance.x=this.direction.x,this.direction.instance.y=this.direction.y,this.direction.instance.z=this.direction.z,this.instance.set(this.position.instance,this.direction.instance)},GameLib.D3.Raycaster.prototype.toApiObject=function(){return new GameLib.D3.API.Raycaster(this.id,this.name,this.position.toApiObject(),this.direction.toApiObject())},GameLib.D3.Raycaster.FromObject=function(e,t){var i=GameLib.D3.API.Raycaster.FromObject(t);return new GameLib.D3.Raycaster(e,i)},GameLib.D3.Raycaster.prototype.set=function(e,t){this.position.x=e.x,this.position.y=e.y,this.position.z=e.z,this.direction.x=t.x,this.direction.y=t.y,this.direction.z=t.z,this.position.updateInstance(),this.direction.updateInstance()},GameLib.D3.Raycaster.prototype.setDirection=function(e){this.direction.x=e.x,this.direction.y=e.y,this.direction.z=e.z,this.direction.updateInstance()},GameLib.D3.Raycaster.prototype.setPosition=function(e){this.position.x=e.x,this.position.y=e.y,this.position.z=e.z,this.position.updateInstance()},GameLib.D3.Raycaster.prototype.setFromCamera=function(e,t){this.instance.setFromCamera(e,t.instance),this.position.x=this.instance.ray.origin.x,this.position.y=this.instance.ray.origin.y,this.position.z=this.instance.ray.origin.z,this.direction.x=this.instance.ray.direction.x,this.direction.y=this.instance.ray.direction.y,this.direction.z=this.instance.ray.direction.z},GameLib.D3.Raycaster.prototype.getIntersectedObjects=function(e){return e.reduce(function(e,t){var i=this.instance.intersectObject(t.instance);return i.length>0&&e.push({mesh:t,distance:i[0].distance}),e}.bind(this),[])},GameLib.D3.Raycaster.prototype.getFaceNormal=function(e){var t=null,i=this.instance.intersectObject(e.instance);return i&&i.length>0&&(t=new GameLib.Vector3(this.graphics,new GameLib.API.Vector3(i[0].face.normal.x,i[0].face.normal.y,i[0].face.normal.z),this)),t},GameLib.D3.Raycaster.prototype.getIntersectPoint=function(e){var t=null,i=this.instance.intersectObject(e.instance);return i&&i.length>0&&(t=new GameLib.Vector3(this.graphics,new GameLib.API.Vector3(i[0].point.x,i[0].point.y,i[0].point.z),this)),t},GameLib.D3.RenderTarget=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.RenderTarget)return t;GameLib.D3.API.RenderTarget.call(this,t.id,t.name,t.width,t.height,t.stencilBuffer,t.texture),GameLib.Component.call(this,GameLib.Component.COMPONENT_RENDER_TARGET,{texture:GameLib.D3.Texture})},GameLib.D3.RenderTarget.prototype=Object.create(GameLib.D3.API.RenderTarget.prototype),GameLib.D3.RenderTarget.prototype.constructor=GameLib.D3.RenderTarget,GameLib.D3.RenderTarget.prototype.createInstance=function(){if(GameLib.Utils.UndefinedOrNull(this.texture))throw new Error("no texture");if(GameLib.Utils.UndefinedOrNull(this.texture.instance))throw new Error("no texture instance");this.instance=new THREE.WebGLRenderTarget(this.width,this.height,{stencilBuffer:this.stencilBuffer}),this.instance.texture=this.texture.instance,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.RenderTarget.prototype.updateInstance=function(){if(this.instance)this.instance.setSize(this.width,this.height),this.instance.stencilBuffer=this.stencilBuffer,this.texture&&this.texture.instance?(this.instance.texture=this.texture.instance,this.instance.texture.needsUpdate=!0):this.instance.texture=null;else try{this.createInstance()}catch(e){console.error(e)}},GameLib.D3.RenderTarget.prototype.toApiObject=function(){return new GameLib.D3.API.RenderTarget(this.id,this.name,this.width,this.height,this.stencilBuffer,GameLib.Utils.IdOrNull(this.texture),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.RenderTarget.FromObject=function(e,t){var i=GameLib.D3.API.RenderTarget.FromObject(t);return new GameLib.D3.RenderTarget(e,i)},GameLib.D3.Renderer=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Renderer)return t;GameLib.D3.API.Renderer.call(this,t.id,t.name,t.autoClear,t.localClipping,t.width,t.height,t.preserveDrawingBuffer,t.domElement,t.clearColor,t.camera,t.scenes,t.viewports,t.clippingPlanes,t.bufferScene,t.bufferCamera,t.renderTarget,t.defaultScene,t.sortObjects,t.parentEntity),this.clearColor=new GameLib.Color(this.graphics,this.clearColor,this),this.domElement instanceof GameLib.API.DomElement&&(this.domElement=new GameLib.DomElement(this.domElement)),this.camera instanceof GameLib.D3.API.Camera&&(this.camera=new GameLib.D3.Camera(this.graphics,this.camera)),this.scenes=this.scenes.map(function(e){return e instanceof GameLib.D3.API.Scene?new GameLib.D3.Scene(this.graphics,e):e}.bind(this)),this.viewports=this.viewports.map(function(e){return e instanceof GameLib.D3.API.Viewport?new GameLib.D3.Viewport(this.graphics,e):e}.bind(this)),this.clippingPlanes=this.clippingPlanes.map(function(e){return e instanceof GameLib.D3.API.Mesh?new GameLib.D3.Mesh.Plane(this.graphics,e,e.width,e.height,e.widthSegments,e.heightSegments,e.heightMapScale,e.isHeightMap,e.isClippingPlane,e.distanceFromOrigin):e}.bind(this)),this.bufferScene instanceof GameLib.D3.API.Scene&&(this.bufferScene=new GameLib.D3.Scene(this.graphics,this.bufferScene)),this.bufferCamera instanceof GameLib.D3.API.Camera&&(this.bufferCamera=new GameLib.D3.Camera(this.graphics,this.bufferCamera)),this.renderTarget instanceof GameLib.D3.API.RenderTarget&&(this.renderTarget=new GameLib.D3.RenderTarget(this.graphics,this.renderTarget)),GameLib.Component.call(this,GameLib.Component.COMPONENT_RENDERER,{domElement:GameLib.DomElement,camera:GameLib.D3.Camera,scenes:[GameLib.D3.Scene],viewports:[GameLib.D3.Viewport],clippingPlanes:[GameLib.D3.Mesh.Plane],bufferScene:GameLib.D3.Scene,bufferCamera:GameLib.D3.Camera,renderTarget:GameLib.D3.RenderTarget,defaultScene:GameLib.D3.Scene})},GameLib.D3.Renderer.prototype=Object.create(GameLib.D3.API.Renderer.prototype),GameLib.D3.Renderer.prototype.constructor=GameLib.D3.Renderer,GameLib.D3.Renderer.prototype.createInstance=function(){if(GameLib.Utils.UndefinedOrNull(this.domElement))throw new Error("no dom element");if(GameLib.Utils.UndefinedOrNull(this.domElement.instance))throw new Error("no dom element instance");this.instance=new THREE.WebGLRenderer({canvas:this.domElement.instance}),this.clippingPlanes.length>0&&(this.instance.clippingPlanes=this.clippingPlanes.map(function(e){if(!e.isClippingPlane||!e.instance||!e.instance.clipping)throw new Error("is not a clipping plane or no clipping plane instance");return e.instance.clipping})),this.instance.localClippingEnabled=this.localClipping,this.instance.setSize(this.width,this.height),this.instance.setClearColor(new THREE.Color(this.clearColor.r,this.clearColor.g,this.clearColor.b),1-this.clearColor.a),this.instance.domElement.width=this.width,this.instance.domElement.height=this.height,this.instance.autoClear=this.autoClear,this.instance.preserveDrawingBuffer=this.preserveDrawingBuffer,this.instance.sortObjects=this.sortObjects,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Renderer.prototype.updateInstance=function(e){if(this.instance)e||console.error("no property for renderer"),"localClipping"===e&&(this.instance.localClippingEnabled=this.localClipping),this.instance.setSize(this.width,this.height),this.instance.domElement.width=this.width,this.instance.domElement.height=this.height,"clearColor"===e&&this.instance.setClearColor(new THREE.Color(this.clearColor.r,this.clearColor.g,this.clearColor.b),1-this.clearColor.a),"autoClear"===e&&(this.instance.autoClear=this.autoClear),"preserveDrawingBuffer"===e&&(this.instance.preserveDrawingBuffer=this.preserveDrawingBuffer),this.clippingPlanes.length>0?this.instance.clippingPlanes=this.clippingPlanes.map(function(e){if(!e.isClippingPlane||!e.instance||!e.instance.clipping)throw new Error("is not a clipping plane or no clipping plane instance");return e.instance.clipping}):this.instance.clippingPlanes=[],"sortObjects"===e&&(this.instance.sortObjects=this.sortObjects);else try{this.createInstance()}catch(e){console.error(e.message)}},GameLib.D3.Renderer.prototype.toApiObject=function(){return new GameLib.D3.API.Renderer(this.id,this.name,this.autoClear,this.localClipping,this.width,this.height,this.preserveDrawingBuffer,GameLib.Utils.IdOrNull(this.domElement),this.clearColor.toApiObject(),GameLib.Utils.IdOrNull(this.camera),this.scenes.map(function(e){return GameLib.Utils.IdOrNull(e)}),this.viewports.map(function(e){return GameLib.Utils.IdOrNull(e)}),this.clippingPlanes.map(function(e){return GameLib.Utils.IdOrNull(e)}),GameLib.Utils.IdOrNull(this.bufferScene),GameLib.Utils.IdOrNull(this.bufferCamera),GameLib.Utils.IdOrNull(this.renderTarget),GameLib.Utils.IdOrNull(this.defaultScene),this.sortObjects,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Renderer.FromObject=function(e,t){var i=GameLib.D3.API.Renderer.FromObject(t);return new GameLib.D3.Renderer(e,i)},GameLib.D3.Renderer.prototype.render=function(e,t){this.instance&&(GameLib.Utils.UndefinedOrNull(t)&&(t=this.scenes),this.viewports.length>1&&(this.instance.autoClear=!1),t.length>1&&(this.instance.autoClear=!1),this.instance.clear(),this.bufferScene&&this.bufferScene.instance&&this.bufferCamera&&this.bufferCamera.instance&&this.renderTarget&&this.renderTarget.instance&&this.instance.render(this.bufferScene.instance,this.bufferCamera.instance,this.renderTarget.instance),this.viewports.map(function(e){this.instance.setViewport(e.x*this.width,e.y*this.height,e.width*this.width,e.height*this.height),t.map(function(e){e.instance&&(this.camera.instance||e.renderCamera||e.renderCamera.instance)&&(e.renderCamera&&e.renderCamera.instance?this.instance.render(e.instance,e.renderCamera.instance):this.instance.render(e.instance,this.camera.instance))}.bind(this))}.bind(this)))};GameLib.D3.Renderer.prototype.setSize=function(e,t){this.width=e,this.height=t, this.instance?this.instance.setSize(this.width,this.height):console.log("renderer not ready to set size")},GameLib.D3.RigidBody=function(e,t){if(this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.RigidBody)return t;GameLib.D3.API.RigidBody.call(this,t.id,t.name,t.mass,t.friction,t.position,t.quaternion,t.velocity,t.angularVelocity,t.linearDamping,t.angularDamping,t.allowSleep,t.sleepSpeedLimit,t.sleepTimeLimit,t.collisionFilterGroup,t.collisionFilterMask,t.fixedRotation,t.shapes,t.kinematic,t.parentMesh,t.parentWorld,t.parentEntity),this.position=new GameLib.Vector3(this.physics,this.position,this),this.quaternion=new GameLib.Quaternion(this.physics,this.quaternion,this),this.velocity=new GameLib.Vector3(this.physics,this.velocity,this),this.angularVelocity=new GameLib.Vector3(this.physics,this.angularVelocity,this),this.force=new GameLib.Vector3(this.physics),this.forcePoint=new GameLib.Vector3(this.physics),GameLib.Component.call(this,GameLib.Component.COMPONENT_RIGID_BODY,{shapes:[GameLib.D3.Shape],parentMesh:GameLib.D3.Mesh,parentWorld:GameLib.D3.PhysicsWorld})},GameLib.D3.RigidBody.prototype=Object.create(GameLib.D3.API.RigidBody.prototype),GameLib.D3.RigidBody.prototype.constructor=GameLib.D3.RigidBody,GameLib.D3.RigidBody.prototype.createInstance=function(){this.instance=new CANNON.Body({mass:this.mass,friction:this.friction,position:this.position.instance,quaternion:this.quaternion.instance,velocity:this.velocity.instance,angularVelocity:this.angularVelocity.instance,linearDamping:this.linearDamping,angularDamping:this.angularDamping,allowSleep:this.allowSleep,sleepSpeedLimit:this.sleepSpeedLimit,sleepTimeLimit:this.sleepTimeLimit,collisionFilterGroup:this.collisionFilterGroup,collisionFilterMask:this.collisionFilterMask,fixedRotation:this.fixedRotation,kinematic:this.kinematic}),this.instance.addEventListener("sleepy",function(){console.log(this.name+" is feeling sleepy...")}.bind(this)),this.instance.addEventListener("sleep",function(){console.log(this.name+" fell asleep!")}.bind(this)),this.instance.addEventListener("wakeup",function(){console.log(this.name+" woke up!")}.bind(this)),this.shapes.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no shape");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no shape instance");this.instance.addShape(e.instance)}.bind(this)),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.RigidBody.prototype.updateInstance=function(){this.instance.mass=this.mass,this.instance.friction=this.friction,this.instance.position.x=this.position.x,this.instance.position.y=this.position.y,this.instance.position.z=this.position.z,this.quaternion.axis.instance.x=this.quaternion.axis.x,this.quaternion.axis.instance.y=this.quaternion.axis.y,this.quaternion.axis.instance.z=this.quaternion.axis.z,this.instance.quaternion.setFromAxisAngle(this.quaternion.axis.instance,this.quaternion.angle),this.quaternion.x=this.instance.quaternion.x,this.quaternion.y=this.instance.quaternion.y,this.quaternion.z=this.instance.quaternion.z,this.quaternion.w=this.instance.quaternion.w,this.parentMesh.position.setFrom(this.position),this.parentMesh.quaternion.setFrom(this.quaternion),this.parentMesh.updateInstance(),this.instance.velocity.x=this.velocity.x,this.instance.velocity.y=this.velocity.y,this.instance.velocity.z=this.velocity.z,this.instance.angularVelocity.x=this.angularVelocity.x,this.instance.angularVelocity.y=this.angularVelocity.y,this.instance.angularVelocity.z=this.angularVelocity.z,this.instance.linearDamping=this.linearDamping,this.instance.angularDamping=this.angularDamping,this.instance.allowSleep=this.allowSleep,this.instance.sleepSpeedLimit=this.sleepSpeedLimit,this.instance.sleepTimeLimit=this.sleepTimeLimit,this.instance.collisionFilterGroup=this.collisionFilterGroup,this.instance.collisionFilterMask=this.collisionFilterMask,this.instance.fixedRotation=this.fixedRotation,this.instance.kinematic=this.kinematic},GameLib.D3.RigidBody.prototype.setFromParentMesh=function(){this.parentMesh&&this.parentMesh.instance||console.log("no parent mesh or instance"),this.instance.position.x=this.parentMesh.position.x,this.instance.position.y=this.parentMesh.position.y,this.instance.position.z=this.parentMesh.position.z,this.instance.quaternion.x=this.parentMesh.quaternion.x,this.instance.quaternion.y=this.parentMesh.quaternion.y,this.instance.quaternion.z=this.parentMesh.quaternion.z,this.instance.quaternion.w=this.parentMesh.quaternion.w},GameLib.D3.RigidBody.prototype.toApiObject=function(){return new GameLib.D3.API.RigidBody(this.id,this.name,this.mass,this.friction,this.position.toApiObject(),this.quaternion.toApiObject(),this.velocity.toApiObject(),this.angularVelocity.toApiObject(),this.linearDamping,this.angularDamping,this.allowSleep,this.sleepSpeedLimit,this.sleepTimeLimit,this.collisionFilterGroup,this.collisionFilterMask,this.fixedRotation,this.shapes.map(function(e){return GameLib.Utils.IdOrNull(e)}),this.kinematic,GameLib.Utils.IdOrNull(this.parentMesh),GameLib.Utils.IdOrNull(this.parentWorld),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.RigidBody.FromObject=function(e,t){var i=GameLib.D3.API.RigidBody.FromObject(t);return new GameLib.D3.RigidBody(e,i)},GameLib.D3.RigidBody.prototype.applyForce=function(){this.instance.applyForce(this.force.instance,this.forcePoint.instance)},GameLib.D3.RigidBody.prototype.applyLocalForce=function(){this.instance.applyLocalForce(this.force.instance,this.forcePoint.instance)},GameLib.D3.Scene=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Scene)return t;GameLib.D3.API.Scene.call(this,t.id,t.name,t.meshes,t.lights,t.textures,t.materials,t.images,t.fog,t.renderCamera,t.showGrid,t.showAxis,t.gridSize,t.gridColor,t.parentEntity),this.meshes=this.meshes.map(function(e){return e instanceof GameLib.D3.API.Mesh?(e.parentScene=this,new GameLib.D3.Mesh(this.graphics,e)):e}.bind(this)),this.lights=this.lights.map(function(e){return e instanceof GameLib.D3.API.Light?new GameLib.D3.Light(this.graphics,e):e}.bind(this)),this.textures=this.textures.map(function(e){if(e instanceof GameLib.D3.API.Texture){return new GameLib.D3.Texture(this.graphics,e)}return e}.bind(this)),this.materials=this.materials.map(function(e){if(e instanceof GameLib.D3.API.Material){return new GameLib.D3.Material(this.graphics,e)}return e}.bind(this)),this.images=this.images.map(function(e){if(e instanceof GameLib.D3.API.Image){return new GameLib.D3.Image(this.graphics,e)}return e}.bind(this)),this.fog instanceof GameLib.D3.API.Fog&&(this.fog=new GameLib.D3.Fog(this.graphics,this.fog)),this.renderCamera instanceof GameLib.D3.API.Camera&&(this.renderCamera=new GameLib.D3.Camera(this.graphics,this.renderCamera)),this.gridColor instanceof GameLib.API.Color&&(this.gridColor=new GameLib.Color(this.graphics,this.gridColor,this)),this.helpers=[],this.clones=[],this.grid=[],this.axis=[],this.storeClones=!1,GameLib.Component.call(this,GameLib.Component.COMPONENT_SCENE,{meshes:[GameLib.D3.Mesh],lights:[GameLib.D3.Light],textures:[GameLib.D3.Texture],materials:[GameLib.D3.Material],images:[GameLib.D3.Image],fog:GameLib.D3.Fog,renderCamera:GameLib.D3.Camera})},GameLib.D3.Scene.prototype=Object.create(GameLib.D3.API.Scene.prototype),GameLib.D3.Scene.prototype.constructor=GameLib.D3.Scene,GameLib.D3.Scene.prototype.createInstance=function(){this.instance=new THREE.Scene,this.instance.name=this.name,this.fog&&this.fog.instance&&(this.instance.fog=this.fog.instance),this.meshes.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no mesh");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no mesh instance");this.instance.add(e.instance),e.parentScene=this}.bind(this)),this.lights.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no light");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no light instance");this.instance.add(e.instance),e.parentScene=this}.bind(this)),this.showGrid&&this.drawGrid(),this.showAxis&&this.drawAxis(),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Scene.prototype.updateInstance=function(e){if("name"===e)return void(this.instance.name=this.name);this.fog&&this.fog.instance!==this.instance.fog&&(this.instance.fog=this.fog.instance),this.meshes.map(function(e){this.instance.children.indexOf(-1===e.instance)&&this.instance.add(e.instance)}.bind(this)),this.lights.map(function(e){-1===this.instance.children.indexOf(e.instance)&&this.instance.add(e.instance)}.bind(this)),this.instance.children.map(function(e){var t=this.meshes.map(function(e){return e.instance}),i=this.lights.map(function(e){return e.instance});(e instanceof THREE.Mesh||e instanceof THREE.Light)&&-1===i.indexOf(e)&&-1===t.indexOf(e)&&this.instance.remove(e)}.bind(this)),"showGrid"!==e&&"gridSize"!==e&&"gridColor"!==e||(this.showGrid?this.drawGrid():this.removeGrid()),"showAxis"===e&&(this.showAxis?this.drawAxis():this.removeAxis())},GameLib.D3.Scene.prototype.toApiObject=function(){var e=this.meshes.reduce(function(e,t){return(-1===this.clones.indexOf(t)||this.storeClones)&&e.push(GameLib.Utils.IdOrNull(t)),e}.bind(this),[]),t=this.lights.reduce(function(e,t){return(-1===this.clones.indexOf(t)||this.storeClones)&&e.push(GameLib.Utils.IdOrNull(t)),e}.bind(this),[]),i=this.textures.map(function(e){return GameLib.Utils.IdOrNull(e)}),n=this.materials.map(function(e){return GameLib.Utils.IdOrNull(e)}),s=this.images.map(function(e){return GameLib.Utils.IdOrNull(e)});return new GameLib.D3.API.Scene(this.id,this.name,e,t,i,n,s,GameLib.Utils.IdOrNull(this.fog),GameLib.Utils.IdOrNull(this.renderCamera),this.showGrid,this.showAxis,this.gridSize,this.gridColor.toApiObject(),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Scene.FromObject=function(e,t){var i=GameLib.D3.API.Scene.FromObject(t);return new GameLib.D3.Scene(e,i)},GameLib.D3.Scene.prototype.addObject=function(e){e instanceof GameLib.D3.Mesh?-1===this.meshes.indexOf(e)&&this.meshes.push(e):e instanceof GameLib.D3.API.Mesh&&(e=new GameLib.D3.Mesh(this.graphics,e),this.meshes.push(e)),e instanceof GameLib.D3.Light?-1===this.lights.indexOf(e)&&this.lights.push(e):e instanceof GameLib.D3.API.Light&&(e=new GameLib.D3.Light(this.graphics,e),this.lights.push(e)),e.parentScene=this,this.instance&&e.instance&&-1===this.instance.children.indexOf(e.instance)&&this.instance.add(e.instance)},GameLib.D3.Scene.prototype.addClone=function(e){(e instanceof GameLib.D3.Mesh||e instanceof GameLib.D3.Light)&&(this.instance&&e.instance&&this.instance.add(e.instance),GameLib.Utils.PushUnique(this.clones,e),e.parentScene=this)},GameLib.D3.Scene.prototype.removeObject=function(e){var t=-1;if(e instanceof GameLib.D3.Mesh)t=this.meshes.indexOf(e),-1!==t&&this.meshes.splice(t,1),-1!==(t=this.clones.indexOf(e))&&this.clones.splice(t,1);else{if(!(e instanceof GameLib.D3.Light))return void console.warn("Cannot remove this object - what is this ?"+e.toString());t=this.lights.indexOf(e),-1!==t&&this.lights.splice(t,1),-1!==(t=this.clones.indexOf(e))&&this.clones.splice(t,1)}-1!==this.instance.children.indexOf(e.instance)?this.instance.remove(e.instance):console.warn("no scene instance"),e.parentScene===this&&(e.parentScene=null)},GameLib.D3.Scene.prototype.drawGrid=function(){this.removeGrid();for(var e=new THREE.LineBasicMaterial({color:this.gridColor.toHex(),linewidth:1}),t=-this.gridSize;t<=this.gridSize;t+=1){var i=new THREE.Geometry;i.vertices.push(new THREE.Vector3(t,0,-1*this.gridSize),new THREE.Vector3(t,0,this.gridSize));var n=new THREE.Line(i,e);this.instance.add(n),this.grid.push(n);var s=new THREE.Geometry;s.vertices.push(new THREE.Vector3(-1*this.gridSize,0,t),new THREE.Vector3(this.gridSize,0,t));var a=new THREE.Line(s,e);this.instance.add(a),this.grid.push(a)}},GameLib.D3.Scene.prototype.removeGrid=function(){this.grid.map(function(e){this.instance.remove(e)}.bind(this))},GameLib.D3.Scene.prototype.drawAxis=function(){this.removeAxis();var e=new THREE.LineBasicMaterial({color:16711680,linewidth:2}),t=new THREE.Geometry;t.vertices.push(new THREE.Vector3(0,0,0),new THREE.Vector3(100,0,0));var i=new THREE.Line(t,e);this.instance.add(i),this.axis.push(i);var n=new THREE.LineBasicMaterial({color:65280,linewidth:2}),s=new THREE.Geometry;s.vertices.push(new THREE.Vector3(0,0,0),new THREE.Vector3(0,100,0));var a=new THREE.Line(s,n);this.instance.add(a),this.axis.push(a);var o=new THREE.LineBasicMaterial({color:255,linewidth:2}),r=new THREE.Geometry;r.vertices.push(new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,100));var h=new THREE.Line(r,o);this.instance.add(h),this.axis.push(h)},GameLib.D3.Scene.prototype.removeAxis=function(){this.axis.map(function(e){this.instance.remove(e)}.bind(this))},GameLib.D3.Shape=function(e,t){if(this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Shape)return t;GameLib.D3.API.Shape.call(this,t.id,t.name,t.boundingSphereRadius,t.collisionResponse,t.frictionMaterial,t.parentMesh,t.parentEntity);var i=GameLib.Component.COMPONENT_SHAPE,n={frictionMaterial:GameLib.D3.FrictionMaterial,parentMesh:GameLib.D3.Mesh};this instanceof GameLib.D3.Shape.Box&&(i=GameLib.Component.COMPONENT_SHAPE_BOX),this instanceof GameLib.D3.Shape.ConvexHull&&(i=GameLib.Component.COMPONENT_SHAPE_CONVEX_HULL),this instanceof GameLib.D3.Shape.ConvexHull.Cylinder&&(i=GameLib.Component.COMPONENT_SHAPE_CONVEX_HULL_CYLINDER),this instanceof GameLib.D3.Shape.Sphere&&(i=GameLib.Component.COMPONENT_SHAPE_SPHERE),this instanceof GameLib.D3.Shape.TriMesh&&(i=GameLib.Component.COMPONENT_SHAPE_TRI_MESH),this instanceof GameLib.D3.Shape.Plane&&(i=GameLib.Component.COMPONENT_SHAPE_PLANE),this instanceof GameLib.D3.Shape.HeightMap&&(i=GameLib.Component.COMPONENT_SHAPE_HEIGHT_MAP),GameLib.Component.call(this,i,n)},GameLib.D3.Shape.prototype=Object.create(GameLib.D3.API.Shape.prototype),GameLib.D3.Shape.prototype.constructor=GameLib.D3.Shape,GameLib.D3.Shape.prototype.createInstance=function(){GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Shape.prototype.updateInstance=function(){throw new Error("Do not instantiate this class directly - use a child class instead")},GameLib.D3.Shape.prototype.toApiObject=function(){return new GameLib.D3.API.Shape(this.id,this.name,this.boundingSphereRadius,this.collisionResponse,GameLib.Utils.IdOrNull(this.frictionMaterial),GameLib.Utils.IdOrNull(this.parentMesh),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Shape.FromObject=function(e,t){throw"not implemented"},GameLib.D3.Shape.prototype.stopVisualize=function(){GameLib.Event.Emit(GameLib.Event.STOP_VISUALIZE,{mesh:this.mesh})},GameLib.D3.Shape.prototype.visualize=function(){GameLib.Event.Emit(GameLib.Event.VISUALIZE,{shape:this})},GameLib.D3.Shape.Box=function(e,t,i){this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(i)?i=new GameLib.Vector3(e,new GameLib.API.Vector3(1,1,1)):i instanceof GameLib.API.Vector3&&(i=new GameLib.Vector3(this.physics,i,this)),this.halfExtents=i,GameLib.D3.Shape.call(this,this.physics,t)},GameLib.D3.Shape.Box.prototype=Object.create(GameLib.D3.Shape.prototype),GameLib.D3.Shape.Box.prototype.constructor=GameLib.D3.Shape.Box,GameLib.D3.Shape.Box.prototype.createInstance=function(){if(GameLib.Utils.UndefinedOrNull(this.halfExtents))throw new Error("no halfExtents");if(GameLib.Utils.UndefinedOrNull(this.halfExtents.instance))throw new Error("no halfExtents instance");this.instance=new CANNON.Box(this.halfExtents.instance),GameLib.D3.Shape.prototype.createInstance.call(this)},GameLib.D3.Shape.Box.prototype.updateInstance=function(){this.instance.halfExtents.x=this.halfExtents.x,this.instance.halfExtents.y=this.halfExtents.y,this.instance.halfExtents.z=this.halfExtents.z,this.instance.updateBoundingSphereRadius(),this.instance.updateConvexPolyhedronRepresentation()},GameLib.D3.Shape.Box.prototype.toApiObject=function(){var e=GameLib.D3.Shape.prototype.toApiObject.call(this);return e.halfExtents=this.halfExtents.toApiObject(),e},GameLib.D3.Shape.Box.prototype.setFromMesh=function(){if(null===this.parentMesh)return void console.log("select a mesh first");var e=this.parentMesh.getBoundingBox();this.halfExtents.x=e.x/2,this.halfExtents.y=e.y/2,this.halfExtents.z=e.z/2,this.halfExtents.updateInstance()},GameLib.D3.Shape.Box.FromObject=function(e,t){var i=GameLib.D3.API.Shape.FromObject(t);return i.halfExtents=GameLib.API.Vector3.FromObject(t.halfExtents),new GameLib.D3.Shape.Box(e,i,i.halfExtents)},GameLib.D3.Shape.ConvexHull=function(e,t,i,n,s,a){if(this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Shape.ConvexHull)return t;GameLib.Utils.UndefinedOrNull(i)&&(i=[]),this.vertices=i,GameLib.Utils.UndefinedOrNull(n)&&(n=[]),this.faces=n,GameLib.Utils.UndefinedOrNull(s)&&(s=[]),this.uniqueAxes=s,GameLib.Utils.UndefinedOrNull(a)&&(a=[]),this.uniqueEdges=a,this.vertices=this.vertices.map(function(e){return e instanceof GameLib.D3.API.Vertex?new GameLib.D3.Vertex(this.physics,e):e}.bind(this)),this.faces=this.faces.map(function(e){return e instanceof GameLib.D3.API.Face?new GameLib.D3.Face(this.physics,e):e}.bind(this)),this.uniqueAxes=this.uniqueAxes.map(function(e){return e instanceof GameLib.API.Vector3?new GameLib.Vector3(this.physics,e,this):e}.bind(this)),this.uniqueEdges=this.uniqueEdges.map(function(e){return e instanceof GameLib.API.Vector3?new GameLib.Vector3(this.physics,e,this):e}.bind(this)),GameLib.D3.Shape.call(this,this.physics,t)},GameLib.D3.Shape.ConvexHull.prototype=Object.create(GameLib.D3.Shape.prototype),GameLib.D3.Shape.ConvexHull.prototype.constructor=GameLib.D3.Shape.ConvexHull,GameLib.D3.Shape.ConvexHull.prototype.createInstance=function(){var e=[];this.instance=new CANNON.ConvexPolyhedron(this.vertices.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no vertex");if(GameLib.Utils.UndefinedOrNull(e.position))throw new Error("no vertex position");if(GameLib.Utils.UndefinedOrNull(e.position.instance))throw new Error("no vertex position instance");return e.position.instance}),this.faces.map(function(t){if(GameLib.Utils.UndefinedOrNull(t))throw new Error("no face");if(GameLib.Utils.UndefinedOrNull(t.normal))throw new Error("no face normal");if(GameLib.Utils.UndefinedOrNull(t.normal.instance))throw new Error("no face normal instance");if(GameLib.Utils.UndefinedOrNull(t.v0index))throw new Error("no face v0index");if(GameLib.Utils.UndefinedOrNull(t.v1index))throw new Error("no face v1index");if(GameLib.Utils.UndefinedOrNull(t.v2index))throw new Error("no face v2index");return e.push(t.normal.instance),[t.v0index,t.v1index,t.v2index]})),this.instance.faceNormals=e,GameLib.D3.Shape.prototype.createInstance.call(this)},GameLib.D3.Shape.ConvexHull.prototype.updateInstance=function(){console.log("todo: update convex hull instance")},GameLib.D3.Shape.ConvexHull.prototype.loadFromInstance=function(){console.log("todo: eventually load the faces and vertices from the instance faces and vertices and normals"),console.log("todo: this way we can nicely visualize them with our gamelib classes :)")},GameLib.D3.Shape.ConvexHull.prototype.toApiObject=function(){var e=GameLib.D3.Shape.prototype.toApiObject.call(this);return e.vertices=this.vertices.map(function(e){return e instanceof GameLib.D3.Vertex?e.toApiObject():e}),e.faces=this.faces.map(function(e){return e instanceof GameLib.D3.Face?e.toApiObject():e}),e.uniqueAxes=this.uniqueAxes.map(function(e){return e instanceof GameLib.Vector3?e.toApiObject():e}),e.uniqueEdges=this.uniqueEdges.map(function(e){return e instanceof GameLib.Vector3?e.toApiObject():e}),e},GameLib.D3.Shape.ConvexHull.prototype.setFromMesh=function(){console.log("todo: set convex hull from mesh"),this.updateInstance()},GameLib.D3.Shape.ConvexHull.InheritableProperties=function(e,t){return{vertices:t.vertices.map(function(t){return GameLib.D3.Vertex.FromObject(e,t)}),faces:t.faces.map(function(t){return GameLib.D3.Face.FromObject(e,t)}),uniqueAxes:t.uniqueAxes.map(function(e){return GameLib.API.Vector3.FromObject(e)}),uniqueEdges:t.uniqueEdges.map(function(e){return GameLib.API.Vector3.FromObject(e)})}},GameLib.D3.Shape.ConvexHull.FromObject=function(e,t){var i=GameLib.D3.API.Shape.FromObject(t),n=GameLib.D3.Shape.ConvexHull.InheritableProperties(e,t);return new GameLib.D3.Shape.ConvexHull.call(this,e,i,n.vertices,n.faces,n.uniqueAxes,n.uniqueEdges)},GameLib.D3.Shape.ConvexHull.Cylinder=function(e,t,i,n,s,a){this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(i)&&(i=1),this.radiusTop=i,GameLib.Utils.UndefinedOrNull(n)&&(n=1),this.radiusBottom=n,GameLib.Utils.UndefinedOrNull(s)&&(s=n/2),this.height=s,GameLib.Utils.UndefinedOrNull(a)&&(a=20),this.numSegments=a,GameLib.D3.Shape.ConvexHull.call(this,this.physics,t)},GameLib.D3.Shape.ConvexHull.Cylinder.prototype=Object.create(GameLib.D3.Shape.ConvexHull.prototype),GameLib.D3.Shape.ConvexHull.Cylinder.prototype.constructor=GameLib.D3.Shape.ConvexHull.Cylinder,GameLib.D3.Shape.ConvexHull.Cylinder.prototype.createInstance=function(){this.instance=new CANNON.Cylinder(this.radiusTop,this.radiusBottom,this.height,this.numSegments),GameLib.D3.Shape.prototype.createInstance.call(this)},GameLib.D3.Shape.ConvexHull.Cylinder.prototype.updateInstance=function(){console.log("todo : update cylinder instance")},GameLib.D3.Shape.ConvexHull.Cylinder.prototype.setFromMesh=function(){this.radiusTop=this.parentMesh.dimensions.x/2,this.radiusBottom=this.parentMesh.dimensions.x/2,this.height=this.parentMesh.dimensions.z},GameLib.D3.Shape.ConvexHull.Cylinder.prototype.toApiObject=function(){var e=GameLib.D3.Shape.ConvexHull.prototype.toApiObject.call(this);return e.radiusTop=this.radiusTop,e.radiusBottom=this.radiusBottom,e.height=this.height,e.numSegments=this.numSegments,e},GameLib.D3.Shape.ConvexHull.Cylinder.FromObject=function(e,t){var i=GameLib.D3.API.Shape.FromObject(t),n=GameLib.D3.Shape.ConvexHull.InheritableProperties(e,t);for(var s in n)n.hasOwnProperty(s)&&(i[s]=n[s]);return new GameLib.D3.Shape.ConvexHull.Cylinder(e,i,t.radiusTop,t.radiusBottom,t.height,t.numSegments)},GameLib.D3.Shape.HeightMap=function(e,t,i,n,s,a){this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(i)&&(i=[[10,10,10],[10,10,10],[10,10,10]]),this.heightData=i,GameLib.Utils.UndefinedOrNull(n)&&(n=0),this.minValue=n,GameLib.Utils.UndefinedOrNull(s)&&(s=10),this.maxValue=s,GameLib.Utils.UndefinedOrNull(a)&&(a=1),this.elementSize=a,GameLib.D3.Shape.call(this,this.physics,t)},GameLib.D3.Shape.HeightMap.prototype=Object.create(GameLib.D3.Shape.prototype),GameLib.D3.Shape.HeightMap.prototype.constructor=GameLib.D3.Shape.HeightMap,GameLib.D3.Shape.HeightMap.prototype.createInstance=function(){this.instance=new CANNON.Heightfield(this.heightData,{elemSize:this.elementSize}),GameLib.D3.Shape.prototype.createInstance.call(this)},GameLib.D3.Shape.HeightMap.prototype.updateInstance=function(){this.instance.data=this.heightData,this.instance.elemSize=this.elemSize,this.instance.update()},GameLib.D3.Shape.HeightMap.prototype.toApiObject=function(){var e=GameLib.D3.Shape.prototype.toApiObject.call(this);return e.heightData=this.heightData,e.minValue=this.minValue,e.maxValue=this.maxValue,e.elemSize=this.elemSize,e},GameLib.D3.Shape.HeightMap.prototype.setFromMesh=function(){if(null===this.parentMesh)return void console.log("select a mesh first");if(!this.parentMesh.isHeightMap)return void console.log("not a heightmap mesh");var e=Array.prototype.slice.call(this.parentMesh.getHeightData());this.heightData=[];for(var t=0;t<=this.parentMesh.widthSegments;t++){this.heightData[t]=[];for(var i=0;i<=this.parentMesh.heightSegments;i++)this.heightData[t][i]=e[t*(this.parentMesh.widthSegments+1)+i]}this.updateInstance()},GameLib.D3.Shape.HeightMap.FromObject=function(e,t){var i=GameLib.D3.API.Shape.FromObject(t);return new GameLib.D3.Shape.HeightMap(e,i,t.heightData,t.minValue,t.maxValue,t.elemSize)},GameLib.D3.Shape.Plane=function(e,t){this.physics=e,this.physics.isNotCannonThrow(),GameLib.D3.Shape.call(this,this.physics,t)},GameLib.D3.Shape.Plane.prototype=Object.create(GameLib.D3.Shape.prototype),GameLib.D3.Shape.Plane.prototype.constructor=GameLib.D3.Shape.Plane,GameLib.D3.Shape.Plane.prototype.createInstance=function(){this.instance=new CANNON.Plane,GameLib.D3.Shape.prototype.createInstance.call(this)},GameLib.D3.Shape.Plane.prototype.updateInstance=function(){},GameLib.D3.Shape.Plane.FromObject=function(e,t){var i=GameLib.D3.API.Shape.FromObject(t);return new GameLib.D3.Shape.Plane(e,i)},GameLib.D3.Shape.Sphere=function(e,t,i){this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(i)&&(i=1),this.radius=i,GameLib.D3.Shape.call(this,this.physics,t)},GameLib.D3.Shape.Sphere.prototype=Object.create(GameLib.D3.Shape.prototype),GameLib.D3.Shape.Sphere.prototype.constructor=GameLib.D3.Shape.Sphere,GameLib.D3.Shape.Sphere.prototype.createInstance=function(){this.instance=new CANNON.Sphere(this.radius),GameLib.D3.Shape.prototype.createInstance.call(this)},GameLib.D3.Shape.Sphere.prototype.updateInstance=function(){this.instance.radius=this.radius,this.instance.updateBoundingSphereRadius()},GameLib.D3.Shape.Sphere.prototype.toApiObject=function(){var e=GameLib.D3.Shape.prototype.toApiObject.call(this);return e.radius=this.radius,e},GameLib.D3.Shape.Sphere.FromObject=function(e,t){var i=GameLib.D3.API.Shape.FromObject(t);return new GameLib.D3.Shape.Sphere(e,i,t.radius)},GameLib.D3.Shape.TriMesh=function(e,t,i,n){this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(i)&&(i=[]),this.vertices=i,GameLib.Utils.UndefinedOrNull(n)&&(n=[]),this.indices=n,GameLib.D3.Shape.call(this,this.physics,t)},GameLib.D3.Shape.TriMesh.prototype=Object.create(GameLib.D3.Shape.prototype),GameLib.D3.Shape.TriMesh.prototype.constructor=GameLib.D3.Shape.TriMesh,GameLib.D3.Shape.TriMesh.prototype.createInstance=function(){this.instance=new CANNON.TriMesh(this.vertices,this.indices),GameLib.D3.Shape.prototype.createInstance.call(this)},GameLib.D3.Shape.TriMesh.prototype.updateInstance=function(){this.instance.vertices=this.vertices,this.instance.indices=this.indices,this.instance.updateAABB(),this.instance.updateBoundingSphereRadius(),this.instance.updateEdges(),this.instance.updateNormals(),this.instance.updateTree()},GameLib.D3.Skeleton=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Skeleton)return t;GameLib.D3.API.Skeleton.call(this,t.id,t.name,t.bones,t.boneInverses,t.useVertexTexture,t.boneTextureWidth,t.boneTextureHeight,t.boneMatrices,t.boneTexture,t.parentEntity),this.bones=this.bones.map(function(e){if(e instanceof GameLib.D3.API.Bone)return new GameLib.D3.Bone(this.graphics,e);throw console.warn("apiBone not an instance of API.Bone"),new Error("apiBone not an instance of API.Bone")}.bind(this)),this.boneInverses=this.boneInverses.map(function(e){if(e instanceof GameLib.API.Matrix4)return new GameLib.Matrix4(this.graphics,e,this);throw console.warn("boneInverse not an instance of API.Matrix4"),new Error("boneInverse not an instance of API.Matrix4")}.bind(this)),this.boneMatrices=this.boneMatrices.map(function(e){if(e instanceof GameLib.API.Matrix4)return new GameLib.Matrix4(this.graphics,e,this);throw console.warn("boneMatrices not an instance of API.Matrix4"),new Error("boneMatrices not an instance of API.Matrix4")}.bind(this)),GameLib.Component.call(this,GameLib.Component.COMPONENT_SKELETON,{bones:[GameLib.D3.Bone]})},GameLib.D3.Skeleton.prototype=Object.create(GameLib.D3.API.Skeleton.prototype),GameLib.D3.Skeleton.prototype.constructor=GameLib.D3.Skeleton,GameLib.D3.Skeleton.prototype.createInstance=function(e){var t=this.bones.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no bone");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no bone instance");return e.instance}),i=this.bones.reduce(function(e,t){return e||(0===t.parentBoneIds.length?t.instance:null)},null);if(GameLib.Utils.UndefinedOrNull(i))throw new Error("could not find parent bone instance");this.instance=new THREE.Skeleton(t),this.rootBoneInstance=i,this.instance.useVertexTexture=this.useVertexTexture,this.boneIdToBone={},this.bones.map(function(e){this.boneIdToBone[e.id]=e}.bind(this)),this.bones.map(function(e){return function(t){t.childBoneIds.map(function(t){e.add(this.boneIdToBone[t].instance)}.bind(this))}}(i).bind(this)),this.instance.update(),this.instance.calculateInverses(),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Skeleton.prototype.updateInstance=function(){},GameLib.D3.Skeleton.prototype.toApiObject=function(){return new GameLib.D3.API.Skeleton(this.id,this.name,this.bones.map(function(e){return e.toApiObject()}),this.boneInverses.map(function(e){return e.toApiObject()}),this.useVertexTexture,this.boneTextureWidth,this.boneTextureHeight,this.boneMatrices.map(function(e){return e.toApiObject()}),this.boneTexture,this.parentEntity)},GameLib.D3.Skeleton.FromObject=function(e,t){if(!t)return null;var i=GameLib.D3.API.Skeleton.FromObject(t);return new GameLib.D3.Skeleton(e,i)},GameLib.D3.Solver=function(e,t){if(this.physics=e,this.physics.isNotCannonThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Solver)return t;GameLib.D3.API.Solver.call(this,t.id,t.name,t.solverType,t.iterations,t.tolerance,t.parentEntity),GameLib.Component.call(this,GameLib.Component.COMPONENT_SOLVER)},GameLib.D3.Solver.prototype=Object.create(GameLib.D3.API.Solver.prototype),GameLib.D3.Solver.prototype.constructor=GameLib.D3.Solver,GameLib.D3.Solver.prototype.createInstance=function(){if(this.solverType===GameLib.D3.Solver.GS_SOLVER)this.instance=new CANNON.GSSolver;else{if(this.solverType!==GameLib.D3.Solver.SPLIT_SOLVER)throw new Error("unsupported solver type: "+this.solverType);this.instance=new CANNON.SplitSolver}this.instance.tolerance=this.tolerance,this.instance.iterations=this.iterations,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Solver.prototype.updateInstance=function(){this.solverType===GameLib.D3.Solver.GS_SOLVER&&(this.instance instanceof CANNON.GSSolver||(this.instance=new CANNON.GSSolver)),this.solverType===GameLib.D3.Solver.SPLIT_SOLVER&&(this.instance instanceof CANNON.SplitSolver||(this.instance=new CANNON.SplitSolver)),this.instance.iterations=this.iterations,this.instance.tolerance=this.tolerance},GameLib.D3.Solver.prototype.toApiObject=function(){return new GameLib.D3.API.Solver(this.id,this.name,this.solverType,this.iterations,this.tolerance,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Solver.FromObject=function(e,t){var i=GameLib.D3.API.Solver.FromObject(t);return new GameLib.D3.Solver(e,i)},GameLib.D3.Solver.GS_SOLVER=1,GameLib.D3.Solver.SPLIT_SOLVER=2,GameLib.D3.Spline=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Spline)return t;GameLib.D3.API.Spline.call(this,t.id,t.name,t.vertices,t.parentEntity),this.vertices=this.vertices.map(function(t){return new GameLib.Vector3(e,t,this)}),GameLib.Component.call(this,GameLib.Component.COMPONENT_SPLINE)},GameLib.D3.Spline.prototype=Object.create(GameLib.D3.API.Spline.prototype),GameLib.D3.Spline.prototype.constructor=GameLib.D3.Spline,GameLib.D3.Spline.prototype.createInstance=function(){var e=this.vertices.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no vertex");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no vertex instance");return e.instance});this.instance=THREE.CatmullRomCurve3(e),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Spline.prototype.updateInstance=function(){var e=this.vertices.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no vertex") diff --git a/build/game-lib.js b/build/game-lib.js index 882d362..04809de 100644 --- a/build/game-lib.js +++ b/build/game-lib.js @@ -1,5 +1,5 @@ // COMPILE TIME DEFINITIONS (Generated via gulp) -var __DATE__ = "Wed Nov 29 2017 22:24:30 GMT+0100 (CET)"; +var __DATE__ = "Wed Nov 29 2017 22:26:34 GMT+0100 (CET)"; // END COMPILE TIME DEFINITIONS /** @@ -13762,7 +13762,7 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) { /** * Setyp mesh vertices colors */ - var colors = Float32Array.from( + var colors = new Float32Array( this.faces.reduce( function(result, face){ result.push(1,1,1,1,1,1,1,1,1); @@ -13785,7 +13785,7 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) { /** * Setup face UVs */ - var uvs = Float32Array.from( + var uvs = new Float32Array( this.faces.reduce( function(result, face) { @@ -13803,7 +13803,7 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) { ); geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2)); - var normals = Float32Array.from( + var normals = new Float32Array( this.faces.reduce( function(result, face) { diff --git a/src/game-lib-d3-mesh-0.js b/src/game-lib-d3-mesh-0.js index e7a1b46..e5e1aac 100644 --- a/src/game-lib-d3-mesh-0.js +++ b/src/game-lib-d3-mesh-0.js @@ -281,7 +281,7 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) { /** * Setyp mesh vertices colors */ - var colors = Float32Array.from( + var colors = new Float32Array( this.faces.reduce( function(result, face){ result.push(1,1,1,1,1,1,1,1,1); @@ -304,7 +304,7 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) { /** * Setup face UVs */ - var uvs = Float32Array.from( + var uvs = new Float32Array( this.faces.reduce( function(result, face) { @@ -322,7 +322,7 @@ GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) { ); geometry.addAttribute('uv', new THREE.BufferAttribute(uvs, 2)); - var normals = Float32Array.from( + var normals = new Float32Array( this.faces.reduce( function(result, face) {