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

13 lines
400 KiB
JavaScript
Raw Normal View History

2017-11-19 20:09:58 +01:00
function GameLib(){}var __DATE__="Sun Nov 19 2017 20:08:36 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.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.GAME_RESTART=90,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_UP
2017-11-19 19:43:53 +01:00
;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 impl
2017-11-19 20:09:58 +01:00
GameLib.D3.API.Light=function(e,t,i,n,s,a,o,r,c,h,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(c)&&(c=new GameLib.API.Vector3(0,0,0)),this.rotation=c,GameLib.Utils.UndefinedOrNull(h)&&(h=new GameLib.API.Vector3(1,1,1)),this.scale=h,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,c,h,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,ce,he,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(c)&&(c=1),this.aoMapIntensity=c,GameLib.Utils.UndefinedOrNull
2017-11-19 19:43:53 +01:00
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,c,h){GameLib.Utils.UndefinedOrNull(h)&&(h=null),this.parentEntity=h,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(c)&&(c=null),this.boneTexture=c},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,
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.im
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.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.instanc
if(this.instance.userData.width!==this.width||this.instance.userData.height!==this.height||this.instance.userData.depth!==this.depth){this.instance.userData.width=this.width,this.instance.userData.height=this.height,this.instance.userData.depth=this.depth;var t=new THREE.BoxGeometry(this.width,this.height,this.depth);this.updateVerticesFromGeometryInstance(t),t=this.createInstanceGeometry(),this.instance.geometry=t}GameLib.D3.Mesh.prototype.updateInstance.call(this,e)},GameLib.D3.Mesh.Box.prototype.toApiObject=function(){var e=GameLib.D3.Mesh.prototype.toApiObject.call(this);return e.width=this.width,e.height=this.height,e.depth=this.depth,e},GameLib.D3.Mesh.Box.FromObject=function(e,t){var i=GameLib.D3.API.Mesh.FromObject(t);return new GameLib.D3.Mesh.Box(e,i,t.width,t.height,t.depth)},GameLib.D3.Mesh.Curve=function(e,t){this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.D3.Mesh.call(this,this.graphics,t)},GameLib.D3.Mesh.Curve.prototype=Object.create(GameLib.D3.Mesh.prototype),GameLib.D3.Mesh.Curve.prototype.constructor=GameLib.D3.Mesh.Curve,GameLib.D3.Mesh.Curve.prototype.createInstance=function(){var e=new THREE.Geometry;this.applyVertexDataToInstance(e);var t=new THREE.Points(e);return this.createInstanceDefaults(t),t},GameLib.D3.Mesh.Cylinder=function(e,t,i,n,s,a,o,r,c,h){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),t instanceof GameLib.D3.Mesh.Box)return t;t.meshType=GameLib.D3.Mesh.MESH_TYPE_CYLINDER,GameLib.Utils.UndefinedOrNull(i)&&(i=1),this.radiusTop=i,GameLib.Utils.UndefinedOrNull(n)&&(n=1),this.radiusBottom=n,GameLib.Utils.UndefinedOrNull(s)&&(s=5),this.height=s,GameLib.Utils.UndefinedOrNull(a)&&(a=10),this.radiusSegments=a,GameLib.Utils.UndefinedOrNull(o)&&(o=10),this.heightSegments=o,GameLib.Utils.UndefinedOrNull(r)&&(r=!1),this.openEnded=r,GameLib.Utils.UndefinedOrNull(c)&&(c=0),this.thetaStart=c,GameLib.Utils.UndefinedOrNull(h)&&(h=2*Math.PI),this.thetaLength=h,GameLib.D3.Mesh.call(this,this.graphics,t)},GameLib.D3.Mesh.Cylinder.prototype=Object.create(GameLib.D3.Mesh.prototype),GameLib.D3.Mesh.Cylinder.prototype.constructor=GameLib.D3.Mesh.Cylinder,GameLib.D3.Mesh.Cylinder.prototype.createInstance=function(){var e=null;0===this.vertices.length&&(e=new THREE.CylinderGeometry(this.radiusTop,this.radiusBottom,this.height,this.radiusSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength),this.updateVerticesFromGeometryInstance(e)),GameLib.D3.Mesh.prototype.createInstance.call(this),this.instance.userData.radiusTop=this.radiusTop,this.instance.userData.radiusBottom=this.radiusBottom,this.instance.userData.height=this.height,this.instance.userData.radiusSegments=this.radiusSegments,this.instance.userData.heightSegments=this.heightSegments,this.instance.userData.openEnded=this.openEnded,this.instance.userData.thetaStart=this.thetaStart,this.instance.userData.thetaLength=this.thetaLength},GameLib.D3.Mesh.Cylinder.prototype.updateInstance=function(e){if(this.instance.userData.radiusTop!==this.radiusTop||this.instance.userData.radiusBottom!==this.radiusBottom||this.instance.userData.height!==this.height||this.instance.userData.radiusSegments!==this.radiusSegments||this.instance.userData.heightSegments!==this.heightSegments||this.instance.userData.openEnded!==this.openEnded||this.instance.userData.thetaStart!==this.thetaStart||this.instance.userData.thetaLength!==this.thetaLength){this.instance.userData.radiusTop=this.radiusTop,this.instance.userData.radiusBottom=this.radiusBottom,this.instance.userData.height=this.height,this.instance.userData.radiusSegments=this.radiusSegments,this.instance.userData.heightSegments=this.heightSegments,this.instance.userData.openEnded=this.openEnded,this.instance.userData.thetaStart=this.thetaStart,this.instance.userData.thetaLength=this.thetaLength;var t=new THREE.CylinderGeometry(this.radiusTop,this.radiusBottom,this.height,this.radiusSegments,this.heightSegments,this.openEnded,this.thetaStart,this.thetaLength);this.updateVerticesFromGeometryInstance(t),t=this.createInstanceGeometry(),this.instance.geome
;GameLib.D3.API.PathFollowing.call(this,t.id,t.name,t.spline,t.mesh,t.raytraceMesh,t.accelleration,t.maxSpeed,t.baseOffset,t.maxOffset,t.steeringSpeed,t.targetOffset,t.currentOffset,t.currentPathValue,t.currentSpeed,t.direction,t.raycaster,t.currentPosition,t.futurePosition,t.up,t.rotationMatrix,t.rotationVector,t.parentEntity),this.baseOffset=new GameLib.Vector3(this.graphics,this.baseOffset,this),this.maxOffset=new GameLib.Vector3(this.graphics,this.maxOffset,this),this.targetOffset=new GameLib.Vector3(this.graphics,this.targetOffset,this),this.currentOffset=new GameLib.Vector3(this.graphics,this.currentOffset,this),this.raycaster=new GameLib.D3.Raycaster(this.graphics,this.raycaster),this.currentPosition=new GameLib.Vector3(this.graphics,this.currentPosition,this),this.futurePosition=new GameLib.Vector3(this.graphics,this.futurePosition,this),this.up=new GameLib.Vector3(this.graphics,this.up,this),this.rotationMatrix=new GameLib.Matrix4(this.graphics,this.rotationMatrix,this),this.rotationVector=new GameLib.Quaternion(this.graphics,this.rotationVector,this),this.mx=new GameLib.Utils.MovingAverage(10),this.my=new GameLib.Utils.MovingAverage(10),this.mz=new GameLib.Utils.MovingAverage(10),GameLib.Component.call(this,GameLib.Component.COMPONENT_PATH_FOLLOWING,{spline:GameLib.D3.Spline,mesh:GameLib.D3.Mesh,raytraceMesh:GameLib.D3.Mesh})},GameLib.D3.PathFollowing.prototype=Object.create(GameLib.D3.API.PathFollowing.prototype),GameLib.D3.PathFollowing.prototype.constructor=GameLib.D3.PathFollowing,GameLib.D3.PathFollowing.prototype.createInstance=function(){console.log("GameLib.D3.PathFollowing.prototype.createInstance()"),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.PathFollowing.prototype.toApiObject=function(){return new GameLib.D3.API.PathFollowing(this.id,this.name,GameLib.Utils.IdOrNull(this.spline),GameLib.Utils.IdOrNull(this.mesh),GameLib.Utils.IdOrNull(this.raytraceMesh),this.accelleration,this.maxSpeed,this.baseOffset.toApiObject(),this.maxOffset.toApiObject(),this.steeringSpeed,this.targetOffset.toApiObject(),this.currentOffset.toApiObject(),this.currentPathValue,this.currentSpeed,this.direction,this.raycaster.toApiObject(),this.currentPosition.toApiObject(),this.futurePosition.toApiObject(),this.up.toApiObject(),this.rotationMatrix.toApiObject(),this.rotationVector.toApiObject(),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.PathFollowing.FromObject=function(e,t){var i=GameLib.D3.API.PathFollowing.FromObject(t);return new GameLib.D3.PathFollowing(e,i)},GameLib.D3.PathFollowing.prototype.update=function(e){if(this.spline&&this.mesh&&this.raytraceMesh){this.currentSpeed+=this.accelleration*e*this.direction,this.currentSpeed>this.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
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.cre
2017-11-19 20:09:58 +01:00
GameLib.D3.Texture.TYPE_NEAREST_MIPMAP_LINEAR_FILTER=1005,GameLib.D3.Texture.TYPE_LINEAR_FILTER=1006,GameLib.D3.Texture.TYPE_LINEAR_MIPMAP_NEAREST_FILTER=1007,GameLib.D3.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER=1008,GameLib.D3.Texture.TYPE_UNSIGNED_BYTE=1009,GameLib.D3.Texture.TYPE_BYTE=1010,GameLib.D3.Texture.TYPE_SHORT=1011,GameLib.D3.Texture.TYPE_UNSIGNED_SHORT=1012,GameLib.D3.Texture.TYPE_INT=1013,GameLib.D3.Texture.TYPE_UNSIGNED_INT=1014,GameLib.D3.Texture.TYPE_FLOAT=1015,GameLib.D3.Texture.TYPE_HALF_FLOAT=1025,GameLib.D3.Texture.TYPE_LINEAR_ENCODING=3e3,GameLib.D3.Texture.TYPE_SRGB_ENCODING=3001,GameLib.D3.Texture.TYPE_GAMMA_ENCODING=3007,GameLib.D3.Texture.TYPE_RGBE_ENCODING=3002,GameLib.D3.Texture.TYPE_LOG_LUV_ENCODING=3003,GameLib.D3.Texture.TYPE_RGBM7_ENCODING=3004,GameLib.D3.Texture.TYPE_RGBM16_ENCODING=3005,GameLib.D3.Texture.TYPE_RGBD_ENCODING=3006,GameLib.D3.Texture.TEXTURE_TYPE_NORMAL=1,GameLib.D3.Texture.TEXTURE_TYPE_CUBE=2,GameLib.D3.Texture.TEXTURE_TYPE_CANVAS=3,GameLib.D3.Texture.prototype.createInstance=function(){if(this.typeId===GameLib.D3.Texture.TEXTURE_TYPE_CUBE){if(6!==this.images.length)throw new Error("not enough images for cube texture");var e=this.images.map(function(e){if(GameLib.Utils.UndefinedOrNull(e))throw new Error("no image");if(GameLib.Utils.UndefinedOrNull(e.instance))throw new Error("no image instance");return e.instance});this.instance=new THREE.CubeTexture(e)}else if(this.typeId===GameLib.D3.Texture.TEXTURE_TYPE_NORMAL)GameLib.Utils.UndefinedOrNull(this.image)||GameLib.Utils.UndefinedOrNull(this.image.instance)?this.instance=new THREE.Texture:this.instance=new THREE.Texture(this.image.instance);else if(this.typeId===GameLib.D3.Texture.TEXTURE_TYPE_CANVAS)if(GameLib.Utils.UndefinedOrNull(this.canvas))this.instance=new THREE.Texture;else{if(GameLib.Utils.UndefinedOrNull(this.canvas.instance))throw new Error("no canvas instance");this.instance=new THREE.Texture(this.canvas.instance)}this.mapping=this.instance.mapping,this.encoding=this.instance.encoding,this.format=this.instance.format,this.instance.name=this.name,this.instance.flipY=this.flipY,this.instance.offset.x=this.offset.x,this.instance.offset.y=this.offset.y,this.instance.repeat.x=this.repeat.x,this.instance.repeat.y=this.repeat.y,this.instance.wrapS=this.wrapS,this.instance.wrapT=this.wrapT,this.instance.needsUpdate=!0,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Texture.prototype.updateInstance=function(e){if(GameLib.Utils.UndefinedOrNull(this.instance))try{return void this.createInstance()}catch(e){console.error(e)}if(GameLib.Utils.UndefinedOrNull(e))throw new Error("need to specify a property");if("image"===e){if(this.typeId===GameLib.D3.Texture.TEXTURE_TYPE_NORMAL){if(GameLib.Utils.UndefinedOrNull(this.image)&&this.instance.image)try{this.createInstance()}catch(e){console.error(e)}if(this.image&&this.image.instance&&this.instance.image!==this.image.instance)try{this.createInstance()}catch(e){console.error(e)}}else if(this.typeId===GameLib.D3.Texture.TEXTURE_TYPE_CANVAS){if(GameLib.Utils.UndefinedOrNull(this.canvas)&&this.instance.canvas)try{this.createInstance()}catch(e){console.error(e)}if(this.canvas&&this.canvas.instance&&this.instance.image!==this.canvas.instance)try{this.createInstance()}catch(e){console.error(e)}}else this.typeId===GameLib.D3.Texture.TEXTURE_TYPE_CUBE&&console.log("todo : cube images change check here");this.publish(GameLib.Event.IMAGE_CHANGED,{texture:this}),this.instance.needsUpdate=!0}"name"===e&&(this.instance.name=this.name),"flipY"===e&&(this.instance.flipY=this.flipY),"encoding"===e&&(this.instance.encoding=this.encoding),"offset"===e&&(this.instance.offset.x=this.offset.x,this.instance.offset.y=this.offset.y),"repeat"===e&&(this.instance.repeat.x=this.repeat.x,this.instance.repeat.y=this.repeat.y),"mapping"===e&&(this.instance.mapping=this.mapping),"format"===e&&(this.instance.format=this.format),"wrapS"===e&&(this.instance.wrapS=this.wrapS),"wrapT"===e&&(this.instance.wrapT=this.wrapT),"animated"===e&&GameLib.Event.Emit(GameLib.Event.TEXTURE_ANIMATED_CHANGE,{texture
delete e.backupRotationYDescriptor,t=!0),e.backupRotationZDescriptor&&(Object.defineProperty(e.rotation,"z",e.backupRotationZDescriptor),delete e.backupRotationZDescriptor,t=!0),e.backupPositionXDescriptor&&(Object.defineProperty(e.position,"x",e.backupPositionXDescriptor),delete e.backupPositionXDescriptor,t=!0),e.backupPositionYDescriptor&&(Object.defineProperty(e.position,"y",e.backupPositionYDescriptor),delete e.backupPositionYDescriptor,t=!0),e.backupPositionZDescriptor&&(Object.defineProperty(e.position,"z",e.backupPositionZDescriptor),delete e.backupPositionZDescriptor,t=!0),e.backupScaleXDescriptor&&(Object.defineProperty(e.scale,"x",e.backupScaleXDescriptor),delete e.backupScaleXDescriptor,t=!0),e.backupScaleYDescriptor&&(Object.defineProperty(e.scale,"y",e.backupScaleYDescriptor),delete e.backupScaleYDescriptor,t=!0),e.backupScaleZDescriptor&&(Object.defineProperty(e.scale,"z",e.backupScaleZDescriptor),delete e.backupScaleZDescriptor,t=!0),this.latest[e.id]&&(e.rotation.x=this.latest[e.id].rotation.x,e.rotation.y=this.latest[e.id].rotation.y,e.rotation.z=this.latest[e.id].rotation.z,e.position.x=this.latest[e.id].position.x,e.position.y=this.latest[e.id].position.y,e.position.z=this.latest[e.id].position.z,e.scale.x=this.latest[e.id].scale.x,e.scale.y=this.latest[e.id].scale.y,e.scale.z=this.latest[e.id].scale.z,e.quaternion.axis.x=this.latest[e.id].quaternion.axis.x,e.quaternion.axis.y=this.latest[e.id].quaternion.axis.y,e.quaternion.axis.z=this.latest[e.id].quaternion.axis.z,e.quaternion.angle=this.latest[e.id].quaternion.angle,delete this.latest[e.id],t=!0),this.animations[e.id]&&(delete this.animations[e.id],t=!0),t&&e.updateInstance()},GameLib.System.Animation.prototype.attachAnimation=function(e,t){if(this.latest[t.id]={rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},position:{x:t.position.x,y:t.position.y,z:t.position.z},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z},quaternion:{axis:{x:t.quaternion.axis.x,y:t.quaternion.axis.y,z:t.quaternion.axis.z},angle:t.quaternion.angle}},this.animations[t.id]=[],t.backupRotationXDescriptor)throw new Error("already a backed up x descriptor");t.backupQuaternionAngleDescriptor=Object.getOwnPropertyDescriptor(t.quaternion,"angle"),t.backupQuaternionAxisXDescriptor=Object.getOwnPropertyDescriptor(t.quaternion.axis,"x"),t.backupQuaternionAxisYDescriptor=Object.getOwnPropertyDescriptor(t.quaternion.axis,"y"),t.backupQuaternionAxisZDescriptor=Object.getOwnPropertyDescriptor(t.quaternion.axis,"z"),t.backupRotationXDescriptor=Object.getOwnPropertyDescriptor(t.rotation,"x"),t.backupRotationYDescriptor=Object.getOwnPropertyDescriptor(t.rotation,"y"),t.backupRotationZDescriptor=Object.getOwnPropertyDescriptor(t.rotation,"z"),t.backupPositionXDescriptor=Object.getOwnPropertyDescriptor(t.position,"x"),t.backupPositionYDescriptor=Object.getOwnPropertyDescriptor(t.position,"y"),t.backupPositionZDescriptor=Object.getOwnPropertyDescriptor(t.position,"z"),t.backupScaleXDescriptor=Object.getOwnPropertyDescriptor(t.scale,"x"),t.backupScaleYDescriptor=Object.getOwnPropertyDescriptor(t.scale,"y"),t.backupScaleZDescriptor=Object.getOwnPropertyDescriptor(t.scale,"z"),Object.defineProperty(t.quaternion,"angle",{get:this.getProperty(t,"angle","quaternion"),set:this.setProperty(t,e,"angle","quaternion"),configurable:!0}),Object.defineProperty(t.quaternion.axis,"x",{get:this.getSubProperty(t,"x","quaternion","axis"),set:this.setSubProperty(t,e,"x","quaternion","axis"),configurable:!0}),Object.defineProperty(t.quaternion.axis,"y",{get:this.getSubProperty(t,"y","quaternion","axis"),set:this.setSubProperty(t,e,"y","quaternion","axis"),configurable:!0}),Object.defineProperty(t.quaternion.axis,"z",{get:this.getSubProperty(t,"z","quaternion","axis"),set:this.setSubProperty(t,e,"z","quaternion","axis"),configurable:!0}),Object.defineProperty(t.rotation,"x",{get:this.getProperty(t,"x","rotation"),set:this.setProperty(t,e,"x","rotation"),configurable:!0}),Object.defineProperty(t.rotation,"y",{get:this.getProperty(t,"y","rotation"),set:this.setProperty(t,e,"y","rotation"),configurable:!0}),Object.d
this.components=e.components.map(function(e){return e})):this.exclusiveMode?(this.exclusiveMode=!1,this.components=this.backupComponents.map(function(e){return e})):console.log("we are already not in mesh select mode - not doing anything with the backup")),this.exclusiveMode||(this.components=this.components.filter(function(e){return e instanceof GameLib.D3.Mesh})),!(GameLib.Utils.UndefinedOrNull(this.components.length)||this.components.length<1)){this.exclusiveMode||(this.components=this.components.reduce(function(e,t){var i=t.getChildrenComponents();return GameLib.Utils.PushUnique(e,t),i.map(function(t){GameLib.Utils.PushUnique(e,t)}),e}.bind(this),[])),this.components.sort(function(e,t){return e.componentType>t.componentType?1:e.componentType<t.componentType?-1:0});var i=this.components.reduce(function(e,t){var i=e.pop();return t.componentType===i.componentType?(i.components.push(t),e.push(i),e):t.componentType!==i.componentType?(e.push(i),e.push({componentType:t.componentType,components:[t]}),e):void 0},[{componentType:this.components[0].componentType,components:[]}]);this.components.map(function(e){var t=!1;i.map(function(i){i.componentType===e.componentType&&1===i.components.length&&i.components[0]===e&&(t=!0)}),t||GameLib.Utils.PushUnique(i,{componentType:e.componentType,components:[e]})}),i.map(function(e){e.components.length<1&&console.warn("invalid number of components");var i={template:{parentEntity:e.components[0].parentEntity},affected:[e.components[0]],componentType:e.componentType};for(var n in e.components[0])(e.components[0].hasOwnProperty(n)||"function"==typeof e.components[0][n])&&("function"==typeof e.components[0][n]?i.template[n]=function(e){return function(){this.affected.map(function(t){t[e].bind(t)()})}.bind(i)}(n):i.template[n]=e.components[0][n]);var s,a=e.components.reduce(function(t,i){if(i===e.components[0])return t;for(var n in i)if(i.hasOwnProperty(n)){if(!t.template.hasOwnProperty(n))continue;if(t.template[n]instanceof GameLib.Vector2||t.template[n]instanceof GameLib.Vector3||t.template[n]instanceof GameLib.Vector4||t.template[n]instanceof GameLib.Quaternion){t.template[n].equals(i[n])||delete t.template[n];continue}t.template[n]!==i[n]&&delete t.template[n]}return t.affected.push(i),t},i);s=GameLib.Utils.UndefinedOrNull(a.template.name)?GameLib.Component.GetComponentName(a.componentType)+" (All Selected ("+a.affected.length+"))":a.template.name;var o=t.addFolder(s);if(o)for(var r in a.template)if(a.template.hasOwnProperty(r)||"function"==typeof a.template[r]){if("function"==typeof a.template[r]){o.add(a.template,r);continue}if(a.template[r]instanceof GameLib.Vector2||a.template[r]instanceof GameLib.Vector3||a.template[r]instanceof GameLib.Vector4){this.buildVectorControl(o,a,r);continue}if(a.template[r]instanceof GameLib.Quaternion&&this.buildQuaternionControl(o,a,r),"parentEntity"===r||"parentWorld"===r||"parentMesh"===r||"parentScene"===r){this.buildParentSelectionControl(o,a,r);continue}if(a.template[r]instanceof Array){if("vertices"===r||"faces"===r)continue;a.template.linkedObjects&&a.template.linkedObjects[r]instanceof Array&&this.buildArrayManagerControl(o,a,r);continue}if(a.template[r]instanceof GameLib.Color){this.buildColorControl(o,a,r);continue}if("object"==typeof a.template[r]){(a.template[r]instanceof GameLib.Component||a.template.linkedObjects&&a.template.linkedObjects[r])&&this.buildSelectControl(o,a,r);continue}this.buildControl(o,a,r)}}.bind(this))}}.bind(this))},GameLib.System.GUI.prototype.meshDeleted=function(e){e.meshes.map(function(e){this.meshDeslected({mesh:e})}.bind(this)),this.buildGUI(null)},GameLib.System.GUI.prototype.removeComponent=function(e){var t=this.backupComponents.indexOf(e.component);-1!==t&&this.backupComponents.splice(t,1),-1!==(t=this.components.indexOf(e.component))&&this.components.splice(t,1)},GameLib.System.GUI.prototype.newEntity=function(e){},GameLib.System.GUI.prototype.stop=function(){GameLib.System.prototype.stop.call(this),this.guis.map(function(e){e.domElement.instance.parentElement.removeChild(e.instance.domElement)}),delete dat.GUI
n.userData.speed+=s),n.userData.speedType===GameLib.D3.Particle.SPEED_TYPE_ONE_OVER_EXP&&(s=1/Math.exp(n.userData.speed)*e.delta,n.userData.speed+=s),n.position.x+=n.userData.direction.x*s,n.position.y+=n.userData.direction.y*s,n.position.z+=n.userData.direction.z*s,t.templateParticle.scaleType,GameLib.D3.Particle.SCALE_TYPE_CONSTANT,t.templateParticle.scaleType===GameLib.D3.Particle.SCALE_TYPE_LINEAR&&(n.scale.x+=n.userData.scale.x*e.delta,n.scale.y+=n.userData.scale.x*e.delta,n.scale.z+=n.userData.scale.x*e.delta),n.quaternion.copy(t.camera.instance.quaternion),t.templateParticle.opacityType===GameLib.D3.Particle.OPACITY_TYPE_INCREASE_LINEAR&&(n.material.opacity+=t.templateParticle.opacityFactor),t.templateParticle.opacityType===GameLib.D3.Particle.OPACITY_TYPE_DECREASE_LINEAR&&(n.material.opacity-=t.templateParticle.opacityFactor),n.userData.elapsed+=e.delta,n.userData.elapsed>n.userData.lifeTime||n.material.opacity<0?(n.userData.scene.remove(n),n.geometry.dispose(),n.material.dispose()):i.push(n),i},[]),t.disabledForRemoval&&0===t.particles.length&&GameLib.Event.Emit(GameLib.Event.REMOVE_PARTICLE_ENGINE,{component:t}),t.enabled&&!t.disabledForRemoval)){var i=null;if(t.pulse){if(0===t.particles.length){t.elapsed=0;for(var n=0;n<t.particlesPerSecond;n++)i=t.templateParticle.cloneInstance(),t.particles.push(i)}}else t.elapsed>t.frequency&&(t.elapsed=0,i=t.templateParticle.cloneInstance(),t.particles.push(i))}}.bind(this))},GameLib.System.Particle.prototype.stop=function(){GameLib.System.prototype.stop.call(this),this.instanceCreatedSubscription.remove(),this.removeComponentSubscription.remove(),this.beforeRenderSubscription.remove()},GameLib.System.Physics=function(e){GameLib.System.call(this,e),this.worlds=[],this.beforeRenderSubscription=null,this.afterRenderSubscription=null},GameLib.System.Physics.prototype=Object.create(GameLib.System.prototype),GameLib.System.Physics.prototype.constructor=GameLib.System.Physics,GameLib.System.Physics.prototype.start=function(){GameLib.System.prototype.start.call(this),this.worlds=GameLib.EntityManager.Instance.queryComponents(GameLib.D3.PhysicsWorld),this.beforeRenderSubscription=this.subscribe(GameLib.Event.BEFORE_RENDER,this.beforeRender)},GameLib.System.Physics.prototype.beforeRender=function(e){this.worlds.map(function(t){t.instance&&(t.instance.step(e.delta),t.rigidBodies.map(function(e){e.position.x=e.instance.position.x,e.position.y=e.instance.position.y,e.position.z=e.instance.position.z,e.quaternion.x=e.instance.quaternion.x,e.quaternion.y=e.instance.quaternion.y,e.quaternion.z=e.instance.quaternion.z,e.quaternion.w=e.instance.quaternion.w,e.parentMesh.position.x=e.instance.position.x,e.parentMesh.position.y=e.instance.position.y,e.parentMesh.position.z=e.instance.position.z,e.parentMesh.quaternion.x=e.instance.quaternion.x,e.parentMesh.quaternion.y=e.instance.quaternion.y,e.parentMesh.quaternion.z=e.instance.quaternion.z,e.parentMesh.quaternion.w=e.instance.quaternion.w,e.instance.getVelocityAtWorldPoint(new CANNON.Vec3(0,0,0),e.velocity.instance),e.velocity.x=e.velocity.instance.x,e.velocity.y=e.velocity.instance.y,e.velocity.z=e.velocity.instance.z,e.parentMesh.updateRotationFromAxisAngle=!1,e.parentMesh.updateInstance(),e.parentMesh.updateRotationFromAxisAngle=!0}))}.bind(this))},GameLib.System.Physics.prototype.stop=function(){GameLib.System.prototype.stop.call(this),this.worlds=[],this.rigidBodies=[],this.wheels=[],this.vehicles=[],this.beforeRenderSubscription&&this.beforeRenderSubscription.remove(),this.afterRenderSubscription&&this.afterRenderSubscription.remove()},GameLib.System.Render=function(e){GameLib.System.call(this,e),this.renderSubscription=null},GameLib.System.Render.prototype=Object.create(GameLib.System.prototype),GameLib.System.Render.prototype.constructor=GameLib.System.Render,GameLib.System.Render.prototype.start=function(){GameLib.System.prototype.start.call(this),this.renderers=GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Renderer),this.statistics=GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Stats),this.instanceCreatedS