functionGameLib(){}var__DATE__="Tue Nov 21 2017 15:07:22 GMT+0100 (CET)";if(void0===GameLib.D3&&(GameLib.D3=function(){}),void0===GameLib.D3.API&&(GameLib.D3.API=function(){}),void0===GameLib.API&&(GameLib.API=function(){}),void0===GameLib.D3.Runtime&&(GameLib.D3.Runtime=function(){}),void0===Q){if("undefined"==typeofrequire)throwconsole.warn("You need the Q promise library for the GameLib.D3"),newError("You need the Q promise library for the GameLib.D3");varQ=require("q")}if(void0===_){if("undefined"==typeofrequire)throwconsole.warn("You need the lodash library for the GameLib.D3"),newError("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.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_INSTAN
;throwconsole.warn("Unsupported object matrix type - whats your DB version?"),newError("Unsupported object matrix type - whats your DB version?")},GameLib.API.Matrix4.prototype.rotationMatrixX=function(e){returnthis.identity(),this.rows[1]=newGameLib.API.Vector4(0,Math.cos(e),-1*Math.sin(e),0),this.rows[2]=newGameLib.API.Vector4(0,Math.sin(e),Math.cos(e),0),this},GameLib.API.Matrix4.prototype.rotationMatrixY=function(e){returnthis.identity(),this.rows[0]=newGameLib.API.Vector4(Math.cos(e),0,Math.sin(e),0),this.rows[2]=newGameLib.API.Vector4(-1*Math.sin(e),0,Math.cos(e),0),this},GameLib.API.Matrix4.prototype.rotationMatrixZ=function(e){returnthis.identity(),this.rows[0]=newGameLib.API.Vector4(Math.cos(e),-1*Math.sin(e),0,0),this.rows[1]=newGameLib.API.Vector4(Math.sin(e),Math.cos(e),0,0),this},GameLib.API.Matrix4.prototype.rotateX=function(e,t){returnthis.identity(),this.rotationMatrixX(e),this.multiply(t)},GameLib.API.Matrix4.prototype.rotateY=function(e,t){returnthis.identity(),this.rotationMatrixY(e),this.multiply(t)},GameLib.API.Matrix4.prototype.rotateZ=function(e,t){returnthis.identity(),this.rotationMatrixZ(e),this.multiply(t)},GameLib.API.Matrix4.prototype.multiply=function(e){returneinstanceofGameLib.API.Quaternion||einstanceofGameLib.API.Vector4?newGameLib.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):einstanceofGameLib.API.Vector3?newGameLib.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):void0},GameLib.API.Matrix4.prototype.identity=function(){this.rows=[newGameLib.API.Vector4(1,0,0,0),newGameLib.API.Vector4(0,1,0,0),newGameLib.API.Vector4(0,0,1,0),newGameLib.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){returnnewGameLib.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=newGameLib.API.Vector3),this.axis=s,GameLib.Utils.UndefinedOrNull(a)&&(a=0),this.angle=a},GameLib.API.Quaternion.prototype.translate=function(e){returnthis.x+=e.x,this.y+=e.y,this.z+=e.z,this},GameLib.API.Quaternion.prototype.copy=function(){returnnewGameLib.API.Quaternion(this.x,this.y,this.z,this.w)},GameLib.API.Quaternion.prototype.normalize=function(){vare=this.x*this.x+this.y*this.y+this.z*this.z;if(e<1e-6)returnthis;vart=1/Math.sqrt(e);this.x*=t,this.y*=t,this.z*=t},GameLib.API.Quaternion.prototype.multiply=function(e){vart,i,n,s,a=e,o=this;if(einstanceofGameLib.API.Matrix4)returnt=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(einstanceofGameLib.API.Quaternion)returnt=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;throwconsole.log("Thisfunctionalitynotimpl
if(tinstanceofGameLib.D3.Material){GameLib.Utils.PushUnique(e,t);for(variint.linkedObjects)if(t.linkedObjects.hasOwnProperty(i)&&t.hasOwnProperty(i)&&t[i]&&"string"!=typeoft[i]&&"parentEntity"!==i){GameLib.Utils.PushUnique(e,t[i]);for(varnint[i].linkedObjects)t[i].linkedObjects.hasOwnProperty(n)&&t[i].hasOwnProperty(n)&&t[i][n]&&"string"!=typeoft[i][n]&&"parentEntity"!==n&&(t[i][n]instanceofArray?t[i][n].map(function(t){GameLib.Utils.PushUnique(e,t)}):GameLib.Utils.PushUnique(e,t[i][n]))}}}.bind(this)),GameLib.EntityManager.Instance.queryComponents(GameLib.D3.RigidBody).map(function(t){t.parentMesh===this&&GameLib.Utils.PushUnique(e,t)}.bind(this)),GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Shape).map(function(t){t.parentMesh===this&&GameLib.Utils.PushUnique(e,t)}.bind(this)),e},GameLib.D3.Mesh.prototype.createHelper=function(){if(GameLib.Utils.UndefinedOrNull(this.parentScene)||GameLib.Utils.UndefinedOrNull(this.parentScene.instance))returnvoidconsole.warn("this mesh has no parent scene - cannot create helper");this.helper&&this.removeHelper(),this.helper=newGameLib.D3.Helper(this.graphics,null,this.name+" Helper",this,GameLib.D3.Helper.HELPER_TYPE_EDGES),this.helper.updateInstance(),this.polygonOffset=this.instance.material.polygonOffset,this.instance.material.polygonOffset=!0,this.parentScene.instance.add(this.helper.instance)},GameLib.D3.Mesh.prototype.addMaterial=function(e){1===this.materials.length?this.instance.material=e.instance:this.instance.material=this.materials.map(function(e){returne.instance})},GameLib.D3.Mesh.prototype.removeHelper=function(){if(GameLib.Utils.UndefinedOrNull(this.parentScene)||GameLib.Utils.UndefinedOrNull(this.parentScene.instance))returnvoidconsole.warn("this mesh has no parent scene - cannot remove helper");this.helper&&this.helper.instance&&(this.parentScene.instance.remove(this.helper.instance),deletethis.helper.instance),this.instance.material.polygonOffset=this.polygonOffset,this.helper=null},GameLib.D3.Mesh.prototype.computeBoundingBox=function(e){GameLib.Utils.UndefinedOrNull(e)&&(this.instance&&this.instance.geometry?e=this.instance.geometry:console.log("no instance geometry to compute bounding box")),e.computeBoundingBox(),this.dimensions.x=e.boundingBox.getSize().x,this.dimensions.y=e.boundingBox.getSize().y,this.dimensions.z=e.boundingBox.getSize().z},GameLib.D3.Mesh.Box=function(e,t,i,n,s){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),tinstanceofGameLib.D3.Mesh.Box)returnt;t.meshType=GameLib.D3.Mesh.MESH_TYPE_BOX,GameLib.Utils.UndefinedOrNull(i)&&(i=1),this.width=i,GameLib.Utils.UndefinedOrNull(n)&&(n=1),this.height=n,GameLib.Utils.UndefinedOrNull(s)&&(s=1),this.depth=s,GameLib.D3.Mesh.call(this,this.graphics,t)},GameLib.D3.Mesh.Box.prototype=Object.create(GameLib.D3.Mesh.prototype),GameLib.D3.Mesh.Box.prototype.constructor=GameLib.D3.Mesh.Box,GameLib.D3.Mesh.Box.prototype.createInstance=function(){vare=null;0===this.vertices.length&&(e=newTHREE.BoxGeometry(this.width,this.height,this.depth),this.updateVerticesFromGeometryInstance(e)),GameLib.D3.Mesh.prototype.createInstance.call(this),this.instance.userData.width=this.width,this.instance.userData.height=this.height,this.instance.userData.depth=this.depth},GameLib.D3.Mesh.Box.prototype.updateInstance=function(e){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;vart=newTHREE.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(){vare=GameLib.D3.Mesh.prototype.toApiObject.call(this);returne.width=this.width,e.height=this.height,e.depth=this.depth,e},GameLib.D3.Mesh.Box.FromObject=function(e,t){vari=GameLib.D3.API.Mesh.FromObject(t);retur
e.userData.scene=this.mesh.parentScene.instance,e.userData.elapsed=0,e.userData.scene.add(e),e},GameLib.D3.Particle.prototype.toApiObject=function(){returnnewGameLib.D3.API.Particle(this.id,this.name,this.lifeTime,this.elapsed,GameLib.Utils.IdOrNull(this.mesh),this.opacityType,this.opacityFactor,this.positionOffsetType,this.positionOffset.toApiObject(),this.positionOffsetFn,this.directionType,this.direction.toApiObject(),this.directionFn,this.speedType,this.speed,this.scaleType,this.scale.toApiObject(),this.scaleFn,this.rotationType,this.rotation.toApiObject(),this.rotationFn,GameLib.Utils.IdOrNull(this.parentEngine),GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Particle.FromObject=function(e,t){vari=GameLib.D3.API.Particle.FromObject(t);returnnewGameLib.D3.Particle(e,i)},GameLib.D3.Pass=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),tinstanceofGameLib.D3.Pass)returnt;GameLib.D3.API.Pass.call(this,t.id,t.name,t.passType,t.camera,t.scene,t.renderToScreen,t.parentEntity),GameLib.Component.call(this,GameLib.Component.COMPONENT_PASS,{camera:GameLib.D3.Camera,scene:GameLib.D3.Scene})},GameLib.D3.Pass.prototype=Object.create(GameLib.D3.API.Pass.prototype),GameLib.D3.Pass.prototype.constructor=GameLib.D3.Pass,GameLib.D3.Pass.PASS_TYPE_RENDER=1,GameLib.D3.Pass.PASS_TYPE_COPY_SHADER=2,GameLib.D3.Pass.prototype.createInstance=function(){if(this.passType===GameLib.D3.Pass.PASS_TYPE_RENDER){if(GameLib.Utils.UndefinedOrNull(this.scene))thrownewError("no scene object");if(GameLib.Utils.UndefinedOrNull(this.camera))thrownewError("no camera object");if(GameLib.Utils.UndefinedOrNull(THREE.RenderPass))thrownewError("no render pass library");this.instance=newTHREE.RenderPass(this.scene.instance,this.camera.instance)}else{if(this.passType!==GameLib.D3.Pass.PASS_TYPE_COPY_SHADER)throwconsole.warn("Render pass not supported yet: "+this.passType),newError("Render pass not supported yet: "+this.passType);if(GameLib.Utils.UndefinedOrNull(THREE.CopyShader))thrownewError("no copyshader library");this.instance=THREE.CopyShader}this.instance.renderToScreen=this.renderToScreen,GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Pass.prototype.updateInstance=function(){this.passType!==GameLib.D3.Pass.PASS_TYPE_RENDER||this.instanceinstanceofTHREE.RenderPass||this.createInstance(),this.passType!==GameLib.D3.Pass.PASS_TYPE_COPY_SHADER||this.instanceinstanceofTHREE.CopyShader||this.createInstance(),this.instance.renderToScreen=this.renderToScreen},GameLib.D3.Pass.prototype.toApiObject=function(){returnnewGameLib.D3.API.Pass(this.id,this.name,this.passType,GameLib.Utils.IdOrNull(this.camera),GameLib.Utils.IdOrNull(this.scene),this.renderToScreen,GameLib.Utils.IdOrNull(this.parentEntity))},GameLib.D3.Pass.FromObject=function(e,t){vari=GameLib.D3.API.Pass.FromObject(t);returnnewGameLib.D3.Pass(e,i)},GameLib.D3.PathFollowing=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),tinstanceofGameLib.D3.PathFollowing)returnt;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=newGameLib.Vector3(this.graphics,this.baseOffset,this),this.maxOffset=newGameLib.Vector3(this.graphics,this.maxOffset,this),this.targetOffset=newGameLib.Vector3(this.graphics,this.targetOffset,this),this.currentOffset=newGameLib.Vector3(this.graphics,this.currentOffset,this),this.raycaster=newGameLib.D3.Raycaster(this.graphics,this.raycaster),this.currentPosition=newGameLib.Vector3(this.graphics,this.currentPosition,this),this.futurePosition=newGameLib.Vector3(this.graphics,this.futurePosition,this),this.up=newGameLib.Vector3(this.graphics,this.up,this),this.rotationMatrix=newGameLib.Matrix4(this.graphics,this.rotationMatrix,this),
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=newCANNON.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))thrownewError("no shape");if(GameLib.Utils.UndefinedOrNull(e.instance))thrownewError("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(){returnnewGameLib.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){returnGameLib.Utils.IdOrNull(e)}),this.kinematic,GameLib.Utils.IdOrNull(this.parentMe
newError("Need a DOM element for stats");this.domElement=n,GameLib.Utils.UndefinedOrNull(s)&&(s=null),this.parentEntity=s,GameLib.Component.call(this,GameLib.Component.COMPONENT_STATS,{domElement:GameLib.DomElement})},GameLib.D3.Stats.prototype=Object.create(GameLib.Component.prototype),GameLib.D3.Stats.prototype.constructor=GameLib.D3.Stats,GameLib.D3.Stats.prototype.resize=function(){console.log("override stats resize per implementation")},GameLib.D3.Stats.prototype.createInstance=function(){this.instance=this.stats(),this.resize(),this.domElement.instance.parentElement.appendChild(this.instance.dom),GameLib.Component.prototype.createInstance.call(this)},GameLib.D3.Stats.prototype.updateInstance=function(){this.instance=newthis.stats},GameLib.D3.Stats.prototype.start=function(){this.instance.begin()},GameLib.D3.Stats.prototype.end=function(){this.instance.end()},GameLib.D3.Texture=function(e,t){if(this.graphics=e,this.graphics.isNotThreeThrow(),GameLib.Utils.UndefinedOrNull(t)&&(t={}),tinstanceofGameLib.D3.Texture)returnt;GameLib.D3.API.Texture.call(this,t.id,t.typeId,t.name,t.image,t.images,t.wrapS,t.wrapT,t.repeat,t.data,t.format,t.mapping,t.magFilter,t.minFilter,t.textureType,t.anisotropy,t.offset,t.generateMipmaps,t.flipY,t.mipmaps,t.unpackAlignment,t.premultiplyAlpha,t.encoding,t.canvas,t.animated,t.reverseAnimation,t.forward,t.parentEntity),this.offset=newGameLib.Vector2(this.graphics,this.offset,this),this.repeat=newGameLib.Vector2(this.graphics,this.repeat,this),this.imageinstanceofGameLib.D3.API.Image&&(this.image=newGameLib.D3.Image(this.graphics,this.image)),this.images=this.images.map(function(e){returneinstanceofGameLib.D3.API.Image?newGameLib.D3.Image(this.graphics,e):e}.bind(this)),this.canvasinstanceofGameLib.D3.API.Canvas&&(this.canvas=newGameLib.D3.Canvas(this.graphics,this.canvas)),GameLib.Component.call(this,GameLib.Component.COMPONENT_TEXTURE,{image:GameLib.D3.Image,images:[GameLib.D3.Image],canvas:GameLib.D3.Canvas})},GameLib.D3.Texture.prototype=Object.create(GameLib.D3.API.Texture.prototype),GameLib.D3.Texture.prototype.constructor=GameLib.D3.Texture,GameLib.D3.Texture.TYPE_ALPHA_FORMAT=1019,GameLib.D3.Texture.TYPE_RGB_FORMAT=1020,GameLib.D3.Texture.TYPE_RGBA_FORMAT=1021,GameLib.D3.Texture.TYPE_LUMINANCE_FORMAT=1022,GameLib.D3.Texture.TYPE_LUMINANCE_ALPHA_FORMAT=1023,GameLib.D3.Texture.TYPE_DEPTH_FORMAT=1026,GameLib.D3.Texture.TYPE_UV_MAPPING=300,GameLib.D3.Texture.TYPE_CUBE_REFLECTION_MAPPING=301,GameLib.D3.Texture.TYPE_CUBE_REFRACTION_MAPPING=302,GameLib.D3.Texture.TYPE_EQUI_RECTANGULAR_REFLECTION_MAPPING=303,GameLib.D3.Texture.TYPE_EQUI_RECTANGULAR_REFRACTION_MAPPING=304,GameLib.D3.Texture.TYPE_SPHERICAL_REFLECTION_MAPPING=305,GameLib.D3.Texture.TYPE_CUBE_UV_REFLECTION_MAPPING=306,GameLib.D3.Texture.TYPE_CUBE_UV_REFRACTION_MAPPING=307,GameLib.D3.Texture.TYPE_REPEAT_WRAPPING=1e3,GameLib.D3.Texture.TYPE_CLAMP_TO_EDGE_WRAPPING=1001,GameLib.D3.Texture.TYPE_MIRRORED_REPEAT_WRAPPING=1002,GameLib.D3.Texture.TYPE_NEAREST_FILTER=1003,GameLib.D3.Texture.TYPE_NEAREST_MIPMAP_NEAREST_FILTER=1004,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.Textu
returne.texture.repeat.x>1||e.texture.repeat.x<0?(console.warn("cannot animate a texture with repeat.x greater than 1 or less than 0"),void(e.texture.userData.animated=!1)):e.texture.repeat.y>1||e.texture.repeat.y<0?(console.warn("cannot animate a texture with repeat.y greater than 1 or less than 0"),void(e.texture.userData.animated=!1)):(e.texture.userData.animated=!0,this.textures[e.texture.id]=e.texture,void(this.textureIds=Object.keys(this.textures)))},GameLib.System.Animation.prototype.beforeRender=function(e){if(!this.paused){vart=e.delta;for(variinthis.animations)if(this.animations.hasOwnProperty(i)){varn=[];if(this.animations[i].length>0)for(vars=!1,a=0;a<this.animations[i].length;a++)"rotation"!==this.animations[i][a].type||s||(s=!0,n.push(this.animations[i][a])),"position"===this.animations[i][a].type&&n.push(this.animations[i][a]),"scale"===this.animations[i][a].type&&n.push(this.animations[i][a]);n.map(function(e){returnfunction(i){varn=!1,s=0;if("rotation"===i.type&&(s=i.animation.rotationSpeed*t),"position"===i.type&&(s=i.animation.translationSpeed*t),"scale"===i.type&&(s=i.animation.scaleSpeed*t),i.from<i.to?i.from+=s:i.from-=s,Math.abs(i.from-i.to)<s?(i.mesh.instance[i.type][i.axis]=i.to,n=!0):i.mesh.instance[i.type][i.axis]=i.from,n){vara=this.animations[e].indexOf(i);this.animations[e].splice(a,1)}}.bind(this)}.bind(this)(i))}this.textureIds.map(function(e){vart=this.textures[e];t.reverseAnimation||t.userData&&t.userData.reverseAnimation?((!0===t.forward||t.userData&&!0===t.userData.forward)&&(t.offset.x+=t.repeat.x,t.offset.x>=1-t.repeat.x&&(t.offset.y>=1-t.repeat.y?(t.offset.x=1-t.repeat.x,t.offset.y=1-t.repeat.y,t.userData?t.userData.forward=!1:t.forward=!1):(t.offset.x=0,t.offset.y+=t.repeat.y))),(!1===t.forward||t.userData&&!1===t.userData.forward)&&(t.offset.x-=t.repeat.x,t.offset.x<=0&&(t.offset.x=0,t.offset.y<t.repeat.y?(t.offset.x=t.repeat.x,t.offset.y=0,t.userData?t.userData.forward=!0:t.forward=!0):(t.offset.x=1-t.repeat.x,t.offset.y-=t.repeat.y)))):(t.offset.x+=t.repeat.x,t.offset.x>=1-t.repeat.x&&(t.offset.y>=1-t.repeat.y?(t.offset.x=0,t.offset.y=0):(t.offset.x=0,t.offset.y+=t.repeat.y))),t.userData||t.updateInstance("offset")}.bind(this))}},GameLib.System.Animation.prototype.detachAnimation=function(e){vart=!1;e.backupQuaternionAngleDescriptor&&(Object.defineProperty(e.quaternion,"angle",e.backupQuaternionAngleDescriptor),deletee.backupQuaternionAngleDescriptor,t=!0),e.backupQuaternionAxisXDescriptor&&(Object.defineProperty(e.quaternion.axis,"x",e.backupQuaternionAxisXDescriptor),deletee.backupQuaternionAxisXDescriptor,t=!0),e.backupQuaternionAxisYDescriptor&&(Object.defineProperty(e.quaternion.axis,"y",e.backupQuaternionAxisYDescriptor),deletee.backupQuaternionAxisYDescriptor,t=!0),e.backupQuaternionAxisZDescriptor&&(Object.defineProperty(e.quaternion.axis,"z",e.backupQuaternionAxisZDescriptor),deletee.backupQuaternionAxisXDescriptor,t=!0),e.backupRotationXDescriptor&&(Object.defineProperty(e.rotation,"x",e.backupRotationXDescriptor),deletee.backupRotationXDescriptor,t=!0),e.backupRotationYDescriptor&&(Object.defineProperty(e.rotation,"y",e.backupRotationYDescriptor),deletee.backupRotationYDescriptor,t=!0),e.backupRotationZDescriptor&&(Object.defineProperty(e.rotation,"z",e.backupRotationZDescriptor),deletee.backupRotationZDescriptor,t=!0),e.backupPositionXDescriptor&&(Object.defineProperty(e.position,"x",e.backupPositionXDescriptor),deletee.backupPositionXDescriptor,t=!0),e.backupPositionYDescriptor&&(Object.defineProperty(e.position,"y",e.backupPositionYDescriptor),deletee.backupPositionYDescriptor,t=!0),e.backupPositionZDescriptor&&(Object.defineProperty(e.position,"z",e.backupPositionZDescriptor),deletee.backupPositionZDescriptor,t=!0),e.backupScaleXDescriptor&&(Object.defineProperty(e.scale,"x",e.backupScaleXDescriptor),deletee.backupScaleXDescriptor,t=!0),e.backupScaleYDescriptor&&(Object.defineProperty(e.scale,"y",e.backupScaleYDescriptor),deletee.backupScaleYDescriptor,t=!0),e.backupScaleZDescriptor&&(Object.defineProperty(e.scale,"z",e.backupScaleZDescrip
}));elseif("encoding"===i)o.push(e.add(n,i,{linear:GameLib.D3.Texture.TYPE_LINEAR_ENCODING,srgb:GameLib.D3.Texture.TYPE_SRGB_ENCODING,gamma:GameLib.D3.Texture.TYPE_GAMMA_ENCODING,rgbe:GameLib.D3.Texture.TYPE_RGBE_ENCODING,"log luv":GameLib.D3.Texture.TYPE_LOG_LUV_ENCODING,rgbm7:GameLib.D3.Texture.TYPE_RGBM7_ENCODING,rgbm16:GameLib.D3.Texture.TYPE_RGBM16_ENCODING,rgbd:GameLib.D3.Texture.TYPE_RGBD_ENCODING}));elseif("lightType"===i)o.push(e.add(n,i,{ambient:GameLib.D3.Light.LIGHT_TYPE_AMBIENT,directional:GameLib.D3.Light.LIGHT_TYPE_DIRECTIONAL,spot:GameLib.D3.Light.LIGHT_TYPE_SPOT,point:GameLib.D3.Light.LIGHT_TYPE_POINT}));elseif("eventId"===i){for(varr={},h=0;h<200;h++)try{r[GameLib.Event.GetEventName(h)]=h}catch(e){}o.push(e.add(n,i,r))}else"functionType"===i?o.push(e.add(n,i,{rotation:GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_ROTATION,translation:GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_TRANSLATION,scale:GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_SCALE})):"opacity"===i||"opacityFactor"===i||"metalness"===i||"roughness"===i||"volume"===i?o.push(e.add(n,i,0,1,.001)):"shininess"===i||"fov"===i?o.push(e.add(n,i,-255,255,1)):"aspect"===i||"wireframeLineWidth"===i||"lineWidth"===i?o.push(e.add(n,i,0,5,.001)):"bumpScale"===i||"normalScale"===i||"displacementScale"===i||"heightMapScale"===i||"intensity"===i?o.push(e.add(n,i,-10,10,.001)):"minX"===i||"minY"===i||"minZ"===i||"maxX"===i||"maxY"===i||"maxZ"===i||"offsetX"===i?o.push(e.add(n,i,-1e3,1e3,.01)):"widthSegments"===i||"radiusSegments"===i||"heightSegments"===i||"particlesPerSecond"===i?o.push(e.add(n,i,1,1e3,1)):"width"===i||"height"===i||"depth"===i||"radius"===i?o.push(e.add(n,i,0,1e3,.1)):"near"===i||"distanceGrain"===i||"envMapIntensity"===i?o.push(e.add(n,i,-10,100,.001)):"bumpScale"===i?o.push(e.add(n,i,0,20,.001)):"heightOffset"===i||"rotationFactor"===i?o.push(e.add(n,i,-100,100,.001)):"friction"===i?o.push(e.add(n,i,0,1e3,.01)):"radiusTop"===i||"radiusBottom"===i?o.push(e.add(n,i,0,100,.1)):"mass"===i?o.push(e.add(n,i,0,1e3,.1)):"sensitivity"===i?o.push(e.add(n,i,1,50,1)):"density"===i?o.push(e.add(n,i,0,1,1e-4)):"thetaLength"===i||"angle"===i?o.push(e.add(n,i,2*-Math.PI,2*Math.PI,.01)):o.push(e.add(n,i,-1e3,1e3,.1))}o.map(function(n){"name"===i?n.onFinishChange(function(e,n){returnfunction(e){t.affected.map(function(t){t[i]=e,t.updateInstance(i)}),n.domElement.getElementsByClassName("title")[0].innerHTML=e}}(0,e)):n.onChange(function(e){"number"==typeofthis.initialValue&&(e=Number(e)),t.affected.map(function(t){t[i]=e,t.updateInstance(i)})}),s&&n.listen()})},GameLib.System.GUI.prototype.meshSelected=function(e){this.exclusiveMode?GameLib.Utils.PushUnique(this.backupComponents,e.mesh):GameLib.Utils.PushUnique(this.components,e.mesh)},GameLib.System.GUI.prototype.meshDeslected=function(e){vart=-1;this.exclusiveMode?-1!==(t=this.backupComponents.indexOf(e.mesh))&&this.backupComponents.splice(t,1):-1!==(t=this.components.indexOf(e.mesh))&&this.components.splice(t,1)},GameLib.System.GUI.prototype.buildGUI=function(e){this.guis.map(function(t){if(t.instance.destroy(),t.removeAllFolders(),e&&(e.components?(this.exclusiveMode||(this.exclusiveMode=!0,this.backupComponents=this.components.map(function(e){returne})),this.components=e.components.map(function(e){returne})):this.exclusiveMode?(this.exclusiveMode=!1,this.components=this.backupComponents.map(function(e){returne})):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){returneinstanceofGameLib.D3.Mesh})),!(GameLib.Utils.UndefinedOrNull(this.components.length)||this.components.length<1)){this.exclusiveMode||(this.components=this.components.reduce(function(e,t){vari=t.getChildrenComponents();returnGameLib.Utils.PushUnique(e,t),i.map(function(t){GameLib.Utils.PushUnique(e,t)}),e}.bind(this),[])),this.components.sort(function(e,t){returne.componentType>t.componentType?1:e.componentType<t.componentType?-1:0});vari=this.components.reduce(function(e,t){vari=e.pop();returnt.componentT