functionGameLib(){}var__DATE__="Sun Nov 19 2017 17:31:12 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.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
;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,a){GameLib.Utils.UndefinedOrNull(a)&&(a=null),this.parentEntity=a,GameLib.Utils.UndefinedOrNull(e)&&(e=GameLib.Utils.RandomId()),this.id=e,GameLib.Utils.UndefinedOrNull(t)&&(t="Mouse ("+this.id+")"),this.name=t,GameLib.Utils.UndefinedOrNull(i)&&(i=0),this.x=i,GameLib.Utils.UndefinedOrNull(n)&&(n=0),this.y=n},GameLib.API.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,a,s){GameLib.Utils.UndefinedOrNull(e)&&(e=0),this.x=e,GameLib.Utils.UndefinedOrNull(t)&&(t=0),this.y=t,GameLib.Utils.UndefinedOrNull(i)&&(i=0),this.z=i,GameLib.Utils.UndefinedOrNull(n)&&(n=1),this.w=n,GameLib.Utils.UndefinedOrNull(a)&&(a=newGameLib.API.Vector3),this.axis=a,GameLib.Utils.UndefinedOrNull(s)&&(s=0),this.angle=s},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,a,s=e,o=this;if(einstanceofGameLib.API.Matrix4)returnt=s.rows[0].x*o.x+s.rows[0].y*o.y+s.rows[0].z*o.z+s.rows[0].w*o.w,i=s.rows[1].x*o.x+s.rows[1].y*o.y+s.rows[1].z*o.z+s.rows[1].w*o.w,n=s.rows[2].x*o.x+s.rows[2].y*o.y+s.rows[2].z*o.z+s.rows[2].w*o.w,a=s.rows[3].x*o.x+s.rows[3].y*o.y+s.rows[3].z*o.z+s.rows[3].w*o.w,this.x=t,this.y=i,this.z=n,this.w=a,this;if(einstanceofGameLib.API.Quaternion)returnt=s.x*o.x-s.y*o.y-s.z*o.z-s.w*s.w,i=s.x*o.y+s.y*o.x-s.z*o.w+s.w*s.z,n=s.x*o.z+s.y*o.w+s.z*o.x-s.w*s.y,a=s.x*o.w-s.y*o.z+s.z*o.y+s.w*s.x,this.x=t,this.y=i,this.z=n,this.w=a,this;throwconsole.log("Thisfunctionalitynotimpl
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.backupScaleZDescriptor),deletee.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,deletethis.latest[e.id],t=!0),this.animations[e.id]&&(deletethis.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)thrownewError("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.defineProperty(t.rotation,"z",{get:this.getProperty(t,"z","rotation"),set:this.setProperty(t,e,"z","rotation"),configurable:!0}),Object.defineProperty(t.scale,"x",{get:this.getProperty(t,"x","scale"),set:this.setProperty(t,e,"x","scale"),configurable:!0}),Object.defineProperty(t.scale,"y",{get:this.getProperty(t,"y","scale"),set:this.setProperty(t,e,"y","scale"),configurable:!0}),Object.defineProperty(t.scale,"z",{get:this.getProperty(t,"z","scale"),set:this.setProperty(t,e,"z","scale"),configurable:!0}),Object.defineProperty(t.position,"x",{get:this.getProperty(t,"x","position"),set
;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.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):void0},[{componentType:this.components[0].componentType,components:[]}]);this.components.map(function(e){vart=!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");vari={template:{parentEntity:e.components[0].parentEntity},affected:[e.components[0]],componentType:e.componentType};for(varnine.components[0])(e.components[0].hasOwnProperty(n)||"function"==typeofe.components[0][n])&&("function"==typeofe.components[0][n]?i.template[n]=function(e){returnfunction(){this.affected.map(function(t){t[e].bind(t)()})}.bind(i)}(n):i.template[n]=e.components[0][n]);vara,s=e.components.reduce(function(t,i){if(i===e.components[0])returnt;for(varnini)if(i.hasOwnProperty(n)){if(!t.template.hasOwnProperty(n))continue;if(t.template[n]instanceofGameLib.Vector2||t.template[n]instanceofGameLib.Vector3||t.template[n]instanceofGameLib.Vector4||t.template[n]instanceofGameLib.Quaternion){t.template[n].equals(i[n])||deletet.template[n];continue}t.template[n]!==i[n]&&deletet.template[n]}returnt.affected.push(i),t},i);a=GameLib.Utils.UndefinedOrNull(s.template.name)?GameLib.Component.GetComponentName(s.componentType)+" (All Selected ("+s.affected.length+"))":s.template.name;varo=t.addFolder(a);if(o)for(varrins.template)if(s.template.hasOwnProperty(r)||"function"==typeofs.template[r]){if("function"==typeofs.template[r]){o.add(s.template,r);continue}if(s.template[r]instanceofGameLib.Vector2||s.template[r]instanceofGameLib.Vector3||s.template[r]instanceofGameLib.Vector4){this.buildVectorControl(o,s,r);continue}if(s.template[r]instanceofGameLib.Quaternion&&this.buildQuaternionControl(o,s,r),"parentEntity"===r||"parentWorld"===r||"parentMesh"===r||"parentScene"===r){this.buildParentSelectionControl(o,s,r);continue}if(s.template[r]instanceofArray){if("vertices"===r||"faces"===r)continue;s.template.linkedObjects&&s.template.linkedObjects[r]instanceofArray&&this.buildArrayManagerControl(o,s,r);continue}if(s.template[r]instanceofGameLib.Color){this.buildColorControl(o,s,r);continue}if("object"==typeofs.template[r]){(s.template[r]instanceofGameLib.Component||s.template.linkedObjects&&s.template.linkedObjects[r])&&this.buildSelectControl(o,s,r);continue}this.buildControl(o,s,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){vart=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)}),deletedat.GUI.removeEmtpyFolders,deletedat.GUI.removeAllFolders,this.buildGUISubscription.remove(),this.meshDeletedSubscription.remove(),this.meshSelectedSubscription.remove(),this.meshDeselectedSubscription.remove(),this.newEntitySubscription.remove(),this.componentRemovedSubscription.remove(),this.guis=[]},GameLib.System.Input=function(e,t){GameLib.System.call(this,e),this.graphics=t,this.graphics.isNotThreeThrow(),this.selectAll=!1,this.controlLeft=!1,this.sensitivityCounter=0,this.editorControls=[],this.touchControls=[],this.keyboardControls=[],this.mouseCont
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)){vari=null;if(t.pulse){if(0===t.particles.length){t.elapsed=0;for(varn=0;n<t.particlesPerSecond;n++)i=t.templateParticle.cloneInstance(),t.particles.push(i)}}elset.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(newCANNON.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.instanceCreatedSubscription=GameLib.Event.Subscribe(GameLib.Event.INSTANCE_CREATED,this.instanceCreated.bind(this)),this.removeComponentSubscription=GameLib.Event.Subscribe(GameLib.Event.REMOVE_COMPONENT,this.removeComponent.bind(this)),this.renderSubscription=this.subscribe(GameLib.Event.RENDER,this.render)},GameLib.System.Render.prototype.instanceCreated=function(e){e.componentinstanceofGameLib.D3.Renderer&&(console.log("new renderer"),this.renderers.push(e.component))},GameLib.System.Render.prototype.removeComponent=function(e){if(e.componentinstanceofGameLib.D3.Renderer){vart=this.renderers.indexOf(e.component);-1!==t?(console.log("removing renderer from system"),this.renderers.splice(t,1)):console.log("fa