From 74134a53af8b32a1be4875243d032897a073621e Mon Sep 17 00:00:00 2001 From: logsol Date: Sun, 21 Dec 2014 20:28:00 +0100 Subject: [PATCH] moved build stuff --- .gitignore | 3 +- build/build.js => build.js | 0 build/client.min.js | 181 ------------------------------------- build/client.min.js.gz | Bin 134841 -> 0 bytes 4 files changed, 2 insertions(+), 182 deletions(-) rename build/build.js => build.js (100%) delete mode 100644 build/client.min.js delete mode 100644 build/client.min.js.gz diff --git a/.gitignore b/.gitignore index d5fd3c1..34d99e1 100755 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules/ .DS_Store lab/audio/ lab/filter/ -static/items/rube/*-backups \ No newline at end of file +static/items/rube/*-backups +build/ diff --git a/build/build.js b/build.js similarity index 100% rename from build/build.js rename to build.js diff --git a/build/client.min.js b/build/client.min.js deleted file mode 100644 index 924aa0a..0000000 --- a/build/client.min.js +++ /dev/null @@ -1,181 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ - -/*! -* screenfull -* v1.2.0 - 2014-04-29 -* (c) Sindre Sorhus; MIT License -*/ - -/** - * @license - * pixi.js - v1.5.1 - * Copyright (c) 2012-2014, Mat Groves - * http://goodboydigital.com/ - * - * Compiled: 2014-02-13 - * - * pixi.js is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license.php - */ - -// MIT license - -/* - PolyK library - url: http://polyk.ivank.net - Released under MIT licence. - - Copyright (c) 2012 Ivan Kuckir - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation - files (the "Software"), to deal in the Software without - restriction, including without limitation the rights to use, - copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following - conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. - - This is an amazing lib! - - slightly modified by Mat Groves (matgroves.com); -*/ - -/* -CryptoJS v3.0.2 -code.google.com/p/crypto-js -(c) 2009-2012 by Jeff Mott. All rights reserved. -code.google.com/p/crypto-js/wiki/License -*/ - -/*! Socket.IO.js build:0.9.6, development. Copyright(c) 2011 LearnBoost MIT Licensed */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * Parses an URI - * - * @author Steven Levithan (MIT license) - * @api public - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/* SWFObject v2.2 - is released under the MIT License -*/ - -// Copyright: Hiroshi Ichikawa -// License: New BSD License -// Reference: http://dev.w3.org/html5/websockets/ -// Reference: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -/** - * socket.io - * Copyright(c) 2011 LearnBoost - * MIT Licensed - */ - -define("Lib/Utilities/Protocol/Parser",[],function(){var e={};return e.encode=function(e){return JSON.stringify(e)},e.decode=function(e){return JSON.parse(e)},e}),define("Lib/Utilities/Exception",[],function(){function e(){var e=[];for(var t=0;t1?n[1]:""},e}),define("Lib/Utilities/Protocol/Helper",["Lib/Utilities/Protocol/Parser","Lib/Utilities/Exception"],function(e,t){var n={};return n.encodeCommand=function(t,n){var r={};return r[t]=n||null,e.encode(r)},n.applyCommand=function(n,r){var i;typeof n=="string"?i=e.decode(n):i=n;for(var s in i){var o="on"+s.toUpperCaseFirstChar(),n=i[s];if(!r[o])throw new t("Helper.applyCommand:",r,"has no method",o);r[o].call(r,n)}},n}),define("Game/Config/Settings",[],function(){var e={STAGE_WIDTH:600,STAGE_HEIGHT:400,ZOOM_FACTOR:.8,ZOOM_DEFAULT:1,ZOOM_MAX:10,BOX2D_WORLD_AABB_SIZE:3e3,BOX2D_ALLOW_SLEEP:!0,BOX2D_GRAVITY:26,BOX2D_VELOCITY_ITERATIONS:5,BOX2D_POSITION_ITERATIONS:5,BOX2D_TIME_STEP:1/60,GRAPHICS_PATH:"static/img/",GRAPHICS_SUBPATH_ITEMS:"Items/",GRAPHICS_SUBPATH_CHARACTERS:"Characters/",GRAPHICS_SUBPATH_TILES:"Tiles/",MAPS_PATH:"static/maps/tiled/",AUDIO_PATH:"static/sounds/",RATIO:21,ORIGINAL_TILE_SIZE:25,TILE_SIZE:20,CAMERA_IS_ORTHOGRAPHIC:!0,CAMERA_GLIDE:12,VIEW_CONTROLLER:"Pixi",ARROW_GLIDE:30,WALK_SPEED:4,RUN_SPEED:8,FLY_SPEED:6.2,JUMP_SPEED:20,JUMP_STOP_DAMPING_FACTOR:.5,MAX_THROW_FORCE:63,MAX_THROW_ANGULAR_VELOCITY:0,MAX_RUNNING_WEIGHT:9,RESPAWN_TIME:5,HEALTH_DISPLAY_TIME:2,RAGDOLL_DESTRUCTION_TIME:20,VIEWPORT_SPEED_FACTOR:640,VIEWPORT_LOOK_AHEAD:.1,TILE_FRICTION:.99,TILE_RESTITUTION:.1,PLAYER_DENSITY:3.68,PLAYER_FRICTION:5,PLAYER_MOTION_FRICTION:.1,PLAYER_RESTITUTION:0,PLAYER_LINEAR_DAMPING:.4,ITEM_DENSITY:.9,ITEM_FRICTION:.99,ITEM_RESTITUTION:.02,ITEM_LINEAR_DAMPING:.02,CANVAS_DOM_ID:"canvasContainer",IS_BROWSER_ENVIRONMENT:typeof window!="undefined",USE_WEBGL:!0,NETWORK_UPDATE_INTERVAL:70,NETWORK_LOG_INCOMING:!1,NETWORK_LOG_OUTGOING:!1,NETWORK_LOG_FILTER:["ping","pong","worldUpdate","lookAt"],CHANNEL_DESTRUCTION_TIME:300,CHANNEL_END_ROUND_TIME:4,CHANNEL_DEFAULT_MAX_USERS:40,CHANNEL_DEFAULT_SCORE_LIMIT:10,CHANNEL_DEFAULT_LEVELS:["debug"],ME_STATE_MAX_DIFFERENCE_METERS:1,PUNKBUSTER_DIFFERENCE_METERS:1};return e.TILE_RATIO=e.ORIGINAL_TILE_SIZE/e.TILE_SIZE,e}),define("Lib/Vendor/Box2D",[],function(){var e={};(function(e,t){function n(){}e.inherit=function(e,t){var r=e;n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=r},e.generateCallback=function(t,n){return function(){n.apply(t,arguments)}},e.NVector=function(n){n===t&&(n=0);var r=new Array(n||0);for(var i=0;i=0&&t>=0;return n=n&&this.lowerBound.IsValid()&&this.upperBound.IsValid(),n},b.prototype.GetCenter=function(){return new g((this.lowerBound.x+this.upperBound.x)/2,(this.lowerBound.y+this.upperBound.y)/2)},b.prototype.GetExtents=function(){return new g((this.upperBound.x-this.lowerBound.x)/2,(this.upperBound.y-this.lowerBound.y)/2)},b.prototype.Contains=function(e){var t=!0;return t=t&&this.lowerBound.x<=e.lowerBound.x,t=t&&this.lowerBound.y<=e.lowerBound.y,t=t&&e.upperBound.x<=this.upperBound.x,t=t&&e.upperBound.y<=this.upperBound.y,t},b.prototype.RayCast=function(e,t){var n=-Number.MAX_VALUE,r=Number.MAX_VALUE,i=t.p1.x,s=t.p1.y,o=t.p2.x-t.p1.x,u=t.p2.y-t.p1.y,a=Math.abs(o),f=Math.abs(u),l=e.normal,c=0,h=0,p=0,d=0,v=0;if(ap&&(d=h,h=p,p=d,v=1),h>n&&(l.x=v,l.y=0,n=h),r=Math.min(r,p);if(n>r)return!1}if(fp&&(d=h,h=p,p=d,v=1),h>n&&(l.y=v,l.x=0,n=h),r=Math.min(r,p);if(n>r)return!1}return e.fraction=n,!0},b.prototype.TestOverlap=function(e){var t=e.lowerBound.x-this.upperBound.x,n=e.lowerBound.y-this.upperBound.y,r=this.lowerBound.x-e.upperBound.x,i=this.lowerBound.y-e.upperBound.y;return t>0||n>0?!1:r>0||i>0?!1:!0},b.Combine=function(e,t){var n=new b;return n.Combine(e,t),n},b.prototype.Combine=function(e,t){this.lowerBound.x=Math.min(e.lowerBound.x,t.lowerBound.x),this.lowerBound.y=Math.min(e.lowerBound.y,t.lowerBound.y),this.upperBound.x=Math.max(e.upperBound.x,t.upperBound.x),this.upperBound.y=Math.max(e.upperBound.y,t.upperBound.y)},w.b2Bound=function(){},w.prototype.IsLower=function(){return(this.value&1)==0},w.prototype.IsUpper=function(){return(this.value&1)==1},w.prototype.Swap=function(e){var t=this.value,n=this.proxy,r=this.stabbingCount;this.value=e.value,this.proxy=e.proxy,this.stabbingCount=e.stabbingCount,e.value=t,e.proxy=n,e.stabbingCount=r},E.b2BoundValues=function(){},E.prototype.b2BoundValues=function(){this.lowerValues=new n,this.lowerValues[0]=0,this.lowerValues[1]=0,this.upperValues=new n,this.upperValues[0]=0,this.upperValues[1]=0},S.b2Collision=function(){},S.ClipSegmentToLine=function(e,t,n,r){r===undefined&&(r=0);var i,s=0;i=t[0];var o=i.v;i=t[1];var u=i.v,a=n.x*o.x+n.y*o.y-r,f=n.x*u.x+n.y*u.y-r;a<=0&&e[s++].Set(t[0]),f<=0&&e[s++].Set(t[1]);if(a*f<0){var l=a/(a-f);i=e[s];var c=i.v;c.x=o.x+l*(u.x-o.x),c.y=o.y+l*(u.y-o.y),i=e[s];var h;a>0?(h=t[0],i.id=h.id):(h=t[1],i.id=h.id),++s}return s},S.EdgeSeparation=function(e,t,n,r,i){n===undefined&&(n=0);var s=parseInt(e.m_vertexCount),o=e.m_vertices,u=e.m_normals,a=parseInt(r.m_vertexCount),f=r.m_vertices,l,c;l=t.R,c=u[n];var h=l.col1.x*c.x+l.col2.x*c.y,p=l.col1.y*c.x+l.col2.y*c.y;l=i.R;var d=l.col1.x*h+l.col1.y*p,v=l.col2.x*h+l.col2.y*p,m=0,g=Number.MAX_VALUE;for(var y=0;yd&&(d=m,p=v)}var g=S.EdgeSeparation(t,n,p,r,i),y=parseInt(p-1>=0?p-1:s-1),b=S.EdgeSeparation(t,n,y,r,i),w=parseInt(p+1g&&b>E)N=-1,x=y,T=b;else{if(!(E>g))return e[0]=p,g;N=1,x=w,T=E}for(;;){N==-1?p=x-1>=0?x-1:s-1:p=x+1T))break;x=p,T=g}return e[0]=x,T},S.FindIncidentEdge=function(e,t,n,r,i,s){r===undefined&&(r=0);var o=parseInt(t.m_vertexCount),u=t.m_normals,a=parseInt(i.m_vertexCount),f=i.m_vertices,l=i.m_normals,c,h;c=n.R,h=u[r];var p=c.col1.x*h.x+c.col2.x*h.y,d=c.col1.y*h.x+c.col2.y*h.y;c=s.R;var v=c.col1.x*p+c.col1.y*d;d=c.col2.x*p+c.col2.y*d,p=v;var m=0,g=Number.MAX_VALUE;for(var y=0;yo)return;var f=0;S.s_edgeBO[0]=f;var l=S.FindMaxSeparation(S.s_edgeBO,r,i,t,n);f=S.s_edgeBO[0];if(l>o)return;var h,p,d,v,m=0,g=0,y=.98,b=.001,w;l>y*a+b?(h=r,p=t,d=i,v=n,m=f,e.m_type=D.e_faceB,g=1):(h=t,p=r,d=n,v=i,m=u,e.m_type=D.e_faceA,g=0);var E=S.s_incidentEdge;S.FindIncidentEdge(E,h,d,m,p,v);var x=parseInt(h.m_vertexCount),T=h.m_vertices,N=T[m],C;m+1d*d)return;e.m_type=D.e_circles,e.m_localPoint.SetV(t.m_p),e.m_localPlaneNormal.SetZero(),e.m_pointCount=1,e.m_points[0].m_localPoint.SetV(r.m_p),e.m_points[0].m_id.key=0},S.CollidePolygonAndCircle=function(e,t,n,r,i){e.m_pointCount=0;var s,o=0,u=0,a=0,f=0,l,c;c=i.R,l=r.m_p;var h=i.position.x+(c.col1.x*l.x+c.col2.x*l.y),p=i.position.y+(c.col1.y*l.x+c.col2.y*l.y);o=h-n.position.x,u=p-n.position.y,c=n.R;var d=o*c.col1.x+u*c.col1.y,v=o*c.col2.x+u*c.col2.y,m=0,g=0,y=-Number.MAX_VALUE,b=t.m_radius+r.m_radius,w=parseInt(t.m_vertexCount),E=t.m_vertices,S=t.m_normals;for(var x=0;xb)return;T>y&&(y=T,g=x)}var N=parseInt(g),C=parseInt(N+1b*b)return;e.m_pointCount=1,e.m_type=D.e_faceA,e.m_localPlaneNormal.x=d-k.x,e.m_localPlaneNormal.y=v-k.y,e.m_localPlaneNormal.Normalize(),e.m_localPoint.SetV(k),e.m_points[0].m_localPoint.SetV(r.m_p),e.m_points[0].m_id.key=0}else if(O<=0){if((d-L.x)*(d-L.x)+(v-L.y)*(v-L.y)>b*b)return;e.m_pointCount=1,e.m_type=D.e_faceA,e.m_localPlaneNormal.x=d-L.x,e.m_localPlaneNormal.y=v-L.y,e.m_localPlaneNormal.Normalize(),e.m_localPoint.SetV(L),e.m_points[0].m_localPoint.SetV(r.m_p),e.m_points[0].m_id.key=0}else{var M=.5*(k.x+L.x),_=.5*(k.y+L.y);y=(d-M)*S[N].x+(v-_)*S[N].y;if(y>b)return;e.m_pointCount=1,e.m_type=D.e_faceA,e.m_localPlaneNormal.x=S[N].x,e.m_localPlaneNormal.y=S[N].y,e.m_localPlaneNormal.Normalize(),e.m_localPoint.Set(M,_),e.m_points[0].m_localPoint.SetV(r.m_p),e.m_points[0].m_id.key=0}},S.TestOverlap=function(e,t){var n=t.lowerBound,r=e.upperBound,i=n.x-r.x,s=n.y-r.y;n=e.lowerBound,r=t.upperBound;var o=n.x-r.x,u=n.y-r.y;return i>0||s>0?!1:o>0||u>0?!1:!0},e.postDefs.push(function(){e.Collision.b2Collision.s_incidentEdge=S.MakeClipPointVector(),e.Collision.b2Collision.s_clipPoints1=S.MakeClipPointVector(),e.Collision.b2Collision.s_clipPoints2=S.MakeClipPointVector(),e.Collision.b2Collision.s_edgeAO=new n(1),e.Collision.b2Collision.s_edgeBO=new n(1),e.Collision.b2Collision.s_localTangent=new g,e.Collision.b2Collision.s_localNormal=new g,e.Collision.b2Collision.s_planePoint=new g,e.Collision.b2Collision.s_normal=new g,e.Collision.b2Collision.s_tangent=new g,e.Collision.b2Collision.s_tangent2=new g,e.Collision.b2Collision.s_v11=new g,e.Collision.b2Collision.s_v12=new g,e.Collision.b2Collision.b2CollidePolyTempVec=new g,e.Collision.b2Collision.b2_nullFeature=255}),x.b2ContactID=function(){this.features=new $},x.prototype.b2ContactID=function(){this.features._m_id=this},x.prototype.Set=function(e){this.key=e._key},x.prototype.Copy=function(){var e=new x;return e.key=this.key,e},Object.defineProperty(x.prototype,"key",{enumerable:!1,configurable:!0,get:function(){return this._key}}),Object.defineProperty(x.prototype,"key",{enumerable:!1,configurable:!0,set:function(e){e===undefined&&(e=0),this._key=e,this.features._referenceEdge=this._key&255,this.features._incidentEdge=(this._key&65280)>>8&255,this.features._incidentVertex=(this._key&16711680)>>16&255,this.features._flip=(this._key&4278190080)>>24&255}}),T.b2ContactPoint=function(){this.position=new g,this.velocity=new g,this.normal=new g,this.id=new x},N.b2Distance=function(){},N.Distance=function(e,t,n){++N.b2_gjkCalls;var r=n.proxyA,i=n.proxyB,s=n.transformA,o=n.transformB,u=N.s_simplex;u.ReadCache(t,r,s,i,o);var a=u.m_vertices,f=20,l=N.s_saveA,h=N.s_saveB,p=0,v=u.GetClosestPoint(),m=v.LengthSquared(),y=m,b=0,w,E=0;while(Em,m=y;var S=u.GetSearchDirection();if(S.LengthSquared()C+k&&e.distance>Number.MIN_VALUE){e.distance-=C+k;var L=d.SubtractVV(e.pointB,e.pointA);L.Normalize(),e.pointA.x+=C*L.x,e.pointA.y+=C*L.y,e.pointB.x-=k*L.x,e.pointB.y-=k*L.y}else w=new g,w.x=.5*(e.pointA.x+e.pointB.x),w.y=.5*(e.pointA.y+e.pointB.y),e.pointA.x=e.pointB.x=w.x,e.pointA.y=e.pointB.y=w.y,e.distance=0}},e.postDefs.push(function(){e.Collision.b2Distance.s_simplex=new q,e.Collision.b2Distance.s_saveA=new n(3),e.Collision.b2Distance.s_saveB=new n(3)}),C.b2DistanceInput=function(){},k.b2DistanceOutput=function(){this.pointA=new g,this.pointB=new g},L.b2DistanceProxy=function(){},L.prototype.Set=function(e){switch(e.GetType()){case a.e_circleShape:var n=e instanceof r?e:null;this.m_vertices=new t(1,!0),this.m_vertices[0]=n.m_p,this.m_count=1,this.m_radius=n.m_radius;break;case a.e_polygonShape:var i=e instanceof u?e:null;this.m_vertices=i.m_vertices,this.m_count=i.m_vertexCount,this.m_radius=i.m_radius;break;default:c.b2Assert(!1)}},L.prototype.GetSupport=function(e){var t=0,n=this.m_vertices[0].x*e.x+this.m_vertices[0].y*e.y;for(var r=1;rn&&(t=r,n=i)}return t},L.prototype.GetSupportVertex=function(e){var t=0,n=this.m_vertices[0].x*e.x+this.m_vertices[0].y*e.y;for(var r=1;rn&&(t=r,n=i)}return this.m_vertices[t]},L.prototype.GetVertexCount=function(){return this.m_count},L.prototype.GetVertex=function(e){return e===undefined&&(e=0),c.b2Assert(0<=e&&e0?n.x:-n.x),i=c.b2_aabbExtension+c.b2_aabbMultiplier*(n.y>0?n.y:-n.y);return e.aabb.lowerBound.x=t.lowerBound.x-r,e.aabb.lowerBound.y=t.lowerBound.y-i,e.aabb.upperBound.x=t.upperBound.x+r,e.aabb.upperBound.y=t.upperBound.y+i,this.InsertLeaf(e),!0},A.prototype.Rebalance=function(e){e===undefined&&(e=0);if(this.m_root==null)return;for(var t=0;t>r&1?n.child2:n.child1,r=r+1&31;++this.m_path,this.RemoveLeaf(n),this.InsertLeaf(n)}},A.prototype.GetFatAABB=function(e){return e.aabb},A.prototype.GetUserData=function(e){return e.userData},A.prototype.Query=function(e,n){if(this.m_root==null)return;var r=new t,i=0;r[i++]=this.m_root;while(i>0){var s=r[--i];if(s.aabb.TestOverlap(n))if(s.IsLeaf()){var o=e(s);if(!o)return}else r[i++]=s.child1,r[i++]=s.child2}},A.prototype.RayCast=function(e,n){if(this.m_root==null)return;var r=n.p1,i=n.p2,s=d.SubtractVV(r,i);s.Normalize();var o=d.CrossFV(1,s),u=d.AbsV(o),a=n.maxFraction,f=new b,l=0,c=0;l=r.x+a*(i.x-r.x),c=r.y+a*(i.y-r.y),f.lowerBound.x=Math.min(r.x,l),f.lowerBound.y=Math.min(r.y,c),f.upperBound.x=Math.max(r.x,l),f.upperBound.y=Math.max(r.y,c);var h=new t,p=0;h[p++]=this.m_root;while(p>0){var v=h[--p];if(v.aabb.TestOverlap(f)==0)continue;var m=v.aabb.GetCenter(),g=v.aabb.GetExtents(),y=Math.abs(o.x*(r.x-m.x)+o.y*(r.y-m.y))-u.x*g.x-u.y*g.y;if(y>0)continue;if(v.IsLeaf()){var w=new B;w.p1=n.p1,w.p2=n.p2,w.maxFraction=n.maxFraction,a=e(w,v);if(a==0)return;a>0&&(l=r.x+a*(i.x-r.x),c=r.y+a*(i.y-r.y),f.lowerBound.x=Math.min(r.x,l),f.lowerBound.y=Math.min(r.y,c),f.upperBound.x=Math.max(r.x,l),f.upperBound.y=Math.max(r.y,c))}else h[p++]=v.child1,h[p++]=v.child2}},A.prototype.AllocateNode=function(){if(this.m_freeList){var e=this.m_freeList;return this.m_freeList=e.parent,e.parent=null,e.child1=null,e.child2=null,e}return new M},A.prototype.FreeNode=function(e){e.parent=this.m_freeList,this.m_freeList=e},A.prototype.InsertLeaf=function(e){++this.m_insertionCount;if(this.m_root==null){this.m_root=e,this.m_root.parent=null;return}var t=e.aabb.GetCenter(),n=this.m_root;if(n.IsLeaf()==0)do{var r=n.child1,i=n.child2,s=Math.abs((r.aabb.lowerBound.x+r.aabb.upperBound.x)/2-t.x)+Math.abs((r.aabb.lowerBound.y+r.aabb.upperBound.y)/2-t.y),o=Math.abs((i.aabb.lowerBound.x+i.aabb.upperBound.x)/2-t.x)+Math.abs((i.aabb.lowerBound.y+i.aabb.upperBound.y)/2-t.y);s=r?e:r,++t.m_pairCount,!0}var s=t.m_tree.GetFatAABB(r);t.m_tree.Query(i,s)}t.m_moveBuffer.length=0;for(var n=0;nc){var p=i.x-this.p1.x,d=i.y-this.p1.y,v=p*f+d*l;if(0<=v&&v<=r*h){var m=-s*d+o*p;if(-c*h<=m&&m<=h*(1+c)){v/=h;var g=Math.sqrt(f*f+l*l);return f/=g,l/=g,e[0]=v,t.Set(f,l),!0}}}return!1},F.prototype.Extend=function(e){this.ExtendForward(e),this.ExtendBackward(e)},F.prototype.ExtendForward=function(e){var t=this.p2.x-this.p1.x,n=this.p2.y-this.p1.y,r=Math.min(t>0?(e.upperBound.x-this.p1.x)/t:t<0?(e.lowerBound.x-this.p1.x)/t:Number.POSITIVE_INFINITY,n>0?(e.upperBound.y-this.p1.y)/n:n<0?(e.lowerBound.y-this.p1.y)/n:Number.POSITIVE_INFINITY);this.p2.x=this.p1.x+t*r,this.p2.y=this.p1.y+n*r},F.prototype.ExtendBackward=function(e){var t=-this.p2.x+this.p1.x,n=-this.p2.y+this.p1.y,r=Math.min(t>0?(e.upperBound.x-this.p2.x)/t:t<0?(e.lowerBound.x-this.p2.x)/t:Number.POSITIVE_INFINITY,n>0?(e.upperBound.y-this.p2.y)/n:n<0?(e.lowerBound.y-this.p2.y)/n:Number.POSITIVE_INFINITY);this.p1.x=this.p2.x+t*r,this.p1.y=this.p2.y+n*r},I.b2SeparationFunction=function(){this.m_localPoint=new g,this.m_axis=new g},I.prototype.Initialize=function(e,t,n,r,i){this.m_proxyA=t,this.m_proxyB=r;var s=parseInt(e.count);c.b2Assert(01){var l=e.metric,h=this.GetMetric();if(h<.5*l||2*l0?d.CrossFV(1,e):d.CrossVF(e,1);default:return c.b2Assert(!1),new g}},q.prototype.GetClosestPoint=function(){switch(this.m_count){case 0:return c.b2Assert(!1),new g;case 1:return this.m_v1.w;case 2:return new g(this.m_v1.a*this.m_v1.w.x+this.m_v2.a*this.m_v2.w.x,this.m_v1.a*this.m_v1.w.y+this.m_v2.a*this.m_v2.w.y);default:return c.b2Assert(!1),new g}},q.prototype.GetWitnessPoints=function(e,t){switch(this.m_count){case 0:c.b2Assert(!1);break;case 1:e.SetV(this.m_v1.wA),t.SetV(this.m_v1.wB);break;case 2:e.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x,e.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y,t.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x,t.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:t.x=e.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x+this.m_v3.a*this.m_v3.wA.x,t.y=e.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y+this.m_v3.a*this.m_v3.wA.y;break;default:c.b2Assert(!1)}},q.prototype.GetMetric=function(){switch(this.m_count){case 0:return c.b2Assert(!1),0;case 1:return 0;case 2:return d.SubtractVV(this.m_v1.w,this.m_v2.w).Length();case 3:return d.CrossVV(d.SubtractVV(this.m_v2.w,this.m_v1.w),d.SubtractVV(this.m_v3.w,this.m_v1.w));default:return c.b2Assert(!1),0}},q.prototype.Solve2=function(){var e=this.m_v1.w,t=this.m_v2.w,n=d.SubtractVV(t,e),r=-(e.x*n.x+e.y*n.y);if(r<=0){this.m_v1.a=1,this.m_count=1;return}var i=t.x*n.x+t.y*n.y;if(i<=0){this.m_v2.a=1,this.m_count=1,this.m_v1.Set(this.m_v2);return}var s=1/(i+r);this.m_v1.a=i*s,this.m_v2.a=r*s,this.m_count=2},q.prototype.Solve3=function(){var e=this.m_v1.w,t=this.m_v2.w,n=this.m_v3.w,r=d.SubtractVV(t,e),i=d.Dot(e,r),s=d.Dot(t,r),o=s,u=-i,a=d.SubtractVV(n,e),f=d.Dot(e,a),l=d.Dot(n,a),c=l,h=-f,p=d.SubtractVV(n,t),v=d.Dot(t,p),m=d.Dot(n,p),g=m,y=-v,b=d.CrossVV(r,a),w=b*d.CrossVV(t,n),E=b*d.CrossVV(n,e),S=b*d.CrossVV(e,t);if(u<=0&&h<=0){this.m_v1.a=1,this.m_count=1;return}if(o>0&&u>0&&S<=0){var x=1/(o+u);this.m_v1.a=o*x,this.m_v2.a=u*x,this.m_count=2;return}if(c>0&&h>0&&E<=0){var T=1/(c+h);this.m_v1.a=c*T,this.m_v3.a=h*T,this.m_count=2,this.m_v2.Set(this.m_v3);return}if(o<=0&&y<=0){this.m_v2.a=1,this.m_count=1,this.m_v1.Set(this.m_v2);return}if(c<=0&&g<=0){this.m_v3.a=1,this.m_count=1,this.m_v1.Set(this.m_v3);return}if(g>0&&y>0&&w<=0){var N=1/(g+y);this.m_v2.a=g*N,this.m_v3.a=y*N,this.m_count=2,this.m_v1.Set(this.m_v3);return}var C=1/(w+E+S);this.m_v1.a=w*C,this.m_v2.a=E*C,this.m_v3.a=S*C,this.m_count=3},R.b2SimplexCache=function(){this.indexA=new n(3),this.indexB=new n(3)},U.b2SimplexVertex=function(){},U.prototype.Set=function(e){this.wA.SetV(e.wA),this.wB.SetV(e.wB),this.w.SetV(e.w),this.a=e.a,this.indexA=e.indexA,this.indexB=e.indexB},z.b2TimeOfImpact=function(){},z.TimeOfImpact=function(e){++z.b2_toiCalls;var t=e.proxyA,n=e.proxyB,r=e.sweepA,i=e.sweepB;c.b2Assert(r.t0==i.t0),c.b2Assert(1-r.t0>Number.MIN_VALUE);var s=t.m_radius+n.m_radius,o=e.tolerance,u=0,a=1e3,f=0,l=0;z.s_cache.count=0,z.s_distanceInput.useRadii=!1;for(;;){r.GetTransform(z.s_xfA,u),i.GetTransform(z.s_xfB,u),z.s_distanceInput.proxyA=t,z.s_distanceInput.proxyB=n,z.s_distanceInput.transformA=z.s_xfA,z.s_distanceInput.transformB=z.s_xfB,N.Distance(z.s_distanceOutput,z.s_cache,z.s_distanceInput);if(z.s_distanceOutput.distance<=0){u=1;break}z.s_fcn.Initialize(z.s_cache,t,z.s_xfA,n,z.s_xfB);var h=z.s_fcn.Evaluate(z.s_xfA,z.s_xfB);if(h<=0){u=1;break}f==0&&(h>s?l=d.Max(s-o,.75*s):l=d.Max(h-o,.02*s));if(h-l<.5*o){if(f==0){u=1;break}break}var p=u,v=u,m=1,g=h;r.GetTransform(z.s_xfA,m),i.GetTransform(z.s_xfB,m);var y=z.s_fcn.Evaluate(z.s_xfA,z.s_xfB);if(y>=l){u=1;break}var b=0;for(;;){var w=0;b&1?w=v+(l-g)*(m-v)/(y-g):w=.5*(v+m),r.GetTransform(z.s_xfA,w),i.GetTransform(z.s_xfB,w);var E=z.s_fcn.Evaluate(z.s_xfA,z.s_xfB);if(d.Abs(E-l)<.025*o){p=w;break}E>l?(v=w,g=E):(m=w,y=E),++b,++z.b2_toiRootIters;if(b==50)break}z.b2_toiMaxRootIters=d.Max(z.b2_toiMaxRootIters,b);if(p<(1+100*Number.MIN_VALUE)*u)break;u=p,f++,++z.b2_toiIters;if(f==a)break}return z.b2_toiMaxIters=d.Max(z.b2_toiMaxIters,f),u},e.postDefs.push(function(){e.Collision.b2TimeOfImpact.b2_toiCalls=0,e.Collision.b2TimeOfImpact.b2_toiIters=0,e.Collision.b2TimeOfImpact.b2_toiMaxIters=0,e.Collision.b2TimeOfImpact.b2_toiRootIters=0,e.Collision.b2TimeOfImpact.b2_toiMaxRootIters=0,e.Collision.b2TimeOfImpact.s_cache=new R,e.Collision.b2TimeOfImpact.s_distanceInput=new C,e.Collision.b2TimeOfImpact.s_xfA=new m,e.Collision.b2TimeOfImpact.s_xfB=new m,e.Collision.b2TimeOfImpact.s_fcn=new I,e.Collision.b2TimeOfImpact.s_distanceOutput=new k}),W.b2TOIInput=function(){this.proxyA=new L,this.proxyB=new L,this.sweepA=new v,this.sweepB=new v},X.b2WorldManifold=function(){this.m_normal=new g},X.prototype.b2WorldManifold=function(){this.m_points=new t(c.b2_maxManifoldPoints);for(var e=0;eNumber.MIN_VALUE*Number.MIN_VALUE){var E=Math.sqrt(w);this.m_normal.x=y/E,this.m_normal.y=b/E}else this.m_normal.x=1,this.m_normal.y=0;var S=d+n*this.m_normal.x,x=v+n*this.m_normal.y,T=m-i*this.m_normal.x,N=g-i*this.m_normal.y;this.m_points[0].x=.5*(S+T),this.m_points[0].y=.5*(x+N);break;case D.e_faceA:u=t.R,o=e.m_localPlaneNormal,a=u.col1.x*o.x+u.col2.x*o.y,f=u.col1.y*o.x+u.col2.y*o.y,u=t.R,o=e.m_localPoint,l=t.position.x+u.col1.x*o.x+u.col2.x*o.y,c=t.position.y+u.col1.y*o.x+u.col2.y*o.y,this.m_normal.x=a,this.m_normal.y=f;for(s=0;sthis.m_radius)return r.SetV(i),Math.PI*this.m_radius*this.m_radius;var o=this.m_radius*this.m_radius,u=s*s,a=o*(Math.asin(s/this.m_radius)+Math.PI/2)+s*Math.sqrt(o-u),f=-2/3*Math.pow(o-u,1.5)/a;return r.x=i.x+e.x*f,r.y=i.y+e.y*f,a},o.prototype.GetLocalPosition=function(){return this.m_p},o.prototype.SetLocalPosition=function(e){this.m_p.SetV(e)},o.prototype.GetRadius=function(){return this.m_radius},o.prototype.SetRadius=function(e){e===undefined&&(e=0),this.m_radius=e},o.prototype.b2CircleShape=function(e){e===undefined&&(e=0),this.__super.b2Shape.call(this),this.m_type=c.e_circleShape,this.m_radius=e},u.b2EdgeChainDef=function(){},u.prototype.b2EdgeChainDef=function(){this.vertexCount=0,this.isALoop=!0,this.vertices=[]},e.inherit(a,e.Collision.Shapes.b2Shape),a.prototype.__super=e.Collision.Shapes.b2Shape.prototype,a.b2EdgeShape=function(){e.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments),this.s_supportVec=new g,this.m_v1=new g,this.m_v2=new g,this.m_coreV1=new g,this.m_coreV2=new g,this.m_normal=new g,this.m_direction=new g,this.m_cornerDir1=new g,this.m_cornerDir2=new g},a.prototype.TestPoint=function(e,t){return!1},a.prototype.RayCast=function(e,t,n){var r,i=t.p2.x-t.p1.x,s=t.p2.y-t.p1.y;r=n.R;var o=n.position.x+(r.col1.x*this.m_v1.x+r.col2.x*this.m_v1.y),u=n.position.y+(r.col1.y*this.m_v1.x+r.col2.y*this.m_v1.y),a=n.position.y+(r.col1.y*this.m_v2.x+r.col2.y*this.m_v2.y)-u,f=-(n.position.x+(r.col1.x*this.m_v2.x+r.col2.x*this.m_v2.y)-o),l=100*Number.MIN_VALUE,c=-(i*a+s*f);if(c>l){var h=t.p1.x-o,p=t.p1.y-u,d=h*a+p*f;if(0<=d&&d<=t.maxFraction*c){var v=-i*p+s*h;if(-l*c<=v&&v<=c*(1+l)){d/=c,e.fraction=d;var m=Math.sqrt(a*a+f*f);return e.normal.x=a/m,e.normal.y=f/m,!0}}}return!1},a.prototype.ComputeAABB=function(e,t){var n=t.R,r=t.position.x+(n.col1.x*this.m_v1.x+n.col2.x*this.m_v1.y),i=t.position.y+(n.col1.y*this.m_v1.x+n.col2.y*this.m_v1.y),s=t.position.x+(n.col1.x*this.m_v2.x+n.col2.x*this.m_v2.y),o=t.position.y+(n.col1.y*this.m_v2.x+n.col2.y*this.m_v2.y);r0){if(a>0)return 0;s.x=-a/(u-a)*s.x+u/(u-a)*o.x,s.y=-a/(u-a)*s.y+u/(u-a)*o.y}else a>0&&(o.x=-a/(u-a)*s.x+u/(u-a)*o.x,o.y=-a/(u-a)*s.y+u/(u-a)*o.y);return r.x=(i.x+s.x+o.x)/3,r.y=(i.y+s.y+o.y)/3,.5*((s.x-i.x)*(o.y-i.y)-(s.y-i.y)*(o.x-i.x))},a.prototype.GetLength=function(){return this.m_length},a.prototype.GetVertex1=function(){return this.m_v1},a.prototype.GetVertex2=function(){return this.m_v2},a.prototype.GetCoreVertex1=function(){return this.m_coreV1},a.prototype.GetCoreVertex2=function(){return this.m_coreV2},a.prototype.GetNormalVector=function(){return this.m_normal},a.prototype.GetDirectionVector=function(){return this.m_direction},a.prototype.GetCorner1Vector=function(){return this.m_cornerDir1},a.prototype.GetCorner2Vector=function(){return this.m_cornerDir2},a.prototype.Corner1IsConvex=function(){return this.m_cornerConvex1},a.prototype.Corner2IsConvex=function(){return this.m_cornerConvex2},a.prototype.GetFirstVertex=function(e){var t=e.R;return new g(e.position.x+(t.col1.x*this.m_coreV1.x+t.col2.x*this.m_coreV1.y),e.position.y+(t.col1.y*this.m_coreV1.x+t.col2.y*this.m_coreV1.y))},a.prototype.GetNextEdge=function(){return this.m_nextEdge},a.prototype.GetPrevEdge=function(){return this.m_prevEdge},a.prototype.Support=function(e,t,n){t===undefined&&(t=0),n===undefined&&(n=0);var r=e.R,i=e.position.x+(r.col1.x*this.m_coreV1.x+r.col2.x*this.m_coreV1.y),s=e.position.y+(r.col1.y*this.m_coreV1.x+r.col2.y*this.m_coreV1.y),o=e.position.x+(r.col1.x*this.m_coreV2.x+r.col2.x*this.m_coreV2.y),u=e.position.y+(r.col1.y*this.m_coreV2.x+r.col2.y*this.m_coreV2.y);return i*t+s*n>o*t+u*n?(this.s_supportVec.x=i,this.s_supportVec.y=s):(this.s_supportVec.x=o,this.s_supportVec.y=u),this.s_supportVec},a.prototype.b2EdgeShape=function(e,t){this.__super.b2Shape.call(this),this.m_type=c.e_edgeShape,this.m_prevEdge=null,this.m_nextEdge=null,this.m_v1=e,this.m_v2=t,this.m_direction.Set(this.m_v2.x-this.m_v1.x,this.m_v2.y-this.m_v1.y),this.m_length=this.m_direction.Normalize(),this.m_normal.Set(this.m_direction.y,-this.m_direction.x),this.m_coreV1.Set(-s.b2_toiSlop*(this.m_normal.x-this.m_direction.x)+this.m_v1.x,-s.b2_toiSlop*(this.m_normal.y-this.m_direction.y)+this.m_v1.y),this.m_coreV2.Set(-s.b2_toiSlop*(this.m_normal.x+this.m_direction.x)+this.m_v2.x,-s.b2_toiSlop*(this.m_normal.y+this.m_direction.y)+this.m_v2.y),this.m_cornerDir1=this.m_normal,this.m_cornerDir2.Set(-this.m_normal.x,-this.m_normal.y)},a.prototype.SetPrevEdge=function(e,t,n,r){this.m_prevEdge=e,this.m_coreV1=t,this.m_cornerDir1=n,this.m_cornerConvex1=r},a.prototype.SetNextEdge=function(e,t,n,r){this.m_nextEdge=e,this.m_coreV2=t,this.m_cornerDir2=n,this.m_cornerConvex2=r},f.b2MassData=function(){this.mass=0,this.center=new g(0,0),this.I=0},e.inherit(l,e.Collision.Shapes.b2Shape),l.prototype.__super=e.Collision.Shapes.b2Shape.prototype,l.b2PolygonShape=function(){e.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments)},l.prototype.Copy=function(){var e=new l;return e.Set(this),e},l.prototype.Set=function(t){this.__super.Set.call(this,t);if(e.is(t,l)){var n=t instanceof l?t:null;this.m_centroid.SetV(n.m_centroid),this.m_vertexCount=n.m_vertexCount,this.Reserve(this.m_vertexCount);for(var r=0;rNumber.MIN_VALUE),this.m_normals[n].SetV(d.CrossVF(o,1)),this.m_normals[n].Normalize()}this.m_centroid=l.ComputeCentroid(this.m_vertices,this.m_vertexCount)},l.AsVector=function(e,t){t===undefined&&(t=0);var n=new l;return n.SetAsVector(e,t),n},l.prototype.SetAsBox=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0),this.m_vertexCount=4,this.Reserve(4),this.m_vertices[0].Set(-e,-t),this.m_vertices[1].Set(e,-t),this.m_vertices[2].Set(e,t),this.m_vertices[3].Set(-e,t),this.m_normals[0].Set(0,-1),this.m_normals[1].Set(1,0),this.m_normals[2].Set(0,1),this.m_normals[3].Set(-1,0),this.m_centroid.SetZero()},l.AsBox=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0);var n=new l;return n.SetAsBox(e,t),n},l.prototype.SetAsOrientedBox=function(e,t,n,r){e===undefined&&(e=0),t===undefined&&(t=0),n===undefined&&(n=null),r===undefined&&(r=0),this.m_vertexCount=4,this.Reserve(4),this.m_vertices[0].Set(-e,-t),this.m_vertices[1].Set(e,-t),this.m_vertices[2].Set(e,t),this.m_vertices[3].Set(-e,t),this.m_normals[0].Set(0,-1),this.m_normals[1].Set(1,0),this.m_normals[2].Set(0,1),this.m_normals[3].Set(-1,0),this.m_centroid=n;var i=new m;i.position=n,i.R.Set(r);for(var s=0;s0)return!1}return!0},l.prototype.RayCast=function(e,t,n){var r=0,i=t.maxFraction,s=0,o=0,u,a;s=t.p1.x-n.position.x,o=t.p1.y-n.position.y,u=n.R;var f=s*u.col1.x+o*u.col1.y,l=s*u.col2.x+o*u.col2.y;s=t.p2.x-n.position.x,o=t.p2.y-n.position.y,u=n.R;var c=s*u.col1.x+o*u.col1.y,h=s*u.col2.x+o*u.col2.y,p=c-f,d=h-l,v=parseInt(-1);for(var m=0;m0&&g=0?(e.fraction=r,u=n.R,a=this.m_normals[v],e.normal.x=u.col1.x*a.x+u.col2.x*a.y,e.normal.y=u.col1.y*a.x+u.col2.y*a.y,!0):!1},l.prototype.ComputeAABB=function(e,t){var n=t.R,r=this.m_vertices[0],i=t.position.x+(n.col1.x*r.x+n.col2.x*r.y),s=t.position.y+(n.col1.y*r.x+n.col2.y*r.y),o=i,u=s;for(var a=1;af?o:f,u=u>l?u:l}e.lowerBound.x=i-this.m_radius,e.lowerBound.y=s-this.m_radius,e.upperBound.x=o+this.m_radius,e.upperBound.y=u+this.m_radius},l.prototype.ComputeMass=function(e,t){t===undefined&&(t=0);if(this.m_vertexCount==2){e.center.x=.5*(this.m_vertices[0].x+this.m_vertices[1].x),e.center.y=.5*(this.m_vertices[0].y+this.m_vertices[1].y),e.mass=0,e.I=0;return}var n=0,r=0,i=0,s=0,o=0,u=0,a=1/3;for(var f=0;f0&&(v?h||(l=p-1,a++):h&&(c=p-1,a++)),h=v}switch(a){case 0:if(h){var m=new f;return this.ComputeMass(m,1),i.SetV(d.MulX(r,m.center)),m.mass}return 0;case 1:l==-1?l=this.m_vertexCount-1:c=this.m_vertexCount-1}var y=parseInt((l+1)%this.m_vertexCount),b=parseInt((c+1)%this.m_vertexCount),w=(0-u[l])/(u[y]-u[l]),E=(0-u[c])/(u[b]-u[c]),S=new g(this.m_vertices[l].x*(1-w)+this.m_vertices[y].x*w,this.m_vertices[l].y*(1-w)+this.m_vertices[y].y*w),x=new g(this.m_vertices[c].x*(1-E)+this.m_vertices[b].x*E,this.m_vertices[c].y*(1-E)+this.m_vertices[b].y*E),T=0,N=new g,C=this.m_vertices[y],k;p=y;while(p!=b){p=(p+1)%this.m_vertexCount,p==b?k=x:k=this.m_vertices[p];var L=.5*((C.x-S.x)*(k.y-S.y)-(C.y-S.y)*(k.x-S.x));T+=L,N.x+=L*(S.x+C.x+k.x)/3,N.y+=L*(S.y+C.y+k.y)/3,C=k}return N.Multiply(1/T),i.SetV(d.MulX(r,N)),T},l.prototype.GetVertexCount=function(){return this.m_vertexCount},l.prototype.GetVertices=function(){return this.m_vertices},l.prototype.GetNormals=function(){return this.m_normals},l.prototype.GetSupport=function(e){var t=0,n=this.m_vertices[0].x*e.x+this.m_vertices[0].y*e.y;for(var r=1;rn&&(t=r,n=i)}return t},l.prototype.GetSupportVertex=function(e){var t=0,n=this.m_vertices[0].x*e.x+this.m_vertices[0].y*e.y;for(var r=1;rn&&(t=r,n=i)}return this.m_vertices[t]},l.prototype.Validate=function(){return!1},l.prototype.b2PolygonShape=function(){this.__super.b2Shape.call(this),this.m_type=c.e_polygonShape,this.m_centroid=new g,this.m_vertices=new t,this.m_normals=new t},l.prototype.Reserve=function(e){e===undefined&&(e=0);for(var t=parseInt(this.m_vertices.length);tv&&(v=w),E>m&&(m=E)}var S=(v-p)*(m-d);if(S<.95*o){o=S,e.R.col1.x=a,e.R.col1.y=f,e.R.col2.x=c,e.R.col2.y=h;var x=.5*(p+v),T=.5*(d+m),N=e.R;e.center.x=u.x+(N.col1.x*x+N.col2.x*T),e.center.y=u.y+(N.col1.y*x+N.col2.y*T),e.extents.x=.5*(v-p),e.extents.y=.5*(m-d)}}},e.postDefs.push(function(){e.Collision.Shapes.b2PolygonShape.s_mat=new h}),c.b2Shape=function(){},c.prototype.Copy=function(){return null},c.prototype.Set=function(e){this.m_radius=e.m_radius},c.prototype.GetType=function(){return this.m_type},c.prototype.TestPoint=function(e,t){return!1},c.prototype.RayCast=function(e,t,n){return!1},c.prototype.ComputeAABB=function(e,t){},c.prototype.ComputeMass=function(e,t){t===undefined&&(t=0)},c.prototype.ComputeSubmergedArea=function(e,t,n,r){return t===undefined&&(t=0),0},c.TestOverlap=function(e,t,n,r){var i=new q;i.proxyA=new U,i.proxyA.Set(e),i.proxyB=new U,i.proxyB.Set(n),i.transformA=t,i.transformB=r,i.useRadii=!0;var s=new tt;s.count=0;var o=new R;return I.Distance(o,s,i),o.distance<10*Number.MIN_VALUE},c.prototype.b2Shape=function(){this.m_type=c.e_unknownShape,this.m_radius=s.b2_linearSlop},e.postDefs.push(function(){e.Collision.Shapes.b2Shape.e_unknownShape=parseInt(-1),e.Collision.Shapes.b2Shape.e_circleShape=0,e.Collision.Shapes.b2Shape.e_polygonShape=1,e.Collision.Shapes.b2Shape.e_edgeShape=2,e.Collision.Shapes.b2Shape.e_shapeTypeCount=3,e.Collision.Shapes.b2Shape.e_hitCollide=1,e.Collision.Shapes.b2Shape.e_missCollide=0,e.Collision.Shapes.b2Shape.e_startsInsideCollide=parseInt(-1)})}(),function(){var t=e.Common.b2Color,n=e.Common.b2internal,r=e.Common.b2Settings,i=e.Common.Math.b2Mat22,s=e.Common.Math.b2Mat33,o=e.Common.Math.b2Math,u=e.Common.Math.b2Sweep,a=e.Common.Math.b2Transform,f=e.Common.Math.b2Vec2,l=e.Common.Math.b2Vec3;t.b2Color=function(){this._r=0,this._g=0,this._b=0},t.prototype.b2Color=function(t,n,r){t===undefined&&(t=0),n===undefined&&(n=0),r===undefined&&(r=0),this._r=e.parseUInt(255*o.Clamp(t,0,1)),this._g=e.parseUInt(255*o.Clamp(n,0,1)),this._b=e.parseUInt(255*o.Clamp(r,0,1))},t.prototype.Set=function(t,n,r){t===undefined&&(t=0),n===undefined&&(n=0),r===undefined&&(r=0),this._r=e.parseUInt(255*o.Clamp(t,0,1)),this._g=e.parseUInt(255*o.Clamp(n,0,1)),this._b=e.parseUInt(255*o.Clamp(r,0,1))},Object.defineProperty(t.prototype,"r",{enumerable:!1,configurable:!0,set:function(t){t===undefined&&(t=0),this._r=e.parseUInt(255*o.Clamp(t,0,1))}}),Object.defineProperty(t.prototype,"g",{enumerable:!1,configurable:!0,set:function(t){t===undefined&&(t=0),this._g=e.parseUInt(255*o.Clamp(t,0,1))}}),Object.defineProperty(t.prototype,"b",{enumerable:!1,configurable:!0,set:function(t){t===undefined&&(t=0),this._b=e.parseUInt(255*o.Clamp(t,0,1))}}),Object.defineProperty(t.prototype,"color",{enumerable:!1,configurable:!0,get:function(){return this._r<<16|this._g<<8|this._b}}),r.b2Settings=function(){},r.b2MixFriction=function(e,t){return e===undefined&&(e=0),t===undefined&&(t=0),Math.sqrt(e*t)},r.b2MixRestitution=function(e,t){return e===undefined&&(e=0),t===undefined&&(t=0),e>t?e:t},r.b2Assert=function(e){if(!e)throw"Assertion Failed"},e.postDefs.push(function(){e.Common.b2Settings.VERSION="2.1alpha",e.Common.b2Settings.USHRT_MAX=65535,e.Common.b2Settings.b2_pi=Math.PI,e.Common.b2Settings.b2_maxManifoldPoints=2,e.Common.b2Settings.b2_aabbExtension=.1,e.Common.b2Settings.b2_aabbMultiplier=2,e.Common.b2Settings.b2_polygonRadius=2*r.b2_linearSlop,e.Common.b2Settings.b2_linearSlop=.005,e.Common.b2Settings.b2_angularSlop=2/180*r.b2_pi,e.Common.b2Settings.b2_toiSlop=8*r.b2_linearSlop,e.Common.b2Settings.b2_maxTOIContactsPerIsland=32,e.Common.b2Settings.b2_maxTOIJointsPerIsland=32,e.Common.b2Settings.b2_velocityThreshold=1,e.Common.b2Settings.b2_maxLinearCorrection=.2,e.Common.b2Settings.b2_maxAngularCorrection=8/180*r.b2_pi,e.Common.b2Settings.b2_maxTranslation=2,e.Common.b2Settings.b2_maxTranslationSquared=r.b2_maxTranslation*r.b2_maxTranslation,e.Common.b2Settings.b2_maxRotation=.5*r.b2_pi,e.Common.b2Settings.b2_maxRotationSquared=r.b2_maxRotation*r.b2_maxRotation,e.Common.b2Settings.b2_contactBaumgarte=.2,e.Common.b2Settings.b2_timeToSleep=.5,e.Common.b2Settings.b2_linearSleepTolerance=.01,e.Common.b2Settings.b2_angularSleepTolerance=2/180*r.b2_pi})}(),function(){var t=e.Collision.b2AABB,n=e.Common.b2Color,r=e.Common.b2internal,i=e.Common.b2Settings,s=e.Common.Math.b2Mat22,o=e.Common.Math.b2Mat33,u=e.Common.Math.b2Math,a=e.Common.Math.b2Sweep,f=e.Common.Math.b2Transform,l=e.Common.Math.b2Vec2,c=e.Common.Math.b2Vec3;s.b2Mat22=function(){this.col1=new l,this.col2=new l},s.prototype.b2Mat22=function(){this.SetIdentity()},s.FromAngle=function(e){e===undefined&&(e=0);var t=new s;return t.Set(e),t},s.FromVV=function(e,t){var n=new s;return n.SetVV(e,t),n},s.prototype.Set=function(e){e===undefined&&(e=0);var t=Math.cos(e),n=Math.sin(e);this.col1.x=t,this.col2.x=-n,this.col1.y=n,this.col2.y=t},s.prototype.SetVV=function(e,t){this.col1.SetV(e),this.col2.SetV(t)},s.prototype.Copy=function(){var e=new s;return e.SetM(this),e},s.prototype.SetM=function(e){this.col1.SetV(e.col1),this.col2.SetV(e.col2)},s.prototype.AddM=function(e){this.col1.x+=e.col1.x,this.col1.y+=e.col1.y,this.col2.x+=e.col2.x,this.col2.y+=e.col2.y},s.prototype.SetIdentity=function(){this.col1.x=1,this.col2.x=0,this.col1.y=0,this.col2.y=1},s.prototype.SetZero=function(){this.col1.x=0,this.col2.x=0,this.col1.y=0,this.col2.y=0},s.prototype.GetAngle=function(){return Math.atan2(this.col1.y,this.col1.x)},s.prototype.GetInverse=function(e){var t=this.col1.x,n=this.col2.x,r=this.col1.y,i=this.col2.y,s=t*i-n*r;return s!=0&&(s=1/s),e.col1.x=s*i,e.col2.x=-s*n,e.col1.y=-s*r,e.col2.y=s*t,e},s.prototype.Solve=function(e,t,n){t===undefined&&(t=0),n===undefined&&(n=0);var r=this.col1.x,i=this.col2.x,s=this.col1.y,o=this.col2.y,u=r*o-i*s;return u!=0&&(u=1/u),e.x=u*(o*t-i*n),e.y=u*(r*n-s*t),e},s.prototype.Abs=function(){this.col1.Abs(),this.col2.Abs()},o.b2Mat33=function(){this.col1=new c,this.col2=new c,this.col3=new c},o.prototype.b2Mat33=function(e,t,n){e===undefined&&(e=null),t===undefined&&(t=null),n===undefined&&(n=null),!e&&!t&&!n?(this.col1.SetZero(),this.col2.SetZero(),this.col3.SetZero()):(this.col1.SetV(e),this.col2.SetV(t),this.col3.SetV(n))},o.prototype.SetVVV=function(e,t,n){this.col1.SetV(e),this.col2.SetV(t),this.col3.SetV(n)},o.prototype.Copy=function(){return new o(this.col1,this.col2,this.col3)},o.prototype.SetM=function(e){this.col1.SetV(e.col1),this.col2.SetV(e.col2),this.col3.SetV(e.col3)},o.prototype.AddM=function(e){this.col1.x+=e.col1.x,this.col1.y+=e.col1.y,this.col1.z+=e.col1.z,this.col2.x+=e.col2.x,this.col2.y+=e.col2.y,this.col2.z+=e.col2.z,this.col3.x+=e.col3.x,this.col3.y+=e.col3.y,this.col3.z+=e.col3.z},o.prototype.SetIdentity=function(){this.col1.x=1,this.col2.x=0,this.col3.x=0,this.col1.y=0,this.col2.y=1,this.col3.y=0,this.col1.z=0,this.col2.z=0,this.col3.z=1},o.prototype.SetZero=function(){this.col1.x=0,this.col2.x=0,this.col3.x=0,this.col1.y=0,this.col2.y=0,this.col3.y=0,this.col1.z=0,this.col2.z=0,this.col3.z=0},o.prototype.Solve22=function(e,t,n){t===undefined&&(t=0),n===undefined&&(n=0);var r=this.col1.x,i=this.col2.x,s=this.col1.y,o=this.col2.y,u=r*o-i*s;return u!=0&&(u=1/u),e.x=u*(o*t-i*n),e.y=u*(r*n-s*t),e},o.prototype.Solve33=function(e,t,n,r){t===undefined&&(t=0),n===undefined&&(n=0),r===undefined&&(r=0);var i=this.col1.x,s=this.col1.y,o=this.col1.z,u=this.col2.x,a=this.col2.y,f=this.col2.z,l=this.col3.x,c=this.col3.y,h=this.col3.z,p=i*(a*h-f*c)+s*(f*l-u*h)+o*(u*c-a*l);return p!=0&&(p=1/p),e.x=p*(t*(a*h-f*c)+n*(f*l-u*h)+r*(u*c-a*l)),e.y=p*(i*(n*h-r*c)+s*(r*l-t*h)+o*(t*c-n*l)),e.z=p*(i*(a*r-f*n)+s*(f*t-u*r)+o*(u*n-a*t)),e},u.b2Math=function(){},u.IsValid=function(e){return e===undefined&&(e=0),isFinite(e)},u.Dot=function(e,t){return e.x*t.x+e.y*t.y},u.CrossVV=function(e,t){return e.x*t.y-e.y*t.x},u.CrossVF=function(e,t){t===undefined&&(t=0);var n=new l(t*e.y,-t*e.x);return n},u.CrossFV=function(e,t){e===undefined&&(e=0);var n=new l(-e*t.y,e*t.x);return n},u.MulMV=function(e,t){var n=new l(e.col1.x*t.x+e.col2.x*t.y,e.col1.y*t.x+e.col2.y*t.y);return n},u.MulTMV=function(e,t){var n=new l(u.Dot(t,e.col1),u.Dot(t,e.col2));return n},u.MulX=function(e,t){var n=u.MulMV(e.R,t);return n.x+=e.position.x,n.y+=e.position.y,n},u.MulXT=function(e,t){var n=u.SubtractVV(t,e.position),r=n.x*e.R.col1.x+n.y*e.R.col1.y;return n.y=n.x*e.R.col2.x+n.y*e.R.col2.y,n.x=r,n},u.AddVV=function(e,t){var n=new l(e.x+t.x,e.y+t.y);return n},u.SubtractVV=function(e,t){var n=new l(e.x-t.x,e.y-t.y);return n},u.Distance=function(e,t){var n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)},u.DistanceSquared=function(e,t){var n=e.x-t.x,r=e.y-t.y;return n*n+r*r},u.MulFV=function(e,t){e===undefined&&(e=0);var n=new l(e*t.x,e*t.y);return n},u.AddMM=function(e,t){var n=s.FromVV(u.AddVV(e.col1,t.col1),u.AddVV(e.col2,t.col2));return n},u.MulMM=function(e,t){var n=s.FromVV(u.MulMV(e,t.col1),u.MulMV(e,t.col2));return n},u.MulTMM=function(e,t){var n=new l(u.Dot(e.col1,t.col1),u.Dot(e.col2,t.col1)),r=new l(u.Dot(e.col1,t.col2),u.Dot(e.col2,t.col2)),i=s.FromVV(n,r);return i},u.Abs=function(e){return e===undefined&&(e=0),e>0?e:-e},u.AbsV=function(e){var t=new l(u.Abs(e.x),u.Abs(e.y));return t},u.AbsM=function(e){var t=s.FromVV(u.AbsV(e.col1),u.AbsV(e.col2));return t},u.Min=function(e,t){return e===undefined&&(e=0),t===undefined&&(t=0),et?e:t},u.MaxV=function(e,t){var n=new l(u.Max(e.x,t.x),u.Max(e.y,t.y));return n},u.Clamp=function(e,t,n){return e===undefined&&(e=0),t===undefined&&(t=0),n===undefined&&(n=0),en?n:e},u.ClampV=function(e,t,n){return u.MaxV(t,u.MinV(e,n))},u.Swap=function(e,t){var n=e[0];e[0]=t[0],t[0]=n},u.Random=function(){return Math.random()*2-1},u.RandomRange=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0);var n=Math.random();return n=(t-e)*n+e,n},u.NextPowerOfTwo=function(e){return e===undefined&&(e=0),e|=e>>1&2147483647,e|=e>>2&1073741823,e|=e>>4&268435455,e|=e>>8&16777215,e|=e>>16&65535,e+1},u.IsPowerOfTwo=function(e){e===undefined&&(e=0);var t=e>0&&(e&e-1)==0;return t},e.postDefs.push(function(){e.Common.Math.b2Math.b2Vec2_zero=new l(0,0),e.Common.Math.b2Math.b2Mat22_identity=s.FromVV(new l(1,0),new l(0,1)),e.Common.Math.b2Math.b2Transform_identity=new f(u.b2Vec2_zero,u.b2Mat22_identity)}),a.b2Sweep=function(){this.localCenter=new l,this.c0=new l,this.c=new l},a.prototype.Set=function(e){this.localCenter.SetV(e.localCenter),this.c0.SetV(e.c0),this.c.SetV(e.c),this.a0=e.a0,this.a=e.a,this.t0=e.t0},a.prototype.Copy=function(){var e=new a;return e.localCenter.SetV(this.localCenter),e.c0.SetV(this.c0),e.c.SetV(this.c),e.a0=this.a0,e.a=this.a,e.t0=this.t0,e},a.prototype.GetTransform=function(e,t){t===undefined&&(t=0),e.position.x=(1-t)*this.c0.x+t*this.c.x,e.position.y=(1-t)*this.c0.y+t*this.c.y;var n=(1-t)*this.a0+t*this.a;e.R.Set(n);var r=e.R;e.position.x-=r.col1.x*this.localCenter.x+r.col2.x*this.localCenter.y,e.position.y-=r.col1.y*this.localCenter.x+r.col2.y*this.localCenter.y},a.prototype.Advance=function(e){e===undefined&&(e=0);if(this.t0Number.MIN_VALUE){var t=(e-this.t0)/(1-this.t0);this.c0.x=(1-t)*this.c0.x+t*this.c.x,this.c0.y=(1-t)*this.c0.y+t*this.c.y,this.a0=(1-t)*this.a0+t*this.a,this.t0=e}},f.b2Transform=function(){this.position=new l,this.R=new s},f.prototype.b2Transform=function(e,t){e===undefined&&(e=null),t===undefined&&(t=null),e&&(this.position.SetV(e),this.R.SetM(t))},f.prototype.Initialize=function(e,t){this.position.SetV(e),this.R.SetM(t)},f.prototype.SetIdentity=function(){this.position.SetZero(),this.R.SetIdentity()},f.prototype.Set=function(e){this.position.SetV(e.position),this.R.SetM(e.R)},f.prototype.GetAngle=function(){return Math.atan2(this.R.col1.y,this.R.col1.x)},l.b2Vec2=function(){},l.prototype.b2Vec2=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0),this.x=e,this.y=t},l.prototype.SetZero=function(){this.x=0,this.y=0},l.prototype.Set=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0),this.x=e,this.y=t},l.prototype.SetV=function(e){this.x=e.x,this.y=e.y},l.prototype.GetNegative=function(){return new l(-this.x,-this.y)},l.prototype.NegativeSelf=function(){this.x=-this.x,this.y=-this.y},l.Make=function(e,t){return e===undefined&&(e=0),t===undefined&&(t=0),new l(e,t)},l.prototype.Copy=function(){return new l(this.x,this.y)},l.prototype.Add=function(e){this.x+=e.x,this.y+=e.y},l.prototype.Subtract=function(e){this.x-=e.x,this.y-=e.y},l.prototype.Multiply=function(e){e===undefined&&(e=0),this.x*=e,this.y*=e},l.prototype.MulM=function(e){var t=this.x;this.x=e.col1.x*t+e.col2.x*this.y,this.y=e.col1.y*t+e.col2.y*this.y},l.prototype.MulTM=function(e){var t=u.Dot(this,e.col1);this.y=u.Dot(this,e.col2),this.x=t},l.prototype.CrossVF=function(e){e===undefined&&(e=0);var t=this.x;this.x=e*this.y,this.y=-e*t},l.prototype.CrossFV=function(e){e===undefined&&(e=0);var t=this.x;this.x=-e*this.y,this.y=e*t},l.prototype.MinV=function(e){this.x=this.xe.x?this.x:e.x,this.y=this.y>e.y?this.y:e.y},l.prototype.Abs=function(){this.x<0&&(this.x=-this.x),this.y<0&&(this.y=-this.y)},l.prototype.Length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},l.prototype.LengthSquared=function(){return this.x*this.x+this.y*this.y},l.prototype.Normalize=function(){var e=Math.sqrt(this.x*this.x+this.y*this.y);if(e0;return e.SetNextEdge(t,s,u,a),t.SetPrevEdge(e,s,u,a),r},Q.prototype.CreateFixture=function(e){if(this.m_world.IsLocked()==1)return null;var t=new st;t.Create(this,this.m_xf,e);if(this.m_flags&Q.e_activeFlag){var n=this.m_world.m_contactManager.m_broadPhase;t.CreateProxy(n,this.m_xf)}return t.m_next=this.m_fixtureList,this.m_fixtureList=t,++this.m_fixtureCount,t.m_body=this,t.m_density>0&&this.ResetMassData(),this.m_world.m_flags|=ft.e_newFixture,t},Q.prototype.CreateFixture2=function(e,t){t===undefined&&(t=0);var n=new ot;return n.shape=e,n.density=t,this.CreateFixture(n)},Q.prototype.DestroyFixture=function(e){if(this.m_world.IsLocked()==1)return;var t=this.m_fixtureList,n=null,r=!1;while(t!=null){if(t==e){n?n.m_next=e.m_next:this.m_fixtureList=e.m_next,r=!0;break}n=t,t=t.m_next}var i=this.m_contactList;while(i){var s=i.contact;i=i.next;var o=s.GetFixtureA(),u=s.GetFixtureB();(e==o||e==u)&&this.m_world.m_contactManager.Destroy(s)}if(this.m_flags&Q.e_activeFlag){var a=this.m_world.m_contactManager.m_broadPhase;e.DestroyProxy(a)}e.Destroy(),e.m_body=null,e.m_next=null,--this.m_fixtureCount,this.ResetMassData()},Q.prototype.SetPositionAndAngle=function(e,t){t===undefined&&(t=0);var n;if(this.m_world.IsLocked()==1)return;this.m_xf.R.Set(t),this.m_xf.position.SetV(e);var r=this.m_xf.R,i=this.m_sweep.localCenter;this.m_sweep.c.x=r.col1.x*i.x+r.col2.x*i.y,this.m_sweep.c.y=r.col1.y*i.x+r.col2.y*i.y,this.m_sweep.c.x+=this.m_xf.position.x,this.m_sweep.c.y+=this.m_xf.position.y,this.m_sweep.c0.SetV(this.m_sweep.c),this.m_sweep.a0=this.m_sweep.a=t;var s=this.m_world.m_contactManager.m_broadPhase;for(n=this.m_fixtureList;n;n=n.m_next)n.Synchronize(s,this.m_xf,this.m_xf);this.m_world.m_contactManager.FindNewContacts()},Q.prototype.SetTransform=function(e){this.SetPositionAndAngle(e.position,e.GetAngle())},Q.prototype.GetTransform=function(){return this.m_xf},Q.prototype.GetPosition=function(){return this.m_xf.position},Q.prototype.SetPosition=function(e){this.SetPositionAndAngle(e,this.GetAngle())},Q.prototype.GetAngle=function(){return this.m_sweep.a},Q.prototype.SetAngle=function(e){e===undefined&&(e=0),this.SetPositionAndAngle(this.GetPosition(),e)},Q.prototype.GetWorldCenter=function(){return this.m_sweep.c},Q.prototype.GetLocalCenter=function(){return this.m_sweep.localCenter},Q.prototype.SetLinearVelocity=function(e){if(this.m_type==Q.b2_staticBody)return;this.m_linearVelocity.SetV(e)},Q.prototype.GetLinearVelocity=function(){return this.m_linearVelocity},Q.prototype.SetAngularVelocity=function(e){e===undefined&&(e=0);if(this.m_type==Q.b2_staticBody)return;this.m_angularVelocity=e},Q.prototype.GetAngularVelocity=function(){return this.m_angularVelocity},Q.prototype.GetDefinition=function(){var e=new G;return e.type=this.GetType(),e.allowSleep=(this.m_flags&Q.e_allowSleepFlag)==Q.e_allowSleepFlag,e.angle=this.GetAngle(),e.angularDamping=this.m_angularDamping,e.angularVelocity=this.m_angularVelocity,e.fixedRotation=(this.m_flags&Q.e_fixedRotationFlag)==Q.e_fixedRotationFlag,e.bullet=(this.m_flags&Q.e_bulletFlag)==Q.e_bulletFlag,e.awake=(this.m_flags&Q.e_awakeFlag)==Q.e_awakeFlag,e.linearDamping=this.m_linearDamping,e.linearVelocity.SetV(this.GetLinearVelocity()),e.position=this.GetPosition(),e.userData=this.GetUserData(),e},Q.prototype.ApplyForce=function(e,t){if(this.m_type!=Q.b2_dynamicBody)return;this.IsAwake()==0&&this.SetAwake(!0),this.m_force.x+=e.x,this.m_force.y+=e.y,this.m_torque+=(t.x-this.m_sweep.c.x)*e.y-(t.y-this.m_sweep.c.y)*e.x},Q.prototype.ApplyTorque=function(e){e===undefined&&(e=0);if(this.m_type!=Q.b2_dynamicBody)return;this.IsAwake()==0&&this.SetAwake(!0),this.m_torque+=e},Q.prototype.ApplyImpulse=function(e,t){if(this.m_type!=Q.b2_dynamicBody)return;this.IsAwake()==0&&this.SetAwake(!0),this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y,this.m_angularVelocity+=this.m_invI*((t.x-this.m_sweep.c.x)*e.y-(t.y-this.m_sweep.c.y)*e.x)},Q.prototype.Split=function(e){var t=this.GetLinearVelocity().Copy(),n=this.GetAngularVelocity(),r=this.GetWorldCenter(),i=this,s=this.m_world.CreateBody(this.GetDefinition()),u;for(var a=i.m_fixtureList;a;)if(e(a)){var f=a.m_next;u?u.m_next=f:i.m_fixtureList=f,i.m_fixtureCount--,a.m_next=s.m_fixtureList,s.m_fixtureList=a,s.m_fixtureCount++,a.m_body=s,a=f}else u=a,a=a.m_next;i.ResetMassData(),s.ResetMassData();var l=i.GetWorldCenter(),c=s.GetWorldCenter(),h=o.AddVV(t,o.CrossFV(n,o.SubtractVV(l,r))),p=o.AddVV(t,o.CrossFV(n,o.SubtractVV(c,r)));return i.SetLinearVelocity(h),s.SetLinearVelocity(p),i.SetAngularVelocity(n),s.SetAngularVelocity(n),i.SynchronizeFixtures(),s.SynchronizeFixtures(),s},Q.prototype.Merge=function(e){var t;for(t=e.m_fixtureList;t;){var n=t.m_next;e.m_fixtureCount--,t.m_next=this.m_fixtureList,this.m_fixtureList=t,this.m_fixtureCount++,t.m_body=i,t=n}r.m_fixtureCount=0;var r=this,i=e,s=r.GetWorldCenter(),o=i.GetWorldCenter(),u=r.GetLinearVelocity().Copy(),a=i.GetLinearVelocity().Copy(),f=r.GetAngularVelocity(),l=i.GetAngularVelocity();r.ResetMassData(),this.SynchronizeFixtures()},Q.prototype.GetMass=function(){return this.m_mass},Q.prototype.GetInertia=function(){return this.m_I},Q.prototype.GetMassData=function(e){e.mass=this.m_mass,e.I=this.m_I,e.center.SetV(this.m_sweep.localCenter)},Q.prototype.SetMassData=function(e){p.b2Assert(this.m_world.IsLocked()==0);if(this.m_world.IsLocked()==1)return;if(this.m_type!=Q.b2_dynamicBody)return;this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_mass=e.mass,this.m_mass<=0&&(this.m_mass=1),this.m_invMass=1/this.m_mass,e.I>0&&(this.m_flags&Q.e_fixedRotationFlag)==0&&(this.m_I=e.I-this.m_mass*(e.center.x*e.center.x+e.center.y*e.center.y),this.m_invI=1/this.m_I);var t=this.m_sweep.c.Copy();this.m_sweep.localCenter.SetV(e.center),this.m_sweep.c0.SetV(o.MulX(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.c.SetV(this.m_sweep.c0),this.m_linearVelocity.x+=this.m_angularVelocity*-(this.m_sweep.c.y-t.y),this.m_linearVelocity.y+=this.m_angularVelocity*+(this.m_sweep.c.x-t.x)},Q.prototype.ResetMassData=function(){this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.SetZero();if(this.m_type==Q.b2_staticBody||this.m_type==Q.b2_kinematicBody)return;var e=f.Make(0,0);for(var t=this.m_fixtureList;t;t=t.m_next){if(t.m_density==0)continue;var n=t.GetMassData();this.m_mass+=n.mass,e.x+=n.center.x*n.mass,e.y+=n.center.y*n.mass,this.m_I+=n.I}this.m_mass>0?(this.m_invMass=1/this.m_mass,e.x*=this.m_invMass,e.y*=this.m_invMass):(this.m_mass=1,this.m_invMass=1),this.m_I>0&&(this.m_flags&Q.e_fixedRotationFlag)==0?(this.m_I-=this.m_mass*(e.x*e.x+e.y*e.y),this.m_I*=this.m_inertiaScale,p.b2Assert(this.m_I>0),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0);var r=this.m_sweep.c.Copy();this.m_sweep.localCenter.SetV(e),this.m_sweep.c0.SetV(o.MulX(this.m_xf,this.m_sweep.localCenter)),this.m_sweep.c.SetV(this.m_sweep.c0),this.m_linearVelocity.x+=this.m_angularVelocity*-(this.m_sweep.c.y-r.y),this.m_linearVelocity.y+=this.m_angularVelocity*+(this.m_sweep.c.x-r.x)},Q.prototype.GetWorldPoint=function(e){var t=this.m_xf.R,n=new f(t.col1.x*e.x+t.col2.x*e.y,t.col1.y*e.x+t.col2.y*e.y);return n.x+=this.m_xf.position.x,n.y+=this.m_xf.position.y,n},Q.prototype.GetWorldVector=function(e){return o.MulMV(this.m_xf.R,e)},Q.prototype.GetLocalPoint=function(e){return o.MulXT(this.m_xf,e)},Q.prototype.GetLocalVector=function(e){return o.MulTMV(this.m_xf.R,e)},Q.prototype.GetLinearVelocityFromWorldPoint=function(e){return new f(this.m_linearVelocity.x-this.m_angularVelocity*(e.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(e.x-this.m_sweep.c.x))},Q.prototype.GetLinearVelocityFromLocalPoint=function(e){var t=this.m_xf.R,n=new f(t.col1.x*e.x+t.col2.x*e.y,t.col1.y*e.x+t.col2.y*e.y);return n.x+=this.m_xf.position.x,n.y+=this.m_xf.position.y,new f(this.m_linearVelocity.x-this.m_angularVelocity*(n.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(n.x-this.m_sweep.c.x))},Q.prototype.GetLinearDamping=function(){return this.m_linearDamping},Q.prototype.SetLinearDamping=function(e){e===undefined&&(e=0),this.m_linearDamping=e},Q.prototype.GetAngularDamping=function(){return this.m_angularDamping},Q.prototype.SetAngularDamping=function(e){e===undefined&&(e=0),this.m_angularDamping=e},Q.prototype.SetType=function(e){e===undefined&&(e=0);if(this.m_type==e)return;this.m_type=e,this.ResetMassData(),this.m_type==Q.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0),this.SetAwake(!0),this.m_force.SetZero(),this.m_torque=0;for(var t=this.m_contactList;t;t=t.next)t.contact.FlagForFiltering()},Q.prototype.GetType=function(){return this.m_type},Q.prototype.SetBullet=function(e){e?this.m_flags|=Q.e_bulletFlag:this.m_flags&=~Q.e_bulletFlag},Q.prototype.IsBullet=function(){return(this.m_flags&Q.e_bulletFlag)==Q.e_bulletFlag},Q.prototype.SetSleepingAllowed=function(e){e?this.m_flags|=Q.e_allowSleepFlag:(this.m_flags&=~Q.e_allowSleepFlag,this.SetAwake(!0))},Q.prototype.SetAwake=function(e){e?(this.m_flags|=Q.e_awakeFlag,this.m_sleepTime=0):(this.m_flags&=~Q.e_awakeFlag,this.m_sleepTime=0,this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0)},Q.prototype.IsAwake=function(){return(this.m_flags&Q.e_awakeFlag)==Q.e_awakeFlag},Q.prototype.SetFixedRotation=function(e){e?this.m_flags|=Q.e_fixedRotationFlag:this.m_flags&=~Q.e_fixedRotationFlag,this.ResetMassData()},Q.prototype.IsFixedRotation=function(){return(this.m_flags&Q.e_fixedRotationFlag)==Q.e_fixedRotationFlag},Q.prototype.SetActive=function(e){if(e==this.IsActive())return;var t,n;if(e){this.m_flags|=Q.e_activeFlag,t=this.m_world.m_contactManager.m_broadPhase;for(n=this.m_fixtureList;n;n=n.m_next)n.CreateProxy(t,this.m_xf)}else{this.m_flags&=~Q.e_activeFlag,t=this.m_world.m_contactManager.m_broadPhase;for(n=this.m_fixtureList;n;n=n.m_next)n.DestroyProxy(t);var r=this.m_contactList;while(r){var i=r;r=r.next,this.m_world.m_contactManager.Destroy(i.contact)}this.m_contactList=null}},Q.prototype.IsActive=function(){return(this.m_flags&Q.e_activeFlag)==Q.e_activeFlag},Q.prototype.IsSleepingAllowed=function(){return(this.m_flags&Q.e_allowSleepFlag)==Q.e_allowSleepFlag},Q.prototype.GetFixtureList=function(){return this.m_fixtureList},Q.prototype.GetJointList=function(){return this.m_jointList},Q.prototype.GetControllerList=function(){return this.m_controllerList},Q.prototype.GetContactList=function(){return this.m_contactList},Q.prototype.GetNext=function(){return this.m_next},Q.prototype.GetUserData=function(){return this.m_userData},Q.prototype.SetUserData=function(e){this.m_userData=e},Q.prototype.GetWorld=function(){return this.m_world},Q.prototype.b2Body=function(e,t){this.m_flags=0,e.bullet&&(this.m_flags|=Q.e_bulletFlag),e.fixedRotation&&(this.m_flags|=Q.e_fixedRotationFlag),e.allowSleep&&(this.m_flags|=Q.e_allowSleepFlag),e.awake&&(this.m_flags|=Q.e_awakeFlag),e.active&&(this.m_flags|=Q.e_activeFlag),this.m_world=t,this.m_xf.position.SetV(e.position),this.m_xf.R.Set(e.angle),this.m_sweep.localCenter.SetZero(),this.m_sweep.t0=1,this.m_sweep.a0=this.m_sweep.a=e.angle;var n=this.m_xf.R,r=this.m_sweep.localCenter;this.m_sweep.c.x=n.col1.x*r.x+n.col2.x*r.y,this.m_sweep.c.y=n.col1.y*r.x+n.col2.y*r.y,this.m_sweep.c.x+=this.m_xf.position.x,this.m_sweep.c.y+=this.m_xf.position.y,this.m_sweep.c0.SetV(this.m_sweep.c),this.m_jointList=null,this.m_controllerList=null,this.m_contactList=null,this.m_controllerCount=0,this.m_prev=null,this.m_next=null,this.m_linearVelocity.SetV(e.linearVelocity),this.m_angularVelocity=e.angularVelocity,this.m_linearDamping=e.linearDamping,this.m_angularDamping=e.angularDamping,this.m_force.Set(0,0),this.m_torque=0,this.m_sleepTime=0,this.m_type=e.type,this.m_type==Q.b2_dynamicBody?(this.m_mass=1,this.m_invMass=1):(this.m_mass=0,this.m_invMass=0),this.m_I=0,this.m_invI=0,this.m_inertiaScale=e.inertiaScale,this.m_userData=e.userData,this.m_fixtureList=null,this.m_fixtureCount=0},Q.prototype.SynchronizeFixtures=function(){var e=Q.s_xf1;e.R.Set(this.m_sweep.a0);var t=e.R,n=this.m_sweep.localCenter;e.position.x=this.m_sweep.c0.x-(t.col1.x*n.x+t.col2.x*n.y),e.position.y=this.m_sweep.c0.y-(t.col1.y*n.x+t.col2.y*n.y);var r,i=this.m_world.m_contactManager.m_broadPhase;for(r=this.m_fixtureList;r;r=r.m_next)r.Synchronize(i,e,this.m_xf)},Q.prototype.SynchronizeTransform=function(){this.m_xf.R.Set(this.m_sweep.a);var e=this.m_xf.R,t=this.m_sweep.localCenter;this.m_xf.position.x=this.m_sweep.c.x-(e.col1.x*t.x+e.col2.x*t.y),this.m_xf.position.y=this.m_sweep.c.y-(e.col1.y*t.x+e.col2.y*t.y)},Q.prototype.ShouldCollide=function(e){if(this.m_type!=Q.b2_dynamicBody&&e.m_type!=Q.b2_dynamicBody)return!1;for(var t=this.m_jointList;t;t=t.next)if(t.other==e&&t.joint.m_collideConnected==0)return!1;return!0},Q.prototype.Advance=function(e){e===undefined&&(e=0),this.m_sweep.Advance(e),this.m_sweep.c.SetV(this.m_sweep.c0),this.m_sweep.a=this.m_sweep.a0,this.SynchronizeTransform()},e.postDefs.push(function(){e.Dynamics.b2Body.s_xf1=new a,e.Dynamics.b2Body.e_islandFlag=1,e.Dynamics.b2Body.e_awakeFlag=2,e.Dynamics.b2Body.e_allowSleepFlag=4,e.Dynamics.b2Body.e_bulletFlag=8,e.Dynamics.b2Body.e_fixedRotationFlag=16,e.Dynamics.b2Body.e_activeFlag=32,e.Dynamics.b2Body.b2_staticBody=0,e.Dynamics.b2Body.b2_kinematicBody=1,e.Dynamics.b2Body.b2_dynamicBody=2}),G.b2BodyDef=function(){this.position=new f,this.linearVelocity=new f},G.prototype.b2BodyDef=function(){this.userData=null,this.position.Set(0,0),this.angle=0,this.linearVelocity.Set(0,0),this.angularVelocity=0,this.linearDamping=0,this.angularDamping=0,this.allowSleep=!0,this.awake=!0,this.fixedRotation=!1,this.bullet=!1,this.type=Q.b2_staticBody,this.active=!0,this.inertiaScale=1},Y.b2ContactFilter=function(){},Y.prototype.ShouldCollide=function(e,t){var n=e.GetFilterData(),r=t.GetFilterData();if(n.groupIndex==r.groupIndex&&n.groupIndex!=0)return n.groupIndex>0;var i=(n.maskBits&r.categoryBits)!=0&&(n.categoryBits&r.maskBits)!=0;return i},Y.prototype.RayCollide=function(e,t){return e?this.ShouldCollide(e instanceof st?e:null,t):!0},e.postDefs.push(function(){e.Dynamics.b2ContactFilter.b2_defaultFilter=new Y}),Z.b2ContactImpulse=function(){this.normalImpulses=new n(p.b2_maxManifoldPoints),this.tangentImpulses=new n(p.b2_maxManifoldPoints)},et.b2ContactListener=function(){},et.prototype.BeginContact=function(e){},et.prototype.EndContact=function(e){},et.prototype.PreSolve=function(e,t){},et.prototype.PostSolve=function(e,t){},e.postDefs.push(function(){e.Dynamics.b2ContactListener.b2_defaultListener=new et}),tt.b2ContactManager=function(){},tt.prototype.b2ContactManager=function(){this.m_world=null,this.m_contactCount=0,this.m_contactFilter=Y.b2_defaultFilter,this.m_contactListener=et.b2_defaultListener,this.m_contactFactory=new vt(this.m_allocator),this.m_broadPhase=new N},tt.prototype.AddPair=function(e,t){var n=e instanceof st?e:null,r=t instanceof st?t:null,i=n.GetBody(),s=r.GetBody();if(i==s)return;var o=s.GetContactList();while(o){if(o.other==i){var u=o.contact.GetFixtureA(),a=o.contact.GetFixtureB();if(u==n&&a==r)return;if(u==r&&a==n)return}o=o.next}if(s.ShouldCollide(i)==0)return;if(this.m_contactFilter.ShouldCollide(n,r)==0)return;var f=this.m_contactFactory.Create(n,r);n=f.GetFixtureA(),r=f.GetFixtureB(),i=n.m_body,s=r.m_body,f.m_prev=null,f.m_next=this.m_world.m_contactList,this.m_world.m_contactList!=null&&(this.m_world.m_contactList.m_prev=f),this.m_world.m_contactList=f,f.m_nodeA.contact=f,f.m_nodeA.other=s,f.m_nodeA.prev=null,f.m_nodeA.next=i.m_contactList,i.m_contactList!=null&&(i.m_contactList.prev=f.m_nodeA),i.m_contactList=f.m_nodeA,f.m_nodeB.contact=f,f.m_nodeB.other=i,f.m_nodeB.prev=null,f.m_nodeB.next=s.m_contactList,s.m_contactList!=null&&(s.m_contactList.prev=f.m_nodeB),s.m_contactList=f.m_nodeB,++this.m_world.m_contactCount;return},tt.prototype.FindNewContacts=function(){this.m_broadPhase.UpdatePairs(e.generateCallback(this,this.AddPair))},tt.prototype.Destroy=function(e){var t=e.GetFixtureA(),n=e.GetFixtureB(),r=t.GetBody(),i=n.GetBody();e.IsTouching()&&this.m_contactListener.EndContact(e),e.m_prev&&(e.m_prev.m_next=e.m_next),e.m_next&&(e.m_next.m_prev=e.m_prev),e==this.m_world.m_contactList&&(this.m_world.m_contactList=e.m_next),e.m_nodeA.prev&&(e.m_nodeA.prev.next=e.m_nodeA.next),e.m_nodeA.next&&(e.m_nodeA.next.prev=e.m_nodeA.prev),e.m_nodeA==r.m_contactList&&(r.m_contactList=e.m_nodeA.next),e.m_nodeB.prev&&(e.m_nodeB.prev.next=e.m_nodeB.next),e.m_nodeB.next&&(e.m_nodeB.next.prev=e.m_nodeB.prev),e.m_nodeB==i.m_contactList&&(i.m_contactList=e.m_nodeB.next),this.m_contactFactory.Destroy(e),--this.m_contactCount},tt.prototype.Collide=function(){var e=this.m_world.m_contactList;while(e){var t=e.GetFixtureA(),n=e.GetFixtureB(),r=t.GetBody(),i=n.GetBody();if(r.IsAwake()==0&&i.IsAwake()==0){e=e.GetNext();continue}if(e.m_flags&ct.e_filterFlag){if(i.ShouldCollide(r)==0){var s=e;e=s.GetNext(),this.Destroy(s);continue}if(this.m_contactFilter.ShouldCollide(t,n)==0){s=e,e=s.GetNext(),this.Destroy(s);continue}e.m_flags&=~ct.e_filterFlag}var o=t.m_proxy,u=n.m_proxy,a=this.m_broadPhase.TestOverlap(o,u);if(a==0){s=e,e=s.GetNext(),this.Destroy(s);continue}e.Update(this.m_contactListener),e=e.GetNext()}},e.postDefs.push(function(){e.Dynamics.b2ContactManager.s_evalCP=new b}),nt.b2DebugDraw=function(){},nt.prototype.b2DebugDraw=function(){},nt.prototype.SetFlags=function(e){e===undefined&&(e=0)},nt.prototype.GetFlags=function(){},nt.prototype.AppendFlags=function(e){e===undefined&&(e=0)},nt.prototype.ClearFlags=function(e){e===undefined&&(e=0)},nt.prototype.SetSprite=function(e){},nt.prototype.GetSprite=function(){},nt.prototype.SetDrawScale=function(e){e===undefined&&(e=0)},nt.prototype.GetDrawScale=function(){},nt.prototype.SetLineThickness=function(e){e===undefined&&(e=0)},nt.prototype.GetLineThickness=function(){},nt.prototype.SetAlpha=function(e){e===undefined&&(e=0)},nt.prototype.GetAlpha=function(){},nt.prototype.SetFillAlpha=function(e){e===undefined&&(e=0)},nt.prototype.GetFillAlpha=function(){},nt.prototype.SetXFormScale=function(e){e===undefined&&(e=0)},nt.prototype.GetXFormScale=function(){},nt.prototype.DrawPolygon=function(e,t,n){t===undefined&&(t=0)},nt.prototype.DrawSolidPolygon=function(e,t,n){t===undefined&&(t=0)},nt.prototype.DrawCircle=function(e,t,n){t===undefined&&(t=0)},nt.prototype.DrawSolidCircle=function(e,t,n,r){t===undefined&&(t=0)},nt.prototype.DrawSegment=function(e,t,n){},nt.prototype.DrawTransform=function(e){},e.postDefs.push(function(){e.Dynamics.b2DebugDraw.e_shapeBit=1,e.Dynamics.b2DebugDraw.e_jointBit=2,e.Dynamics.b2DebugDraw.e_aabbBit=4,e.Dynamics.b2DebugDraw.e_pairBit=8,e.Dynamics.b2DebugDraw.e_centerOfMassBit=16,e.Dynamics.b2DebugDraw.e_controllerBit=32}),rt.b2DestructionListener=function(){},rt.prototype.SayGoodbyeJoint=function(e){},rt.prototype.SayGoodbyeFixture=function(e){},it.b2FilterData=function(){this.categoryBits=1,this.maskBits=65535,this.groupIndex=0},it.prototype.Copy=function(){var e=new it;return e.categoryBits=this.categoryBits,e.maskBits=this.maskBits,e.groupIndex=this.groupIndex,e},st.b2Fixture=function(){this.m_filter=new it},st.prototype.GetType=function(){return this.m_shape.GetType()},st.prototype.GetShape=function(){return this.m_shape},st.prototype.SetSensor=function(e){if(this.m_isSensor==e)return;this.m_isSensor=e;if(this.m_body==null)return;var t=this.m_body.GetContactList();while(t){var n=t.contact,r=n.GetFixtureA(),i=n.GetFixtureB();(r==this||i==this)&&n.SetSensor(r.IsSensor()||i.IsSensor()),t=t.next}},st.prototype.IsSensor=function(){return this.m_isSensor},st.prototype.SetFilterData=function(e){this.m_filter=e.Copy();if(this.m_body)return;var t=this.m_body.GetContactList();while(t){var n=t.contact,r=n.GetFixtureA(),i=n.GetFixtureB();(r==this||i==this)&&n.FlagForFiltering(),t=t.next}},st.prototype.GetFilterData=function(){return this.m_filter.Copy()},st.prototype.GetBody=function(){return this.m_body},st.prototype.GetNext=function(){return this.m_next},st.prototype.GetUserData=function(){return this.m_userData},st.prototype.SetUserData=function(e){this.m_userData=e},st.prototype.TestPoint=function(e){return this.m_shape.TestPoint(this.m_body.GetTransform(),e)},st.prototype.RayCast=function(e,t){return this.m_shape.RayCast(e,t,this.m_body.GetTransform())},st.prototype.GetMassData=function(e){return e===undefined&&(e=null),e==null&&(e=new $),this.m_shape.ComputeMass(e,this.m_density),e},st.prototype.SetDensity=function(e){e===undefined&&(e=0),this.m_density=e},st.prototype.GetDensity=function(){return this.m_density},st.prototype.GetFriction=function(){return this.m_friction},st.prototype.SetFriction=function(e){e===undefined&&(e=0),this.m_friction=e},st.prototype.GetRestitution=function(){return this.m_restitution},st.prototype.SetRestitution=function(e){e===undefined&&(e=0),this.m_restitution=e},st.prototype.GetAABB=function(){return this.m_aabb},st.prototype.b2Fixture=function(){this.m_aabb=new d,this.m_userData=null,this.m_body=null,this.m_next=null,this.m_shape=null,this.m_density=0,this.m_friction=0,this.m_restitution=0},st.prototype.Create=function(e,t,n){this.m_userData=n.userData,this.m_friction=n.friction,this.m_restitution=n.restitution,this.m_body=e,this.m_next=null,this.m_filter=n.filter.Copy(),this.m_isSensor=n.isSensor,this.m_shape=n.shape.Copy(),this.m_density=n.density},st.prototype.Destroy=function(){this.m_shape=null},st.prototype.CreateProxy=function(e,t){this.m_shape.ComputeAABB(this.m_aabb,t),this.m_proxy=e.CreateProxy(this.m_aabb,this)},st.prototype.DestroyProxy=function(e){if(this.m_proxy==null)return;e.DestroyProxy(this.m_proxy),this.m_proxy=null},st.prototype.Synchronize=function(e,t,n){if(!this.m_proxy)return;var r=new d,i=new d;this.m_shape.ComputeAABB(r,t),this.m_shape.ComputeAABB(i,n),this.m_aabb.Combine(r,i);var s=o.SubtractVV(n.position,t.position);e.MoveProxy(this.m_proxy,this.m_aabb,s)},ot.b2FixtureDef=function(){this.filter=new it},ot.prototype.b2FixtureDef=function(){this.shape=null,this.userData=null,this.friction=.2,this.restitution=0,this.density=0,this.filter.categoryBits=1,this.filter.maskBits=65535,this.filter.groupIndex=0,this.isSensor=!1},ut.b2Island=function(){},ut.prototype.b2Island=function(){this.m_bodies=new t,this.m_contacts=new t,this.m_joints=new t},ut.prototype.Initialize=function(e,t,n,r,i,s){e===undefined&&(e=0),t===undefined&&(t=0),n===undefined&&(n=0);var o=0;this.m_bodyCapacity=e,this.m_contactCapacity=t,this.m_jointCapacity=n,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_allocator=r,this.m_listener=i,this.m_contactSolver=s;for(o=this.m_bodies.length;op.b2_maxTranslationSquared&&(s.m_linearVelocity.Normalize(),s.m_linearVelocity.x*=p.b2_maxTranslation*e.inv_dt,s.m_linearVelocity.y*=p.b2_maxTranslation*e.inv_dt);var c=e.dt*s.m_angularVelocity;c*c>p.b2_maxRotationSquared&&(s.m_angularVelocity<0?s.m_angularVelocity=-p.b2_maxRotation*e.inv_dt:s.m_angularVelocity=p.b2_maxRotation*e.inv_dt),s.m_sweep.c0.SetV(s.m_sweep.c),s.m_sweep.a0=s.m_sweep.a,s.m_sweep.c.x+=e.dt*s.m_linearVelocity.x,s.m_sweep.c.y+=e.dt*s.m_linearVelocity.y,s.m_sweep.a+=e.dt*s.m_angularVelocity,s.SynchronizeTransform()}for(r=0;ry||o.Dot(s.m_linearVelocity,s.m_linearVelocity)>g?(s.m_sleepTime=0,m=0):(s.m_sleepTime+=e.dt,m=o.Min(m,s.m_sleepTime))}if(m>=p.b2_timeToSleep)for(r=0;rp.b2_maxTranslationSquared&&(i.m_linearVelocity.Normalize(),i.m_linearVelocity.x*=p.b2_maxTranslation*e.inv_dt,i.m_linearVelocity.y*=p.b2_maxTranslation*e.inv_dt);var u=e.dt*i.m_angularVelocity;u*u>p.b2_maxRotationSquared&&(i.m_angularVelocity<0?i.m_angularVelocity=-p.b2_maxRotation*e.inv_dt:i.m_angularVelocity=p.b2_maxRotation*e.inv_dt),i.m_sweep.c0.SetV(i.m_sweep.c),i.m_sweep.a0=i.m_sweep.a,i.m_sweep.c.x+=e.dt*i.m_linearVelocity.x,i.m_sweep.c.y+=e.dt*i.m_linearVelocity.y,i.m_sweep.a+=e.dt*i.m_angularVelocity,i.SynchronizeTransform()}var a=.75;for(t=0;t0?r.inv_dt=1/e:r.inv_dt=0,r.dtRatio=this.m_inv_dt0*e,r.warmStarting=ft.m_warmStarting,this.m_contactManager.Collide(),r.dt>0&&this.Solve(r),ft.m_continuousPhysics&&r.dt>0&&this.SolveTOI(r),r.dt>0&&(this.m_inv_dt0=r.inv_dt),this.m_flags&=~ft.e_locked},ft.prototype.ClearForces=function(){for(var e=this.m_bodyList;e;e=e.m_next)e.m_force.SetZero(),e.m_torque=0},ft.prototype.DrawDebugData=function(){if(this.m_debugDraw==null)return;this.m_debugDraw.m_sprite.graphics.clear();var e=this.m_debugDraw.GetFlags(),t=0,n,r,i,s,o,u=new f,a=new f,l=new f,h,p=new d,v=new d,m=[new f,new f,new f,new f],g=new c(0,0,0);if(e&nt.e_shapeBit)for(n=this.m_bodyList;n;n=n.m_next){h=n.m_xf;for(r=n.GetFixtureList();r;r=r.m_next)i=r.GetShape(),n.IsActive()==0?(g.Set(.5,.5,.3),this.DrawShape(i,h,g)):n.GetType()==Q.b2_staticBody?(g.Set(.5,.9,.5),this.DrawShape(i,h,g)):n.GetType()==Q.b2_kinematicBody?(g.Set(.5,.5,.9),this.DrawShape(i,h,g)):n.IsAwake()==0?(g.Set(.6,.6,.6),this.DrawShape(i,h,g)):(g.Set(.9,.7,.7),this.DrawShape(i,h,g))}if(e&nt.e_jointBit)for(s=this.m_jointList;s;s=s.m_next)this.DrawJoint(s);if(e&nt.e_controllerBit)for(var y=this.m_controllerList;y;y=y.m_next)y.Draw(this.m_debugDraw);if(e&nt.e_pairBit){g.Set(.3,.9,.9);for(var b=this.m_contactManager.m_contactList;b;b=b.GetNext()){var w=b.GetFixtureA(),E=b.GetFixtureB(),S=w.GetAABB().GetCenter(),x=E.GetAABB().GetCenter();this.m_debugDraw.DrawSegment(S,x,g)}}if(e&nt.e_aabbBit){o=this.m_contactManager.m_broadPhase,m=[new f,new f,new f,new f];for(n=this.m_bodyList;n;n=n.GetNext()){if(n.IsActive()==0)continue;for(r=n.GetFixtureList();r;r=r.GetNext()){var T=o.GetFatAABB(r.m_proxy);m[0].Set(T.lowerBound.x,T.lowerBound.y),m[1].Set(T.upperBound.x,T.lowerBound.y),m[2].Set(T.upperBound.x,T.upperBound.y),m[3].Set(T.lowerBound.x,T.upperBound.y),this.m_debugDraw.DrawPolygon(m,4,g)}}}if(e&nt.e_centerOfMassBit)for(n=this.m_bodyList;n;n=n.m_next)h=ft.s_xf,h.R=n.m_xf.R,h.position=n.GetWorldCenter(),this.m_debugDraw.DrawTransform(h)},ft.prototype.QueryAABB=function(e,t){function i(t){return e(r.GetUserData(t))}var n=this,r=n.m_contactManager.m_broadPhase;r.Query(i,t)},ft.prototype.QueryShape=function(e,t,n){function s(r){var s=i.GetUserData(r)instanceof st?i.GetUserData(r):null;return K.TestOverlap(t,n,s.GetShape(),s.GetBody().GetTransform())?e(s):!0}var r=this;n===undefined&&(n=null),n==null&&(n=new a,n.SetIdentity());var i=r.m_contactManager.m_broadPhase,o=new d;t.ComputeAABB(o,n),i.Query(s,o)},ft.prototype.QueryPoint=function(e,t){function i(n){var i=r.GetUserData(n)instanceof st?r.GetUserData(n):null;return i.TestPoint(t)?e(i):!0}var n=this,r=n.m_contactManager.m_broadPhase,s=new d;s.lowerBound.Set(t.x-p.b2_linearSlop,t.y-p.b2_linearSlop),s.upperBound.Set(t.x+p.b2_linearSlop,t.y+p.b2_linearSlop),r.Query(i,s)},ft.prototype.RayCast=function(e,t,n){function o(r,o){var u=i.GetUserData(o),a=u instanceof st?u:null,l=a.RayCast(s,r);if(l){var c=s.fraction,h=new f((1-c)*t.x+c*n.x,(1-c)*t.y+c*n.y);return e(a,h,s.normal,c)}return r.maxFraction}var r=this,i=r.m_contactManager.m_broadPhase,s=new _,u=new M(t,n);i.RayCast(o,u)},ft.prototype.RayCastOne=function(e,t){function i(e,t,n,i){return i===undefined&&(i=0),r=e,i}var n=this,r;return n.RayCast(i,e,t),r},ft.prototype.RayCastAll=function(e,n){function s(e,t,n,r){return r===undefined&&(r=0),i[i.length]=e,1}var r=this,i=new t;return r.RayCast(s,e,n),i},ft.prototype.GetBodyList=function(){return this.m_bodyList},ft.prototype.GetJointList=function(){return this.m_jointList},ft.prototype.GetContactList=function(){return this.m_contactList},ft.prototype.IsLocked=function(){return(this.m_flags&ft.e_locked)>0},ft.prototype.Solve=function(e){var t;for(var n=this.m_controllerList;n;n=n.m_next)n.Step(e);var r=this.m_island;r.Initialize(this.m_bodyCount,this.m_contactCount,this.m_jointCount,null,this.m_contactManager.m_contactListener,this.m_contactSolver);for(t=this.m_bodyList;t;t=t.m_next)t.m_flags&=~Q.e_islandFlag;for(var i=this.m_contactList;i;i=i.m_next)i.m_flags&=~ct.e_islandFlag;for(var s=this.m_jointList;s;s=s.m_next)s.m_islandFlag=!1;var o=parseInt(this.m_bodyCount),u=this.s_stack;for(var a=this.m_bodyList;a;a=a.m_next){if(a.m_flags&Q.e_islandFlag)continue;if(a.IsAwake()==0||a.IsActive()==0)continue;if(a.GetType()==Q.b2_staticBody)continue;r.Clear();var f=0;u[f++]=a,a.m_flags|=Q.e_islandFlag;while(f>0){t=u[--f],r.AddBody(t),t.IsAwake()==0&&t.SetAwake(!0);if(t.GetType()==Q.b2_staticBody)continue;var l;for(var c=t.m_contactList;c;c=c.next){if(c.contact.m_flags&ct.e_islandFlag)continue;if(c.contact.IsSensor()==1||c.contact.IsEnabled()==0||c.contact.IsTouching()==0)continue;r.AddContact(c.contact),c.contact.m_flags|=ct.e_islandFlag,l=c.other;if(l.m_flags&Q.e_islandFlag)continue;u[f++]=l,l.m_flags|=Q.e_islandFlag}for(var h=t.m_jointList;h;h=h.next){if(h.joint.m_islandFlag==1)continue;l=h.other;if(l.IsActive()==0)continue;r.AddJoint(h.joint),h.joint.m_islandFlag=!0;if(l.m_flags&Q.e_islandFlag)continue;u[f++]=l,l.m_flags|=Q.e_islandFlag}}r.Solve(e,this.m_gravity,this.m_allowSleep);for(var p=0;p0&&d<1&&(d=(1-d)*v+d,d>1&&(d=1)),l.m_toi=d,l.m_flags|=ct.e_toiFlag}Number.MIN_VALUE0){t=f[g++],--y,a.AddBody(t),t.IsAwake()==0&&t.SetAwake(!0);if(t.GetType()!=Q.b2_dynamicBody)continue;for(o=t.m_contactList;o;o=o.next){if(a.m_contactCount==a.m_contactCapacity)break;if(o.contact.m_flags&ct.e_islandFlag)continue;if(o.contact.IsSensor()==1||o.contact.IsEnabled()==0||o.contact.IsTouching()==0)continue;a.AddContact(o.contact),o.contact.m_flags|=ct.e_islandFlag;var b=o.other;if(b.m_flags&Q.e_islandFlag)continue;b.GetType()!=Q.b2_staticBody&&(b.Advance(h),b.SetAwake(!0)),f[g+y]=b,++y,b.m_flags|=Q.e_islandFlag}for(var w=t.m_jointList;w;w=w.next){if(a.m_jointCount==a.m_jointCapacity)continue;if(w.joint.m_islandFlag==1)continue;b=w.other;if(b.IsActive()==0)continue;a.AddJoint(w.joint),w.joint.m_islandFlag=!0;if(b.m_flags&Q.e_islandFlag)continue;b.GetType()!=Q.b2_staticBody&&(b.Advance(h),b.SetAwake(!0)),f[g+y]=b,++y,b.m_flags|=Q.e_islandFlag}}var E=ft.s_timestep;E.warmStarting=!1,E.dt=(1-h)*e.dt,E.inv_dt=1/E.dt,E.dtRatio=0,E.velocityIterations=e.velocityIterations,E.positionIterations=e.positionIterations,a.SolveTOI(E);var S=0;for(S=0;S0;for(var p=0;p0&&(e.m_fixtureA.m_body.SetAwake(!0),e.m_fixtureB.m_body.SetAwake(!0));var t=parseInt(e.m_fixtureA.GetType()),n=parseInt(e.m_fixtureB.GetType()),r=this.m_registers[t][n];r.poolCount++,e.m_next=r.pool,r.pool=e;var i=r.destroyFcn;i(e,this.m_allocator)},v.b2ContactRegister=function(){},m.b2ContactResult=function(){this.position=new V,this.normal=new V,this.id=new Y},g.b2ContactSolver=function(){this.m_step=new B,this.m_constraints=new t},g.prototype.b2ContactSolver=function(){},g.prototype.Initialize=function(e,t,n,r){n===undefined&&(n=0);var i;this.m_step.Set(e),this.m_allocator=r;var s=0,o,u;this.m_constraintCount=n;while(this.m_constraints.length0),g.s_worldManifold.Initialize(y,v.m_xf,p,m.m_xf,d);var k=g.s_worldManifold.m_normal.x,L=g.s_worldManifold.m_normal.y,A=this.m_constraints[s];A.bodyA=v,A.bodyB=m,A.manifold=y,A.normal.x=k,A.normal.y=L,A.pointCount=y.m_pointCount,A.friction=b,A.restitution=w,A.localPlaneNormal.x=y.m_localPlaneNormal.x,A.localPlaneNormal.y=y.m_localPlaneNormal.y,A.localPoint.x=y.m_localPoint.x,A.localPoint.y=y.m_localPoint.y,A.radius=p+d,A.type=y.m_type;for(var O=0;O0?h:0,l=h-t.normalImpulse,p=l*H,d=l*B,A.x-=M*p,A.y-=M*d,k-=_*(t.rA.x*d-t.rA.y*p),O.x+=D*p,O.y+=D*d,L+=P*(t.rB.x*d-t.rB.y*p),t.normalImpulse=h;else{var U=T.points[0],W=T.points[1],X=U.normalImpulse,V=W.normalImpulse,$=O.x-L*U.rB.y-A.x+k*U.rA.y,J=O.y+L*U.rB.x-A.y-k*U.rA.x,K=O.x-L*W.rB.y-A.x+k*W.rA.y,Q=O.y+L*W.rB.x-A.y-k*W.rA.x,G=$*H+J*B,Y=K*H+Q*B,Z=G-U.velocityBias,et=Y-W.velocityBias;E=T.K,Z-=E.col1.x*X+E.col2.x*V,et-=E.col1.y*X+E.col2.y*V;var tt=.001;for(;;){E=T.normalMass;var nt=-(E.col1.x*Z+E.col2.x*et),rt=-(E.col1.y*Z+E.col2.y*et);if(nt>=0&&rt>=0){v=nt-X,m=rt-V,g=v*H,y=v*B,b=m*H,w=m*B,A.x-=M*(g+b),A.y-=M*(y+w),k-=_*(U.rA.x*y-U.rA.y*g+W.rA.x*w-W.rA.y*b),O.x+=D*(g+b),O.y+=D*(y+w),L+=P*(U.rB.x*y-U.rB.y*g+W.rB.x*w-W.rB.y*b),U.normalImpulse=nt,W.normalImpulse=rt;break}nt=-U.normalMass*Z,rt=0,G=0,Y=T.K.col1.y*nt+et;if(nt>=0&&Y>=0){v=nt-X,m=rt-V,g=v*H,y=v*B,b=m*H,w=m*B,A.x-=M*(g+b),A.y-=M*(y+w),k-=_*(U.rA.x*y-U.rA.y*g+W.rA.x*w-W.rA.y*b),O.x+=D*(g+b),O.y+=D*(y+w),L+=P*(U.rB.x*y-U.rB.y*g+W.rB.x*w-W.rB.y*b),U.normalImpulse=nt,W.normalImpulse=rt;break}nt=0,rt=-W.normalMass*et,G=T.K.col2.x*rt+Z,Y=0;if(rt>=0&&G>=0){v=nt-X,m=rt-V,g=v*H,y=v*B,b=m*H,w=m*B,A.x-=M*(g+b),A.y-=M*(y+w),k-=_*(U.rA.x*y-U.rA.y*g+W.rA.x*w-W.rA.y*b),O.x+=D*(g+b),O.y+=D*(y+w),L+=P*(U.rB.x*y-U.rB.y*g+W.rB.x*w-W.rB.y*b),U.normalImpulse=nt,W.normalImpulse=rt;break}nt=0,rt=0,G=Z,Y=et;if(G>=0&&Y>=0){v=nt-X,m=rt-V,g=v*H,y=v*B,b=m*H,w=m*B,A.x-=M*(g+b),A.y-=M*(y+w),k-=_*(U.rA.x*y-U.rA.y*g+W.rA.x*w-W.rA.y*b),O.x+=D*(g+b),O.y+=D*(y+w),L+=P*(U.rB.x*y-U.rB.y*g+W.rB.x*w-W.rB.y*b),U.normalImpulse=nt,W.normalImpulse=rt;break}break}}N.m_angularVelocity=k,C.m_angularVelocity=L}},g.prototype.FinalizeVelocityConstraints=function(){for(var e=0;e-1.5*q.b2_linearSlop},e.postDefs.push(function(){e.Dynamics.Contacts.b2ContactSolver.s_worldManifold=new wt,e.Dynamics.Contacts.b2ContactSolver.s_psm=new x}),e.inherit(y,e.Dynamics.Contacts.b2Contact),y.prototype.__super=e.Dynamics.Contacts.b2Contact.prototype,y.b2EdgeAndCircleContact=function(){e.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)},y.Create=function(e){return new y},y.Destroy=function(e,t){},y.prototype.Reset=function(e,t){this.__super.Reset.call(this,e,t)},y.prototype.Evaluate=function(){var e=this.m_fixtureA.GetBody(),t=this.m_fixtureB.GetBody();this.b2CollideEdgeAndCircle(this.m_manifold,this.m_fixtureA.GetShape()instanceof s?this.m_fixtureA.GetShape():null,e.m_xf,this.m_fixtureB.GetShape()instanceof r?this.m_fixtureB.GetShape():null,t.m_xf)},y.prototype.b2CollideEdgeAndCircle=function(e,t,n,r,i){},e.inherit(b,e.Dynamics.Contacts.b2Contact),b.prototype.__super=e.Dynamics.Contacts.b2Contact.prototype,b.b2NullContact=function(){e.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)},b.prototype.b2NullContact=function(){this.__super.b2Contact.call(this)},b.prototype.Evaluate=function(){},e.inherit(w,e.Dynamics.Contacts.b2Contact),w.prototype.__super=e.Dynamics.Contacts.b2Contact.prototype,w.b2PolyAndCircleContact=function(){e.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)},w.Create=function(e){return new w},w.Destroy=function(e,t){},w.prototype.Reset=function(e,t){this.__super.Reset.call(this,e,t),q.b2Assert(e.GetType()==a.e_polygonShape),q.b2Assert(t.GetType()==a.e_circleShape)},w.prototype.Evaluate=function(){var e=this.m_fixtureA.m_body,t=this.m_fixtureB.m_body;G.CollidePolygonAndCircle(this.m_manifold,this.m_fixtureA.GetShape()instanceof u?this.m_fixtureA.GetShape():null,e.m_xf,this.m_fixtureB.GetShape()instanceof r?this.m_fixtureB.GetShape():null,t.m_xf)},e.inherit(E,e.Dynamics.Contacts.b2Contact),E.prototype.__super=e.Dynamics.Contacts.b2Contact.prototype,E.b2PolyAndEdgeContact=function(){e.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)},E.Create=function(e){return new E},E.Destroy=function(e,t){},E.prototype.Reset=function(e,t){this.__super.Reset.call(this,e,t),q.b2Assert(e.GetType()==a.e_polygonShape),q.b2Assert(t.GetType()==a.e_edgeShape)},E.prototype.Evaluate=function(){var e=this.m_fixtureA.GetBody(),t=this.m_fixtureB.GetBody();this.b2CollidePolyAndEdge(this.m_manifold,this.m_fixtureA.GetShape()instanceof u?this.m_fixtureA.GetShape():null,e.m_xf,this.m_fixtureB.GetShape()instanceof s?this.m_fixtureB.GetShape():null,t.m_xf)},E.prototype.b2CollidePolyAndEdge=function(e,t,n,r,i){},e.inherit(S,e.Dynamics.Contacts.b2Contact),S.prototype.__super=e.Dynamics.Contacts.b2Contact.prototype,S.b2PolygonContact=function(){e.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)},S.Create=function(e){return new S},S.Destroy=function(e,t){},S.prototype.Reset=function(e,t){this.__super.Reset.call(this,e,t)},S.prototype.Evaluate=function(){var e=this.m_fixtureA.GetBody(),t=this.m_fixtureB.GetBody();G.CollidePolygons(this.m_manifold,this.m_fixtureA.GetShape()instanceof u?this.m_fixtureA.GetShape():null,e.m_xf,this.m_fixtureB.GetShape()instanceof u?this.m_fixtureB.GetShape():null,t.m_xf)},x.b2PositionSolverManifold=function(){},x.prototype.b2PositionSolverManifold=function(){this.m_normal=new V,this.m_separations=new n(q.b2_maxManifoldPoints),this.m_points=new t(q.b2_maxManifoldPoints);for(var e=0;e0);var t=0,n=0,r=0,i,s,o=0,u=0;switch(e.type){case at.e_circles:i=e.bodyA.m_xf.R,s=e.localPoint;var a=e.bodyA.m_xf.position.x+(i.col1.x*s.x+i.col2.x*s.y),f=e.bodyA.m_xf.position.y+(i.col1.y*s.x+i.col2.y*s.y);i=e.bodyB.m_xf.R,s=e.points[0].localPoint;var l=e.bodyB.m_xf.position.x+(i.col1.x*s.x+i.col2.x*s.y),c=e.bodyB.m_xf.position.y+(i.col1.y*s.x+i.col2.y*s.y),h=l-a,p=c-f,d=h*h+p*p;if(d>Number.MIN_VALUE*Number.MIN_VALUE){var v=Math.sqrt(d);this.m_normal.x=h/v,this.m_normal.y=p/v}else this.m_normal.x=1,this.m_normal.y=0;this.m_points[0].x=.5*(a+l),this.m_points[0].y=.5*(f+c),this.m_separations[0]=h*this.m_normal.x+p*this.m_normal.y-e.radius;break;case at.e_faceA:i=e.bodyA.m_xf.R,s=e.localPlaneNormal,this.m_normal.x=i.col1.x*s.x+i.col2.x*s.y,this.m_normal.y=i.col1.y*s.x+i.col2.y*s.y,i=e.bodyA.m_xf.R,s=e.localPoint,o=e.bodyA.m_xf.position.x+(i.col1.x*s.x+i.col2.x*s.y),u=e.bodyA.m_xf.position.y+(i.col1.y*s.x+i.col2.y*s.y),i=e.bodyB.m_xf.R;for(t=0;t0||t>0?this.maxTimestep=1/Math.max(e,t):this.maxTimestep=0},j.prototype.Step=function(e){var t=e.dt;if(t<=Number.MIN_VALUE)return;t>this.maxTimestep&&this.maxTimestep>0&&(t=this.maxTimestep);for(var n=this.m_bodyList;n;n=n.nextBody){var r=n.body;if(!r.IsAwake())continue;var i=r.GetWorldVector(g.MulMV(this.T,r.GetLocalVector(r.GetLinearVelocity())));r.SetLinearVelocity(new w(r.GetLinearVelocity().x+i.x*t,r.GetLinearVelocity().y+i.y*t))}}}(),function(){var t=e.Common.b2Color,n=e.Common.b2internal,r=e.Common.b2Settings,i=e.Common.Math.b2Mat22,s=e.Common.Math.b2Mat33,o=e.Common.Math.b2Math,u=e.Common.Math.b2Sweep,a=e.Common.Math.b2Transform,f=e.Common.Math.b2Vec2,l=e.Common.Math.b2Vec3,c=e.Dynamics.Joints.b2DistanceJoint,h=e.Dynamics.Joints.b2DistanceJointDef,p=e.Dynamics.Joints.b2FrictionJoint,d=e.Dynamics.Joints.b2FrictionJointDef,v=e.Dynamics.Joints.b2GearJoint,m=e.Dynamics.Joints.b2GearJointDef,g=e.Dynamics.Joints.b2Jacobian,y=e.Dynamics.Joints.b2Joint,b=e.Dynamics.Joints.b2JointDef,w=e.Dynamics.Joints.b2JointEdge,E=e.Dynamics.Joints.b2LineJoint,S=e.Dynamics.Joints.b2LineJointDef,x=e.Dynamics.Joints.b2MouseJoint,T=e.Dynamics.Joints.b2MouseJointDef,N=e.Dynamics.Joints.b2PrismaticJoint,C=e.Dynamics.Joints.b2PrismaticJointDef,k=e.Dynamics.Joints.b2PulleyJoint,L=e.Dynamics.Joints.b2PulleyJointDef,A=e.Dynamics.Joints.b2RevoluteJoint,O=e.Dynamics.Joints.b2RevoluteJointDef,M=e.Dynamics.Joints.b2WeldJoint,_=e.Dynamics.Joints.b2WeldJointDef,D=e.Dynamics.b2Body,P=e.Dynamics.b2BodyDef,H=e.Dynamics.b2ContactFilter,B=e.Dynamics.b2ContactImpulse,j=e.Dynamics.b2ContactListener,F=e.Dynamics.b2ContactManager,I=e.Dynamics.b2DebugDraw,q=e.Dynamics.b2DestructionListener,R=e.Dynamics.b2FilterData,U=e.Dynamics.b2Fixture,z=e.Dynamics.b2FixtureDef,W=e.Dynamics.b2Island,X=e.Dynamics.b2TimeStep,V=e.Dynamics.b2World;e.inherit(c,e.Dynamics.Joints.b2Joint),c.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,c.b2DistanceJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_localAnchor1=new f,this.m_localAnchor2=new f,this.m_u=new f},c.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)},c.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)},c.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_impulse*this.m_u.x,e*this.m_impulse*this.m_u.y)},c.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),0},c.prototype.GetLength=function(){return this.m_length},c.prototype.SetLength=function(e){e===undefined&&(e=0),this.m_length=e},c.prototype.GetFrequency=function(){return this.m_frequencyHz},c.prototype.SetFrequency=function(e){e===undefined&&(e=0),this.m_frequencyHz=e},c.prototype.GetDampingRatio=function(){return this.m_dampingRatio},c.prototype.SetDampingRatio=function(e){e===undefined&&(e=0),this.m_dampingRatio=e},c.prototype.b2DistanceJoint=function(e){this.__super.b2Joint.call(this,e);var t,n=0,r=0;this.m_localAnchor1.SetV(e.localAnchorA),this.m_localAnchor2.SetV(e.localAnchorB),this.m_length=e.length,this.m_frequencyHz=e.frequencyHz,this.m_dampingRatio=e.dampingRatio,this.m_impulse=0,this.m_gamma=0,this.m_bias=0},c.prototype.InitVelocityConstraints=function(e){var t,n=0,i=this.m_bodyA,s=this.m_bodyB;t=i.m_xf.R;var o=this.m_localAnchor1.x-i.m_sweep.localCenter.x,u=this.m_localAnchor1.y-i.m_sweep.localCenter.y;n=t.col1.x*o+t.col2.x*u,u=t.col1.y*o+t.col2.y*u,o=n,t=s.m_xf.R;var a=this.m_localAnchor2.x-s.m_sweep.localCenter.x,f=this.m_localAnchor2.y-s.m_sweep.localCenter.y;n=t.col1.x*a+t.col2.x*f,f=t.col1.y*a+t.col2.y*f,a=n,this.m_u.x=s.m_sweep.c.x+a-i.m_sweep.c.x-o,this.m_u.y=s.m_sweep.c.y+f-i.m_sweep.c.y-u;var l=Math.sqrt(this.m_u.x*this.m_u.x+this.m_u.y*this.m_u.y);l>r.b2_linearSlop?this.m_u.Multiply(1/l):this.m_u.SetZero();var c=o*this.m_u.y-u*this.m_u.x,h=a*this.m_u.y-f*this.m_u.x,p=i.m_invMass+i.m_invI*c*c+s.m_invMass+s.m_invI*h*h;this.m_mass=p!=0?1/p:0;if(this.m_frequencyHz>0){var d=l-this.m_length,v=2*Math.PI*this.m_frequencyHz,m=2*this.m_mass*this.m_dampingRatio*v,g=this.m_mass*v*v;this.m_gamma=e.dt*(m+e.dt*g),this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0,this.m_bias=d*e.dt*g*this.m_gamma,this.m_mass=p+this.m_gamma,this.m_mass=this.m_mass!=0?1/this.m_mass:0}if(e.warmStarting){this.m_impulse*=e.dtRatio;var y=this.m_impulse*this.m_u.x,b=this.m_impulse*this.m_u.y;i.m_linearVelocity.x-=i.m_invMass*y,i.m_linearVelocity.y-=i.m_invMass*b,i.m_angularVelocity-=i.m_invI*(o*b-u*y),s.m_linearVelocity.x+=s.m_invMass*y,s.m_linearVelocity.y+=s.m_invMass*b,s.m_angularVelocity+=s.m_invI*(a*b-f*y)}else this.m_impulse=0},c.prototype.SolveVelocityConstraints=function(e){var t,n=this.m_bodyA,r=this.m_bodyB;t=n.m_xf.R;var i=this.m_localAnchor1.x-n.m_sweep.localCenter.x,s=this.m_localAnchor1.y-n.m_sweep.localCenter.y,o=t.col1.x*i+t.col2.x*s;s=t.col1.y*i+t.col2.y*s,i=o,t=r.m_xf.R;var u=this.m_localAnchor2.x-r.m_sweep.localCenter.x,a=this.m_localAnchor2.y-r.m_sweep.localCenter.y;o=t.col1.x*u+t.col2.x*a,a=t.col1.y*u+t.col2.y*a,u=o;var f=n.m_linearVelocity.x+ -n.m_angularVelocity*s,l=n.m_linearVelocity.y+n.m_angularVelocity*i,c=r.m_linearVelocity.x+ -r.m_angularVelocity*a,h=r.m_linearVelocity.y+r.m_angularVelocity*u,p=this.m_u.x*(c-f)+this.m_u.y*(h-l),d=-this.m_mass*(p+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=d;var v=d*this.m_u.x,m=d*this.m_u.y;n.m_linearVelocity.x-=n.m_invMass*v,n.m_linearVelocity.y-=n.m_invMass*m,n.m_angularVelocity-=n.m_invI*(i*m-s*v),r.m_linearVelocity.x+=r.m_invMass*v,r.m_linearVelocity.y+=r.m_invMass*m,r.m_angularVelocity+=r.m_invI*(u*m-a*v)},c.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t;if(this.m_frequencyHz>0)return!0;var n=this.m_bodyA,i=this.m_bodyB;t=n.m_xf.R;var s=this.m_localAnchor1.x-n.m_sweep.localCenter.x,u=this.m_localAnchor1.y-n.m_sweep.localCenter.y,a=t.col1.x*s+t.col2.x*u;u=t.col1.y*s+t.col2.y*u,s=a,t=i.m_xf.R;var f=this.m_localAnchor2.x-i.m_sweep.localCenter.x,l=this.m_localAnchor2.y-i.m_sweep.localCenter.y;a=t.col1.x*f+t.col2.x*l,l=t.col1.y*f+t.col2.y*l,f=a;var c=i.m_sweep.c.x+f-n.m_sweep.c.x-s,h=i.m_sweep.c.y+l-n.m_sweep.c.y-u,p=Math.sqrt(c*c+h*h);c/=p,h/=p;var d=p-this.m_length;d=o.Clamp(d,-r.b2_maxLinearCorrection,r.b2_maxLinearCorrection);var v=-this.m_mass*d;this.m_u.Set(c,h);var m=v*this.m_u.x,g=v*this.m_u.y;return n.m_sweep.c.x-=n.m_invMass*m,n.m_sweep.c.y-=n.m_invMass*g,n.m_sweep.a-=n.m_invI*(s*g-u*m),i.m_sweep.c.x+=i.m_invMass*m,i.m_sweep.c.y+=i.m_invMass*g,i.m_sweep.a+=i.m_invI*(f*g-l*m),n.SynchronizeTransform(),i.SynchronizeTransform(),o.Abs(d)0&&(this.m_angularMass=1/this.m_angularMass);if(e.warmStarting){this.m_linearImpulse.x*=e.dtRatio,this.m_linearImpulse.y*=e.dtRatio,this.m_angularImpulse*=e.dtRatio;var v=this.m_linearImpulse;r.m_linearVelocity.x-=l*v.x,r.m_linearVelocity.y-=l*v.y,r.m_angularVelocity-=h*(o*v.y-u*v.x+this.m_angularImpulse),s.m_linearVelocity.x+=c*v.x,s.m_linearVelocity.y+=c*v.y,s.m_angularVelocity+=p*(a*v.y-f*v.x+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0},p.prototype.SolveVelocityConstraints=function(e){var t,n=0,r=this.m_bodyA,i=this.m_bodyB,s=r.m_linearVelocity,u=r.m_angularVelocity,a=i.m_linearVelocity,l=i.m_angularVelocity,c=r.m_invMass,h=i.m_invMass,p=r.m_invI,d=i.m_invI;t=r.m_xf.R;var v=this.m_localAnchorA.x-r.m_sweep.localCenter.x,m=this.m_localAnchorA.y-r.m_sweep.localCenter.y;n=t.col1.x*v+t.col2.x*m,m=t.col1.y*v+t.col2.y*m,v=n,t=i.m_xf.R;var g=this.m_localAnchorB.x-i.m_sweep.localCenter.x,y=this.m_localAnchorB.y-i.m_sweep.localCenter.y;n=t.col1.x*g+t.col2.x*y,y=t.col1.y*g+t.col2.y*y,g=n;var b=0,w=l-u,E=-this.m_angularMass*w,S=this.m_angularImpulse;b=e.dt*this.m_maxTorque,this.m_angularImpulse=o.Clamp(this.m_angularImpulse+E,-b,b),E=this.m_angularImpulse-S,u-=p*E,l+=d*E;var x=a.x-l*y-s.x+u*m,T=a.y+l*g-s.y-u*v,N=o.MulMV(this.m_linearMass,new f(-x,-T)),C=this.m_linearImpulse.Copy();this.m_linearImpulse.Add(N),b=e.dt*this.m_maxForce,this.m_linearImpulse.LengthSquared()>b*b&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.Multiply(b)),N=o.SubtractVV(this.m_linearImpulse,C),s.x-=c*N.x,s.y-=c*N.y,u-=p*(v*N.y-m*N.x),a.x+=h*N.x,a.y+=h*N.y,l+=d*(g*N.y-y*N.x),r.m_angularVelocity=u,i.m_angularVelocity=l},p.prototype.SolvePositionConstraints=function(e){return e===undefined&&(e=0),!0},e.inherit(d,e.Dynamics.Joints.b2JointDef),d.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,d.b2FrictionJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.localAnchorA=new f,this.localAnchorB=new f},d.prototype.b2FrictionJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_frictionJoint,this.maxForce=0,this.maxTorque=0},d.prototype.Initialize=function(e,t,n){this.bodyA=e,this.bodyB=t,this.localAnchorA.SetV(this.bodyA.GetLocalPoint(n)),this.localAnchorB.SetV(this.bodyB.GetLocalPoint(n))},e.inherit(v,e.Dynamics.Joints.b2Joint),v.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,v.b2GearJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_groundAnchor1=new f,this.m_groundAnchor2=new f,this.m_localAnchor1=new f,this.m_localAnchor2=new f,this.m_J=new g},v.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)},v.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)},v.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_impulse*this.m_J.linearB.x,e*this.m_impulse*this.m_J.linearB.y)},v.prototype.GetReactionTorque=function(e){e===undefined&&(e=0);var t=this.m_bodyB.m_xf.R,n=this.m_localAnchor1.x-this.m_bodyB.m_sweep.localCenter.x,r=this.m_localAnchor1.y-this.m_bodyB.m_sweep.localCenter.y,i=t.col1.x*n+t.col2.x*r;r=t.col1.y*n+t.col2.y*r,n=i;var s=this.m_impulse*this.m_J.linearB.x,o=this.m_impulse*this.m_J.linearB.y;return e*(this.m_impulse*this.m_J.angularB-n*o+r*s)},v.prototype.GetRatio=function(){return this.m_ratio},v.prototype.SetRatio=function(e){e===undefined&&(e=0),this.m_ratio=e},v.prototype.b2GearJoint=function(e){this.__super.b2Joint.call(this,e);var t=parseInt(e.joint1.m_type),n=parseInt(e.joint2.m_type);this.m_revolute1=null,this.m_prismatic1=null,this.m_revolute2=null,this.m_prismatic2=null;var r=0,i=0;this.m_ground1=e.joint1.GetBodyA(),this.m_bodyA=e.joint1.GetBodyB(),t==y.e_revoluteJoint?(this.m_revolute1=e.joint1 instanceof A?e.joint1:null,this.m_groundAnchor1.SetV(this.m_revolute1.m_localAnchor1),this.m_localAnchor1.SetV(this.m_revolute1.m_localAnchor2),r=this.m_revolute1.GetJointAngle()):(this.m_prismatic1=e.joint1 instanceof N?e.joint1:null,this.m_groundAnchor1.SetV(this.m_prismatic1.m_localAnchor1),this.m_localAnchor1.SetV(this.m_prismatic1.m_localAnchor2),r=this.m_prismatic1.GetJointTranslation()),this.m_ground2=e.joint2.GetBodyA(),this.m_bodyB=e.joint2.GetBodyB(),n==y.e_revoluteJoint?(this.m_revolute2=e.joint2 instanceof A?e.joint2:null,this.m_groundAnchor2.SetV(this.m_revolute2.m_localAnchor1),this.m_localAnchor2.SetV(this.m_revolute2.m_localAnchor2),i=this.m_revolute2.GetJointAngle()):(this.m_prismatic2=e.joint2 instanceof N?e.joint2:null,this.m_groundAnchor2.SetV(this.m_prismatic2.m_localAnchor1),this.m_localAnchor2.SetV(this.m_prismatic2.m_localAnchor2),i=this.m_prismatic2.GetJointTranslation()),this.m_ratio=e.ratio,this.m_constant=r+this.m_ratio*i,this.m_impulse=0},v.prototype.InitVelocityConstraints=function(e){var t=this.m_ground1,n=this.m_ground2,r=this.m_bodyA,i=this.m_bodyB,s=0,o=0,u=0,a=0,f,l,c=0,h=0,p=0;this.m_J.SetZero(),this.m_revolute1?(this.m_J.angularA=-1,p+=r.m_invI):(f=t.m_xf.R,l=this.m_prismatic1.m_localXAxis1,s=f.col1.x*l.x+f.col2.x*l.y,o=f.col1.y*l.x+f.col2.y*l.y,f=r.m_xf.R,u=this.m_localAnchor1.x-r.m_sweep.localCenter.x,a=this.m_localAnchor1.y-r.m_sweep.localCenter.y,h=f.col1.x*u+f.col2.x*a,a=f.col1.y*u+f.col2.y*a,u=h,c=u*o-a*s,this.m_J.linearA.Set(-s,-o),this.m_J.angularA=-c,p+=r.m_invMass+r.m_invI*c*c),this.m_revolute2?(this.m_J.angularB=-this.m_ratio,p+=this.m_ratio*this.m_ratio*i.m_invI):(f=n.m_xf.R,l=this.m_prismatic2.m_localXAxis1,s=f.col1.x*l.x+f.col2.x*l.y,o=f.col1.y*l.x+f.col2.y*l.y,f=i.m_xf.R,u=this.m_localAnchor2.x-i.m_sweep.localCenter.x,a=this.m_localAnchor2.y-i.m_sweep.localCenter.y,h=f.col1.x*u+f.col2.x*a,a=f.col1.y*u+f.col2.y*a,u=h,c=u*o-a*s,this.m_J.linearB.Set(-this.m_ratio*s,-this.m_ratio*o),this.m_J.angularB=-this.m_ratio*c,p+=this.m_ratio*this.m_ratio*(i.m_invMass+i.m_invI*c*c)),this.m_mass=p>0?1/p:0,e.warmStarting?(r.m_linearVelocity.x+=r.m_invMass*this.m_impulse*this.m_J.linearA.x,r.m_linearVelocity.y+=r.m_invMass*this.m_impulse*this.m_J.linearA.y,r.m_angularVelocity+=r.m_invI*this.m_impulse*this.m_J.angularA,i.m_linearVelocity.x+=i.m_invMass*this.m_impulse*this.m_J.linearB.x,i.m_linearVelocity.y+=i.m_invMass*this.m_impulse*this.m_J.linearB.y,i.m_angularVelocity+=i.m_invI*this.m_impulse*this.m_J.angularB):this.m_impulse=0},v.prototype.SolveVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,r=this.m_J.Compute(t.m_linearVelocity,t.m_angularVelocity,n.m_linearVelocity,n.m_angularVelocity),i=-this.m_mass*r;this.m_impulse+=i,t.m_linearVelocity.x+=t.m_invMass*i*this.m_J.linearA.x,t.m_linearVelocity.y+=t.m_invMass*i*this.m_J.linearA.y,t.m_angularVelocity+=t.m_invI*i*this.m_J.angularA,n.m_linearVelocity.x+=n.m_invMass*i*this.m_J.linearB.x,n.m_linearVelocity.y+=n.m_invMass*i*this.m_J.linearB.y,n.m_angularVelocity+=n.m_invI*i*this.m_J.angularB},v.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t=0,n=this.m_bodyA,i=this.m_bodyB,s=0,o=0;this.m_revolute1?s=this.m_revolute1.GetJointAngle():s=this.m_prismatic1.GetJointTranslation(),this.m_revolute2?o=this.m_revolute2.GetJointAngle():o=this.m_prismatic2.GetJointTranslation();var u=this.m_constant-(s+this.m_ratio*o),a=-this.m_mass*u;return n.m_sweep.c.x+=n.m_invMass*a*this.m_J.linearA.x,n.m_sweep.c.y+=n.m_invMass*a*this.m_J.linearA.y,n.m_sweep.a+=n.m_invI*a*this.m_J.angularA,i.m_sweep.c.x+=i.m_invMass*a*this.m_J.linearB.x,i.m_sweep.c.y+=i.m_invMass*a*this.m_J.linearB.y,i.m_sweep.a+=i.m_invI*a*this.m_J.angularB,n.SynchronizeTransform(),i.SynchronizeTransform(),tNumber.MIN_VALUE?1/this.m_motorMass:0,this.m_perp.SetV(o.MulMV(u.R,this.m_localYAxis1)),this.m_s1=(p+f)*this.m_perp.y-(d+l)*this.m_perp.x,this.m_s2=c*this.m_perp.y-h*this.m_perp.x;var v=this.m_invMassA,m=this.m_invMassB,g=this.m_invIA,b=this.m_invIB;this.m_K.col1.x=v+m+g*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,this.m_K.col1.y=g*this.m_s1*this.m_a1+b*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=v+m+g*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2;if(this.m_enableLimit){var w=this.m_axis.x*p+this.m_axis.y*d;o.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*r.b2_linearSlop?this.m_limitState=y.e_equalLimits:w<=this.m_lowerTranslation?this.m_limitState!=y.e_atLowerLimit&&(this.m_limitState=y.e_atLowerLimit,this.m_impulse.y=0):w>=this.m_upperTranslation?this.m_limitState!=y.e_atUpperLimit&&(this.m_limitState=y.e_atUpperLimit,this.m_impulse.y=0):(this.m_limitState=y.e_inactiveLimit,this.m_impulse.y=0)}else this.m_limitState=y.e_inactiveLimit;this.m_enableMotor==0&&(this.m_motorImpulse=0);if(e.warmStarting){this.m_impulse.x*=e.dtRatio,this.m_impulse.y*=e.dtRatio,this.m_motorImpulse*=e.dtRatio;var E=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.x,S=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y,x=this.m_impulse.x*this.m_s1+(this.m_motorImpulse+this.m_impulse.y)*this.m_a1,T=this.m_impulse.x*this.m_s2+(this.m_motorImpulse+this.m_impulse.y)*this.m_a2;t.m_linearVelocity.x-=this.m_invMassA*E,t.m_linearVelocity.y-=this.m_invMassA*S,t.m_angularVelocity-=this.m_invIA*x,n.m_linearVelocity.x+=this.m_invMassB*E,n.m_linearVelocity.y+=this.m_invMassB*S,n.m_angularVelocity+=this.m_invIB*T}else this.m_impulse.SetZero(),this.m_motorImpulse=0},E.prototype.SolveVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,r=t.m_linearVelocity,i=t.m_angularVelocity,s=n.m_linearVelocity,u=n.m_angularVelocity,a=0,l=0,c=0,h=0;if(this.m_enableMotor&&this.m_limitState!=y.e_equalLimits){var p=this.m_axis.x*(s.x-r.x)+this.m_axis.y*(s.y-r.y)+this.m_a2*u-this.m_a1*i,d=this.m_motorMass*(this.m_motorSpeed-p),v=this.m_motorImpulse,m=e.dt*this.m_maxMotorForce;this.m_motorImpulse=o.Clamp(this.m_motorImpulse+d,-m,m),d=this.m_motorImpulse-v,a=d*this.m_axis.x,l=d*this.m_axis.y,c=d*this.m_a1,h=d*this.m_a2,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*l,i-=this.m_invIA*c,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*l,u+=this.m_invIB*h}var g=this.m_perp.x*(s.x-r.x)+this.m_perp.y*(s.y-r.y)+this.m_s2*u-this.m_s1*i;if(this.m_enableLimit&&this.m_limitState!=y.e_inactiveLimit){var b=this.m_axis.x*(s.x-r.x)+this.m_axis.y*(s.y-r.y)+this.m_a2*u-this.m_a1*i,w=this.m_impulse.Copy(),E=this.m_K.Solve(new f,-g,-b);this.m_impulse.Add(E),this.m_limitState==y.e_atLowerLimit?this.m_impulse.y=o.Max(this.m_impulse.y,0):this.m_limitState==y.e_atUpperLimit&&(this.m_impulse.y=o.Min(this.m_impulse.y,0));var S=-g-(this.m_impulse.y-w.y)*this.m_K.col2.x,x=0;this.m_K.col1.x!=0?x=S/this.m_K.col1.x+w.x:x=w.x,this.m_impulse.x=x,E.x=this.m_impulse.x-w.x,E.y=this.m_impulse.y-w.y,a=E.x*this.m_perp.x+E.y*this.m_axis.x,l=E.x*this.m_perp.y+E.y*this.m_axis.y,c=E.x*this.m_s1+E.y*this.m_a1,h=E.x*this.m_s2+E.y*this.m_a2,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*l,i-=this.m_invIA*c,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*l,u+=this.m_invIB*h}else{var T=0;this.m_K.col1.x!=0?T=-g/this.m_K.col1.x:T=0,this.m_impulse.x+=T,a=T*this.m_perp.x,l=T*this.m_perp.y,c=T*this.m_s1,h=T*this.m_s2,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*l,i-=this.m_invIA*c,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*l,u+=this.m_invIB*h}t.m_linearVelocity.SetV(r),t.m_angularVelocity=i,n.m_linearVelocity.SetV(s),n.m_angularVelocity=u},E.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t=0,n=0,s=this.m_bodyA,u=this.m_bodyB,a=s.m_sweep.c,l=s.m_sweep.a,c=u.m_sweep.c,h=u.m_sweep.a,p,d=0,v=0,m=0,g=0,y=0,b=0,w=0,E=!1,S=0,x=i.FromAngle(l),T=i.FromAngle(h);p=x;var N=this.m_localAnchor1.x-this.m_localCenterA.x,C=this.m_localAnchor1.y-this.m_localCenterA.y;d=p.col1.x*N+p.col2.x*C,C=p.col1.y*N+p.col2.y*C,N=d,p=T;var k=this.m_localAnchor2.x-this.m_localCenterB.x,L=this.m_localAnchor2.y-this.m_localCenterB.y;d=p.col1.x*k+p.col2.x*L,L=p.col1.y*k+p.col2.y*L,k=d;var A=c.x+k-a.x-N,O=c.y+L-a.y-C;if(this.m_enableLimit){this.m_axis=o.MulMV(x,this.m_localXAxis1),this.m_a1=(A+N)*this.m_axis.y-(O+C)*this.m_axis.x,this.m_a2=k*this.m_axis.y-L*this.m_axis.x;var M=this.m_axis.x*A+this.m_axis.y*O;o.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*r.b2_linearSlop?(S=o.Clamp(M,-r.b2_maxLinearCorrection,r.b2_maxLinearCorrection),b=o.Abs(M),E=!0):M<=this.m_lowerTranslation?(S=o.Clamp(M-this.m_lowerTranslation+r.b2_linearSlop,-r.b2_maxLinearCorrection,0),b=this.m_lowerTranslation-M,E=!0):M>=this.m_upperTranslation&&(S=o.Clamp(M-this.m_upperTranslation+r.b2_linearSlop,0,r.b2_maxLinearCorrection),b=M-this.m_upperTranslation,E=!0)}this.m_perp=o.MulMV(x,this.m_localYAxis1),this.m_s1=(A+N)*this.m_perp.y-(O+C)*this.m_perp.x,this.m_s2=k*this.m_perp.y-L*this.m_perp.x;var _=new f,D=this.m_perp.x*A+this.m_perp.y*O;b=o.Max(b,o.Abs(D)),w=0;if(E)v=this.m_invMassA,m=this.m_invMassB,g=this.m_invIA,y=this.m_invIB,this.m_K.col1.x=v+m+g*this.m_s1*this.m_s1+y*this.m_s2*this.m_s2,this.m_K.col1.y=g*this.m_s1*this.m_a1+y*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=v+m+g*this.m_a1*this.m_a1+y*this.m_a2*this.m_a2,this.m_K.Solve(_,-D,-S);else{v=this.m_invMassA,m=this.m_invMassB,g=this.m_invIA,y=this.m_invIB;var P=v+m+g*this.m_s1*this.m_s1+y*this.m_s2*this.m_s2,H=0;P!=0?H=-D/P:H=0,_.x=H,_.y=0}var B=_.x*this.m_perp.x+_.y*this.m_axis.x,j=_.x*this.m_perp.y+_.y*this.m_axis.y,F=_.x*this.m_s1+_.y*this.m_a1,I=_.x*this.m_s2+_.y*this.m_a2;return a.x-=this.m_invMassA*B,a.y-=this.m_invMassA*j,l-=this.m_invIA*F,c.x+=this.m_invMassB*B,c.y+=this.m_invMassB*j,h+=this.m_invIB*I,s.m_sweep.a=l,u.m_sweep.a=h,s.SynchronizeTransform(),u.SynchronizeTransform(),b<=r.b2_linearSlop&&w<=r.b2_angularSlop},e.inherit(S,e.Dynamics.Joints.b2JointDef),S.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,S.b2LineJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.localAnchorA=new f,this.localAnchorB=new f,this.localAxisA=new f},S.prototype.b2LineJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_lineJoint,this.localAxisA.Set(1,0),this.enableLimit=!1,this.lowerTranslation=0,this.upperTranslation=0,this.enableMotor=!1,this.maxMotorForce=0,this.motorSpeed=0},S.prototype.Initialize=function(e,t,n,r){this.bodyA=e,this.bodyB=t,this.localAnchorA=this.bodyA.GetLocalPoint(n),this.localAnchorB=this.bodyB.GetLocalPoint(n),this.localAxisA=this.bodyA.GetLocalVector(r)},e.inherit(x,e.Dynamics.Joints.b2Joint),x.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,x.b2MouseJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.K=new i,this.K1=new i,this.K2=new i,this.m_localAnchor=new f,this.m_target=new f,this.m_impulse=new f,this.m_mass=new i,this.m_C=new f},x.prototype.GetAnchorA=function(){return this.m_target},x.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor)},x.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_impulse.x,e*this.m_impulse.y)},x.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),0},x.prototype.GetTarget=function(){return this.m_target},x.prototype.SetTarget=function(e){this.m_bodyB.IsAwake()==0&&this.m_bodyB.SetAwake(!0),this.m_target=e},x.prototype.GetMaxForce=function(){return this.m_maxForce},x.prototype.SetMaxForce=function(e){e===undefined&&(e=0),this.m_maxForce=e},x.prototype.GetFrequency=function(){return this.m_frequencyHz},x.prototype.SetFrequency=function(e){e===undefined&&(e=0),this.m_frequencyHz=e},x.prototype.GetDampingRatio=function(){return this.m_dampingRatio},x.prototype.SetDampingRatio=function(e){e===undefined&&(e=0),this.m_dampingRatio=e},x.prototype.b2MouseJoint=function(e){this.__super.b2Joint.call(this,e),this.m_target.SetV(e.target);var t=this.m_target.x-this.m_bodyB.m_xf.position.x,n=this.m_target.y-this.m_bodyB.m_xf.position.y,r=this.m_bodyB.m_xf.R;this.m_localAnchor.x=t*r.col1.x+n*r.col1.y,this.m_localAnchor.y=t*r.col2.x+n*r.col2.y,this.m_maxForce=e.maxForce,this.m_impulse.SetZero(),this.m_frequencyHz=e.frequencyHz,this.m_dampingRatio=e.dampingRatio,this.m_beta=0,this.m_gamma=0},x.prototype.InitVelocityConstraints=function(e){var t=this.m_bodyB,n=t.GetMass(),r=2*Math.PI*this.m_frequencyHz,i=2*n*this.m_dampingRatio*r,s=n*r*r;this.m_gamma=e.dt*(i+e.dt*s),this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0,this.m_beta=e.dt*s*this.m_gamma;var o;o=t.m_xf.R;var u=this.m_localAnchor.x-t.m_sweep.localCenter.x,a=this.m_localAnchor.y-t.m_sweep.localCenter.y,f=o.col1.x*u+o.col2.x*a;a=o.col1.y*u+o.col2.y*a,u=f;var l=t.m_invMass,c=t.m_invI;this.K1.col1.x=l,this.K1.col2.x=0,this.K1.col1.y=0,this.K1.col2.y=l,this.K2.col1.x=c*a*a,this.K2.col2.x=-c*u*a,this.K2.col1.y=-c*u*a,this.K2.col2.y=c*u*u,this.K.SetM(this.K1),this.K.AddM(this.K2),this.K.col1.x+=this.m_gamma,this.K.col2.y+=this.m_gamma,this.K.GetInverse(this.m_mass),this.m_C.x=t.m_sweep.c.x+u-this.m_target.x,this.m_C.y=t.m_sweep.c.y+a-this.m_target.y,t.m_angularVelocity*=.98,this.m_impulse.x*=e.dtRatio,this.m_impulse.y*=e.dtRatio,t.m_linearVelocity.x+=l*this.m_impulse.x,t.m_linearVelocity.y+=l*this.m_impulse.y,t.m_angularVelocity+=c*(u*this.m_impulse.y-a*this.m_impulse.x)},x.prototype.SolveVelocityConstraints=function(e){var t=this.m_bodyB,n,r=0,i=0;n=t.m_xf.R;var s=this.m_localAnchor.x-t.m_sweep.localCenter.x,o=this.m_localAnchor.y-t.m_sweep.localCenter.y;r=n.col1.x*s+n.col2.x*o,o=n.col1.y*s+n.col2.y*o,s=r;var u=t.m_linearVelocity.x+ -t.m_angularVelocity*o,a=t.m_linearVelocity.y+t.m_angularVelocity*s;n=this.m_mass,r=u+this.m_beta*this.m_C.x+this.m_gamma*this.m_impulse.x,i=a+this.m_beta*this.m_C.y+this.m_gamma*this.m_impulse.y;var f=-(n.col1.x*r+n.col2.x*i),l=-(n.col1.y*r+n.col2.y*i),c=this.m_impulse.x,h=this.m_impulse.y;this.m_impulse.x+=f,this.m_impulse.y+=l;var p=e.dt*this.m_maxForce;this.m_impulse.LengthSquared()>p*p&&this.m_impulse.Multiply(p/this.m_impulse.Length()),f=this.m_impulse.x-c,l=this.m_impulse.y-h,t.m_linearVelocity.x+=t.m_invMass*f,t.m_linearVelocity.y+=t.m_invMass*l,t.m_angularVelocity+=t.m_invI*(s*l-o*f)},x.prototype.SolvePositionConstraints=function(e){return e===undefined&&(e=0),!0},e.inherit(T,e.Dynamics.Joints.b2JointDef),T.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,T.b2MouseJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.target=new f},T.prototype.b2MouseJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_mouseJoint,this.maxForce=0,this.frequencyHz=5,this.dampingRatio=.7},e.inherit(N,e.Dynamics.Joints.b2Joint),N.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,N.b2PrismaticJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_localAnchor1=new f,this.m_localAnchor2=new f,this.m_localXAxis1=new f,this.m_localYAxis1=new f,this.m_axis=new f,this.m_perp=new f,this.m_K=new s,this.m_impulse=new l},N.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)},N.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)},N.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),e*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y))},N.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),e*this.m_impulse.y},N.prototype.GetJointTranslation=function(){var e=this.m_bodyA,t=this.m_bodyB,n,r=e.GetWorldPoint(this.m_localAnchor1),i=t.GetWorldPoint(this.m_localAnchor2),s=i.x-r.x,o=i.y-r.y,u=e.GetWorldVector(this.m_localXAxis1),a=u.x*s+u.y*o;return a},N.prototype.GetJointSpeed=function(){var e=this.m_bodyA,t=this.m_bodyB,n;n=e.m_xf.R;var r=this.m_localAnchor1.x-e.m_sweep.localCenter.x,i=this.m_localAnchor1.y-e.m_sweep.localCenter.y,s=n.col1.x*r+n.col2.x*i;i=n.col1.y*r+n.col2.y*i,r=s,n=t.m_xf.R;var o=this.m_localAnchor2.x-t.m_sweep.localCenter.x,u=this.m_localAnchor2.y-t.m_sweep.localCenter.y;s=n.col1.x*o+n.col2.x*u,u=n.col1.y*o+n.col2.y*u,o=s;var a=e.m_sweep.c.x+r,f=e.m_sweep.c.y+i,l=t.m_sweep.c.x+o,c=t.m_sweep.c.y+u,h=l-a,p=c-f,d=e.GetWorldVector(this.m_localXAxis1),v=e.m_linearVelocity,m=t.m_linearVelocity,g=e.m_angularVelocity,y=t.m_angularVelocity,b=h*-g*d.y+p*g*d.x+(d.x*(m.x+ -y*u-v.x- -g*i)+d.y*(m.y+y*o-v.y-g*r));return b},N.prototype.IsLimitEnabled=function(){return this.m_enableLimit},N.prototype.EnableLimit=function(e){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=e},N.prototype.GetLowerLimit=function(){return this.m_lowerTranslation},N.prototype.GetUpperLimit=function(){return this.m_upperTranslation},N.prototype.SetLimits=function(e,t){e===undefined&&(e=0),t===undefined&&(t=0),this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_lowerTranslation=e,this.m_upperTranslation=t},N.prototype.IsMotorEnabled=function(){return this.m_enableMotor},N.prototype.EnableMotor=function(e){this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=e},N.prototype.SetMotorSpeed=function(e){e===undefined&&(e=0),this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=e},N.prototype.GetMotorSpeed=function(){return this.m_motorSpeed},N.prototype.SetMaxMotorForce=function(e){e===undefined&&(e=0),this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorForce=e},N.prototype.GetMotorForce=function(){return this.m_motorImpulse},N.prototype.b2PrismaticJoint=function(e){this.__super.b2Joint.call(this,e);var t,n=0,r=0;this.m_localAnchor1.SetV(e.localAnchorA),this.m_localAnchor2.SetV(e.localAnchorB),this.m_localXAxis1.SetV(e.localAxisA),this.m_localYAxis1.x=-this.m_localXAxis1.y,this.m_localYAxis1.y=this.m_localXAxis1.x,this.m_refAngle=e.referenceAngle,this.m_impulse.SetZero(),this.m_motorMass=0,this.m_motorImpulse=0,this.m_lowerTranslation=e.lowerTranslation,this.m_upperTranslation=e.upperTranslation,this.m_maxMotorForce=e.maxMotorForce,this.m_motorSpeed=e.motorSpeed,this.m_enableLimit=e.enableLimit,this.m_enableMotor=e.enableMotor,this.m_limitState=y.e_inactiveLimit,this.m_axis.SetZero(),this.m_perp.SetZero()},N.prototype.InitVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,i,s=0;this.m_localCenterA.SetV(t.GetLocalCenter()),this.m_localCenterB.SetV(n.GetLocalCenter());var u=t.GetTransform(),a=n.GetTransform();i=t.m_xf.R;var f=this.m_localAnchor1.x-this.m_localCenterA.x,l=this.m_localAnchor1.y-this.m_localCenterA.y;s=i.col1.x*f+i.col2.x*l,l=i.col1.y*f+i.col2.y*l,f=s,i=n.m_xf.R;var c=this.m_localAnchor2.x-this.m_localCenterB.x,h=this.m_localAnchor2.y-this.m_localCenterB.y;s=i.col1.x*c+i.col2.x*h,h=i.col1.y*c+i.col2.y*h,c=s;var p=n.m_sweep.c.x+c-t.m_sweep.c.x-f,d=n.m_sweep.c.y+h-t.m_sweep.c.y-l;this.m_invMassA=t.m_invMass,this.m_invMassB=n.m_invMass,this.m_invIA=t.m_invI,this.m_invIB=n.m_invI,this.m_axis.SetV(o.MulMV(u.R,this.m_localXAxis1)),this.m_a1=(p+f)*this.m_axis.y-(d+l)*this.m_axis.x,this.m_a2=c*this.m_axis.y-h*this.m_axis.x,this.m_motorMass=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_a1*this.m_a1+this.m_invIB*this.m_a2*this.m_a2,this.m_motorMass>Number.MIN_VALUE&&(this.m_motorMass=1/this.m_motorMass),this.m_perp.SetV(o.MulMV(u.R,this.m_localYAxis1)),this.m_s1=(p+f)*this.m_perp.y-(d+l)*this.m_perp.x,this.m_s2=c*this.m_perp.y-h*this.m_perp.x;var v=this.m_invMassA,m=this.m_invMassB,g=this.m_invIA,b=this.m_invIB;this.m_K.col1.x=v+m+g*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,this.m_K.col1.y=g*this.m_s1+b*this.m_s2,this.m_K.col1.z=g*this.m_s1*this.m_a1+b*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=g+b,this.m_K.col2.z=g*this.m_a1+b*this.m_a2,this.m_K.col3.x=this.m_K.col1.z,this.m_K.col3.y=this.m_K.col2.z,this.m_K.col3.z=v+m+g*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2;if(this.m_enableLimit){var w=this.m_axis.x*p+this.m_axis.y*d;o.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*r.b2_linearSlop?this.m_limitState=y.e_equalLimits:w<=this.m_lowerTranslation?this.m_limitState!=y.e_atLowerLimit&&(this.m_limitState=y.e_atLowerLimit,this.m_impulse.z=0):w>=this.m_upperTranslation?this.m_limitState!=y.e_atUpperLimit&&(this.m_limitState=y.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=y.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=y.e_inactiveLimit;this.m_enableMotor==0&&(this.m_motorImpulse=0);if(e.warmStarting){this.m_impulse.x*=e.dtRatio,this.m_impulse.y*=e.dtRatio,this.m_motorImpulse*=e.dtRatio;var E=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x,S=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y,x=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,T=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;t.m_linearVelocity.x-=this.m_invMassA*E,t.m_linearVelocity.y-=this.m_invMassA*S,t.m_angularVelocity-=this.m_invIA*x,n.m_linearVelocity.x+=this.m_invMassB*E,n.m_linearVelocity.y+=this.m_invMassB*S,n.m_angularVelocity+=this.m_invIB*T}else this.m_impulse.SetZero(),this.m_motorImpulse=0},N.prototype.SolveVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,r=t.m_linearVelocity,i=t.m_angularVelocity,s=n.m_linearVelocity,u=n.m_angularVelocity,a=0,c=0,h=0,p=0;if(this.m_enableMotor&&this.m_limitState!=y.e_equalLimits){var d=this.m_axis.x*(s.x-r.x)+this.m_axis.y*(s.y-r.y)+this.m_a2*u-this.m_a1*i,v=this.m_motorMass*(this.m_motorSpeed-d),m=this.m_motorImpulse,g=e.dt*this.m_maxMotorForce;this.m_motorImpulse=o.Clamp(this.m_motorImpulse+v,-g,g),v=this.m_motorImpulse-m,a=v*this.m_axis.x,c=v*this.m_axis.y,h=v*this.m_a1,p=v*this.m_a2,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*c,i-=this.m_invIA*h,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*c,u+=this.m_invIB*p}var b=this.m_perp.x*(s.x-r.x)+this.m_perp.y*(s.y-r.y)+this.m_s2*u-this.m_s1*i,w=u-i;if(this.m_enableLimit&&this.m_limitState!=y.e_inactiveLimit){var E=this.m_axis.x*(s.x-r.x)+this.m_axis.y*(s.y-r.y)+this.m_a2*u-this.m_a1*i,S=this.m_impulse.Copy(),x=this.m_K.Solve33(new l,-b,-w,-E);this.m_impulse.Add(x),this.m_limitState==y.e_atLowerLimit?this.m_impulse.z=o.Max(this.m_impulse.z,0):this.m_limitState==y.e_atUpperLimit&&(this.m_impulse.z=o.Min(this.m_impulse.z,0));var T=-b-(this.m_impulse.z-S.z)*this.m_K.col3.x,N=-w-(this.m_impulse.z-S.z)*this.m_K.col3.y,C=this.m_K.Solve22(new f,T,N);C.x+=S.x,C.y+=S.y,this.m_impulse.x=C.x,this.m_impulse.y=C.y,x.x=this.m_impulse.x-S.x,x.y=this.m_impulse.y-S.y,x.z=this.m_impulse.z-S.z,a=x.x*this.m_perp.x+x.z*this.m_axis.x,c=x.x*this.m_perp.y+x.z*this.m_axis.y,h=x.x*this.m_s1+x.y+x.z*this.m_a1,p=x.x*this.m_s2+x.y+x.z*this.m_a2,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*c,i-=this.m_invIA*h,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*c,u+=this.m_invIB*p}else{var k=this.m_K.Solve22(new f,-b,-w);this.m_impulse.x+=k.x,this.m_impulse.y+=k.y,a=k.x*this.m_perp.x,c=k.x*this.m_perp.y,h=k.x*this.m_s1+k.y,p=k.x*this.m_s2+k.y,r.x-=this.m_invMassA*a,r.y-=this.m_invMassA*c,i-=this.m_invIA*h,s.x+=this.m_invMassB*a,s.y+=this.m_invMassB*c,u+=this.m_invIB*p}t.m_linearVelocity.SetV(r),t.m_angularVelocity=i,n.m_linearVelocity.SetV(s),n.m_angularVelocity=u},N.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t=0,n=0,s=this.m_bodyA,u=this.m_bodyB,a=s.m_sweep.c,c=s.m_sweep.a,h=u.m_sweep.c,p=u.m_sweep.a,d,v=0,m=0,g=0,y=0,b=0,w=0,E=0,S=!1,x=0,T=i.FromAngle(c),N=i.FromAngle(p);d=T;var C=this.m_localAnchor1.x-this.m_localCenterA.x,k=this.m_localAnchor1.y-this.m_localCenterA.y;v=d.col1.x*C+d.col2.x*k,k=d.col1.y*C+d.col2.y*k,C=v,d=N;var L=this.m_localAnchor2.x-this.m_localCenterB.x,A=this.m_localAnchor2.y-this.m_localCenterB.y;v=d.col1.x*L+d.col2.x*A,A=d.col1.y*L+d.col2.y*A,L=v;var O=h.x+L-a.x-C,M=h.y+A-a.y-k;if(this.m_enableLimit){this.m_axis=o.MulMV(T,this.m_localXAxis1),this.m_a1=(O+C)*this.m_axis.y-(M+k)*this.m_axis.x,this.m_a2=L*this.m_axis.y-A*this.m_axis.x;var _=this.m_axis.x*O+this.m_axis.y*M;o.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*r.b2_linearSlop?(x=o.Clamp(_,-r.b2_maxLinearCorrection,r.b2_maxLinearCorrection),w=o.Abs(_),S=!0):_<=this.m_lowerTranslation?(x=o.Clamp(_-this.m_lowerTranslation+r.b2_linearSlop,-r.b2_maxLinearCorrection,0),w=this.m_lowerTranslation-_,S=!0):_>=this.m_upperTranslation&&(x=o.Clamp(_-this.m_upperTranslation+r.b2_linearSlop,0,r.b2_maxLinearCorrection),w=_-this.m_upperTranslation,S=!0)}this.m_perp=o.MulMV(T,this.m_localYAxis1),this.m_s1=(O+C)*this.m_perp.y-(M+k)*this.m_perp.x,this.m_s2=L*this.m_perp.y-A*this.m_perp.x;var D=new l,P=this.m_perp.x*O+this.m_perp.y*M,H=p-c-this.m_refAngle;w=o.Max(w,o.Abs(P)),E=o.Abs(H);if(S)m=this.m_invMassA,g=this.m_invMassB,y=this.m_invIA,b=this.m_invIB,this.m_K.col1.x=m+g+y*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,this.m_K.col1.y=y*this.m_s1+b*this.m_s2,this.m_K.col1.z=y*this.m_s1*this.m_a1+b*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=y+b,this.m_K.col2.z=y*this.m_a1+b*this.m_a2,this.m_K.col3.x=this.m_K.col1.z,this.m_K.col3.y=this.m_K.col2.z,this.m_K.col3.z=m+g+y*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2,this.m_K.Solve33(D,-P,-H,-x);else{m=this.m_invMassA,g=this.m_invMassB,y=this.m_invIA,b=this.m_invIB;var B=m+g+y*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,j=y*this.m_s1+b*this.m_s2,F=y+b;this.m_K.col1.Set(B,j,0),this.m_K.col2.Set(j,F,0);var I=this.m_K.Solve22(new f,-P,-H);D.x=I.x,D.y=I.y,D.z=0}var q=D.x*this.m_perp.x+D.z*this.m_axis.x,R=D.x*this.m_perp.y+D.z*this.m_axis.y,U=D.x*this.m_s1+D.y+D.z*this.m_a1,z=D.x*this.m_s2+D.y+D.z*this.m_a2;return a.x-=this.m_invMassA*q,a.y-=this.m_invMassA*R,c-=this.m_invIA*U,h.x+=this.m_invMassB*q,h.y+=this.m_invMassB*R,p+=this.m_invIB*z,s.m_sweep.a=c,u.m_sweep.a=p,s.SynchronizeTransform(),u.SynchronizeTransform(),w<=r.b2_linearSlop&&E<=r.b2_angularSlop},e.inherit(C,e.Dynamics.Joints.b2JointDef),C.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,C.b2PrismaticJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.localAnchorA=new f,this.localAnchorB=new f,this.localAxisA=new f},C.prototype.b2PrismaticJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_prismaticJoint,this.localAxisA.Set(1,0),this.referenceAngle=0,this.enableLimit=!1,this.lowerTranslation=0,this.upperTranslation=0,this.enableMotor=!1,this.maxMotorForce=0,this.motorSpeed=0},C.prototype.Initialize=function(e,t,n,r){this.bodyA=e,this.bodyB=t,this.localAnchorA=this.bodyA.GetLocalPoint(n),this.localAnchorB=this.bodyB.GetLocalPoint(n),this.localAxisA=this.bodyA.GetLocalVector(r),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},e.inherit(k,e.Dynamics.Joints.b2Joint),k.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,k.b2PulleyJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_groundAnchor1=new f,this.m_groundAnchor2=new f,this.m_localAnchor1=new f,this.m_localAnchor2=new f,this.m_u1=new f,this.m_u2=new f},k.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)},k.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)},k.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_impulse*this.m_u2.x,e*this.m_impulse*this.m_u2.y)},k.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),0},k.prototype.GetGroundAnchorA=function(){var e=this.m_ground.m_xf.position.Copy();return e.Add(this.m_groundAnchor1),e},k.prototype.GetGroundAnchorB=function(){var e=this.m_ground.m_xf.position.Copy();return e.Add(this.m_groundAnchor2),e},k.prototype.GetLength1=function(){var e=this.m_bodyA.GetWorldPoint(this.m_localAnchor1),t=this.m_ground.m_xf.position.x+this.m_groundAnchor1.x,n=this.m_ground.m_xf.position.y+this.m_groundAnchor1.y,r=e.x-t,i=e.y-n;return Math.sqrt(r*r+i*i)},k.prototype.GetLength2=function(){var e=this.m_bodyB.GetWorldPoint(this.m_localAnchor2),t=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,n=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y,r=e.x-t,i=e.y-n;return Math.sqrt(r*r+i*i)},k.prototype.GetRatio=function(){return this.m_ratio},k.prototype.b2PulleyJoint=function(e){this.__super.b2Joint.call(this,e);var t,n=0,r=0;this.m_ground=this.m_bodyA.m_world.m_groundBody,this.m_groundAnchor1.x=e.groundAnchorA.x-this.m_ground.m_xf.position.x,this.m_groundAnchor1.y=e.groundAnchorA.y-this.m_ground.m_xf.position.y,this.m_groundAnchor2.x=e.groundAnchorB.x-this.m_ground.m_xf.position.x,this.m_groundAnchor2.y=e.groundAnchorB.y-this.m_ground.m_xf.position.y,this.m_localAnchor1.SetV(e.localAnchorA),this.m_localAnchor2.SetV(e.localAnchorB),this.m_ratio=e.ratio,this.m_constant=e.lengthA+this.m_ratio*e.lengthB,this.m_maxLength1=o.Min(e.maxLengthA,this.m_constant-this.m_ratio*k.b2_minPulleyLength),this.m_maxLength2=o.Min(e.maxLengthB,(this.m_constant-k.b2_minPulleyLength)/this.m_ratio),this.m_impulse=0,this.m_limitImpulse1=0,this.m_limitImpulse2=0},k.prototype.InitVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,i;i=t.m_xf.R;var s=this.m_localAnchor1.x-t.m_sweep.localCenter.x,o=this.m_localAnchor1.y-t.m_sweep.localCenter.y,u=i.col1.x*s+i.col2.x*o;o=i.col1.y*s+i.col2.y*o,s=u,i=n.m_xf.R;var a=this.m_localAnchor2.x-n.m_sweep.localCenter.x,f=this.m_localAnchor2.y-n.m_sweep.localCenter.y;u=i.col1.x*a+i.col2.x*f,f=i.col1.y*a+i.col2.y*f,a=u;var l=t.m_sweep.c.x+s,c=t.m_sweep.c.y+o,h=n.m_sweep.c.x+a,p=n.m_sweep.c.y+f,d=this.m_ground.m_xf.position.x+this.m_groundAnchor1.x,v=this.m_ground.m_xf.position.y+this.m_groundAnchor1.y,m=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,g=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y;this.m_u1.Set(l-d,c-v),this.m_u2.Set(h-m,p-g);var b=this.m_u1.Length(),w=this.m_u2.Length();b>r.b2_linearSlop?this.m_u1.Multiply(1/b):this.m_u1.SetZero(),w>r.b2_linearSlop?this.m_u2.Multiply(1/w):this.m_u2.SetZero();var E=this.m_constant-b-this.m_ratio*w;E>0?(this.m_state=y.e_inactiveLimit,this.m_impulse=0):this.m_state=y.e_atUpperLimit,br.b2_linearSlop?this.m_u1.Multiply(1/b):this.m_u1.SetZero(),w>r.b2_linearSlop?this.m_u2.Multiply(1/w):this.m_u2.SetZero(),E=this.m_constant-b-this.m_ratio*w,C=o.Max(C,-E),E=o.Clamp(E+r.b2_linearSlop,-r.b2_maxLinearCorrection,0),S=-this.m_pulleyMass*E,d=-S*this.m_u1.x,v=-S*this.m_u1.y,m=-this.m_ratio*S*this.m_u2.x,g=-this.m_ratio*S*this.m_u2.y,t.m_sweep.c.x+=t.m_invMass*d,t.m_sweep.c.y+=t.m_invMass*v,t.m_sweep.a+=t.m_invI*(l*v-c*d),n.m_sweep.c.x+=n.m_invMass*m,n.m_sweep.c.y+=n.m_invMass*g,n.m_sweep.a+=n.m_invI*(h*g-p*m),t.SynchronizeTransform(),n.SynchronizeTransform()),this.m_limitState1==y.e_atUpperLimit&&(i=t.m_xf.R,l=this.m_localAnchor1.x-t.m_sweep.localCenter.x,c=this.m_localAnchor1.y-t.m_sweep.localCenter.y,N=i.col1.x*l+i.col2.x*c,c=i.col1.y*l+i.col2.y*c,l=N,d=t.m_sweep.c.x+l,v=t.m_sweep.c.y+c,this.m_u1.Set(d-s,v-u),b=this.m_u1.Length(),b>r.b2_linearSlop?(this.m_u1.x*=1/b,this.m_u1.y*=1/b):this.m_u1.SetZero(),E=this.m_maxLength1-b,C=o.Max(C,-E),E=o.Clamp(E+r.b2_linearSlop,-r.b2_maxLinearCorrection,0),S=-this.m_limitMass1*E,d=-S*this.m_u1.x,v=-S*this.m_u1.y,t.m_sweep.c.x+=t.m_invMass*d,t.m_sweep.c.y+=t.m_invMass*v,t.m_sweep.a+=t.m_invI*(l*v-c*d),t.SynchronizeTransform()),this.m_limitState2==y.e_atUpperLimit&&(i=n.m_xf.R,h=this.m_localAnchor2.x-n.m_sweep.localCenter.x,p=this.m_localAnchor2.y-n.m_sweep.localCenter.y,N=i.col1.x*h+i.col2.x*p,p=i.col1.y*h+i.col2.y*p,h=N,m=n.m_sweep.c.x+h,g=n.m_sweep.c.y+p,this.m_u2.Set(m-a,g-f),w=this.m_u2.Length(),w>r.b2_linearSlop?(this.m_u2.x*=1/w,this.m_u2.y*=1/w):this.m_u2.SetZero(),E=this.m_maxLength2-w,C=o.Max(C,-E),E=o.Clamp(E+r.b2_linearSlop,-r.b2_maxLinearCorrection,0),S=-this.m_limitMass2*E,m=-S*this.m_u2.x,g=-S*this.m_u2.y,n.m_sweep.c.x+=n.m_invMass*m,n.m_sweep.c.y+=n.m_invMass*g,n.m_sweep.a+=n.m_invI*(h*g-p*m),n.SynchronizeTransform()),C=this.m_upperAngle?(this.m_limitState!=y.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=y.e_atUpperLimit):(this.m_limitState=y.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=y.e_inactiveLimit;if(e.warmStarting){this.m_impulse.x*=e.dtRatio,this.m_impulse.y*=e.dtRatio,this.m_motorImpulse*=e.dtRatio;var m=this.m_impulse.x,g=this.m_impulse.y;t.m_linearVelocity.x-=c*m,t.m_linearVelocity.y-=c*g,t.m_angularVelocity-=p*(u*g-a*m+this.m_motorImpulse+this.m_impulse.z),n.m_linearVelocity.x+=h*m,n.m_linearVelocity.y+=h*g,n.m_angularVelocity+=d*(f*g-l*m+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.SetZero(),this.m_motorImpulse=0},A.prototype.SolveVelocityConstraints=function(e){var t=this.m_bodyA,n=this.m_bodyB,r,i=0,s=0,u=0,a=0,f=0,l=0,c=t.m_linearVelocity,h=t.m_angularVelocity,p=n.m_linearVelocity,d=n.m_angularVelocity,v=t.m_invMass,m=n.m_invMass,g=t.m_invI,b=n.m_invI;if(this.m_enableMotor&&this.m_limitState!=y.e_equalLimits){var w=d-h-this.m_motorSpeed,E=this.m_motorMass*-w,S=this.m_motorImpulse,x=e.dt*this.m_maxMotorTorque;this.m_motorImpulse=o.Clamp(this.m_motorImpulse+E,-x,x),E=this.m_motorImpulse-S,h-=g*E,d+=b*E}if(this.m_enableLimit&&this.m_limitState!=y.e_inactiveLimit){r=t.m_xf.R,u=this.m_localAnchor1.x-t.m_sweep.localCenter.x,a=this.m_localAnchor1.y-t.m_sweep.localCenter.y,i=r.col1.x*u+r.col2.x*a,a=r.col1.y*u+r.col2.y*a,u=i,r=n.m_xf.R,f=this.m_localAnchor2.x-n.m_sweep.localCenter.x,l=this.m_localAnchor2.y-n.m_sweep.localCenter.y,i=r.col1.x*f+r.col2.x*l,l=r.col1.y*f+r.col2.y*l,f=i;var T=p.x+ -d*l-c.x- -h*a,N=p.y+d*f-c.y-h*u,C=d-h;this.m_mass.Solve33(this.impulse3,-T,-N,-C),this.m_limitState==y.e_equalLimits?this.m_impulse.Add(this.impulse3):this.m_limitState==y.e_atLowerLimit?(s=this.m_impulse.z+this.impulse3.z,s<0&&(this.m_mass.Solve22(this.reduced,-T,-N),this.impulse3.x=this.reduced.x,this.impulse3.y=this.reduced.y,this.impulse3.z=-this.m_impulse.z,this.m_impulse.x+=this.reduced.x,this.m_impulse.y+=this.reduced.y,this.m_impulse.z=0)):this.m_limitState==y.e_atUpperLimit&&(s=this.m_impulse.z+this.impulse3.z,s>0&&(this.m_mass.Solve22(this.reduced,-T,-N),this.impulse3.x=this.reduced.x,this.impulse3.y=this.reduced.y,this.impulse3.z=-this.m_impulse.z,this.m_impulse.x+=this.reduced.x,this.m_impulse.y+=this.reduced.y,this.m_impulse.z=0)),c.x-=v*this.impulse3.x,c.y-=v*this.impulse3.y,h-=g*(u*this.impulse3.y-a*this.impulse3.x+this.impulse3.z),p.x+=m*this.impulse3.x,p.y+=m*this.impulse3.y,d+=b*(f*this.impulse3.y-l*this.impulse3.x+this.impulse3.z)}else{r=t.m_xf.R,u=this.m_localAnchor1.x-t.m_sweep.localCenter.x,a=this.m_localAnchor1.y-t.m_sweep.localCenter.y,i=r.col1.x*u+r.col2.x*a,a=r.col1.y*u+r.col2.y*a,u=i,r=n.m_xf.R,f=this.m_localAnchor2.x-n.m_sweep.localCenter.x,l=this.m_localAnchor2.y-n.m_sweep.localCenter.y,i=r.col1.x*f+r.col2.x*l,l=r.col1.y*f+r.col2.y*l,f=i;var k=p.x+ -d*l-c.x- -h*a,L=p.y+d*f-c.y-h*u;this.m_mass.Solve22(this.impulse2,-k,-L),this.m_impulse.x+=this.impulse2.x,this.m_impulse.y+=this.impulse2.y,c.x-=v*this.impulse2.x,c.y-=v*this.impulse2.y,h-=g*(u*this.impulse2.y-a*this.impulse2.x),p.x+=m*this.impulse2.x,p.y+=m*this.impulse2.y,d+=b*(f*this.impulse2.y-l*this.impulse2.x)}t.m_linearVelocity.SetV(c),t.m_angularVelocity=h,n.m_linearVelocity.SetV(p),n.m_angularVelocity=d},A.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t=0,n=0,i,s=this.m_bodyA,u=this.m_bodyB,a=0,f=0,l=0,c=0,h=0;if(this.m_enableLimit&&this.m_limitState!=y.e_inactiveLimit){var p=u.m_sweep.a-s.m_sweep.a-this.m_referenceAngle,d=0;this.m_limitState==y.e_equalLimits?(n=o.Clamp(p-this.m_lowerAngle,-r.b2_maxAngularCorrection,r.b2_maxAngularCorrection),d=-this.m_motorMass*n,a=o.Abs(n)):this.m_limitState==y.e_atLowerLimit?(n=p-this.m_lowerAngle,a=-n,n=o.Clamp(n+r.b2_angularSlop,-r.b2_maxAngularCorrection,0),d=-this.m_motorMass*n):this.m_limitState==y.e_atUpperLimit&&(n=p-this.m_upperAngle,a=n,n=o.Clamp(n-r.b2_angularSlop,0,r.b2_maxAngularCorrection),d=-this.m_motorMass*n),s.m_sweep.a-=s.m_invI*d,u.m_sweep.a+=u.m_invI*d,s.SynchronizeTransform(),u.SynchronizeTransform()}i=s.m_xf.R;var v=this.m_localAnchor1.x-s.m_sweep.localCenter.x,m=this.m_localAnchor1.y-s.m_sweep.localCenter.y;l=i.col1.x*v+i.col2.x*m,m=i.col1.y*v+i.col2.y*m,v=l,i=u.m_xf.R;var g=this.m_localAnchor2.x-u.m_sweep.localCenter.x,b=this.m_localAnchor2.y-u.m_sweep.localCenter.y;l=i.col1.x*g+i.col2.x*b,b=i.col1.y*g+i.col2.y*b,g=l;var w=u.m_sweep.c.x+g-s.m_sweep.c.x-v,E=u.m_sweep.c.y+b-s.m_sweep.c.y-m,S=w*w+E*E,x=Math.sqrt(S);f=x;var T=s.m_invMass,N=u.m_invMass,C=s.m_invI,k=u.m_invI,L=10*r.b2_linearSlop;if(S>L*L){var O=w/x,M=E/x,_=T+N,D=1/_;c=D*-w,h=D*-E;var P=.5;s.m_sweep.c.x-=P*T*c,s.m_sweep.c.y-=P*T*h,u.m_sweep.c.x+=P*N*c,u.m_sweep.c.y+=P*N*h,w=u.m_sweep.c.x+g-s.m_sweep.c.x-v,E=u.m_sweep.c.y+b-s.m_sweep.c.y-m}return this.K1.col1.x=T+N,this.K1.col2.x=0,this.K1.col1.y=0,this.K1.col2.y=T+N,this.K2.col1.x=C*m*m,this.K2.col2.x=-C*v*m,this.K2.col1.y=-C*v*m,this.K2.col2.y=C*v*v,this.K3.col1.x=k*b*b,this.K3.col2.x=-k*g*b,this.K3.col1.y=-k*g*b,this.K3.col2.y=k*g*g,this.K.SetM(this.K1),this.K.AddM(this.K2),this.K.AddM(this.K3),this.K.Solve(A.tImpulse,-w,-E),c=A.tImpulse.x,h=A.tImpulse.y,s.m_sweep.c.x-=s.m_invMass*c,s.m_sweep.c.y-=s.m_invMass*h,s.m_sweep.a-=s.m_invI*(v*h-m*c),u.m_sweep.c.x+=u.m_invMass*c,u.m_sweep.c.y+=u.m_invMass*h,u.m_sweep.a+=u.m_invI*(g*h-b*c),s.SynchronizeTransform(),u.SynchronizeTransform(),f<=r.b2_linearSlop&&a<=r.b2_angularSlop},e.postDefs.push(function(){e.Dynamics.Joints.b2RevoluteJoint.tImpulse=new f}),e.inherit(O,e.Dynamics.Joints.b2JointDef),O.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,O.b2RevoluteJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.localAnchorA=new f,this.localAnchorB=new f},O.prototype.b2RevoluteJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_revoluteJoint,this.localAnchorA.Set(0,0),this.localAnchorB.Set(0,0),this.referenceAngle=0,this.lowerAngle=0,this.upperAngle=0,this.maxMotorTorque=0,this.motorSpeed=0,this.enableLimit=!1,this.enableMotor=!1},O.prototype.Initialize=function(e,t,n){this.bodyA=e,this.bodyB=t,this.localAnchorA=this.bodyA.GetLocalPoint(n),this.localAnchorB=this.bodyB.GetLocalPoint(n),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},e.inherit(M,e.Dynamics.Joints.b2Joint),M.prototype.__super=e.Dynamics.Joints.b2Joint.prototype,M.b2WeldJoint=function(){e.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments),this.m_localAnchorA=new f,this.m_localAnchorB=new f,this.m_impulse=new l,this.m_mass=new s},M.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)},M.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)},M.prototype.GetReactionForce=function(e){return e===undefined&&(e=0),new f(e*this.m_impulse.x,e*this.m_impulse.y)},M.prototype.GetReactionTorque=function(e){return e===undefined&&(e=0),e*this.m_impulse.z},M.prototype.b2WeldJoint=function(e){this.__super.b2Joint.call(this,e),this.m_localAnchorA.SetV(e.localAnchorA),this.m_localAnchorB.SetV(e.localAnchorB),this.m_referenceAngle=e.referenceAngle,this.m_impulse.SetZero(),this.m_mass=new s},M.prototype.InitVelocityConstraints=function(e){var t,n=0,r=this.m_bodyA,i=this.m_bodyB;t=r.m_xf.R;var s=this.m_localAnchorA.x-r.m_sweep.localCenter.x,o=this.m_localAnchorA.y-r.m_sweep.localCenter.y;n=t.col1.x*s+t.col2.x*o,o=t.col1.y*s+t.col2.y*o,s=n,t=i.m_xf.R;var u=this.m_localAnchorB.x-i.m_sweep.localCenter.x,a=this.m_localAnchorB.y-i.m_sweep.localCenter.y;n=t.col1.x*u+t.col2.x*a,a=t.col1.y*u+t.col2.y*a,u=n;var f=r.m_invMass,l=i.m_invMass,c=r.m_invI,h=i.m_invI;this.m_mass.col1.x=f+l+o*o*c+a*a*h,this.m_mass.col2.x=-o*s*c-a*u*h,this.m_mass.col3.x=-o*c-a*h,this.m_mass.col1.y=this.m_mass.col2.x,this.m_mass.col2.y=f+l+s*s*c+u*u*h,this.m_mass.col3.y=s*c+u*h,this.m_mass.col1.z=this.m_mass.col3.x,this.m_mass.col2.z=this.m_mass.col3.y,this.m_mass.col3.z=c+h,e.warmStarting?(this.m_impulse.x*=e.dtRatio,this.m_impulse.y*=e.dtRatio,this.m_impulse.z*=e.dtRatio,r.m_linearVelocity.x-=f*this.m_impulse.x,r.m_linearVelocity.y-=f*this.m_impulse.y,r.m_angularVelocity-=c*(s*this.m_impulse.y-o*this.m_impulse.x+this.m_impulse.z),i.m_linearVelocity.x+=l*this.m_impulse.x,i.m_linearVelocity.y+=l*this.m_impulse.y,i.m_angularVelocity+=h*(u*this.m_impulse.y-a*this.m_impulse.x+this.m_impulse.z)):this.m_impulse.SetZero()},M.prototype.SolveVelocityConstraints=function(e){var t,n=0,r=this.m_bodyA,i=this.m_bodyB,s=r.m_linearVelocity,o=r.m_angularVelocity,u=i.m_linearVelocity,a=i.m_angularVelocity,f=r.m_invMass,c=i.m_invMass,h=r.m_invI,p=i.m_invI;t=r.m_xf.R;var d=this.m_localAnchorA.x-r.m_sweep.localCenter.x,v=this.m_localAnchorA.y-r.m_sweep.localCenter.y;n=t.col1.x*d+t.col2.x*v,v=t.col1.y*d+t.col2.y*v,d=n,t=i.m_xf.R;var m=this.m_localAnchorB.x-i.m_sweep.localCenter.x,g=this.m_localAnchorB.y-i.m_sweep.localCenter.y;n=t.col1.x*m+t.col2.x*g,g=t.col1.y*m+t.col2.y*g,m=n;var y=u.x-a*g-s.x+o*v,b=u.y+a*m-s.y-o*d,w=a-o,E=new l;this.m_mass.Solve33(E,-y,-b,-w),this.m_impulse.Add(E),s.x-=f*E.x,s.y-=f*E.y,o-=h*(d*E.y-v*E.x+E.z),u.x+=c*E.x,u.y+=c*E.y,a+=p*(m*E.y-g*E.x+E.z),r.m_angularVelocity=o,i.m_angularVelocity=a},M.prototype.SolvePositionConstraints=function(e){e===undefined&&(e=0);var t,n=0,i=this.m_bodyA,s=this.m_bodyB;t=i.m_xf.R;var u=this.m_localAnchorA.x-i.m_sweep.localCenter.x,a=this.m_localAnchorA.y-i.m_sweep.localCenter.y;n=t.col1.x*u+t.col2.x*a,a=t.col1.y*u+t.col2.y*a,u=n,t=s.m_xf.R;var f=this.m_localAnchorB.x-s.m_sweep.localCenter.x,c=this.m_localAnchorB.y-s.m_sweep.localCenter.y;n=t.col1.x*f+t.col2.x*c,c=t.col1.y*f+t.col2.y*c,f=n;var h=i.m_invMass,p=s.m_invMass,d=i.m_invI,v=s.m_invI,m=s.m_sweep.c.x+f-i.m_sweep.c.x-u,g=s.m_sweep.c.y+c-i.m_sweep.c.y-a,y=s.m_sweep.a-i.m_sweep.a-this.m_referenceAngle,b=10*r.b2_linearSlop,w=Math.sqrt(m*m+g*g),E=o.Abs(y);w>b&&(d*=1,v*=1),this.m_mass.col1.x=h+p+a*a*d+c*c*v,this.m_mass.col2.x=-a*u*d-c*f*v,this.m_mass.col3.x=-a*d-c*v,this.m_mass.col1.y=this.m_mass.col2.x,this.m_mass.col2.y=h+p+u*u*d+f*f*v,this.m_mass.col3.y=u*d+f*v,this.m_mass.col1.z=this.m_mass.col3.x,this.m_mass.col2.z=this.m_mass.col3.y,this.m_mass.col3.z=d+v;var S=new l;return this.m_mass.Solve33(S,-m,-g,-y),i.m_sweep.c.x-=h*S.x,i.m_sweep.c.y-=h*S.y,i.m_sweep.a-=d*(u*S.y-a*S.x+S.z),s.m_sweep.c.x+=p*S.x,s.m_sweep.c.y+=p*S.y,s.m_sweep.a+=v*(f*S.y-c*S.x+S.z),i.SynchronizeTransform(),s.SynchronizeTransform(),w<=r.b2_linearSlop&&E<=r.b2_angularSlop},e.inherit(_,e.Dynamics.Joints.b2JointDef),_.prototype.__super=e.Dynamics.Joints.b2JointDef.prototype,_.b2WeldJointDef=function(){e.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments),this.localAnchorA=new f,this.localAnchorB=new f},_.prototype.b2WeldJointDef=function(){this.__super.b2JointDef.call(this),this.type=y.e_weldJoint,this.referenceAngle=0},_.prototype.Initialize=function(e,t,n){this.bodyA=e,this.bodyB=t,this.localAnchorA.SetV(this.bodyA.GetLocalPoint(n)),this.localAnchorB.SetV(this.bodyB.GetLocalPoint(n)),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()}}(),function(){var t=e.Dynamics.b2DebugDraw;t.b2DebugDraw=function(){this.m_drawScale=1,this.m_lineThickness=1,this.m_alpha=1,this.m_fillAlpha=1,this.m_xformScale=1;var e=this;this.m_sprite={graphics:{clear:function(){e.m_ctx.clearRect(0,0,e.m_ctx.canvas.width,e.m_ctx.canvas.height)}}}},t.prototype._color=function(e,t){return"rgba("+((e&16711680)>>16)+","+((e&65280)>>8)+","+(e&255)+","+t+")"},t.prototype.b2DebugDraw=function(){this.m_drawFlags=0},t.prototype.SetFlags=function(e){e===undefined&&(e=0),this.m_drawFlags=e},t.prototype.GetFlags=function(){return this.m_drawFlags},t.prototype.AppendFlags=function(e){e===undefined&&(e=0),this.m_drawFlags|=e},t.prototype.ClearFlags=function(e){e===undefined&&(e=0),this.m_drawFlags&=~e},t.prototype.SetSprite=function(e){this.m_ctx=e},t.prototype.GetSprite=function(){return this.m_ctx},t.prototype.SetDrawScale=function(e){e===undefined&&(e=0),this.m_drawScale=e},t.prototype.GetDrawScale=function(){return this.m_drawScale},t.prototype.SetLineThickness=function(e){e===undefined&&(e=0),this.m_lineThickness=e,this.m_ctx.strokeWidth=e},t.prototype.GetLineThickness=function(){return this.m_lineThickness},t.prototype.SetAlpha=function(e){e===undefined&&(e=0),this.m_alpha=e},t.prototype.GetAlpha=function(){return this.m_alpha},t.prototype.SetFillAlpha=function(e){e===undefined&&(e=0),this.m_fillAlpha=e},t.prototype.GetFillAlpha=function(){return this.m_fillAlpha},t.prototype.SetXFormScale=function(e){e===undefined&&(e=0),this.m_xformScale=e},t.prototype.GetXFormScale=function(){return this.m_xformScale},t.prototype.DrawPolygon=function(e,t,n){if(!t)return;var r=this.m_ctx,i=this.m_drawScale;r.beginPath(),r.strokeStyle=this._color(n.color,this.m_alpha),r.moveTo(e[0].x*i,e[0].y*i);for(var s=1;sp.children.length;){var d=document.createElement("span");d.style.cssText="width:1px;height:30px;float:left;background-color:#113",p.appendChild(d)}var v=document.createElement("div");v.id="ms",v.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none",l.appendChild(v);var m=document.createElement("div");m.id="msText",m.style.cssText="color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px",m.innerHTML="MS",v.appendChild(m);var g=document.createElement("div");g.id="msGraph",g.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0";for(v.appendChild(g);74>g.children.length;)d=document.createElement("span"),d.style.cssText="width:1px;height:30px;float:left;background-color:#131",g.appendChild(d);var y=function(e){f=e;switch(f){case 0:c.style.display="block",v.style.display="none";break;case 1:c.style.display="none",v.style.display="block"}};return{REVISION:11,domElement:l,setMode:y,begin:function(){e=Date.now()},end:function(){var f=Date.now();n=f-e,r=Math.min(r,n),i=Math.max(i,n),m.textContent=n+" MS ("+r+"-"+i+")";var l=Math.min(30,30-30*(n/200));return g.appendChild(g.firstChild).style.height=l+"px",a++,f>t+1e3&&(s=Math.round(1e3*a/(f-t)),o=Math.min(o,s),u=Math.max(u,s),h.textContent=s+" FPS ("+o+"-"+u+")",l=Math.min(30,30-30*(s/100)),p.appendChild(p.firstChild).style.height=l+"px",t=f,a=0),f},update:function(){e=this.end()}}};return e}),function(){var e=typeof module!="undefined"&&module.exports,t=typeof Element!="undefined"&&"ALLOW_KEYBOARD_INPUT"in Element,n=function(){var e,t,n=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],r=0,i=n.length,s={};for(;r=0;v--)i.push(new y(t.polygon.vertices.x[v],-t.polygon.vertices.y[v]));n.shape.SetAsArray(i,i.length);var r=e.CreateFixture(n);r&&t.name&&(r.name=t.name)}else if(t.hasOwnProperty("chain")){n.shape=new l;var o=new y;for(v=t.chain.vertices.x.length-1;v>=0;v--){var u=new y(t.chain.vertices.x[v],-t.chain.vertices.y[v]);if(v=n.length)return console.log("Index for bodyA is invalid: "+e.bodyA),null;if(e.bodyB>=n.length)return console.log("Index for bodyB is invalid: "+e.bodyB),null;var r=null;if(e.type=="revolute"){var i=new b2RevoluteJointDef;this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("refAngle")&&(i.referenceAngle=e.refAngle),e.hasOwnProperty("lowerLimit")&&(i.lowerAngle=e.lowerLimit),e.hasOwnProperty("upperLimit")&&(i.upperAngle=e.upperLimit),e.hasOwnProperty("maxMotorTorque")&&(i.maxMotorTorque=e.maxMotorTorque),e.hasOwnProperty("motorSpeed")&&(i.motorSpeed=e.motorSpeed),e.hasOwnProperty("enableLimit")&&(i.enableLimit=e.enableLimit),e.hasOwnProperty("enableMotor")&&(i.enableMotor=e.enableMotor),r=t.CreateJoint(i)}else if(e.type=="distance"||e.type=="rope"){e.type=="rope"&&console.log("Replacing unsupported rope joint with distance joint!");var i=new b2DistanceJointDef;this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("length")&&(i.length=e.length),e.hasOwnProperty("dampingRatio")&&(i.dampingRatio=e.dampingRatio),e.hasOwnProperty("frequency")&&(i.frequencyHz=e.frequency),r=t.CreateJoint(i)}else if(e.type=="prismatic"){var i=new b2PrismaticJointDef;this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("localAxisA")&&i.localAxisA.SetV(this.getVectorValue(e.localAxisA)),e.hasOwnProperty("refAngle")&&(i.referenceAngle=e.refAngle),e.hasOwnProperty("enableLimit")&&(i.enableLimit=e.enableLimit),e.hasOwnProperty("lowerLimit")&&(i.lowerTranslation=e.lowerLimit),e.hasOwnProperty("upperLimit")&&(i.upperTranslation=e.upperLimit),e.hasOwnProperty("enableMotor")&&(i.enableMotor=e.enableMotor),e.hasOwnProperty("maxMotorForce")&&(i.maxMotorForce=e.maxMotorForce),e.hasOwnProperty("motorSpeed")&&(i.motorSpeed=e.motorSpeed),r=t.CreateJoint(i)}else if(e.type=="wheel"){var i=new b2DistanceJointDef;this.loadJointCommonProperties(i,e,n),i.length=0,e.hasOwnProperty("springDampingRatio")&&(i.dampingRatio=e.springDampingRatio),e.hasOwnProperty("springFrequency")&&(i.frequencyHz=e.springFrequency),t.CreateJoint(i),i=new b2LineJointDef,this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("localAxisA")&&i.localAxisA.SetV(this.getVectorValue(e.localAxisA)),r=t.CreateJoint(i)}else if(e.type=="friction"){var i=new b2FrictionJointDef;this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("maxForce")&&(i.maxForce=e.maxForce),e.hasOwnProperty("maxTorque")&&(i.maxTorque=e.maxTorque),r=t.CreateJoint(i)}else if(e.type=="weld"){var i=new b2WeldJointDef;this.loadJointCommonProperties(i,e,n),e.hasOwnProperty("referenceAngle")&&(i.referenceAngle=e.referenceAngle),r=t.CreateJoint(i)}else console.log("Unsupported joint type: "+e.type),console.log(e);return r&&e.name&&(r.name=e.name),r},pt.prototype.makeClone=function(e){var t=e instanceof Array?[]:{};for(var n in e)e[n]&&typeof e[n]=="object"?t[n]=this.makeClone(e[n]):t[n]=e[n];return t},pt.prototype.loadImageFromRUBE=function(e,t,n){var r=this.makeClone(e);return r.hasOwnProperty("body")&&r.body>=0?r.body=n[r.body]:r.body=null,r.center=new y,r.center.SetV(this.getVectorValue(e.center)),r},pt.prototype.loadSceneIntoWorld=function(e,t){var n=[];if(e.hasOwnProperty("body"))for(var r=0;r=n&&e<=n+this.width){var r=this.y;if(t>=r&&t<=r+this.height)return!0}return!1},t.Rectangle.prototype.constructor=t.Rectangle,t.EmptyRectangle=new t.Rectangle(0,0,0,0),t.Polygon=function(e){e instanceof Array||(e=Array.prototype.slice.call(arguments));if(typeof e[0]=="number"){var n=[];for(var r=0,i=e.length;rt!=a>t&&e<(u-s)*(t-o)/(a-o)+s;f&&(n=!n)}return n},t.Polygon.prototype.constructor=t.Polygon,t.Circle=function(e,t,n){this.x=e||0,this.y=t||0,this.radius=n||0},t.Circle.prototype.clone=function(){return new t.Circle(this.x,this.y,this.radius)},t.Circle.prototype.contains=function(e,t){if(this.radius<=0)return!1;var n=this.x-e,r=this.y-t,i=this.radius*this.radius;return n*=n,r*=r,n+r<=i},t.Circle.prototype.constructor=t.Circle,t.Ellipse=function(e,t,n,r){this.x=e||0,this.y=t||0,this.width=n||0,this.height=r||0},t.Ellipse.prototype.clone=function(){return new t.Ellipse(this.x,this.y,this.width,this.height)},t.Ellipse.prototype.contains=function(e,t){if(this.width<=0||this.height<=0)return!1;var n=(e-this.x)/this.width,r=(t-this.y)/this.height;return n*=n,r*=r,n+r<=1},t.Ellipse.prototype.getBounds=function(){return new t.Rectangle(this.x,this.y,this.width,this.height)},t.Ellipse.prototype.constructor=t.Ellipse,t.determineMatrixArrayType=function(){return typeof Float32Array!="undefined"?Float32Array:Array},t.Matrix2=t.determineMatrixArrayType(),t.Matrix=function(){this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0},t.Matrix.prototype.fromArray=function(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]},t.Matrix.prototype.toArray=function(e){this.array||(this.array=new Float32Array(9));var t=this.array;return e?(this.array[0]=this.a,this.array[1]=this.c,this.array[2]=0,this.array[3]=this.b,this.array[4]=this.d,this.array[5]=0,this.array[6]=this.tx,this.array[7]=this.ty,this.array[8]=1):(this.array[0]=this.a,this.array[1]=this.b,this.array[2]=this.tx,this.array[3]=this.c,this.array[4]=this.d,this.array[5]=this.ty,this.array[6]=0,this.array[7]=0,this.array[8]=1),t},t.identityMatrix=new t.Matrix,t.DisplayObject=function(){this.position=new t.Point,this.scale=new t.Point(1,1),this.pivot=new t.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.buttonMode=!1,this.renderable=!1,this.parent=null,this.stage=null,this.worldAlpha=1,this._interactive=!1,this.defaultCursor="pointer",this.worldTransform=new t.Matrix,this.color=[],this.dynamic=!0,this._sr=0,this._cr=1,this.filterArea=new t.Rectangle(0,0,1,1),this._bounds=new t.Rectangle(0,0,1,1),this._currentBounds=null,this._mask=null},t.DisplayObject.prototype.constructor=t.DisplayObject,t.DisplayObject.prototype.setInteractive=function(e){this.interactive=e},Object.defineProperty(t.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(e){this._interactive=e,this.stage&&(this.stage.dirty=!0)}}),Object.defineProperty(t.DisplayObject.prototype,"worldVisible",{get:function(){var e=this;do{if(!e.visible)return!1;e=e.parent}while(e);return!0}}),Object.defineProperty(t.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(e){this._mask&&(this._mask.isMask=!1),this._mask=e,this._mask&&(this._mask.isMask=!0)}}),Object.defineProperty(t.DisplayObject.prototype,"filters",{get:function(){return this._filters},set:function(e){if(e){var t=[];for(var n=0;n=0&&t<=this.children.length))throw new Error(e+" The index "+t+" supplied is out of bounds "+this.children.length);e.parent&&e.parent.removeChild(e),e.parent=this,this.children.splice(t,0,e),this.stage&&e.setStageReference(this.stage)},t.DisplayObjectContainer.prototype.swapChildren=function(e,t){if(e===t)return;var n=this.children.indexOf(e),r=this.children.indexOf(t);if(n<0||r<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[n]=t,this.children[r]=e},t.DisplayObjectContainer.prototype.getChildAt=function(e){if(e>=0&&ea?s:a,o=o>f?o:f}if(!l)return t.EmptyRectangle;var d=this._bounds;return d.x=r,d.y=i,d.width=s-r,d.height=o-i,d},t.DisplayObjectContainer.prototype.getLocalBounds=function(){var e=this.worldTransform;this.worldTransform=t.identityMatrix;for(var n=0,r=this.children.length;nS?d:S,S=m>S?m:S,S=y>S?y:S,S=w>S?w:S,x=v>x?v:x,x=g>x?g:x,x=b>x?b:x,x=E>x?E:x;var C=this._bounds;return C.x=T,C.width=S-T,C.y=N,C.height=x-N,this._currentBounds=C,C},t.Sprite.prototype._renderWebGL=function(e){if(!this.visible||this.alpha<=0)return;var t,n;if(this._mask||this._filters){var r=e.spriteBatch;this._mask&&(r.stop(),e.maskManager.pushMask(this.mask,e),r.start()),this._filters&&(r.flush(),e.filterManager.pushFilter(this._filterBlock)),r.render(this);for(t=0,n=this.children.length;t=this.textures.length&&(this.gotoAndStop(this.textures.length-1),this.onComplete&&this.onComplete())},t.FilterBlock=function(){this.visible=!0,this.renderable=!0},t.Text=function(e,n){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),t.Sprite.call(this,t.Texture.fromCanvas(this.canvas)),this.setText(e),this.setStyle(n),this.updateText(),this.dirty=!1},t.Text.prototype=Object.create(t.Sprite.prototype),t.Text.prototype.constructor=t.Text,t.Text.prototype.setStyle=function(e){e=e||{},e.font=e.font||"bold 20pt Arial",e.fill=e.fill||"black",e.align=e.align||"left",e.stroke=e.stroke||"black",e.strokeThickness=e.strokeThickness||0,e.wordWrap=e.wordWrap||!1,e.wordWrapWidth=e.wordWrapWidth||100,this.style=e,this.dirty=!0},t.Text.prototype.setText=function(e){this.text=e.toString()||" ",this.dirty=!0},t.Text.prototype.updateText=function(){this.context.font=this.style.font;var e=this.text;this.style.wordWrap&&(e=this.wordWrap(this.text));var n=e.split(/(?:\r\n|\r|\n)/),r=[],i=0;for(var s=0;si?(o>0&&(t+="\n"),t+=s[o]+" ",i=this.style.wordWrapWidth-u):(i-=a,t+=s[o]+" ")}r=2?parseInt(n[n.length-2],10):t.BitmapText.fonts[this.fontName].size,this.dirty=!0,this.tint=e.tint},t.BitmapText.prototype.updateText=function(){var e=t.BitmapText.fonts[this.fontName],n=new t.Point,r=null,i=[],s=0,o=[],u=0,a=this.fontSize/e.size;for(var f=0;fv){var y=this.getChildAt(this.children.length-1);this._pool.push(y),this.removeChild(y)}this.textWidth=s*a,this.textHeight=(n.y+e.lineHeight)*a},t.BitmapText.prototype.updateTransform=function(){this.dirty&&(this.updateText(),this.dirty=!1),t.DisplayObjectContainer.prototype.updateTransform.call(this)},t.BitmapText.fonts={},t.InteractionData=function(){this.global=new t.Point,this.local=new t.Point,this.target=null,this.originalEvent=null},t.InteractionData.prototype.getLocalPosition=function(e){var n=e.worldTransform,r=this.global,i=n.a,s=n.b,o=n.tx,u=n.c,a=n.d,f=n.ty,l=1/(i*a+s*-u);return new t.Point(a*l*r.x+ -s*l*r.y+(f*s-o*a)*l,i*l*r.y+ -u*l*r.x+(-f*i+o*u)*l)},t.InteractionData.prototype.constructor=t.InteractionData,t.InteractionManager=function(e){this.stage=e,this.mouse=new t.InteractionData,this.touchs={},this.tempPoint=new t.Point,this.mouseoverEnabled=!0,this.pool=[],this.interactiveItems=[],this.interactionDOMElement=null,this.onMouseMove=this.onMouseMove.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.last=0,this.currentCursorStyle="inherit",this.mouseOut=!1},t.InteractionManager.prototype.constructor=t.InteractionManager,t.InteractionManager.prototype.collectInteractiveSprite=function(e,t){var n=e.children,r=n.length;for(var i=r-1;i>=0;i--){var s=n[i];s.interactive?(t.interactiveChildren=!0,this.interactiveItems.push(s),s.children.length>0&&this.collectInteractiveSprite(s,s)):(s.__iParent=null,s.children.length>0&&this.collectInteractiveSprite(s,t))}},t.InteractionManager.prototype.setTarget=function(e){this.target=e,this.interactionDOMElement===null&&this.setTargetDomElement(e.view)},t.InteractionManager.prototype.setTargetDomElement=function(e){this.removeEvents(),window.navigator.msPointerEnabled&&(e.style["-ms-content-zooming"]="none",e.style["-ms-touch-action"]="none"),this.interactionDOMElement=e,e.addEventListener("mousemove",this.onMouseMove,!0),e.addEventListener("mousedown",this.onMouseDown,!0),e.addEventListener("mouseout",this.onMouseOut,!0),e.addEventListener("touchstart",this.onTouchStart,!0),e.addEventListener("touchend",this.onTouchEnd,!0),e.addEventListener("touchmove",this.onTouchMove,!0),document.body.addEventListener("mouseup",this.onMouseUp,!0)},t.InteractionManager.prototype.removeEvents=function(){if(!this.interactionDOMElement)return;this.interactionDOMElement.style["-ms-content-zooming"]="",this.interactionDOMElement.style["-ms-touch-action"]="",this.interactionDOMElement.removeEventListener("mousemove",this.onMouseMove,!0),this.interactionDOMElement.removeEventListener("mousedown",this.onMouseDown,!0),this.interactionDOMElement.removeEventListener("mouseout",this.onMouseOut,!0),this.interactionDOMElement.removeEventListener("touchstart",this.onTouchStart,!0),this.interactionDOMElement.removeEventListener("touchend",this.onTouchEnd,!0),this.interactionDOMElement.removeEventListener("touchmove",this.onTouchMove,!0),this.interactionDOMElement=null,document.body.removeEventListener("mouseup",this.onMouseUp,!0)},t.InteractionManager.prototype.update=function(){if(!this.target)return;var e=Date.now(),n=e-this.last;n=n*t.INTERACTION_FREQUENCY/1e3;if(n<1)return;this.last=e;var r=0;if(this.dirty){this.dirty=!1;var i=this.interactiveItems.length;for(r=0;rg&&py&&d>16&255)/255,(e>>8&255)/255,(e&255)/255]},t.rgb2hex=function(e){return(e[0]*255<<16)+(e[1]*255<<8)+e[2]*255},typeof Function.prototype.bind!="function"&&(Function.prototype.bind=function(){var e=Array.prototype.slice;return function(t){function i(){var s=r.concat(e.call(arguments));n.apply(this instanceof i?this:t,s)}var n=this,r=e.call(arguments,1);if(typeof n!="function")throw new TypeError;return i.prototype=function s(e){e&&(s.prototype=e);if(!(this instanceof s))return new s}(n.prototype),i}}()),t.AjaxRequest=function(){var e=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"];if(!window.ActiveXObject)return window.XMLHttpRequest?new window.XMLHttpRequest:!1;for(var t=0;t0&&(e&e-1)===0)return e;var t=1;while(t>1;if(r<3)return[];var i=[],s=[];for(var o=0;o3){var a=s[(o+0)%u],f=s[(o+1)%u],l=s[(o+2)%u],c=e[2*a],h=e[2*a+1],p=e[2*f],d=e[2*f+1],v=e[2*l],m=e[2*l+1],g=!1;if(t.PolyK._convex(c,h,p,d,v,m,n)){g=!0;for(var y=0;y3*u){if(!n)return window.console.log("PIXI Warning: shape too complex to fill"),[];i=[],s=[];for(o=0;o=0&&E>=0&&w+E<1},t.PolyK._convex=function(e,t,n,r,i,s,o){return(t-r)*(i-n)+(n-e)*(s-r)>=0===o},t.initDefaultShaders=function(){},t.CompileVertexShader=function(e,n){return t._CompileShader(e,n,e.VERTEX_SHADER)},t.CompileFragmentShader=function(e,n){return t._CompileShader(e,n,e.FRAGMENT_SHADER)},t._CompileShader=function(e,t,n){var r=t.join("\n"),i=e.createShader(n);return e.shaderSource(i,r),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)?i:(window.console.log(e.getShaderInfoLog(i)),null)},t.compileProgram=function(e,n,r){var i=t.CompileFragmentShader(e,r),s=t.CompileVertexShader(e,n),o=e.createProgram();return e.attachShader(o,s),e.attachShader(o,i),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS)||window.console.log("Could not initialise shaders"),o},t.PixiShader=function(e){this.gl=e,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.textureCount=0,this.attributes=[],this.init()},t.PixiShader.prototype.init=function(){var e=this.gl,n=t.compileProgram(e,this.vertexSrc||t.PixiShader.defaultVertexSrc,this.fragmentSrc);e.useProgram(n),this.uSampler=e.getUniformLocation(n,"uSampler"),this.projectionVector=e.getUniformLocation(n,"projectionVector"),this.offsetVector=e.getUniformLocation(n,"offsetVector"),this.dimensions=e.getUniformLocation(n,"dimensions"),this.aVertexPosition=e.getAttribLocation(n,"aVertexPosition"),this.aTextureCoord=e.getAttribLocation(n,"aTextureCoord"),this.colorAttribute=e.getAttribLocation(n,"aColor"),this.colorAttribute===-1&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute];for(var r in this.uniforms)this.uniforms[r].uniformLocation=e.getUniformLocation(n,r);this.initUniforms(),this.program=n},t.PixiShader.prototype.initUniforms=function(){this.textureCount=1;var e=this.gl,t;for(var n in this.uniforms){t=this.uniforms[n];var r=t.type;r==="sampler2D"?(t._init=!1,t.value!==null&&this.initSampler2D(t)):r==="mat2"||r==="mat3"||r==="mat4"?(t.glMatrix=!0,t.glValueLength=1,r==="mat2"?t.glFunc=e.uniformMatrix2fv:r==="mat3"?t.glFunc=e.uniformMatrix3fv:r==="mat4"&&(t.glFunc=e.uniformMatrix4fv)):(t.glFunc=e["uniform"+r],r==="2f"||r==="2i"?t.glValueLength=2:r==="3f"||r==="3i"?t.glValueLength=3:r==="4f"||r==="4i"?t.glValueLength=4:t.glValueLength=1)}},t.PixiShader.prototype.initSampler2D=function(e){if(!e.value||!e.value.baseTexture||!e.value.baseTexture.hasLoaded)return;var t=this.gl;t.activeTexture(t["TEXTURE"+this.textureCount]),t.bindTexture(t.TEXTURE_2D,e.value.baseTexture._glTexture);if(e.textureData){var n=e.textureData,r=n.magFilter?n.magFilter:t.LINEAR,i=n.minFilter?n.minFilter:t.LINEAR,s=n.wrapS?n.wrapS:t.CLAMP_TO_EDGE,o=n.wrapT?n.wrapT:t.CLAMP_TO_EDGE,u=n.luminance?t.LUMINANCE:t.RGBA;n.repeat&&(s=t.REPEAT,o=t.REPEAT),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!!n.flipY);if(n.width){var a=n.width?n.width:512,f=n.height?n.height:2,l=n.border?n.border:0;t.texImage2D(t.TEXTURE_2D,0,u,a,f,l,u,t.UNSIGNED_BYTE,null)}else t.texImage2D(t.TEXTURE_2D,0,u,t.RGBA,t.UNSIGNED_BYTE,e.value.baseTexture.source);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,s),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,o)}t.uniform1i(e.uniformLocation,this.textureCount),e._init=!0,this.textureCount++},t.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var e,n=this.gl;for(var r in this.uniforms)e=this.uniforms[r],e.glValueLength===1?e.glMatrix===!0?e.glFunc.call(n,e.uniformLocation,e.transpose,e.value):e.glFunc.call(n,e.uniformLocation,e.value):e.glValueLength===2?e.glFunc.call(n,e.uniformLocation,e.value.x,e.value.y):e.glValueLength===3?e.glFunc.call(n,e.uniformLocation,e.value.x,e.value.y,e.value.z):e.glValueLength===4?e.glFunc.call(n,e.uniformLocation,e.value.x,e.value.y,e.value.z,e.value.w):e.type==="sampler2D"&&(e._init?(n.activeTexture(n["TEXTURE"+this.textureCount]),n.bindTexture(n.TEXTURE_2D,e.value.baseTexture._glTextures[n.id]||t.createWebGLTexture(e.value.baseTexture,n)),n.uniform1i(e.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(e))},t.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},t.PixiShader.defaultVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec2 aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vec3 color = mod(vec3(aColor.y/65536.0, aColor.y/256.0, aColor.y), 256.0) / 256.0;"," vColor = vec4(color * aColor.x, aColor.x);","}"],t.PixiFastShader=function(e){this.gl=e,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"],this.textureCount=0,this.init()},t.PixiFastShader.prototype.init=function(){var e=this.gl,n=t.compileProgram(e,this.vertexSrc,this.fragmentSrc);e.useProgram(n),this.uSampler=e.getUniformLocation(n,"uSampler"),this.projectionVector=e.getUniformLocation(n,"projectionVector"),this.offsetVector=e.getUniformLocation(n,"offsetVector"),this.dimensions=e.getUniformLocation(n,"dimensions"),this.uMatrix=e.getUniformLocation(n,"uMatrix"),this.aVertexPosition=e.getAttribLocation(n,"aVertexPosition"),this.aPositionCoord=e.getAttribLocation(n,"aPositionCoord"),this.aScale=e.getAttribLocation(n,"aScale"),this.aRotation=e.getAttribLocation(n,"aRotation"),this.aTextureCoord=e.getAttribLocation(n,"aTextureCoord"),this.colorAttribute=e.getAttribLocation(n,"aColor"),this.colorAttribute===-1&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute],this.program=n},t.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},t.StripShader=function(){this.program=null,this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));"," gl_FragColor = gl_FragColor * alpha;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","uniform vec2 offsetVector;","varying float vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / projectionVector.y + 1.0 , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"]},t.StripShader.prototype.init=function(){var e=t.gl,n=t.compileProgram(e,this.vertexSrc,this.fragmentSrc);e.useProgram(n),this.uSampler=e.getUniformLocation(n,"uSampler"),this.projectionVector=e.getUniformLocation(n,"projectionVector"),this.offsetVector=e.getUniformLocation(n,"offsetVector"),this.colorAttribute=e.getAttribLocation(n,"aColor"),this.aVertexPosition=e.getAttribLocation(n,"aVertexPosition"),this.aTextureCoord=e.getAttribLocation(n,"aTextureCoord"),this.translationMatrix=e.getUniformLocation(n,"translationMatrix"),this.alpha=e.getUniformLocation(n,"alpha"),this.program=n},t.PrimitiveShader=function(e){this.gl=e,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()},t.PrimitiveShader.prototype.init=function(){var e=this.gl,n=t.compileProgram(e,this.vertexSrc,this.fragmentSrc);e.useProgram(n),this.projectionVector=e.getUniformLocation(n,"projectionVector"),this.offsetVector=e.getUniformLocation(n,"offsetVector"),this.tintColor=e.getUniformLocation(n,"tint"),this.aVertexPosition=e.getAttribLocation(n,"aVertexPosition"),this.colorAttribute=e.getAttribLocation(n,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=e.getUniformLocation(n,"translationMatrix"),this.alpha=e.getUniformLocation(n,"alpha"),this.program=n},t.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},t.WebGLGraphics=function(){},t.WebGLGraphics.renderGraphics=function(e,n){var r=n.gl,i=n.projection,s=n.offset,o=n.shaderManager.primitiveShader;e._webGL[r.id]||(e._webGL[r.id]={points:[],indices:[],lastIndex:0,buffer:r.createBuffer(),indexBuffer:r.createBuffer()});var u=e._webGL[r.id];e.dirty&&(e.dirty=!1,e.clearDirty&&(e.clearDirty=!1,u.lastIndex=0,u.points=[],u.indices=[]),t.WebGLGraphics.updateGraphics(e,r)),n.shaderManager.activatePrimitiveShader(),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.uniformMatrix3fv(o.translationMatrix,!1,e.worldTransform.toArray(!0)),r.uniform2f(o.projectionVector,i.x,-i.y),r.uniform2f(o.offsetVector,-s.x,-s.y),r.uniform3fv(o.tintColor,t.hex2rgb(e.tint)),r.uniform1f(o.alpha,e.worldAlpha),r.bindBuffer(r.ARRAY_BUFFER,u.buffer),r.vertexAttribPointer(o.aVertexPosition,2,r.FLOAT,!1,24,0),r.vertexAttribPointer(o.colorAttribute,4,r.FLOAT,!1,24,8),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,u.indexBuffer),r.drawElements(r.TRIANGLE_STRIP,u.indices.length,r.UNSIGNED_SHORT,0),n.shaderManager.deactivatePrimitiveShader()},t.WebGLGraphics.updateGraphics=function(e,n){var r=e._webGL[n.id];for(var i=r.lastIndex;i3&&t.WebGLGraphics.buildPoly(s,r),s.lineWidth>0&&t.WebGLGraphics.buildLine(s,r)):s.type===t.Graphics.RECT?t.WebGLGraphics.buildRectangle(s,r):(s.type===t.Graphics.CIRC||s.type===t.Graphics.ELIP)&&t.WebGLGraphics.buildCircle(s,r)}r.lastIndex=e.graphicsData.length,r.glPoints=new Float32Array(r.points),n.bindBuffer(n.ARRAY_BUFFER,r.buffer),n.bufferData(n.ARRAY_BUFFER,r.glPoints,n.STATIC_DRAW),r.glIndicies=new Uint16Array(r.indices),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,r.indexBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,r.glIndicies,n.STATIC_DRAW)},t.WebGLGraphics.buildRectangle=function(e,n){var r=e.points,i=r[0],s=r[1],o=r[2],u=r[3];if(e.fill){var a=t.hex2rgb(e.fillColor),f=e.fillAlpha,l=a[0]*f,c=a[1]*f,h=a[2]*f,p=n.points,d=n.indices,v=p.length/6;p.push(i,s),p.push(l,c,h,f),p.push(i+o,s),p.push(l,c,h,f),p.push(i,s+u),p.push(l,c,h,f),p.push(i+o,s+u),p.push(l,c,h,f),d.push(v,v,v+1,v+2,v+3,v+3)}if(e.lineWidth){var m=e.points;e.points=[i,s,i+o,s,i+o,s+u,i,s+u,i,s],t.WebGLGraphics.buildLine(e,n),e.points=m}},t.WebGLGraphics.buildCircle=function(e,n){var r=e.points,i=r[0],s=r[1],o=r[2],u=r[3],a=40,f=Math.PI*2/a,l=0;if(e.fill){var c=t.hex2rgb(e.fillColor),h=e.fillAlpha,p=c[0]*h,d=c[1]*h,v=c[2]*h,m=n.points,g=n.indices,y=m.length/6;g.push(y);for(l=0;l19600?(_=L-O,D=A-M,U=Math.sqrt(_*_+D*D),_/=U,D/=U,_*=d,D*=d,f.push(T-_,N-D),f.push(g,y,b,m),f.push(T+_,N+D),f.push(g,y,b,m),f.push(T-_,N-D),f.push(g,y,b,m),h++):(f.push(w,E),f.push(g,y,b,m),f.push(T-(w-T),N-(E-N)),f.push(g,y,b,m))}S=i[(c-2)*2],x=i[(c-2)*2+1],T=i[(c-1)*2],N=i[(c-1)*2+1],L=-(x-N),A=S-T,U=Math.sqrt(L*L+A*A),L/=U,A/=U,L*=d,A*=d,f.push(T-L,N-A),f.push(g,y,b,m),f.push(T+L,N+A),f.push(g,y,b,m),l.push(p);for(r=0;r=0;n--){var r=e._glTextures[n],i=t.glContexts[n];i&&r&&i.deleteTexture(r)}e._glTextures.length=0},t.WebGLRenderer.updateTextureFrame=function(e){e.updateFrame=!1,e._updateWebGLuvs()},t.WebGLRenderer.prototype.resize=function(e,t){this.width=e,this.height=t,this.view.width=e,this.view.height=t,this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2,this.projection.y=-this.height/2},t.createWebGLTexture=function(e,n){return e.hasLoaded&&(e._glTextures[n.id]=n.createTexture(),n.bindTexture(n.TEXTURE_2D,e._glTextures[n.id]),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e.source),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e.scaleMode===t.scaleModes.LINEAR?n.LINEAR:n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e.scaleMode===t.scaleModes.LINEAR?n.LINEAR:n.NEAREST),e._powerOf2?(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT)):(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)),n.bindTexture(n.TEXTURE_2D,null)),e._glTextures[n.id]},t.updateWebGLTexture=function(e,n){e._glTextures[n.id]&&(n.bindTexture(n.TEXTURE_2D,e._glTextures[n.id]),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e.source),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e.scaleMode===t.scaleModes.LINEAR?n.LINEAR:n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e.scaleMode===t.scaleModes.LINEAR?n.LINEAR:n.NEAREST),e._powerOf2?(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT)):(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)),n.bindTexture(n.TEXTURE_2D,null))},t.WebGLRenderer.prototype.handleContextLost=function(e){e.preventDefault(),this.contextLost=!0},t.WebGLRenderer.prototype.handleContextRestored=function(){try{this.gl=this.view.getContext("experimental-webgl",this.options)}catch(e){try{this.gl=this.view.getContext("webgl",this.options)}catch(n){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}}var r=this.gl;r.id=t.WebGLRenderer.glContextId++,this.shaderManager.setContext(r),this.spriteBatch.setContext(r),this.maskManager.setContext(r),this.filterManager.setContext(r),this.renderSession.gl=this.gl,r.disable(r.DEPTH_TEST),r.disable(r.CULL_FACE),r.enable(r.BLEND),r.colorMask(!0,!0,!0,this.transparent),this.gl.viewport(0,0,this.width,this.height);for(var i in t.TextureCache){var s=t.TextureCache[i].baseTexture;s._glTextures=[]}this.contextLost=!1},t.WebGLRenderer.prototype.destroy=function(){this.view.removeEventListener("webglcontextlost",this.contextLost),this.view.removeEventListener("webglcontextrestored",this.contextRestoredLost),t.glContexts[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.maskManager.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.maskManager=null,this.filterManager=null,this.gl=null,this.renderSession=null},t.WebGLRenderer.glContextId=0,t.WebGLMaskManager=function(e){this.maskStack=[],this.maskPosition=0,this.setContext(e)},t.WebGLMaskManager.prototype.setContext=function(e){this.gl=e},t.WebGLMaskManager.prototype.pushMask=function(e,n){var r=this.gl;this.maskStack.length===0&&(r.enable(r.STENCIL_TEST),r.stencilFunc(r.ALWAYS,1,1)),this.maskStack.push(e),r.colorMask(!1,!1,!1,!0),r.stencilOp(r.KEEP,r.KEEP,r.INCR),t.WebGLGraphics.renderGraphics(e,n),r.colorMask(!0,!0,!0,!0),r.stencilFunc(r.NOTEQUAL,0,this.maskStack.length),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)},t.WebGLMaskManager.prototype.popMask=function(e){var n=this.gl,r=this.maskStack.pop();r&&(n.colorMask(!1,!1,!1,!1),n.stencilOp(n.KEEP,n.KEEP,n.DECR),t.WebGLGraphics.renderGraphics(r,e),n.colorMask(!0,!0,!0,!0),n.stencilFunc(n.NOTEQUAL,0,this.maskStack.length),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)),this.maskStack.length===0&&n.disable(n.STENCIL_TEST)},t.WebGLMaskManager.prototype.destroy=function(){this.maskStack=null,this.gl=null},t.WebGLShaderManager=function(e){this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var t=0;t=this.size)this.flush(),this.currentBaseTexture=e.texture.baseTexture;e.blendMode!==this.currentBlendMode&&this.setBlendMode(e.blendMode);var t=e._uvs||e.texture._uvs;if(!t)return;var n=e.worldAlpha,r=e.tint,i=this.vertices,s=e.texture.frame.width,o=e.texture.frame.height,u=e.anchor.x,a=e.anchor.y,f,l,c,h;if(e.texture.trim){var p=e.texture.trim;l=p.x-u*p.width,f=l+s,h=p.y-a*p.height,c=h+o}else f=s*(1-u),l=s*-u,c=o*(1-a),h=o*-a;var d=this.currentBatchSize*4*this.vertSize,v=e.worldTransform,m=v.a,g=v.c,y=v.b,b=v.d,w=v.tx,E=v.ty;i[d++]=m*l+y*h+w,i[d++]=b*h+g*l+E,i[d++]=t.x0,i[d++]=t.y0,i[d++]=n,i[d++]=r,i[d++]=m*f+y*h+w,i[d++]=b*h+g*f+E,i[d++]=t.x1,i[d++]=t.y1,i[d++]=n,i[d++]=r,i[d++]=m*f+y*c+w,i[d++]=b*c+g*f+E,i[d++]=t.x2,i[d++]=t.y2,i[d++]=n,i[d++]=r,i[d++]=m*l+y*c+w,i[d++]=b*c+g*l+E,i[d++]=t.x3,i[d++]=t.y3,i[d++]=n,i[d++]=r,this.currentBatchSize++},t.WebGLSpriteBatch.prototype.renderTilingSprite=function(e){var n=e.tilingTexture;if(n.baseTexture!==this.currentBaseTexture||this.currentBatchSize>=this.size)this.flush(),this.currentBaseTexture=n.baseTexture;e.blendMode!==this.currentBlendMode&&this.setBlendMode(e.blendMode),e._uvs||(e._uvs=new t.TextureUvs);var r=e._uvs;e.tilePosition.x%=n.baseTexture.width,e.tilePosition.y%=n.baseTexture.height;var i=e.tilePosition.x/n.baseTexture.width,s=e.tilePosition.y/n.baseTexture.height,o=e.width/n.baseTexture.width/(e.tileScale.x*e.tileScaleOffset.x),u=e.height/n.baseTexture.height/(e.tileScale.y*e.tileScaleOffset.y);r.x0=0-i,r.y0=0-s,r.x1=1*o-i,r.y1=0-s,r.x2=1*o-i,r.y2=1*u-s,r.x3=0-i,r.y3=1*u-s;var a=e.worldAlpha,f=e.tint,l=this.vertices,c=e.width,h=e.height,p=e.anchor.x,d=e.anchor.y,v=c*(1-p),m=c*-p,g=h*(1-d),y=h*-d,b=this.currentBatchSize*4*this.vertSize,w=e.worldTransform,E=w.a,S=w.c,x=w.b,T=w.d,N=w.tx,C=w.ty;l[b++]=E*m+x*y+N,l[b++]=T*y+S*m+C,l[b++]=r.x0,l[b++]=r.y0,l[b++]=a,l[b++]=f,l[b++]=E*v+x*y+N,l[b++]=T*y+S*v+C,l[b++]=r.x1,l[b++]=r.y1,l[b++]=a,l[b++]=f,l[b++]=E*v+x*g+N,l[b++]=T*g+S*v+C,l[b++]=r.x2,l[b++]=r.y2,l[b++]=a,l[b++]=f,l[b++]=E*m+x*g+N,l[b++]=T*g+S*m+C,l[b++]=r.x3,l[b++]=r.y3,l[b++]=a,l[b++]=f,this.currentBatchSize++},t.WebGLSpriteBatch.prototype.flush=function(){if(this.currentBatchSize===0)return;var e=this.gl;e.bindTexture(e.TEXTURE_2D,this.currentBaseTexture._glTextures[e.id]||t.createWebGLTexture(this.currentBaseTexture,e));if(this.currentBatchSize>this.size*.5)e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices);else{var n=this.vertices.subarray(0,this.currentBatchSize*4*this.vertSize);e.bufferSubData(e.ARRAY_BUFFER,0,n)}e.drawElements(e.TRIANGLES,this.currentBatchSize*6,e.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++},t.WebGLSpriteBatch.prototype.stop=function(){this.flush()},t.WebGLSpriteBatch.prototype.start=function(){var e=this.gl;e.activeTexture(e.TEXTURE0),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var n=this.renderSession.projection;e.uniform2f(this.shader.projectionVector,n.x,n.y);var r=this.vertSize*4;e.vertexAttribPointer(this.shader.aVertexPosition,2,e.FLOAT,!1,r,0),e.vertexAttribPointer(this.shader.aTextureCoord,2,e.FLOAT,!1,r,8),e.vertexAttribPointer(this.shader.colorAttribute,2,e.FLOAT,!1,r,16),this.currentBlendMode!==t.blendModes.NORMAL&&this.setBlendMode(t.blendModes.NORMAL)},t.WebGLSpriteBatch.prototype.setBlendMode=function(e){this.flush(),this.currentBlendMode=e;var n=t.blendModesWebGL[this.currentBlendMode];this.gl.blendFunc(n[0],n[1])},t.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},t.WebGLFastSpriteBatch=function(e){this.vertSize=10,this.maxSize=6e3,this.size=this.maxSize;var t=this.size*4*this.vertSize,n=this.maxSize*6;this.vertices=new Float32Array(t),this.indices=new Uint16Array(n),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var r=0,i=0;r=this.size&&this.flush()},t.WebGLFastSpriteBatch.prototype.flush=function(){if(this.currentBatchSize===0)return;var e=this.gl;this.currentBaseTexture._glTextures[e.id]||t.createWebGLTexture(this.currentBaseTexture,e),e.bindTexture(e.TEXTURE_2D,this.currentBaseTexture._glTextures[e.id]);if(this.currentBatchSize>this.size*.5)e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices);else{var n=this.vertices.subarray(0,this.currentBatchSize*4*this.vertSize);e.bufferSubData(e.ARRAY_BUFFER,0,n)}e.drawElements(e.TRIANGLES,this.currentBatchSize*6,e.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++},t.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},t.WebGLFastSpriteBatch.prototype.start=function(){var e=this.gl;e.activeTexture(e.TEXTURE0),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var n=this.renderSession.projection;e.uniform2f(this.shader.projectionVector,n.x,n.y),e.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var r=this.vertSize*4;e.vertexAttribPointer(this.shader.aVertexPosition,2,e.FLOAT,!1,r,0),e.vertexAttribPointer(this.shader.aPositionCoord,2,e.FLOAT,!1,r,8),e.vertexAttribPointer(this.shader.aScale,2,e.FLOAT,!1,r,16),e.vertexAttribPointer(this.shader.aRotation,1,e.FLOAT,!1,r,24),e.vertexAttribPointer(this.shader.aTextureCoord,2,e.FLOAT,!1,r,28),e.vertexAttribPointer(this.shader.colorAttribute,1,e.FLOAT,!1,r,36),this.currentBlendMode!==t.blendModes.NORMAL&&this.setBlendMode(t.blendModes.NORMAL)},t.WebGLFastSpriteBatch.prototype.setBlendMode=function(e){this.flush(),this.currentBlendMode=e;var n=t.blendModesWebGL[this.currentBlendMode];this.gl.blendFunc(n[0],n[1])},t.WebGLFilterManager=function(e,t){this.transparent=t,this.filterStack=[],this.offsetX=0,this.offsetY=0,this.setContext(e)},t.WebGLFilterManager.prototype.setContext=function(e){this.gl=e,this.texturePool=[],this.initShaderBuffers()},t.WebGLFilterManager.prototype.begin=function(e,t){this.renderSession=e,this.defaultShader=e.shaderManager.defaultShader;var n=this.renderSession.projection;this.width=n.x*2,this.height=-n.y*2,this.buffer=t},t.WebGLFilterManager.prototype.pushFilter=function(e){var n=this.gl,r=this.renderSession.projection,i=this.renderSession.offset;this.filterStack.push(e);var s=e.filterPasses[0];this.offsetX+=e.target.filterArea.x,this.offsetY+=e.target.filterArea.y;var o=this.texturePool.pop();o?o.resize(this.width,this.height):o=new t.FilterTexture(this.gl,this.width,this.height),n.bindTexture(n.TEXTURE_2D,o.texture),e.target.filterArea=e.target.getBounds();var u=e.target.filterArea,a=s.padding;u.x-=a,u.y-=a,u.width+=a*2,u.height+=a*2,u.x<0&&(u.x=0),u.width>this.width&&(u.width=this.width),u.y<0&&(u.y=0),u.height>this.height&&(u.height=this.height),n.bindFramebuffer(n.FRAMEBUFFER,o.frameBuffer),n.viewport(0,0,u.width,u.height),r.x=u.width/2,r.y=-u.height/2,i.x=-u.x,i.y=-u.y,n.uniform2f(this.defaultShader.projectionVector,u.width/2,-u.height/2),n.uniform2f(this.defaultShader.offsetVector,-u.x,-u.y),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),e._glFilterTexture=o},t.WebGLFilterManager.prototype.popFilter=function(){var e=this.gl,n=this.filterStack.pop(),r=n.target.filterArea,i=n._glFilterTexture,s=this.renderSession.projection,o=this.renderSession.offset;if(n.filterPasses.length>1){e.viewport(0,0,r.width,r.height),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=r.height,this.vertexArray[2]=r.width,this.vertexArray[3]=r.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=r.width,this.vertexArray[7]=0,e.bufferSubData(e.ARRAY_BUFFER,0,this.vertexArray),e.bindBuffer(e.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=r.width/this.width,this.uvArray[5]=r.height/this.height,this.uvArray[6]=r.width/this.width,this.uvArray[7]=r.height/this.height,e.bufferSubData(e.ARRAY_BUFFER,0,this.uvArray);var u=i,a=this.texturePool.pop();a||(a=new t.FilterTexture(this.gl,this.width,this.height)),e.bindFramebuffer(e.FRAMEBUFFER,a.frameBuffer),e.clear(e.COLOR_BUFFER_BIT),e.disable(e.BLEND);for(var f=0;f0&&(t.Texture.frameUpdates.length=0)},t.CanvasRenderer.prototype.resize=function(e,t){this.width=e,this.height=t,this.view.width=e,this.view.height=t},t.CanvasRenderer.prototype.renderDisplayObject=function(e,t){this.renderSession.context=t||this.context,e._renderCanvas(this.renderSession)},t.CanvasRenderer.prototype.renderStripFlat=function(e){var t=this.context,n=e.verticies,r=n.length/2;this.count++,t.beginPath();for(var i=1;i1&&(r=1,window.console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));for(var i=0;i<1;i++){var s=e.graphicsData[i],o=s.points;if(s.type===t.Graphics.POLY){n.beginPath(),n.moveTo(o[0],o[1]);for(var u=1;uw?h:w,w=d>w?d:w,w=m>w?m:w,w=y>w?y:w,E=p>E?p:E,E=v>E?v:E,E=g>E?g:E,E=b>E?b:E;var T=this._bounds;return T.x=S,T.width=w-S,T.y=x,T.height=E-x,T},t.Graphics.prototype.updateBounds=function(){var e=Infinity,n=-Infinity,r=Infinity,i=-Infinity,s,o,u,a,f;for(var l=0;ln?o+a:n,r=ui?u+f:i;else if(h===t.Graphics.CIRC||h===t.Graphics.ELIP)o=s[0],u=s[1],a=s[2]+p/2,f=s[3]+p/2,e=o-an?o+a:n,r=u-fi?u+f:i;else for(var d=0;dn?o+p:n,r=u-pi?u+p:i}var v=this.boundsPadding;this.bounds=new t.Rectangle(e-v,r-v,n-e+v*2,i-r+v*2)},t.Graphics.prototype._generateCachedSprite=function(){var e=this.getLocalBounds();if(!this._cachedSprite){var n=new t.CanvasBuffer(e.width,e.height),r=t.Texture.fromCanvas(n.canvas);this._cachedSprite=new t.Sprite(r),this._cachedSprite.buffer=n,this._cachedSprite.worldTransform=this.worldTransform}else this._cachedSprite.buffer.resize(e.width,e.height);this._cachedSprite.anchor.x=-(e.x/e.width),this._cachedSprite.anchor.y=-(e.y/e.height),this._cachedSprite.buffer.context.translate(-e.x,-e.y),t.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context)},t.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},t.Graphics.POLY=0,t.Graphics.RECT=1,t.Graphics.CIRC=2,t.Graphics.ELIP=3,t.Strip=function(e,n,r){t.DisplayObjectContainer.call(this),this.texture=e,this.blendMode=t.blendModes.NORMAL;try{this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.verticies=new Float32Array([0,0,0,0,0,0,0,0,0]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3])}catch(i){this.uvs=[0,1,1,1,1,0,0,1],this.verticies=[0,0,0,0,0,0,0,0,0],this.colors=[1,1,1,1],this.indices=[0,1,2,3]}this.width=n,this.height=r,e.baseTexture.hasLoaded?(this.width=this.texture.frame.width,this.height=this.texture.frame.height,this.updateFrame=!0):(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},t.Strip.prototype=Object.create(t.DisplayObjectContainer.prototype),t.Strip.prototype.constructor=t.Strip,t.Strip.prototype.setTexture=function(e){this.texture=e,this.width=e.frame.width,this.height=e.frame.height,this.updateFrame=!0},t.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},t.Rope=function(e,n){t.Strip.call(this,e),this.points=n;try{this.verticies=new Float32Array(n.length*4),this.uvs=new Float32Array(n.length*4),this.colors=new Float32Array(n.length*2),this.indices=new Uint16Array(n.length*2)}catch(r){this.verticies=new Array(n.length*4),this.uvs=new Array(n.length*4),this.colors=new Array(n.length*2),this.indices=new Array(n.length*2)}this.refresh()},t.Rope.prototype=Object.create(t.Strip.prototype),t.Rope.prototype.constructor=t.Rope,t.Rope.prototype.refresh=function(){var e=this.points;if(e.length<1)return;var t=this.uvs,n=e[0],r=this.indices,i=this.colors;this.count-=.2,t[0]=0,t[1]=1,t[2]=0,t[3]=1,i[0]=1,i[1]=1,r[0]=0,r[1]=1;var s=e.length,o,u,a;for(var f=1;f1&&(f=1),l=Math.sqrt(i.x*i.x+i.y*i.y),c=this.texture.height/2,i.x/=l,i.y/=l,i.x*=c,i.y*=c,s[a]=u.x+i.x,s[a+1]=u.y+i.y,s[a+2]=u.x-i.x,s[a+3]=u.y-i.y,n=u;t.DisplayObjectContainer.prototype.updateTransform.call(this)},t.Rope.prototype.setTexture=function(e){this.texture=e,this.updateFrame=!0},t.TilingSprite=function(e,n,r){t.Sprite.call(this,e),this.width=n||100,this.height=r||100,this.tileScale=new t.Point(1,1),this.tileScaleOffset=new t.Point(1,1),this.tilePosition=new t.Point(0,0),this.renderable=!0,this.tint=16777215,this.blendMode=t.blendModes.NORMAL},t.TilingSprite.prototype=Object.create(t.Sprite.prototype),t.TilingSprite.prototype.constructor=t.TilingSprite,Object.defineProperty(t.TilingSprite.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(t.TilingSprite.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),t.TilingSprite.prototype.onTextureUpdate=function(){this.updateFrame=!0},t.TilingSprite.prototype._renderWebGL=function(e){if(this.visible===!1||this.alpha===0)return;var t,n;if(this.mask||this.filters){this.mask&&(e.spriteBatch.stop(),e.maskManager.pushMask(this.mask,e),e.spriteBatch.start()),this.filters&&(e.spriteBatch.flush(),e.filterManager.pushFilter(this._filterBlock)),this.tilingTexture?e.spriteBatch.renderTilingSprite(this):this.generateTilingTexture(!0);for(t=0,n=this.children.length;tE?p:E,E=v>E?v:E,E=g>E?g:E,E=b>E?b:E,S=d>S?d:S,S=m>S?m:S,S=y>S?y:S,S=w>S?w:S;var N=this._bounds;return N.x=x,N.width=E-x,N.y=T,N.height=S-T,this._currentBounds=N,N},t.TilingSprite.prototype.generateTilingTexture=function(e){var n=this.texture;if(!n.baseTexture.hasLoaded)return;var r=n.baseTexture,i=n.frame,s,o,u=i.width!==r.width||i.height!==r.height;this.tilingTexture=n;var a=!1;e?(s=t.getNextPowerOfTwo(n.frame.width),o=t.getNextPowerOfTwo(n.frame.height),i.width!==s&&i.height!==o&&(a=!0)):u&&(s=i.width,o=i.height,a=!0);if(a){var f=new t.CanvasBuffer(s,o);f.context.drawImage(n.baseTexture.source,i.x,i.y,i.width,i.height,0,0,s,o),this.tilingTexture=t.Texture.fromCanvas(f.canvas),this.tileScaleOffset.x=i.width/s,this.tileScaleOffset.y=i.height/o}this.tilingTexture.baseTexture._powerOf2=!0};var o={};o.BoneData=function(e,t){this.name=e,this.parent=t},o.BoneData.prototype={length:0,x:0,y:0,rotation:0,scaleX:1,scaleY:1},o.SlotData=function(e,t){this.name=e,this.boneData=t},o.SlotData.prototype={r:1,g:1,b:1,a:1,attachmentName:null},o.Bone=function(e,t){this.data=e,this.parent=t,this.setToSetupPose()},o.Bone.yDown=!1,o.Bone.prototype={x:0,y:0,rotation:0,scaleX:1,scaleY:1,m00:0,m01:0,worldX:0,m10:0,m11:0,worldY:0,worldRotation:0,worldScaleX:1,worldScaleY:1,updateWorldTransform:function(e,t){var n=this.parent;n!=null?(this.worldX=this.x*n.m00+this.y*n.m01+n.worldX,this.worldY=this.x*n.m10+this.y*n.m11+n.worldY,this.worldScaleX=n.worldScaleX*this.scaleX,this.worldScaleY=n.worldScaleY*this.scaleY,this.worldRotation=n.worldRotation+this.rotation):(this.worldX=this.x,this.worldY=this.y,this.worldScaleX=this.scaleX,this.worldScaleY=this.scaleY,this.worldRotation=this.rotation);var r=this.worldRotation*Math.PI/180,i=Math.cos(r),s=Math.sin(r);this.m00=i*this.worldScaleX,this.m10=s*this.worldScaleX,this.m01=-s*this.worldScaleY,this.m11=i*this.worldScaleY,e&&(this.m00=-this.m00,this.m01=-this.m01),t&&(this.m10=-this.m10,this.m11=-this.m11),o.Bone.yDown&&(this.m10=-this.m10,this.m11=-this.m11)},setToSetupPose:function(){var e=this.data;this.x=e.x,this.y=e.y,this.rotation=e.rotation,this.scaleX=e.scaleX,this.scaleY=e.scaleY}},o.Slot=function(e,t,n){this.data=e,this.skeleton=t,this.bone=n,this.setToSetupPose()},o.Slot.prototype={r:1,g:1,b:1,a:1,_attachmentTime:0,attachment:null,setAttachment:function(e){this.attachment=e,this._attachmentTime=this.skeleton.time},setAttachmentTime:function(e){this._attachmentTime=this.skeleton.time-e},getAttachmentTime:function(){return this.skeleton.time-this._attachmentTime},setToSetupPose:function(){var e=this.data;this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a;var t=this.skeleton.data.slots;for(var n=0,r=t.length;n>>1;for(;;){e[(s+1)*n]<=t?r=s+1:i=s;if(r==i)return(r+1)*n;s=r+i>>>1}},o.linearSearch=function(e,t,n){for(var r=0,i=e.length-n;r<=i;r+=n)if(e[r]>t)return r;return-1},o.Curves=function(e){this.curves=[],this.curves.length=(e-1)*6},o.Curves.prototype={setLinear:function(e){this.curves[e*6]=0},setStepped:function(e){this.curves[e*6]=-1},setCurve:function(e,t,n,r,i){var s=.1,o=s*s,u=o*s,a=3*s,f=3*o,l=6*o,c=6*u,h=-t*2+r,p=-n*2+i,d=(t-r)*3+1,v=(n-i)*3+1,m=e*6,g=this.curves;g[m]=t*a+h*f+d*u,g[m+1]=n*a+p*f+v*u,g[m+2]=h*l+d*c,g[m+3]=p*l+v*c,g[m+4]=d*c,g[m+5]=v*c},getCurvePercent:function(e,t){t=t<0?0:t>1?1:t;var n=e*6,r=this.curves,i=r[n];if(!i)return t;if(i==-1)return 0;var s=r[n+1],o=r[n+2],u=r[n+3],a=r[n+4],f=r[n+5],l=i,c=s,h=8;for(;;){if(l>=t){var p=l-i,d=c-s;return d+(c-d)*(t-p)/(l-p)}if(!h)break;h--,i+=o,s+=u,o+=a,u+=f,l+=i,c+=s}return c+(1-c)*(t-l)/(1-l)}},o.RotateTimeline=function(e){this.curves=new o.Curves(e),this.frames=[],this.frames.length=e*2},o.RotateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(e,t,n){e*=2,this.frames[e]=t,this.frames[e+1]=n},apply:function(e,t,n){var r=this.frames,i;if(t=r[r.length-2]){i=s.data.rotation+r[r.length-1]-s.rotation;while(i>180)i-=360;while(i<-180)i+=360;s.rotation+=i*n;return}var u=o.binarySearch(r,t,2),a=r[u-1],f=r[u],l=1-(t-f)/(r[u-2]-f);l=this.curves.getCurvePercent(u/2-1,l),i=r[u+1]-a;while(i>180)i-=360;while(i<-180)i+=360;i=s.data.rotation+(a+i*l)-s.rotation;while(i>180)i-=360;while(i<-180)i+=360;s.rotation+=i*n}},o.TranslateTimeline=function(e){this.curves=new o.Curves(e),this.frames=[],this.frames.length=e*3},o.TranslateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(e,t,n,r){e*=3,this.frames[e]=t,this.frames[e+1]=n,this.frames[e+2]=r},apply:function(e,t,n){var r=this.frames;if(t=r[r.length-3]){i.x+=(i.data.x+r[r.length-2]-i.x)*n,i.y+=(i.data.y+r[r.length-1]-i.y)*n;return}var s=o.binarySearch(r,t,3),u=r[s-2],a=r[s-1],f=r[s],l=1-(t-f)/(r[s+ -3]-f);l=this.curves.getCurvePercent(s/3-1,l),i.x+=(i.data.x+u+(r[s+1]-u)*l-i.x)*n,i.y+=(i.data.y+a+(r[s+2]-a)*l-i.y)*n}},o.ScaleTimeline=function(e){this.curves=new o.Curves(e),this.frames=[],this.frames.length=e*3},o.ScaleTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(e,t,n,r){e*=3,this.frames[e]=t,this.frames[e+1]=n,this.frames[e+2]=r},apply:function(e,t,n){var r=this.frames;if(t=r[r.length-3]){i.scaleX+=(i.data.scaleX-1+r[r.length-2]-i.scaleX)*n,i.scaleY+=(i.data.scaleY-1+r[r.length-1]-i.scaleY)*n;return}var s=o.binarySearch(r,t,3),u=r[s-2],a=r[s-1],f=r[s],l=1-(t-f)/(r[s+ -3]-f);l=this.curves.getCurvePercent(s/3-1,l),i.scaleX+=(i.data.scaleX-1+u+(r[s+1]-u)*l-i.scaleX)*n,i.scaleY+=(i.data.scaleY-1+a+(r[s+2]-a)*l-i.scaleY)*n}},o.ColorTimeline=function(e){this.curves=new o.Curves(e),this.frames=[],this.frames.length=e*5},o.ColorTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(e,t,n,i){e*=5,this.frames[e]=t,this.frames[e+1]=r,this.frames[e+2]=g,this.frames[e+3]=b,this.frames[e+4]=a},apply:function(e,t,n){var r=this.frames;if(t=r[r.length-5]){var s=r.length-1;i.r=r[s-3],i.g=r[s-2],i.b=r[s-1],i.a=r[s];return}var u=o.binarySearch(r,t,5),a=r[u-4],f=r[u-3],l=r[u-2],c=r[u-1],h=r[u],p=1-(t-h)/(r[u-5]-h);p=this.curves.getCurvePercent(u/5-1,p);var d=a+(r[u+1]-a)*p,v=f+(r[u+2]-f)*p,m=l+(r[u+3]-l)*p,g=c+(r[u+4]-c)*p;n<1?(i.r+=(d-i.r)*n,i.g+=(v-i.g)*n,i.b+=(m-i.b)*n,i.a+=(g-i.a)*n):(i.r=d,i.g=v,i.b=m,i.a=g)}},o.AttachmentTimeline=function(e){this.curves=new o.Curves(e),this.frames=[],this.frames.length=e,this.attachmentNames=[],this.attachmentNames.length=e},o.AttachmentTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length},setFrame:function(e,t,n){this.frames[e]=t,this.attachmentNames[e]=n},apply:function(e,t,n){var r=this.frames;if(t=r[r.length-1]?i=r.length-1:i=o.binarySearch(r,t,1)-1;var s=this.attachmentNames[i];e.slots[this.slotIndex].setAttachment(s?e.getAttachmentBySlotIndex(this.slotIndex,s):null)}},o.SkeletonData=function(){this.bones=[],this.slots=[],this.skins=[],this.animations=[]},o.SkeletonData.prototype={defaultSkin:null,findBone:function(e){var t=this.bones;for(var n=0,r=t.length;n0){var t=this.queue[0];this.currentTime>=t.delay&&(this._setAnimation(t.animation,t.loop),this.queue.shift())}},apply:function(e){if(!this.current)return;if(this.previous){this.previous.apply(e,this.previousTime,this.previousLoop);var t=this.mixTime/this.mixDuration;t>=1&&(t=1,this.previous=null),this.current.mix(e,this.currentTime,this.currentLoop,t)}else this.current.apply(e,this.currentTime,this.currentLoop)},clearAnimation:function(){this.previous=null,this.current=null,this.queue.length=0},_setAnimation:function(e,t){this.previous=null,e&&this.current&&(this.mixDuration=this.data.getMix(this.current,e),this.mixDuration>0&&(this.mixTime=0,this.previous=this.current,this.previousTime=this.currentTime,this.previousLoop=this.currentLoop)),this.current=e,this.currentLoop=t,this.currentTime=0},setAnimationByName:function(e,t){var n=this.data.skeletonData.findAnimation(e);if(!n)throw"Animation not found: "+e;this.setAnimation(n,t)},setAnimation:function(e,t){this.queue.length=0,this._setAnimation(e,t)},addAnimationByName:function(e,t,n){var r=this.data.skeletonData.findAnimation(e);if(!r)throw"Animation not found: "+e;this.addAnimation(r,t,n)},addAnimation:function(e,t,n){var r={};r.animation=e,r.loop=t;if(!n||n<=0){var i=this.queue.length?this.queue[this.queue.length-1].animation:this.current;i!=null?n=i.duration-this.data.getMix(i,e)+(n||0):n=0}r.delay=n,this.queue.push(r)},isComplete:function(){return!this.current||this.currentTime>=this.current.duration}},o.SkeletonJson=function(e){this.attachmentLoader=e},o.SkeletonJson.prototype={scale:1,readSkeletonData:function(e){var t=new o.SkeletonData,n,r=e.bones;for(var i=0,s=r.length;i=this.lines.length?null:this.lines[this.index++]},readValue:function(){var e=this.readLine(),t=e.indexOf(":");if(t==-1)throw"Invalid line: "+e;return this.trim(e.substring(t+1))},readTuple:function(e){var t=this.readLine(),n=t.indexOf(":");if(n==-1)throw"Invalid line: "+t;var r=0,i=n+1;for(;r<3;r++){var s=t.indexOf(",",i);if(s==-1){if(!r)throw"Invalid line: "+t;break}e[r]=this.trim(t.substr(i,s-i)),i=s+1}return e[r]=this.trim(t.substring(i)),r+1}},o.AtlasAttachmentLoader=function(e){this.atlas=e},o.AtlasAttachmentLoader.prototype={newAttachment:function(e,t,n){switch(t){case o.AttachmentType.region:var r=this.atlas.findRegion(n);if(!r)throw"Region not found in atlas: "+n+" ("+t+")";var i=new o.RegionAttachment(n);return i.rendererObject=r,i.setUVs(r.u,r.v,r.u2,r.v2,r.rotate),i.regionOffsetX=r.offsetX,i.regionOffsetY=r.offsetY,i.regionWidth=r.width,i.regionHeight=r.height,i.regionOriginalWidth=r.originalWidth,i.regionOriginalHeight=r.originalHeight,i}throw"Unknown attachment type: "+t}},o.Bone.yDown=!0,t.AnimCache={},t.Spine=function(e){t.DisplayObjectContainer.call(this),this.spineData=t.AnimCache[e];if(!this.spineData)throw new Error("Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader: "+e);this.skeleton=new o.Skeleton(this.spineData),this.skeleton.updateWorldTransform(),this.stateData=new o.AnimationStateData(this.spineData),this.state=new o.AnimationState(this.stateData),this.slotContainers=[];for(var n=0,r=this.skeleton.drawOrder.length;nthis.baseTexture.width||e.y+e.height>this.baseTexture.height)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.updateFrame=!0,t.Texture.frameUpdates.push(this)},t.Texture.prototype._updateWebGLuvs=function(){this._uvs||(this._uvs=new t.TextureUvs);var e=this.frame,n=this.baseTexture.width,r=this.baseTexture.height;this._uvs.x0=e.x/n,this._uvs.y0=e.y/r,this._uvs.x1=(e.x+e.width)/n,this._uvs.y1=e.y/r,this._uvs.x2=(e.x+e.width)/n,this._uvs.y2=(e.y+e.height)/r,this._uvs.x3=e.x/n,this._uvs.y3=(e.y+e.height)/r},t.Texture.fromImage=function(e,n,r){var i=t.TextureCache[e];return i||(i=new t.Texture(t.BaseTexture.fromImage(e,n,r)),t.TextureCache[e]=i),i},t.Texture.fromFrame=function(e){var n=t.TextureCache[e];if(!n)throw new Error('The frameId "'+e+'" does not exist in the texture cache ');return n},t.Texture.fromCanvas=function(e,n){var r=t.BaseTexture.fromCanvas(e,n);return new t.Texture(r)},t.Texture.addTextureToCache=function(e,n){t.TextureCache[n]=e},t.Texture.removeTextureFromCache=function(e){var n=t.TextureCache[e];return t.TextureCache[e]=null,n},t.Texture.frameUpdates=[],t.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y4=0},t.RenderTexture=function(e,n,r){t.EventTarget.call(this),this.width=e||100,this.height=n||100,this.frame=new t.Rectangle(0,0,this.width,this.height),this.baseTexture=new t.BaseTexture,this.baseTexture.width=this.width,this.baseTexture.height=this.height,this.baseTexture._glTextures=[],this.baseTexture.hasLoaded=!0,this.renderer=r||t.defaultRenderer;if(this.renderer.type===t.WEBGL_RENDERER){var i=this.renderer.gl;this.textureBuffer=new t.FilterTexture(i,this.width,this.height),this.baseTexture._glTextures[i.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=new t.Point(this.width/2,-this.height/2)}else this.render=this.renderCanvas,this.textureBuffer=new t.CanvasBuffer(this.width,this.height),this.baseTexture.source=this.textureBuffer.canvas;t.Texture.frameUpdates.push(this)},t.RenderTexture.prototype=Object.create(t.Texture.prototype),t.RenderTexture.prototype.constructor=t.RenderTexture,t.RenderTexture.prototype.resize=function(e,n){this.width=e,this.height=n,this.frame.width=this.width,this.frame.height=this.height;if(this.renderer.type===t.WEBGL_RENDERER){this.projection.x=this.width/2,this.projection.y=-this.height/2;var r=this.renderer.gl;r.bindTexture(r.TEXTURE_2D,this.baseTexture._glTextures[r.id]),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,this.width,this.height,0,r.RGBA,r.UNSIGNED_BYTE,null)}else this.textureBuffer.resize(this.width,this.height);t.Texture.frameUpdates.push(this)},t.RenderTexture.prototype.renderWebGL=function(e,n,r){var i=this.renderer.gl;i.colorMask(!0,!0,!0,!0),i.viewport(0,0,this.width,this.height),i.bindFramebuffer(i.FRAMEBUFFER,this.textureBuffer.frameBuffer),r&&this.textureBuffer.clear();var s=e.children,o=e.worldTransform;e.worldTransform=t.RenderTexture.tempMatrix,e.worldTransform.d=-1,e.worldTransform.ty=this.projection.y*-2,n&&(e.worldTransform.tx=n.x,e.worldTransform.ty-=n.y);for(var u=0,a=s.length;u0){if(s===o)this.atlas.meta.image.push(e[o]),r=this.atlas.meta.image.length-1,this.atlas.frames.push({}),n=-3;else if(n>0)if(n%7===1)i!=null&&(this.atlas.frames[r][i.name]=i),i={name:e[o],frame:{}};else{var f=e[o].split(" ");if(n%7===3)i.frame.x=Number(f[1].replace(",","")),i.frame.y=Number(f[2]);else if(n%7===4)i.frame.w=Number(f[1].replace(",","")),i.frame.h=Number(f[2]);else if(n%7===5){var l={x:0,y:0,w:Number(f[1].replace(",","")),h:Number(f[2])};l.w>i.frame.w||l.h>i.frame.h?(i.trimmed=!0,i.realSize=l):i.trimmed=!1}}n++}}i!=null&&(this.atlas.frames[r][i.name]=i);if(this.atlas.meta.image.length>0){this.images=[];for(u=0;uthis.currentImageId?(this.currentImageId++,this.images[this.currentImageId].load()):(this.loaded=!0,this.dispatchEvent({type:"loaded",content:this}))},t.AtlasLoader.prototype.onError=function(){this.dispatchEvent({type:"error",content:this})},t.SpriteSheetLoader=function(e,n){t.EventTarget.call(this),this.url=e,this.crossorigin=n,this.baseUrl=e.replace(/[^\/]*$/,""),this.texture=null,this.frames={}},t.SpriteSheetLoader.prototype.constructor=t.SpriteSheetLoader,t.SpriteSheetLoader.prototype.load=function(){var e=this,n=new t.JsonLoader(this.url,this.crossorigin);n.addEventListener("loaded",function(t){e.json=t.content.json,e.onLoaded()}),n.load()},t.SpriteSheetLoader.prototype.onLoaded=function(){this.dispatchEvent({type:"loaded",content:this})},t.ImageLoader=function(e,n){t.EventTarget.call(this),this.texture=t.Texture.fromImage(e,n),this.frames=[]},t.ImageLoader.prototype.constructor=t.ImageLoader,t.ImageLoader.prototype.load=function(){if(!this.texture.baseTexture.hasLoaded){var e=this;this.texture.baseTexture.addEventListener("loaded",function(){e.onLoaded()})}else this.onLoaded()},t.ImageLoader.prototype.onLoaded=function(){this.dispatchEvent({type:"loaded",content:this})},t.ImageLoader.prototype.loadFramedSpriteSheet=function(e,n,r){this.frames=[];var i=Math.floor(this.texture.width/e),s=Math.floor(this.texture.height/n),o=0;for(var u=0;u=0;o--){var a=t.layers[o];a.z=o,a.layerId=r(a.name,o),a.name=="spawnpoints"&&(i=!0);if(!i)continue;this.setupLayer(a,!0,s),this.layerMapping[a.name]&&this.layerMapping[a.name](a),s=a.layerId}i=!1,s=u.ID.SPAWN;for(var o=0;o=r&&e=0},o.prototype.spawn=function(e,r){this.body.SetPosition(new t.Common.Math.b2Vec2(e/n.RATIO,r/n.RATIO)),this.body.SetActive(!0),this.setActionState("fall")},o.prototype.getHeadPosition=function(){var e=this.body.GetPosition();return{x:e.x,y:e.y-(this.height-this.headHeight/2)/n.RATIO}},o.prototype.setFriction=function(e){e||(e=-1),this.legs.GetFriction()!=e&&this.legs.SetFriction(e)},o.prototype.move=function(e){this.moveDirection=e;var r,i=this.holdingItem&&this.holdingItem.options.weight>n.MAX_RUNNING_WEIGHT;switch(!0){case e==this.lookDirection&&this.isStanding()&&!i:r=n.RUN_SPEED;break;case!this.isStanding():r=n.FLY_SPEED,i&&n.FLY_SPEED>n.WALK_SPEED&&(r=n.WALK_SPEED);break;default:r=n.WALK_SPEED}this.setFriction(n.PLAYER_MOTION_FRICTION),this.body.SetAwake(!0);var s=new t.Common.Math.b2Vec2(r*e,this.body.GetLinearVelocity().y);this.body.SetLinearVelocity(s),this.isStanding()&&(this.moveDirection==this.lookDirection?i?this.setActionState("walk"):this.setActionState("run"):this.setActionState("walkback"))},o.prototype.stop=function(){this.moveDirection=0,this.setFriction(n.PLAYER_FRICTION);if(this.isStanding())this.setActionState("stand");else{var e=this.body.GetLinearVelocity().Copy();e.x*=n.JUMP_STOP_DAMPING_FACTOR,this.body.SetLinearVelocity(e)}},o.prototype.jump=function(){if(this.isStanding()){this.body.SetAwake(!0);var e=new t.Common.Math.b2Vec2(0,-n.JUMP_SPEED);this.body.SetLinearVelocity(e),this.setStanding(!1),this.setActionState("jump")}},o.prototype.jumpStop=function(){if(!this.isStanding()){this.body.SetAwake(!0);var e=this.body.GetLinearVelocity().Copy();e.y<0&&(e.y*=n.JUMP_STOP_DAMPING_FACTOR,this.body.SetLinearVelocity(e))}},o.prototype.setStanding=function(e){if(this.standing==e)return;this.standing=e,e&&this.setActionState("stand")},o.prototype.isStanding=function(){return this.standing},o.prototype.lookAt=function(e,t){var n=this.lookDirection;this.body.SetAwake(!0),e<0?this.lookDirection=-1:this.lookDirection=1,this.lookAtXY.x=e,this.lookAtXY.y=t,n!=this.lookDirection&&this.positionHoldingItem()},o.prototype.grab=function(e){this.holdingItem=e,this.positionHoldingItem()},o.prototype.positionHoldingItem=function(){if(this.holdingItem){this.holdingJoint&&(this.body.GetWorld().DestroyJoint(this.holdingJoint),this.holdingJoint=null);var e=this.body.GetPosition(),r=new t.Common.Math.b2Vec2(e.x+this.width/2/n.RATIO*this.lookDirection,e.y-this.height/4*2/n.RATIO);this.holdingItem.reposition(r,this.lookDirection);var i=new t.Dynamics.Joints.b2WeldJointDef;i.Initialize(this.body,this.holdingItem.body,this.holdingItem.getGrabPoint()),this.holdingJoint=this.body.GetWorld().CreateJoint(i)}},o.prototype.throw=function(e,t,n){this.body.GetWorld().DestroyJoint(this.holdingJoint),this.holdingJoint=null,this.holdingItem=null,e.throw(t,n)},o.prototype.isAnotherPlayerNearby=function(){return this.nearbyDolls.length>0},o.prototype.onFootSensorDetection=function(e,t){var r=this,i=this.body.GetLinearVelocity().y<-n.JUMP_SPEED;if(e)i||this.setStanding(!0);else{var s=0,o=r.body.GetContactList();while(o){var u=o.contact;if(!u.IsTouching()){o=o.next;continue}u.GetFixtureA()===r.footSensor&&s++,u.GetFixtureB()===r.footSensor&&s++,o=o.next}s===0&&r.setStanding(!1)}},o.prototype.onImpact=function(e,t){},o.prototype.onFixtureWithinReach=function(e,t,n){var r=n.GetBody().GetUserData();if(!(r instanceof i))return;if(e)this.reachableItems[t].push(r);else{var s=this.reachableItems[t].indexOf(r);s>=0&&this.reachableItems[t].splice(s,1)}},o.prototype.getVelocities=function(){return{linearVelocity:this.body.GetLinearVelocity(),angularVelocity:this.body.GetAngularVelocity()}},o.prototype.update=function(){this.body.GetLinearVelocity().x==0&&this.isWalking()&&this.stop(),!this.body.IsAwake()&&!this.isStanding()&&this.setStanding(!0)},o.prototype.destroy=function(){e.prototype.destroy.call(this)},o}),define("Lib/Vendor/CryptoJS",[],function(){var e=e||function(e,t){var n={},r=n.lib={},i=r.Base=function(){function e(){}return{extend:function(t){e.prototype=this;var n=new e;return t&&n.mixIn(t),n.$super=this,n},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.$super.extend(this)}}}(),s=r.WordArray=i.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,e=e.sigBytes;this.clamp();if(r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-8*(i%4)&255)<<24-8*((r+i)%4);else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-8*(n%4),t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-8*(r%4)&255;n.push((i>>>4).toString(16)),n.push((i&15).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-4*(r%8);return s.create(n,t/2)}},a=o.Latin1={stringify:function(e){for(var t=e.words,e=e.sigBytes,n=[],r=0;r>>2]>>>24-8*(r%4)&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(e.charCodeAt(r)&255)<<24-8*(r%4);return s.create(n,t)}},f=o.Utf8={stringify:function(e){try{return decodeURIComponent(escape(a.stringify(e)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(e){return a.parse(unescape(encodeURIComponent(e)))}},l=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=s.create(),this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,u=i/(4*o),u=t?e.ceil(u):e.max((u|0)-this._minBufferSize,0),t=u*o,i=e.min(4*t,i);if(t){for(var a=0;a>>32-s)+t}function r(e,t,n,r,i,s,o){return e=e+(t&r|n&~r)+i+o,(e<>>32-s)+t}function i(e,t,n,r,i,s,o){return e=e+(t^n^r)+i+o,(e<>>32-s)+t}function s(e,t,n,r,i,s,o){return e=e+(n^(t|~r))+i+o,(e<>>32-s)+t}var o=e,u=o.lib,a=u.WordArray,u=u.Hasher,f=o.algo,l=[];(function(){for(var e=0;64>e;e++)l[e]=4294967296*t.abs(t.sin(e+1))|0})(),f=f.MD5=u.extend({_doReset:function(){this._hash=a.create([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var o=0;16>o;o++){var u=t+o,a=e[u];e[u]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360}for(var u=this._hash.words,a=u[0],f=u[1],c=u[2],p=u[3],o=0;64>o;o+=4)16>o?(a=n(a,f,c,p,e[t+o],7,l[o]),p=n(p,a,f,c,e[t+o+1],12,l[o+1]),c=n(c,p,a,f,e[t+o+2],17,l[o+2]),f=n(f,c,p,a,e[t+o+3],22,l[o+3])):32>o?(a=r(a,f,c,p,e[t+(o+1)%16],5,l[o]),p=r(p,a,f,c,e[t+(o+6)%16],9,l[o+1]),c=r(c,p,a,f,e[t+(o+11)%16],14,l[o+2]),f=r(f,c,p,a,e[t+o%16],20,l[o+3])):48>o?(a=i(a,f,c,p,e[t+(3*o+5)%16],4,l[o]),p=i(p,a,f,c,e[t+(3*o+8)%16],11,l[o+1]),c=i(c,p,a,f,e[t+(3*o+11)%16],16,l[o+2]),f=i(f,c,p,a,e[t+(3*o+14)%16],23,l[o+3])):(a=s(a,f,c,p,e[t+3*o%16],6,l[o]),p=s(p,a,f,c,e[t+(3*o+7)%16],10,l[o+1]),c=s(c,p,a,f,e[t+(3*o+14)%16],15,l[o+2]),f=s(f,c,p,a,e[t+(3*o+5)%16],21,l[o+3]));u[0]=u[0]+a|0,u[1]=u[1]+f|0,u[2]=u[2]+c|0,u[3]=u[3]+p|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32,t[(r+64>>>9<<4)+14]=(n<<8|n>>>24)&16711935|(n<<24|n>>>8)&4278255360,e.sigBytes=4*(t.length+1),this._process(),e=this._hash.words;for(t=0;4>t;t++)n=e[t],e[t]=(n<<8|n>>>24)&16711935|(n<<24|n>>>8)&4278255360}}),o.MD5=u._createHelper(f),o.HmacMD5=u._createHmacHelper(f)}(Math),e}),define("Lib/Utilities/ColorConverter",["Lib/Vendor/CryptoJS"],function(e){function t(){this.sin=0;var e=[6507634,7490654,7895376,5273969,5270137,9191996,5602890,4417413,10888227,4358023,4664858,5072508,2767945,8158763,3882017,2505767,8292734,11882516,9931826,7573815,4620879,1683636,794289,13414918,4406816,2103827,283542,3226888,12034885,14423690,3212549,333361];this.palette=e}return t.prototype.getColorByName=function(t){t=e.MD5(t).toString();var n=0;for(var r=0;r=0&&this.gameObjects[e].splice(n,1)},s.prototype.getPhysicsEngine=function(){return this.physicsEngine},s.prototype.loadLevel=function(e){this.level&&(this.level.destroy(),this.resetGameObjects()),this.level=new t(e,this.physicsEngine,this.gameObjects)},s.prototype.onResetLevel=function(){this.loadLevel(this.level.uid)},s.prototype.onUserLeft=function(e){var t=this.players[e];if(!t){console.warn("User (",e,") left who has not joined");return}t.destroy(),delete this.players[e]},s.prototype.createPlayer=function(e){var t=new n(e.id,this.physicsEngine,e);return this.players[e.id]=t,t},s.prototype.destroy=function(){for(var e in this.players);for(var t=0;t= minColor.x && pixel.y >= minColor.y && pixel.z >= minColor.z"," && pixel.w == 1.0"," && pixel.x <= maxColor.x && pixel.y <= maxColor.y && pixel.z <= maxColor.z) {"," pixel.rgb = mix(pixel.rgb, vec3(0.2126*pixel.r + 0.7152*pixel.g + 0.0722*pixel.b), 1.0);"," pixel.rgb += brightnessOffset;"," pixel.rgb *= newColor;"," }"," gl_FragColor = pixel;","}"]}var t=e.AbstractFilter;return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,Object.defineProperty(n.prototype,"minColor",{get:function(){return e.rgb2hex(this.uniforms.minColor.value)},set:function(t){this.uniforms.minColor.value=e.hex2rgb(t)}}),Object.defineProperty(n.prototype,"maxColor",{get:function(){return e.rgb2hex(this.uniforms.maxColor.value)},set:function(t){this.uniforms.maxColor.value=e.hex2rgb(t)}}),Object.defineProperty(n.prototype,"newColor",{get:function(){return e.rgb2hex(this.uniforms.newColor.value)},set:function(t){this.uniforms.newColor.value=e.hex2rgb(t)}}),Object.defineProperty(n.prototype,"brightnessOffset",{get:function(){return this.uniforms.brightnessOffset.value},set:function(e){this.uniforms.brightnessOffset.value=e}}),n}),define("Game/Client/View/Pixi/Layer",["Game/Client/View/Abstract/Layer","Lib/Vendor/Pixi","Game/Client/View/Pixi/ColorRangeReplaceFilter","Game/Config/Settings"],function(e,t,n,r){function s(n,r){e.call(this,n,r),this.container=new t.DisplayObjectContainer,this.container.x=0,this.container.y=0}var i={blur:t.BlurFilter,desaturate:t.GrayFilter,pixelate:t.PixelateFilter,colorRangeReplace:n};return s.prototype=Object.create(e.prototype),s.prototype.getContainer=function(){return this.container},s.prototype.show=function(){this.container.visible=!0},s.prototype.hide=function(){this.container.visible=!1},s.prototype.addMesh=function(e){this.container.addChild(e)},s.prototype.removeMesh=function(e){this.container.removeChild(e)},s.prototype.createMesh=function(e,n,r){var i=t.Texture.fromImage(e),s=new t.Sprite(i);r&&this.updateMesh(s,r),n(s)},s.prototype.createAnimatedMesh=function(e,n,r){var i=[];for(var s=0;s=0;t--)e=this.layers[t],this.container.children.indexOf(e.getContainer())!==-1&&this.container.removeChild(e.getContainer());this.container.children.length!==0&&console.warn("Unmanaged stuff in container... ",this.container.children);for(var t=0;t0){var a=65280;n.healthFactor<.3&&(a=16711680),e.beginFill(a),e.lineStyle(0,0),e.drawRect(s,s,r*n.healthFactor,i),e.endFill()}}n.x&&n.y&&(e.position=new t.Point(o+n.x,u+n.y));if(n.visible===!0||n.visible===!1)e.visible=n.visible},i.prototype.onRemoveHealthBar=function(e){this.container.removeChild(e)},i.prototype.destroy=function(){for(var e=0;e0){var o=16715683;this.loader.beginFill(o),this.loader.lineStyle(0,0),this.loader.drawRect(s,s,t*e/100,i),this.loader.endFill()}this.loader.position=new n.Point(r.STAGE_WIDTH/2-t/2-s,r.STAGE_HEIGHT/2-i/2-s)}this.loader.visible=e<100},l.prototype.onZoomIn=function(){console.log("onZoomIn"),this.currentZoom+r.ZOOM_FACTOR<=r.ZOOM_MAX&&(this.currentZoom+=r.ZOOM_FACTOR)},l.prototype.onZoomOut=function(){this.currentZoom-r.ZOOM_FACTOR>0&&(this.currentZoom-=r.ZOOM_FACTOR)},l.prototype.onZoomReset=function(){this.currentZoom=r.ZOOM_DEFAULT},l.prototype.destroy=function(){this.layerManager.destroy(),this.ghostLayer.destroy(),this.swiperLayer.destroy();for(var t=0;tt)return;this.points.push({x:n,y:r}),e.trigger(e.ns.client.view.swiper.swipe,n,r);var i=this.points;if(i.length>=3){var s=i.length-1,o=[{x:i[s].x-i[s-1].x,y:i[s].y-i[s-1].y},{x:i[s-2].x-i[s-1].x,y:i[s-2].y-i[s-1].y}],u=o[0].y*o[1].x,a=o[0].x*o[1].y,f=0;u>a?f=-1:uMath.abs(h.y)?h.x:h.y;return h.x/=Math.abs(p),h.y/=Math.abs(p),this.angleSum=0,this.lengthSum=0,this.points=[],{x:h.x*i/100,y:h.y*i/100,spin:r}},n.prototype.destroy=function(){for(var t=0;t1&&(this.x=1),this.x<-1&&(this.x=-1),this.y-=n/r.VIEWPORT_SPEED_FACTOR,this.y>1&&(this.y=1),this.y<-1&&(this.y=-1),this.lastLookDirection=this.x>=0?1:-1,this.onXyChange(this.x,this.y)},s.prototype.draw=function(e){var t=e.movementX||e.mozMovementX||e.webkitMovementX||0,n=e.movementY||e.mozMovementY||e.webkitMovementY||0;this.swiper.swipe(t,-n)},s.prototype.activateModifier=function(){this.modifier=!0},s.prototype.deactivateModifier=function(){this.modifier=!1,this.x=this.lastLookDirection*r.VIEWPORT_LOOK_AHEAD,this.y=0,this.onXyChange(this.x,this.y)},s}),define("Game/Client/Control/Inputs/Gamepad",["Game/Client/Control/Input","Game/Config/Settings"],function(e,t){function n(t){this.playerController=t,e.call(this),this.gamepad=null,this.oldHoldingPressure=0,this.keyChanged={w:!1,a:!1,d:!1};var n=this;window.addEventListener("gamepadconnected",function(e){n.gamepad=e.gamepad}),window.addEventListener("gamepaddisconnected",function(e){n.gamepad=null})}return n.prototype=Object.create(e.prototype),n.prototype.update=function(){if(this.gamepad){var e=this.gamepad.axes[2],t=-this.gamepad.axes[3];this.onXyChange(e,t);var n=this.gamepad.axes[5];(n>0&&this.oldHoldingPressure<=0||n<=0&&this.oldHoldingPressure>0)&&this.playerController.handActionRequest(e,t),this.oldHoldingPressure=n,this.simulateKeyboard()}},n.prototype.simulateKeyboard=function(){this.key(11,87),this.key(13,65),this.key(14,68)},n.prototype.key=function(e,t){if(this.keyChanged[t]!=this.gamepad.buttons[e].pressed){var n={keyCode:t};this.gamepad.buttons[e].pressed?window.onkeydown(n):window.onkeyup(n),this.keyChanged[t]=this.gamepad.buttons[e].pressed}},n}),define("Game/Client/Control/PlayerController",["Game/Core/Control/PlayerController","Lib/Utilities/NotificationCenter","Game/Client/Control/Inputs/KeyboardAndMouse","Game/Client/Control/Inputs/Gamepad"],function(e,t,n,r){function i(t){e.call(this,t),this.keyboardAndMouse=new n(this),this.gamepad=new r(this)}return i.prototype=Object.create(e.prototype),i.prototype.update=function(){e.prototype.update.call(this),this.gamepad.update()},i.prototype.moveLeft=function(){e.prototype.moveLeft.call(this),t.trigger(t.ns.client.to.server.gameCommand.send,"moveLeft")},i.prototype.moveRight=function(){e.prototype.moveRight.call(this),t.trigger(t.ns.client.to.server.gameCommand.send,"moveRight")},i.prototype.stop=function(){e.prototype.stop.call(this),t.trigger(t.ns.client.to.server.gameCommand.send,"stop")},i.prototype.jump=function(){e.prototype.jump.call(this),t.trigger(t.ns.client.to.server.gameCommand.send,"jump")},i.prototype.jumpStop=function(){e.prototype.jumpStop.call(this),t.trigger(t.ns.client.to.server.gameCommand.send,"jumpStop")},i.prototype.setXY=function(n,r){var i={x:n,y:r};e.prototype.lookAt.call(this,i),t.trigger(t.ns.client.to.server.gameCommand.send,"lookAt",i)},i.prototype.handActionLeft=function(){this.handActionRequest(-0.5,.5)},i.prototype.handActionRight=function(){this.handActionRequest(.5,.5)},i.prototype.suicide=function(){t.trigger(t.ns.client.to.server.gameCommand.send,"suicide")},i.prototype.handActionRequest=function(e,n){var r={x:e,y:n};t.trigger(t.ns.client.to.server.gameCommand.send,"handActionRequest",r)},i.prototype.showInfo=function(){t.trigger(t.ns.client.game.gameStats.toggle,!0)},i.prototype.hideInfo=function(){t.trigger(t.ns.client.game.gameStats.toggle,!1)},i.prototype.zoomIn=function(){t.trigger(t.ns.client.game.zoomIn,!0)},i.prototype.zoomOut=function(){t.trigger(t.ns.client.game.zoomOut,!1)},i.prototype.zoomReset=function(){t.trigger(t.ns.client.game.zoomReset,!1)},i}),define("Lib/Utilities/RequestAnimFrame",["Game/Config/Settings"],function(e){var t=function(){var t=function(t){return setTimeout(t,e.BOX2D_TIME_STEP*1e3)};return typeof window!="undefined"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||t:t}();return t}),define("Game/Client/Me",["Game/Client/Player","Game/Config/Settings","Lib/Utilities/NotificationCenter"],function(e,t,n){function r(n,r,i){e.call(this,n,r,i),this.lookAtXY={x:t.VIEWPORT_LOOK_AHEAD,y:0},this.lastServerPositionState={p:{x:0,y:0}},this.arrowMesh=null,this.createAndAddArrow()}return r.prototype=Object.create(e.prototype),r.prototype.lookAt=function(t,n){this.lookAtXY={x:t,y:n},e.prototype.lookAt.call(this,t,n)},r.prototype.getLookAt=function(){return{x:this.lookAtXY.x,y:this.lookAtXY.y}},r.prototype.setLastServerPositionState=function(e){this.lastServerPositionState=e},r.prototype.isPositionStateUpdateNeeded=function(){if(!this.doll)return!1;if(this.doll.isAnotherPlayerNearby())return!1;var e={x:Math.abs(this.lastServerPositionState.p.x-this.doll.body.GetPosition().x),y:Math.abs(this.lastServerPositionState.p.y-this.doll.body.GetPosition().y)};return e.x>t.ME_STATE_MAX_DIFFERENCE_METERS||e.y>t.ME_STATE_MAX_DIFFERENCE_METERS?!0:!1},r.prototype.getPositionStateUpdate=function(){return{p:this.doll.body.GetPosition().Copy(),lv:this.doll.body.GetLinearVelocity().Copy()}},r.prototype.acceptPositionStateUpdateFromServer=function(){return this.doll.isAnotherPlayerNearby()},r.prototype.resetPositionState=function(e){this.doll.body.SetPosition(e.p),this.doll.body.SetLinearVelocity(e.lv)},r.prototype.createAndAddArrow=function(e){var r=this,i=this.getPosition(),s={x:i.x*t.RATIO,y:i.y*t.RATIO},o=function(e){r.arrowMesh=e};n.trigger(n.ns.client.view.playerArrow.createAndAdd,o,s)},r.prototype.render=function(){e.prototype.render.call(this);var r=this.getPosition(),i={x:r.x*t.RATIO,y:r.y*t.RATIO};n.trigger(n.ns.client.view.playerArrow.update,this.arrowMesh,i)},r}),define("Game/Client/AudioPlayer",[],function(){function e(e){this.audio=new Audio(e),this.audio.loop=!0,this.audio.volume=.1,this.audio.addEventListener("timeupdate",function(){var e=1;this.currentTime>this.duration-e&&(this.currentTime=1,this.play())},!1)}return e.prototype.play=function(){},e.prototype.stop=function(){this.audio.stop(),this.doPlay=!1},e.prototype.destroy=function(){this.stop()},e}),define("Game/Client/GameController",["Game/Core/GameController","Lib/Vendor/Box2D","Game/Client/Physics/Engine","Game/Client/View/ViewManager","Game/Client/Control/PlayerController","Lib/Utilities/NotificationCenter","Lib/Utilities/RequestAnimFrame","Game/Config/Settings","Game/Client/GameObjects/GameObject","Game/Client/GameObjects/Doll","Game/Client/View/DomController","Lib/Utilities/Protocol/Helper","Game/Client/Me","Game/Client/AudioPlayer"],function(e,t,n,r,i,s,o,u,a,f,l,c,h,p){function d(t){this.clientIsReady=!1,this.view=r.createView(),this.me=null,this.animationRequestId=null,this.audioPlayer=null,e.call(this,t),this.ncTokens=this.ncTokens.concat([s.on(s.ns.client.game.gameStats.toggle,this.toggleGameStats,this)])}return window.cancelAnimationFrame||(window.cancelAnimationFrame=function(e){clearTimeout(e)}),d.prototype=Object.create(e.prototype),d.prototype.getMe=function(){return this.me},d.prototype.update=function(){e.prototype.update.call(this),l.statsBegin(),this.animationRequestId=o(this.update.bind(this)),this.physicsEngine.update(),this.me&&(this.me.update(),this.mePositionStateUpdate());for(var t=0;tt.stats.score?-1:e.stats.scoret.stats.deaths?1:e.stats.health>t.stats.health?-1:e.stats.health0){var s=!1,o;for(var u=0;u1?i.path:"")}}("object"==typeof module?module.exports:this.io={},this),function(e,t){var n=e.util={},r=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,i=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];n.parseUri=function(e){var t=r.exec(e||""),n={},s=14;while(s--)n[i[s]]=t[s]||"";return n},n.uniqueUri=function(e){var n=e.protocol,r=e.host,i=e.port;return"document"in t?(r=r||document.domain,i=i||(n=="https"&&document.location.protocol!=="https:"?443:document.location.port)):(r=r||"localhost",!i&&n=="https"&&(i=443)),(n||"http")+"://"+r+":"+(i||80)},n.query=function(e,t){var r=n.chunkQuery(e||""),i=[];n.merge(r,n.chunkQuery(t||""));for(var s in r)r.hasOwnProperty(s)&&i.push(s+"="+r[s]);return i.length?"?"+i.join("&"):""},n.chunkQuery=function(e){var t={},n=e.split("&"),r=0,i=n.length,s;for(;rt.length?e:t,s=e.length>t.length?t:e;for(var o=0,u=s.length;o0&&e.splice(0,1)[0]!=n.transport.name);e.length?u(e):n.publish("connect_failed")}}},n.options["connect timeout"]))})}n.sessionid=r,n.closeTimeout=s*1e3,n.heartbeatTimeout=i*1e3,n.transports=o?t.util.intersect(o.split(","),n.options.transports):n.options.transports,n.setHeartbeatTimeout(),u(n.transports),n.once("connect",function(){clearTimeout(n.connectTimeoutTimer),e&&typeof e=="function"&&e()})}),this},r.prototype.setHeartbeatTimeout=function(){clearTimeout(this.heartbeatTimeoutTimer);var e=this;this.heartbeatTimeoutTimer=setTimeout(function(){e.transport.onClose()},this.heartbeatTimeout)},r.prototype.packet=function(e){return this.connected&&!this.doBuffer?this.transport.packet(e):this.buffer.push(e),this},r.prototype.setBuffer=function(e){this.doBuffer=e,!e&&this.connected&&this.buffer.length&&(this.transport.payload(this.buffer),this.buffer=[])},r.prototype.disconnect=function(){if(this.connected||this.connecting)this.open&&this.of("").packet({type:"disconnect"}),this.onDisconnect("booted");return this},r.prototype.disconnectSync=function(){var e=t.util.request(),n=this.resource+"/"+t.protocol+"/"+this.sessionid;e.open("GET",n,!0),this.onDisconnect("booted")},r.prototype.isXDomain=function(){var e=n.location.port||("https:"==n.location.protocol?443:80);return this.options.host!==n.location.hostname||this.options.port!=e},r.prototype.onConnect=function(){this.connected||(this.connected=!0,this.connecting=!1,this.doBuffer||this.setBuffer(!1),this.emit("connect"))},r.prototype.onOpen=function(){this.open=!0},r.prototype.onClose=function(){this.open=!1,clearTimeout(this.heartbeatTimeoutTimer)},r.prototype.onPacket=function(e){this.of(e.endpoint).onPacket(e)},r.prototype.onError=function(e){e&&e.advice&&e.advice==="reconnect"&&(this.connected||this.connecting)&&(this.disconnect(),this.options.reconnect&&this.reconnect()),this.publish("error",e&&e.reason?e.reason:e)},r.prototype.onDisconnect=function(e){var t=this.connected,n=this.connecting;this.connected=!1,this.connecting=!1,this.open=!1;if(t||n)this.transport.close(),this.transport.clearTimeouts(),t&&(this.publish("disconnect",e),"booted"!=e&&this.options.reconnect&&!this.reconnecting&&this.reconnect())},r.prototype.reconnect=function(){function i(){if(e.connected){for(var t in e.namespaces)e.namespaces.hasOwnProperty(t)&&""!==t&&e.namespaces[t].packet({type:"connect"});e.publish("reconnect",e.transport.name,e.reconnectionAttempts)}clearTimeout(e.reconnectionTimer),e.removeListener("connect_failed",s),e.removeListener("connect",s),e.reconnecting=!1,delete e.reconnectionAttempts,delete e.reconnectionDelay,delete e.reconnectionTimer,delete e.redoTransports,e.options["try multiple transports"]=n}function s(){if(!e.reconnecting)return;if(e.connected)return i();if(e.connecting&&e.reconnecting)return e.reconnectionTimer=setTimeout(s,1e3);e.reconnectionAttempts++>=t?e.redoTransports?(e.publish("reconnect_failed"),i()):(e.on("connect_failed",s),e.options["try multiple transports"]=!0,e.transport=e.getTransport(),e.redoTransports=!0,e.connect()):(e.reconnectionDelay=10:!1},n.xdomainCheck=function(){return!0},typeof window!="undefined"&&(WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0),t.transports.push("flashsocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports);if("undefined"!=typeof window)var swfobject=function(){function C(){if(b)return;try{var e=a.getElementsByTagName("body")[0].appendChild(U("span"));e.parentNode.removeChild(e)}catch(t){return}b=!0;var n=c.length;for(var r=0;r0)for(var n=0;n0){var o=R(r);if(o)if(W(h[n].swfVersion)&&!(T.wk&&T.wk<312))V(r,!0),i&&(s.success=!0,s.ref=_(r),i(s));else if(h[n].expressInstall&&D()){var u={};u.data=h[n].expressInstall,u.width=o.getAttribute("width")||"0",u.height=o.getAttribute("height")||"0",o.getAttribute("class")&&(u.styleclass=o.getAttribute("class")),o.getAttribute("align")&&(u.align=o.getAttribute("align"));var a={},f=o.getElementsByTagName("param"),l=f.length;for(var c=0;c');u.outerHTML='"+l+"",p[p.length]=n.id,o=R(n.id)}else{var h=U(t);h.setAttribute("type",i);for(var d in n)n[d]!=Object.prototype[d]&&(d.toLowerCase()=="styleclass"?h.setAttribute("class",n[d]):d.toLowerCase()!="classid"&&h.setAttribute(d,n[d]));for(var v in r)r[v]!=Object.prototype[v]&&v.toLowerCase()!="movie"&&F(h,v,r[v]);u.parentNode.replaceChild(h,u),o=h}}return o}function F(e,t,n){var r=U("param");r.setAttribute("name",t),r.setAttribute("value",n),e.appendChild(r)}function I(e){var t=R(e);t&&t.nodeName=="OBJECT"&&(T.ie&&T.win?(t.style.display="none",function(){t.readyState==4?q(e):setTimeout(arguments.callee,10)}()):t.parentNode.removeChild(t))}function q(e){var t=R(e);if(t){for(var n in t)typeof t[n]=="function"&&(t[n]=null);t.parentNode.removeChild(t)}}function R(e){var t=null;try{t=a.getElementById(e)}catch(n){}return t}function U(e){return a.createElement(e)}function z(e,t,n){e.attachEvent(t,n),d[d.length]=[e,t,n]}function W(e){var t=T.pv,n=e.split(".");return n[0]=parseInt(n[0],10),n[1]=parseInt(n[1],10)||0,n[2]=parseInt(n[2],10)||0,t[0]>n[0]||t[0]==n[0]&&t[1]>n[1]||t[0]==n[0]&&t[1]==n[1]&&t[2]>=n[2]?!0:!1}function X(n,r,i,s){if(T.ie&&T.mac)return;var o=a.getElementsByTagName("head")[0];if(!o)return;var u=i&&typeof i=="string"?i:"screen";s&&(E=null,S=null);if(!E||S!=u){var f=U("style");f.setAttribute("type","text/css"),f.setAttribute("media",u),E=o.appendChild(f),T.ie&&T.win&&typeof a.styleSheets!=e&&a.styleSheets.length>0&&(E=a.styleSheets[a.styleSheets.length-1]),S=u}T.ie&&T.win?E&&typeof E.addRule==t&&E.addRule(n,r):E&&typeof a.createTextNode!=e&&E.appendChild(a.createTextNode(n+" {"+r+"}"))}function V(e,t){if(!x)return;var n=t?"visible":"hidden";b&&R(e)?R(e).style.visibility=n:X("#"+e,"visibility:"+n)}function $(t){var n=/[\\\"<>\.;]/,r=n.exec(t)!=null;return r&&typeof encodeURIComponent!=e?encodeURIComponent(t):t}var e="undefined",t="object",n="Shockwave Flash",r="ShockwaveFlash.ShockwaveFlash",i="application/x-shockwave-flash",s="SWFObjectExprInst",o="onreadystatechange",u=window,a=document,f=navigator,l=!1,c=[A],h=[],p=[],d=[],v,m,g,y,b=!1,w=!1,E,S,x=!0,T=function(){var s=typeof a.getElementById!=e&&typeof a.getElementsByTagName!=e&&typeof a.createElement!=e,o=f.userAgent.toLowerCase(),c=f.platform.toLowerCase(),h=c?/win/.test(c):/win/.test(o),p=c?/mac/.test(c):/mac/.test(o),d=/webkit/.test(o)?parseFloat(o.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,v=!1,m=[0,0,0],g=null;if(typeof f.plugins!=e&&typeof f.plugins[n]==t)g=f.plugins[n].description,g&&(typeof f.mimeTypes==e||!f.mimeTypes[i]||!!f.mimeTypes[i].enabledPlugin)&&(l=!0,v=!1,g=g.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),m[0]=parseInt(g.replace(/^(.*)\..*$/,"$1"),10),m[1]=parseInt(g.replace(/^.*\.(.*)\s.*$/,"$1"),10),m[2]=/[a-zA-Z]/.test(g)?parseInt(g.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof u[["Active"].concat("Object").join("X")]!=e)try{var y=new(window[["Active"].concat("Object").join("X")])(r);y&&(g=y.GetVariable("$version"),g&&(v=!0,g=g.split(" ")[1].split(","),m=[parseInt(g[0],10),parseInt(g[1],10),parseInt(g[2],10)]))}catch(b){}return{w3:s,pv:m,wk:d,ie:v,win:h,mac:p}}(),N=function(){if(!T.w3)return;(typeof a.readyState!=e&&a.readyState=="complete"||typeof a.readyState==e&&(a.getElementsByTagName("body")[0]||a.body))&&C(),b||(typeof a.addEventListener!=e&&a.addEventListener("DOMContentLoaded",C,!1),T.ie&&T.win&&(a.attachEvent(o,function(){a.readyState=="complete"&&(a.detachEvent(o,arguments.callee),C())}),u==top&&function(){if(b)return;try{a.documentElement.doScroll("left")}catch(e){setTimeout(arguments.callee,0);return}C()}()),T.wk&&function(){if(b)return;if(!/loaded|complete/.test(a.readyState)){setTimeout(arguments.callee,0);return}C()}(),L(C))}(),J=function(){T.ie&&T.win&&window.attachEvent("onunload",function(){var e=d.length;for(var t=0;t= 10.0.0 is required.");return}location.protocol=="file:"&&e.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://..."),WebSocket=function(e,t,n,r,i){var s=this;s.__id=WebSocket.__nextId++,WebSocket.__instances[s.__id]=s,s.readyState=WebSocket.CONNECTING,s.bufferedAmount=0,s.__events={},t?typeof t=="string"&&(t=[t]):t=[],setTimeout(function(){WebSocket.__addTask(function(){WebSocket.__flash.create(s.__id,e,t,n||null,r||0,i||null)})},0)},WebSocket.prototype.send=function(e){if(this.readyState==WebSocket.CONNECTING)throw"INVALID_STATE_ERR: Web Socket connection has not been established";var t=WebSocket.__flash.send(this.__id,encodeURIComponent(e));return t<0?!0:(this.bufferedAmount+=t,!1)},WebSocket.prototype.close=function(){if(this.readyState==WebSocket.CLOSED||this.readyState==WebSocket.CLOSING)return;this.readyState=WebSocket.CLOSING,WebSocket.__flash.close(this.__id)},WebSocket.prototype.addEventListener=function(e,t,n){e in this.__events||(this.__events[e]=[]),this.__events[e].push(t)},WebSocket.prototype.removeEventListener=function(e,t,n){if(!(e in this.__events))return;var r=this.__events[e];for(var i=r.length-1;i>=0;--i)if(r[i]===t){r.splice(i,1);break}},WebSocket.prototype.dispatchEvent=function(e){var t=this.__events[e.type]||[];for(var n=0;n"),this.doc.close(),this.doc.parentWindow.s=this;var e=this.doc.createElement("div");e.className="socketio",this.doc.body.appendChild(e),this.iframe=this.doc.createElement("iframe"),e.appendChild(this.iframe);var n=this,r=t.util.query(this.socket.options.query,"t="+ +(new Date));this.iframe.src=this.prepareUrl()+r,t.util.on(window,"unload",function(){n.destroy()})},n.prototype._=function(e,t){this.onData(e);try{var n=t.getElementsByTagName("script")[0];n.parentNode.removeChild(n)}catch(r){}},n.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(e){}this.doc=null,this.iframe.parentNode.removeChild(this.iframe),this.iframe=null,CollectGarbage()}},n.prototype.close=function(){return this.destroy(),t.Transport.XHR.prototype.close.call(this)},n.check=function(){if(typeof window!="undefined"&&["Active"].concat("Object").join("X")in window)try{var e=new(window[["Active"].concat("Object").join("X")])("htmlfile");return e&&t.Transport.XHR.check()}catch(n){}return!1},n.xdomainCheck=function(){return!1},t.transports.push("htmlfile")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(e,t,n){function r(){t.Transport.XHR.apply(this,arguments)}function i(){}e["xhr-polling"]=r,t.util.inherit(r,t.Transport.XHR),t.util.merge(r,t.Transport.XHR),r.prototype.name="xhr-polling",r.prototype.open=function(){var e=this;return t.Transport.XHR.prototype.open.call(e),!1},r.prototype.get=function(){function t(){this.readyState==4&&(this.onreadystatechange=i,this.status==200?(e.onData(this.responseText),e.get()):e.onClose())}function r(){this.onload=i,this.onerror=i,e.onData(this.responseText),e.get()}function s(){e.onClose()}if(!this.open)return;var e=this;this.xhr=this.request(),n.XDomainRequest&&this.xhr instanceof XDomainRequest?(this.xhr.onload=r,this.xhr.onerror=s):this.xhr.onreadystatechange=t,this.xhr.send(null)},r.prototype.onClose=function(){t.Transport.XHR.prototype.onClose.call(this);if(this.xhr){this.xhr.onreadystatechange=this.xhr.onload=this.xhr.onerror=i;try{this.xhr.abort()}catch(e){}this.xhr=null}},r.prototype.ready=function(e,n){var r=this;t.util.defer(function(){n.call(r)})},t.transports.push("xhr-polling")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(e,t,n){function i(e){t.Transport["xhr-polling"].apply(this,arguments),this.index=t.j.length;var n=this;t.j.push(function(e){n._(e)})}var r=n.document&&"MozAppearance"in n.document.documentElement.style;e["jsonp-polling"]=i,t.util.inherit(i,t.Transport["xhr-polling"]),i.prototype.name="jsonp-polling",i.prototype.post=function(e){function a(){f(),n.socket.setBuffer(!1)}function f(){n.iframe&&n.form.removeChild(n.iframe);try{u=document.createElement('