-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplanck.min.js
23 lines (23 loc) · 197 KB
/
planck.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
* Planck.js v0.3.0-rc.2
*
* Copyright (c) 2016-2018 Ali Shakiba http://shakiba.me/planck.js
* Copyright (c) 2006-2013 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.
*/
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i;"undefined"!=typeof window?i=window:"undefined"!=typeof global?i=global:"undefined"!=typeof self&&(i=self),i.planck=t()}}(function(){return function t(i,e,o){function s(r,m){if(!e[r]){if(!i[r]){var a="function"==typeof require&&require;if(!m&&a)return a(r,!0);if(n)return n(r,!0);var h=new Error("Cannot find module '"+r+"'");throw h.code="MODULE_NOT_FOUND",h}var c=e[r]={exports:{}};i[r][0].call(c.exports,function(t){var e=i[r][1][t];return s(e||t)},c,c.exports,t,i,e,o)}return e[r].exports}for(var n="function"==typeof require&&require,r=0;r<o.length;r++)s(o[r]);return s}({1:[function(t,i,e){e.internal={},e.Math=t("./common/Math"),e.Vec2=t("./common/Vec2"),e.Vec3=t("./common/Vec3"),e.Mat22=t("./common/Mat22"),e.Mat33=t("./common/Mat33"),e.Transform=t("./common/Transform"),e.Rot=t("./common/Rot"),e.AABB=t("./collision/AABB"),e.Shape=t("./Shape"),e.Fixture=t("./Fixture"),e.Body=t("./Body"),e.Contact=t("./Contact"),e.Joint=t("./Joint"),e.World=t("./World"),e.Circle=t("./shape/CircleShape"),e.Edge=t("./shape/EdgeShape"),e.Polygon=t("./shape/PolygonShape"),e.Chain=t("./shape/ChainShape"),e.Box=t("./shape/BoxShape"),t("./shape/CollideCircle"),t("./shape/CollideEdgeCircle"),e.internal.CollidePolygons=t("./shape/CollidePolygon"),t("./shape/CollideCirclePolygone"),t("./shape/CollideEdgePolygon"),e.DistanceJoint=t("./joint/DistanceJoint"),e.FrictionJoint=t("./joint/FrictionJoint"),e.GearJoint=t("./joint/GearJoint"),e.MotorJoint=t("./joint/MotorJoint"),e.MouseJoint=t("./joint/MouseJoint"),e.PrismaticJoint=t("./joint/PrismaticJoint"),e.PulleyJoint=t("./joint/PulleyJoint"),e.RevoluteJoint=t("./joint/RevoluteJoint"),e.RopeJoint=t("./joint/RopeJoint"),e.WeldJoint=t("./joint/WeldJoint"),e.WheelJoint=t("./joint/WheelJoint"),e.internal.Sweep=t("./common/Sweep"),e.internal.stats=t("./common/stats"),e.internal.Manifold=t("./Manifold"),e.internal.Distance=t("./collision/Distance"),e.internal.TimeOfImpact=t("./collision/TimeOfImpact"),e.internal.DynamicTree=t("./collision/DynamicTree"),e.internal.Settings=t("./Settings")},{"./Body":2,"./Contact":3,"./Fixture":4,"./Joint":5,"./Manifold":6,"./Settings":7,"./Shape":8,"./World":10,"./collision/AABB":11,"./collision/Distance":13,"./collision/DynamicTree":14,"./collision/TimeOfImpact":15,"./common/Mat22":16,"./common/Mat33":17,"./common/Math":18,"./common/Rot":20,"./common/Sweep":21,"./common/Transform":22,"./common/Vec2":23,"./common/Vec3":24,"./common/stats":26,"./joint/DistanceJoint":27,"./joint/FrictionJoint":28,"./joint/GearJoint":29,"./joint/MotorJoint":30,"./joint/MouseJoint":31,"./joint/PrismaticJoint":32,"./joint/PulleyJoint":33,"./joint/RevoluteJoint":34,"./joint/RopeJoint":35,"./joint/WeldJoint":36,"./joint/WheelJoint":37,"./shape/BoxShape":38,"./shape/ChainShape":39,"./shape/CircleShape":40,"./shape/CollideCircle":41,"./shape/CollideCirclePolygone":42,"./shape/CollideEdgeCircle":43,"./shape/CollideEdgePolygon":44,"./shape/CollidePolygon":45,"./shape/EdgeShape":46,"./shape/PolygonShape":47}],2:[function(t,i,e){function o(t,i){i=m(i,x),n&&r.assert(a.isValid(i.position)),n&&r.assert(a.isValid(i.linearVelocity)),n&&r.assert(c.isFinite(i.angle)),n&&r.assert(c.isFinite(i.angularVelocity)),n&&r.assert(c.isFinite(i.angularDamping)&&i.angularDamping>=0),n&&r.assert(c.isFinite(i.linearDamping)&&i.linearDamping>=0),this.m_world=t,this.m_awakeFlag=i.awake,this.m_autoSleepFlag=i.allowSleep,this.m_bulletFlag=i.bullet,this.m_fixedRotationFlag=i.fixedRotation,this.m_activeFlag=i.active,this.m_islandFlag=!1,this.m_toiFlag=!1,this.m_userData=i.userData,this.m_type=i.type,this.m_type==f?(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_xf=l.identity(),this.m_xf.p=a.clone(i.position),this.m_xf.q.setAngle(i.angle),this.m_sweep=new _,this.m_sweep.setTransform(this.m_xf),this.c_velocity=new u,this.c_position=new p,this.m_force=a.zero(),this.m_torque=0,this.m_linearVelocity=a.clone(i.linearVelocity),this.m_angularVelocity=i.angularVelocity,this.m_linearDamping=i.linearDamping,this.m_angularDamping=i.angularDamping,this.m_gravityScale=i.gravityScale,this.m_sleepTime=0,this.m_jointList=null,this.m_contactList=null,this.m_fixtureList=null,this.m_prev=null,this.m_next=null,this.m_destroyed=!1}function s(){this.mass=0,this.center=a.zero(),this.I=0}var n=!1;i.exports=o;var r=t("./util/common"),m=t("./util/options"),a=t("./common/Vec2"),h=t("./common/Rot"),c=t("./common/Math"),_=t("./common/Sweep"),l=t("./common/Transform"),u=t("./common/Velocity"),p=t("./common/Position"),y=t("./Fixture"),d=(t("./Shape"),t("./World"),o.STATIC="static"),v=o.KINEMATIC="kinematic",f=o.DYNAMIC="dynamic",x={type:d,position:a.zero(),angle:0,linearVelocity:a.zero(),angularVelocity:0,linearDamping:0,angularDamping:0,fixedRotation:!1,bullet:!1,gravityScale:1,allowSleep:!0,awake:!0,active:!0,userData:null};o.prototype.isWorldLocked=function(){return!(!this.m_world||!this.m_world.isLocked())},o.prototype.getWorld=function(){return this.m_world},o.prototype.getNext=function(){return this.m_next},o.prototype.setUserData=function(t){this.m_userData=t},o.prototype.getUserData=function(){return this.m_userData},o.prototype.getFixtureList=function(){return this.m_fixtureList},o.prototype.getJointList=function(){return this.m_jointList},o.prototype.getContactList=function(){return this.m_contactList},o.prototype.isStatic=function(){return this.m_type==d},o.prototype.isDynamic=function(){return this.m_type==f},o.prototype.isKinematic=function(){return this.m_type==v},o.prototype.setStatic=function(){return this.setType(d),this},o.prototype.setDynamic=function(){return this.setType(f),this},o.prototype.setKinematic=function(){return this.setType(v),this},o.prototype.getType=function(){return this.m_type},o.prototype.setType=function(t){if(n&&r.assert(t===d||t===v||t===f),n&&r.assert(0==this.isWorldLocked()),1!=this.isWorldLocked()&&this.m_type!=t){this.m_type=t,this.resetMassData(),this.m_type==d&&(this.m_linearVelocity.setZero(),this.m_angularVelocity=0,this.m_sweep.forward(),this.synchronizeFixtures()),this.setAwake(!0),this.m_force.setZero(),this.m_torque=0;for(var i=this.m_contactList;i;){var e=i;i=i.next,this.m_world.destroyContact(e.contact)}this.m_contactList=null;for(var o=this.m_world.m_broadPhase,s=this.m_fixtureList;s;s=s.m_next)for(var m=s.m_proxyCount,a=0;a<m;++a)o.touchProxy(s.m_proxies[a].proxyId)}},o.prototype.isBullet=function(){return this.m_bulletFlag},o.prototype.setBullet=function(t){this.m_bulletFlag=!!t},o.prototype.isSleepingAllowed=function(){return this.m_autoSleepFlag},o.prototype.setSleepingAllowed=function(t){this.m_autoSleepFlag=!!t,0==this.m_autoSleepFlag&&this.setAwake(!0)},o.prototype.isAwake=function(){return this.m_awakeFlag},o.prototype.setAwake=function(t){t?0==this.m_awakeFlag&&(this.m_awakeFlag=!0,this.m_sleepTime=0):(this.m_awakeFlag=!1,this.m_sleepTime=0,this.m_linearVelocity.setZero(),this.m_angularVelocity=0,this.m_force.setZero(),this.m_torque=0)},o.prototype.isActive=function(){return this.m_activeFlag},o.prototype.setActive=function(t){if(n&&r.assert(0==this.isWorldLocked()),t!=this.m_activeFlag)if(this.m_activeFlag=!!t,this.m_activeFlag)for(var i=this.m_world.m_broadPhase,e=this.m_fixtureList;e;e=e.m_next)e.createProxies(i,this.m_xf);else{for(i=this.m_world.m_broadPhase,e=this.m_fixtureList;e;e=e.m_next)e.destroyProxies(i);for(var o=this.m_contactList;o;){var s=o;o=o.next,this.m_world.destroyContact(s.contact)}this.m_contactList=null}},o.prototype.isFixedRotation=function(){return this.m_fixedRotationFlag},o.prototype.setFixedRotation=function(t){this.m_fixedRotationFlag!=t&&(this.m_fixedRotationFlag=!!t,this.m_angularVelocity=0,this.resetMassData())},o.prototype.getTransform=function(){return this.m_xf},o.prototype.setTransform=function(t,i){if(n&&r.assert(0==this.isWorldLocked()),1!=this.isWorldLocked()){this.m_xf.set(t,i),this.m_sweep.setTransform(this.m_xf);for(var e=this.m_world.m_broadPhase,o=this.m_fixtureList;o;o=o.m_next)o.synchronize(e,this.m_xf,this.m_xf)}},o.prototype.synchronizeTransform=function(){this.m_sweep.getTransform(this.m_xf,1)},o.prototype.synchronizeFixtures=function(){var t=l.identity();this.m_sweep.getTransform(t,0);for(var i=this.m_world.m_broadPhase,e=this.m_fixtureList;e;e=e.m_next)e.synchronize(i,t,this.m_xf)},o.prototype.advance=function(t){this.m_sweep.advance(t),this.m_sweep.c.set(this.m_sweep.c0),this.m_sweep.a=this.m_sweep.a0,this.m_sweep.getTransform(this.m_xf,1)},o.prototype.getPosition=function(){return this.m_xf.p},o.prototype.setPosition=function(t){this.setTransform(t,this.m_sweep.a)},o.prototype.getAngle=function(){return this.m_sweep.a},o.prototype.setAngle=function(t){this.setTransform(this.m_xf.p,t)},o.prototype.getWorldCenter=function(){return this.m_sweep.c},o.prototype.getLocalCenter=function(){return this.m_sweep.localCenter},o.prototype.getLinearVelocity=function(){return this.m_linearVelocity},o.prototype.getLinearVelocityFromWorldPoint=function(t){var i=a.sub(t,this.m_sweep.c);return a.add(this.m_linearVelocity,a.cross(this.m_angularVelocity,i))},o.prototype.getLinearVelocityFromLocalPoint=function(t){return this.getLinearVelocityFromWorldPoint(this.getWorldPoint(t))},o.prototype.setLinearVelocity=function(t){this.m_type!=d&&(a.dot(t,t)>0&&this.setAwake(!0),this.m_linearVelocity.set(t))},o.prototype.getAngularVelocity=function(){return this.m_angularVelocity},o.prototype.setAngularVelocity=function(t){this.m_type!=d&&(t*t>0&&this.setAwake(!0),this.m_angularVelocity=t)},o.prototype.getLinearDamping=function(){return this.m_linearDamping},o.prototype.setLinearDamping=function(t){this.m_linearDamping=t},o.prototype.getAngularDamping=function(){return this.m_angularDamping},o.prototype.setAngularDamping=function(t){this.m_angularDamping=t},o.prototype.getGravityScale=function(){return this.m_gravityScale},o.prototype.setGravityScale=function(t){this.m_gravityScale=t},o.prototype.getMass=function(){return this.m_mass},o.prototype.getInertia=function(){return this.m_I+this.m_mass*a.dot(this.m_sweep.localCenter,this.m_sweep.localCenter)},o.prototype.getMassData=function(t){t.mass=this.m_mass,t.I=this.getInertia(),t.center.set(this.m_sweep.localCenter)},o.prototype.resetMassData=function(){if(this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.setZero(),this.isStatic()||this.isKinematic())return this.m_sweep.c0.set(this.m_xf.p),this.m_sweep.c.set(this.m_xf.p),void(this.m_sweep.a0=this.m_sweep.a);n&&r.assert(this.isDynamic());for(var t=a.zero(),i=this.m_fixtureList;i;i=i.m_next)if(0!=i.m_density){var e=new s;i.getMassData(e),this.m_mass+=e.mass,t.addMul(e.mass,e.center),this.m_I+=e.I}this.m_mass>0?(this.m_invMass=1/this.m_mass,t.mul(this.m_invMass)):(this.m_mass=1,this.m_invMass=1),this.m_I>0&&0==this.m_fixedRotationFlag?(this.m_I-=this.m_mass*a.dot(t,t),n&&r.assert(this.m_I>0),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0);var o=a.clone(this.m_sweep.c);this.m_sweep.setLocalCenter(t,this.m_xf),this.m_linearVelocity.add(a.cross(this.m_angularVelocity,a.sub(this.m_sweep.c,o)))},o.prototype.setMassData=function(t){if(n&&r.assert(0==this.isWorldLocked()),1!=this.isWorldLocked()&&this.m_type==f){this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_mass=t.mass,this.m_mass<=0&&(this.m_mass=1),this.m_invMass=1/this.m_mass,t.I>0&&0==this.m_fixedRotationFlag&&(this.m_I=t.I-this.m_mass*a.dot(t.center,t.center),n&&r.assert(this.m_I>0),this.m_invI=1/this.m_I);var i=a.clone(this.m_sweep.c);this.m_sweep.setLocalCenter(t.center,this.m_xf),this.m_linearVelocity.add(a.cross(this.m_angularVelocity,a.sub(this.m_sweep.c,i)))}},o.prototype.applyForce=function(t,i,e){this.m_type==f&&(e&&0==this.m_awakeFlag&&this.setAwake(!0),this.m_awakeFlag&&(this.m_force.add(t),this.m_torque+=a.cross(a.sub(i,this.m_sweep.c),t)))},o.prototype.applyForceToCenter=function(t,i){this.m_type==f&&(i&&0==this.m_awakeFlag&&this.setAwake(!0),this.m_awakeFlag&&this.m_force.add(t))},o.prototype.applyTorque=function(t,i){this.m_type==f&&(i&&0==this.m_awakeFlag&&this.setAwake(!0),this.m_awakeFlag&&(this.m_torque+=t))},o.prototype.applyLinearImpulse=function(t,i,e){this.m_type==f&&(e&&0==this.m_awakeFlag&&this.setAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.addMul(this.m_invMass,t),this.m_angularVelocity+=this.m_invI*a.cross(a.sub(i,this.m_sweep.c),t)))},o.prototype.applyAngularImpulse=function(t,i){this.m_type==f&&(i&&0==this.m_awakeFlag&&this.setAwake(!0),this.m_awakeFlag&&(this.m_angularVelocity+=this.m_invI*t))},o.prototype.shouldCollide=function(t){if(this.m_type!=f&&t.m_type!=f)return!1;for(var i=this.m_jointList;i;i=i.next)if(i.other==t&&0==i.joint.m_collideConnected)return!1;return!0},o.prototype.createFixture=function(t,i){if(n&&r.assert(0==this.isWorldLocked()),1==this.isWorldLocked())return null;var e=new y(this,t,i);if(this.m_activeFlag){var o=this.m_world.m_broadPhase;e.createProxies(o,this.m_xf)}return e.m_next=this.m_fixtureList,this.m_fixtureList=e,e.m_density>0&&this.resetMassData(),this.m_world.m_newFixture=!0,e},o.prototype.destroyFixture=function(t){if(n&&r.assert(0==this.isWorldLocked()),1!=this.isWorldLocked()){n&&r.assert(t.m_body==this);var i=!1;if(this.m_fixtureList===t)this.m_fixtureList=t.m_next,i=!0;else for(var e=this.m_fixtureList;null!=e;){if(e.m_next===t){e.m_next=t.m_next,i=!0;break}e=e.m_next}n&&r.assert(i);for(var o=this.m_contactList;o;){var s=o.contact;o=o.next;var m=s.getFixtureA(),a=s.getFixtureB();t!=m&&t!=a||this.m_world.destroyContact(s)}if(this.m_activeFlag){var h=this.m_world.m_broadPhase;t.destroyProxies(h)}t.m_body=null,t.m_next=null,this.m_world.publish("remove-fixture",t),this.resetMassData()}},o.prototype.getWorldPoint=function(t){return l.mulVec2(this.m_xf,t)},o.prototype.getWorldVector=function(t){return h.mulVec2(this.m_xf.q,t)},o.prototype.getLocalPoint=function(t){return l.mulTVec2(this.m_xf,t)},o.prototype.getLocalVector=function(t){return h.mulTVec2(this.m_xf.q,t)}},{"./Fixture":4,"./Shape":8,"./World":10,"./common/Math":18,"./common/Position":19,"./common/Rot":20,"./common/Sweep":21,"./common/Transform":22,"./common/Vec2":23,"./common/Velocity":25,"./util/common":50,"./util/options":52}],3:[function(t,i,e){function o(t){this.contact=t,this.prev=null,this.next=null,this.other=null}function s(){this.m_nodeA=new o(this),this.m_nodeB=new o(this),this.m_manifold=new y,this.v_points_cache=[new n,new n],this.v_points=[],this.v_normal=c.zero(),this.v_normalMass=new l,this.v_K=new l,this.p_localPoints_cache=[c.zero(),c.zero()],this.p_localPoints=[],this.p_localNormal=c.zero(),this.p_localPoint=c.zero(),this.p_localCenterA=c.zero(),this.p_localCenterB=c.zero()}function n(){this.rA=c.zero(),this.rB=c.zero(),this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0}function r(t,i){return h.sqrt(t*i)}function m(t,i){return t>i?t:i}t("./util/common");var a=t("./util/Pool"),h=t("./common/Math"),c=t("./common/Vec2"),_=t("./common/Transform"),l=t("./common/Mat22"),u=t("./common/Rot"),p=t("./Settings"),y=t("./Manifold"),d=t("./collision/Distance");i.exports=s,s.prototype.init=function(t,i,e,o,s){this.m_fixtureA=t,this.m_fixtureB=e,this.m_indexA=i,this.m_indexB=o,this.m_evaluateFcn=s,this.m_manifold.init(),this.m_prev=null,this.m_next=null,this.m_toi=1,this.m_toiCount=0,this.m_toiFlag=!1,this.m_friction=r(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction),this.m_restitution=m(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution),this.m_tangentSpeed=0,this.m_enabledFlag=!0,this.m_islandFlag=!1,this.m_touchingFlag=!1,this.m_filterFlag=!1,this.m_bulletHitFlag=!1,this.v_points.length=0,this.v_normal.setZero(),this.v_normalMass.setZero(),this.v_K.setZero(),this.v_pointCount=null,this.v_tangentSpeed=null,this.v_friction=null,this.v_restitution=null,this.v_invMassA=null,this.v_invMassB=null,this.v_invIA=null,this.v_invIB=null,this.p_localPoints.length=0,this.p_localNormal.setZero(),this.p_localPoint.setZero(),this.p_localCenterA.setZero(),this.p_localCenterB.setZero(),this.p_type=null,this.p_radiusA=null,this.p_radiusB=null,this.p_pointCount=null,this.p_invMassA=null,this.p_invMassB=null,this.p_invIA=null,this.p_invIB=null},s.prototype.initConstraint=function(t){var i=this.m_fixtureA,e=this.m_fixtureB,o=i.getShape(),s=e.getShape(),n=i.getBody(),r=e.getBody(),m=this.m_manifold,a=m.pointCount;this.v_invMassA=n.m_invMass,this.v_invMassB=r.m_invMass,this.v_invIA=n.m_invI,this.v_invIB=r.m_invI,this.v_friction=this.m_friction,this.v_restitution=this.m_restitution,this.v_tangentSpeed=this.m_tangentSpeed,this.v_pointCount=a,this.v_K.setZero(),this.v_normalMass.setZero(),this.p_invMassA=n.m_invMass,this.p_invMassB=r.m_invMass,this.p_invIA=n.m_invI,this.p_invIB=r.m_invI,this.p_localCenterA.setVec2(n.m_sweep.localCenter),this.p_localCenterB.setVec2(r.m_sweep.localCenter),this.p_radiusA=o.m_radius,this.p_radiusB=s.m_radius,this.p_type=m.type,this.p_localNormal.setVec2(m.localNormal),this.p_localPoint.setVec2(m.localPoint),this.p_pointCount=a;for(var h=0;h<a;++h){var c=m.points[h],_=this.v_points[h]=this.v_points_cache[h].init();t.warmStarting?(_.normalImpulse=t.dtRatio*c.normalImpulse,_.tangentImpulse=t.dtRatio*c.tangentImpulse):(_.normalImpulse=0,_.tangentImpulse=0),_.rA.setZero(),_.rB.setZero(),_.normalMass=0,_.tangentMass=0,_.velocityBias=0,this.p_localPoints[h]=this.p_localPoints_cache[h].setVec2(c.localPoint)}},s.prototype.getManifold=function(){return this.m_manifold},s.prototype.getWorldManifold=function(t){var i=this.m_fixtureA.getBody(),e=this.m_fixtureB.getBody(),o=this.m_fixtureA.getShape(),s=this.m_fixtureB.getShape();return this.m_manifold.getWorldManifold(t,i.getTransform(),o.m_radius,e.getTransform(),s.m_radius)},s.prototype.setEnabled=function(t){this.m_enabledFlag=!!t},s.prototype.isEnabled=function(){return this.m_enabledFlag},s.prototype.isTouching=function(){return this.m_touchingFlag},s.prototype.getNext=function(){return this.m_next},s.prototype.getFixtureA=function(){return this.m_fixtureA},s.prototype.getFixtureB=function(){return this.m_fixtureB},s.prototype.getChildIndexA=function(){return this.m_indexA},s.prototype.getChildIndexB=function(){return this.m_indexB},s.prototype.flagForFiltering=function(){this.m_filterFlag=!0},s.prototype.setFriction=function(t){this.m_friction=t},s.prototype.getFriction=function(){return this.m_friction},s.prototype.resetFriction=function(){this.m_friction=r(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction)},s.prototype.setRestitution=function(t){this.m_restitution=t},s.prototype.getRestitution=function(){return this.m_restitution},s.prototype.resetRestitution=function(){this.m_restitution=m(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)},s.prototype.setTangentSpeed=function(t){this.m_tangentSpeed=t},s.prototype.getTangentSpeed=function(){return this.m_tangentSpeed},s.prototype.evaluate=function(t,i,e){this.m_evaluateFcn(t,i,this.m_fixtureA,this.m_indexA,e,this.m_fixtureB,this.m_indexB)};var v=new y;s.prototype.update=function(t){this.m_enabledFlag=!0;var i=!1,e=this.m_touchingFlag,o=this.m_fixtureA.isSensor(),s=this.m_fixtureB.isSensor(),n=o||s,r=this.m_fixtureA.getBody(),m=this.m_fixtureB.getBody(),a=r.getTransform(),h=m.getTransform();if(n){var c=this.m_fixtureA.getShape(),_=this.m_fixtureB.getShape();i=d.testOverlap(c,this.m_indexA,_,this.m_indexB,a,h),this.m_manifold.pointCount=0}else{var l=this.m_manifold;this.m_manifold=v.init(),v=l,this.evaluate(this.m_manifold,a,h),i=this.m_manifold.pointCount>0;for(var u=0;u<this.m_manifold.pointCount;++u){var p=this.m_manifold.points[u];p.normalImpulse=0,p.tangentImpulse=0;for(var y=0;y<l.pointCount;++y){var f=l.points[y];if(f.id.key==p.id.key){p.normalImpulse=f.normalImpulse,p.tangentImpulse=f.tangentImpulse;break}}}i!==e&&(r.setAwake(!0),m.setAwake(!0))}this.m_touchingFlag=i,!e&&i&&t&&t.beginContact(this),e&&!i&&t&&t.endContact(this),!n&&i&&t&&t.preSolve(this,l)},s.prototype.solvePositionConstraint=function(t){return this._solvePositionConstraint(t,!1)},s.prototype.solvePositionConstraintTOI=function(t,i,e){return this._solvePositionConstraint(t,!0,i,e)};var f=c.zero(),x=c.zero(),g=c.zero(),A=c.zero(),b=_.identity(),B=_.identity(),w=c.zero(),M=c.zero(),C=c.zero(),V=c.zero(),S=c.zero(),I=c.zero(),z=c.zero(),P=c.zero(),T=c.zero(),L=c.zero(),q=c.zero();s.prototype._solvePositionConstraint=function(t,i,e,o){var s=this.m_fixtureA,n=this.m_fixtureB,r=s.getBody(),m=n.getBody(),a=(r.c_velocity,m.c_velocity,r.c_position),l=m.c_position,d=f.setVec2(this.p_localCenterA),v=x.setVec2(this.p_localCenterB),F=0,R=0;i&&r!==e&&r!==o||(F=this.p_invMassA,R=this.p_invIA);var k=0,D=0;i&&m!==e&&m!==o||(k=this.p_invMassB,D=this.p_invIB);for(var j=g.setVec2(a.c),E=a.a,J=A.setVec2(l.c),O=l.a,N=0,Y=0;Y<this.p_pointCount;++Y){var W=b.setIdentity(),Z=B.setIdentity();W.q.set(E),Z.q.set(O),W.p.setVec2(c.sub_(j,u.mulVec2_(W.q,d,w),M)),Z.p.setVec2(c.sub_(J,u.mulVec2_(Z.q,v,w),M));var H,X,K;switch(this.p_type){case y.e_circles:var G=_.mulVec2_(W,this.p_localPoint,S),U=_.mulVec2_(Z,this.p_localPoints[0],I);(H=c.sub_(U,G,C)).normalize(),X=c.combine_(.5,G,.5,U,V),K=c.dot(c.sub(U,G),H)-this.p_radiusA-this.p_radiusB;break;case y.e_faceA:H=u.mulVec2_(W.q,this.p_localNormal,C);var Q=_.mulVec2_(W,this.p_localPoint,z),$=_.mulVec2_(Z,this.p_localPoints[Y],P);K=c.dot(c.sub_($,Q,w),H)-this.p_radiusA-this.p_radiusB,X=V.setVec2($);break;case y.e_faceB:H=u.mulVec2_(Z.q,this.p_localNormal,C);Q=_.mulVec2_(Z,this.p_localPoint,z),$=_.mulVec2_(W,this.p_localPoints[Y],P);K=c.dot(c.sub_($,Q,w),H)-this.p_radiusA-this.p_radiusB,X=V.setVec2($),H.mul(-1)}var tt=c.sub_(X,j,T),it=c.sub_(X,J,L);N=h.min(N,K);var et=i?p.toiBaugarte:p.baumgarte,ot=p.linearSlop,st=p.maxLinearCorrection,nt=h.clamp(et*(K+ot),-st,0),rt=c.crossVec2Vec2(tt,H),mt=c.crossVec2Vec2(it,H),at=F+k+R*rt*rt+D*mt*mt,ht=at>0?-nt/at:0,ct=c.mulNumVec2_(ht,H,q);j.subMul(F,ct),E-=R*c.crossVec2Vec2(tt,ct),J.addMul(k,ct),O+=D*c.crossVec2Vec2(it,ct)}return a.c.setVec2(j),a.a=E,l.c.setVec2(J),l.a=O,N},n.prototype.init=function(){return this.rA.setZero(),this.rB.setZero(),this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0,this};var F=c.zero(),R=c.zero(),k=c.zero(),D=c.zero(),j=c.zero(),E=c.zero(),J=c.zero(),O=c.zero(),N=c.zero(),Y=_.identity(),W=_.identity();s.prototype.initVelocityConstraint=function(t){var i=this.m_fixtureA,e=this.m_fixtureB,o=i.getBody(),s=e.getBody(),n=o.c_velocity,r=s.c_velocity,m=o.c_position,a=s.c_position,h=this.p_radiusA,_=this.p_radiusB,l=this.m_manifold,y=this.v_invMassA,d=this.v_invMassB,v=this.v_invIA,f=this.v_invIB,x=F.setVec2(this.p_localCenterA),g=R.setVec2(this.p_localCenterB),A=D.setVec2(m.c),b=m.a,B=E.setVec2(n.v),w=n.w,M=j.set(a.c),C=a.a,V=J.set(r.v),S=r.w,I=Y.setIdentity(),z=W.setIdentity();I.q.set(b),z.q.set(C),I.p.setCombine(1,A,-1,u.mulVec2(I.q,x)),z.p.setCombine(1,M,-1,u.mulVec2(z.q,g));var P=l.getWorldManifold(null,I,h,z,_);this.v_normal.set(P.normal);for(var T=0;T<this.v_pointCount;++T){var L=this.v_points[T];L.rA.setCombine(1,P.points[T],-1,A),L.rB.setCombine(1,P.points[T],-1,M);var q=c.crossVec2Vec2(L.rA,this.v_normal),Z=c.crossVec2Vec2(L.rB,this.v_normal),H=y+d+v*q*q+f*Z*Z;L.normalMass=H>0?1/H:0;var X=c.crossVec2Num_(this.v_normal,1,k),K=c.crossVec2Vec2(L.rA,X),G=c.crossVec2Vec2(L.rB,X),U=y+d+v*K*K+f*G*G;L.tangentMass=U>0?1/U:0,L.velocityBias=0;var Q=c.dot(this.v_normal,V)+c.dot(this.v_normal,c.crossNumVec2_(S,L.rB,O))-c.dot(this.v_normal,B)-c.dot(this.v_normal,c.crossNumVec2_(w,L.rA,N));Q<-p.velocityThreshold&&(L.velocityBias=-this.v_restitution*Q)}if(2===this.v_pointCount&&t.blockSolve){var $=this.v_points[0],tt=this.v_points[1],it=c.crossVec2Vec2($.rA,this.v_normal),et=c.crossVec2Vec2($.rB,this.v_normal),ot=c.crossVec2Vec2(tt.rA,this.v_normal),st=c.crossVec2Vec2(tt.rB,this.v_normal),nt=y+d+v*it*it+f*et*et,rt=y+d+v*ot*ot+f*st*st,mt=y+d+v*it*ot+f*et*st;nt*nt<1e3*(nt*rt-mt*mt)?(this.v_K.ex.set(nt,mt),this.v_K.ey.set(mt,rt),this.v_normalMass.set(this.v_K.getInverse())):this.v_pointCount=1}m.c.set(A),m.a=b,n.v.set(B),n.w=w,a.c.set(M),a.a=C,r.v.set(V),r.w=S};var Z=c.zero(),H=c.zero(),X=c.zero(),K=c.zero();s.prototype.warmStartConstraint=function(t){for(var i=this.m_fixtureA,e=this.m_fixtureB,o=i.getBody(),s=e.getBody(),n=o.c_velocity,r=s.c_velocity,m=(o.c_position,s.c_position,this.v_invMassA),a=this.v_invIA,h=this.v_invMassB,_=this.v_invIB,l=Z.set(n.v),u=n.w,p=H.set(r.v),y=r.w,d=this.v_normal,v=c.crossVec2Num_(d,1,X),f=0;f<this.v_pointCount;++f){var x=this.v_points[f],g=K.setCombine(x.normalImpulse,d,x.tangentImpulse,v);u-=a*c.crossVec2Vec2(x.rA,g),l.subMul(m,g),y+=_*c.crossVec2Vec2(x.rB,g),p.addMul(h,g)}n.v.set(l),n.w=u,r.v.set(p),r.w=y},s.prototype.storeConstraintImpulses=function(t){for(var i=this.m_manifold,e=0;e<this.v_pointCount;++e)i.points[e].normalImpulse=this.v_points[e].normalImpulse,i.points[e].tangentImpulse=this.v_points[e].tangentImpulse};c.zero(),c.zero(),c.zero(),c.zero();var G=c.zero();c.zero(),c.zero(),c.zero(),c.zero(),c.zero(),c.zero(),c.zero(),c.zero(),c.zero(),c.zero();s.prototype.solveVelocityConstraint=function(t){for(var i=this.m_fixtureA.m_body,e=this.m_fixtureB.m_body,o=i.c_velocity,s=(i.c_position,e.c_velocity),n=(e.c_position,this.v_invMassA),r=this.v_invIA,m=this.v_invMassB,a=this.v_invIB,_=o.v.x,l=o.v.y,u=o.w,p=s.v.x,y=s.v.y,d=s.w,v=this.v_normal,f=c.crossVec2Num_(v,1,G),x=this.v_friction,g=0;g<this.v_pointCount;++g){var A=0,b=0;A+=p+-d*(V=this.v_points[g]).rB.y,b+=y+d*V.rB.x,A-=_+-u*V.rA.y,b-=l+u*V.rA.x;var B=A*f.x+b*f.y-this.v_tangentSpeed,w=V.tangentMass*-B,M=x*V.normalImpulse;w=(S=h.clamp(V.tangentImpulse+w,-M,M))-V.tangentImpulse,V.tangentImpulse=S;_-=n*(z=w*f.x),_-=n*(P=w*f.y),u-=r*(V.rA.x*P-V.rA.y*z),p+=m*z,y+=m*P,d+=a*(V.rB.x*P-V.rB.y*z)}if(1===this.v_pointCount||!1===t.blockSolve)for(var C=0;C<this.v_pointCount;++C){var V;A=0,b=0;A+=p+-d*(V=this.v_points[C]).rB.y,b+=y+d*V.rB.x,A-=_+-u*V.rA.y,b-=l+u*V.rA.x;var S,I=A*v.x+b*v.y;w=-V.normalMass*(I-V.velocityBias);w=(S=h.max(V.normalImpulse+w,0))-V.normalImpulse,V.normalImpulse=S;var z,P;_-=n*(z=w*v.x),l-=n*(P=w*v.y),u-=r*(V.rA.x*P-V.rA.y*z),p+=m*z,y+=m*P,d+=a*(V.rB.x*P-V.rB.y*z)}else{var T=this.v_points[0],L=this.v_points[1],q=T.normalImpulse,F=L.normalImpulse,R=p+-d*T.rB.y-(_+-u*T.rA.y),k=y+d*T.rB.x-(l+u*T.rA.x),D=p+-d*L.rB.y-(_+-u*L.rA.y),j=y+d*L.rB.x-(l+u*L.rA.x),E=R*v.x+k*v.y,J=D*v.x+j*v.y,O=E-T.velocityBias,N=J-L.velocityBias;O-=this.v_K.ex.x*q+this.v_K.ey.x*F,N-=this.v_K.ex.y*q+this.v_K.ey.y*F;for(;;){var Y=-(this.v_normalMass.ex.x*O+this.v_normalMass.ey.x*N),W=-(this.v_normalMass.ex.y*O+this.v_normalMass.ey.y*N);if(Y>=0&&W>=0){var Z=W-F,H=(K=Y-q)*v.x,X=K*v.y;_-=n*H+n*(U=Z*v.x),l-=n*X+n*(Q=Z*v.y),u-=r*(T.rA.x*X-T.rA.y*H+L.rA.x*Q-L.rA.y*U),p+=m*H+m*U,y+=m*X+m*Q,d+=a*(T.rB.x*X-T.rB.y*H+L.rB.x*Q-L.rB.y*U),T.normalImpulse=Y,L.normalImpulse=W;break}if(Y=-T.normalMass*O,W=0,E=0,J=this.v_K.ex.y*Y+N,Y>=0&&J>=0){Z=W-F,H=(K=Y-q)*v.x,X=K*v.y;_-=n*H+n*(U=Z*v.x),l-=n*X+n*(Q=Z*v.y),u-=r*(T.rA.x*X-T.rA.y*H+L.rA.x*Q-L.rA.y*U),p+=m*H+m*U,y+=m*X+m*Q,d+=a*(T.rB.x*X-T.rB.y*H+L.rB.x*Q-L.rB.y*U),T.normalImpulse=Y,L.normalImpulse=W;break}if(Y=0,W=-L.normalMass*N,E=this.v_K.ey.x*W+O,J=0,W>=0&&E>=0){Z=W-F,H=(K=Y-q)*v.x,X=K*v.y;_-=n*H+n*(U=Z*v.x),l-=n*X+n*(Q=Z*v.y),u-=r*(T.rA.x*X-T.rA.y*H+L.rA.x*Q-L.rA.y*U),p+=m*H+m*U,y+=m*X+m*Q,d+=a*(T.rB.x*X-T.rB.y*H+L.rB.x*Q-L.rB.y*U),T.normalImpulse=Y,L.normalImpulse=W;break}if(Y=0,W=0,E=O,J=N,E>=0&&J>=0){var K,U,Q;Z=W-F,H=(K=Y-q)*v.x,X=K*v.y;_-=n*H+n*(U=Z*v.x),l-=n*X+n*(Q=Z*v.y),u-=r*(T.rA.x*X-T.rA.y*H+L.rA.x*Q-L.rA.y*U),p+=m*H+m*U,y+=m*X+m*Q,d+=a*(T.rB.x*X-T.rB.y*H+L.rB.x*Q-L.rB.y*U),T.normalImpulse=Y,L.normalImpulse=W;break}break}}o.v.x=_,o.v.y=l,o.w=u,s.v.x=p,s.v.y=y,s.w=d};var U=[],Q=new a({create:function(){return new s}});s.addType=function(t,i,e){U[t]=U[t]||{},U[t][i]=e},s.create=function(t,i,e,o){var s,n,r=t.getType(),m=e.getType();if(n=U[r]&&U[r][m])(s=Q.allocate()).init(t,i,e,o,n);else{if(!(n=U[m]&&U[m][r]))return null;(s=Q.allocate()).init(e,o,t,i,n)}t=s.getFixtureA(),e=s.getFixtureB(),i=s.getChildIndexA(),o=s.getChildIndexB();var a=t.getBody(),h=e.getBody();return s.m_nodeA.contact=s,s.m_nodeA.other=h,s.m_nodeA.prev=null,s.m_nodeA.next=a.m_contactList,null!=a.m_contactList&&(a.m_contactList.prev=s.m_nodeA),a.m_contactList=s.m_nodeA,s.m_nodeB.contact=s,s.m_nodeB.other=a,s.m_nodeB.prev=null,s.m_nodeB.next=h.m_contactList,null!=h.m_contactList&&(h.m_contactList.prev=s.m_nodeB),h.m_contactList=s.m_nodeB,t.isSensor()||e.isSensor()||(a.setAwake(!0),h.setAwake(!0)),s},s.destroy=function(t,i){var e=t.m_fixtureA,o=t.m_fixtureB,s=e.getBody(),n=o.getBody();t.isTouching()&&i.endContact(t),t.m_nodeA.prev&&(t.m_nodeA.prev.next=t.m_nodeA.next),t.m_nodeA.next&&(t.m_nodeA.next.prev=t.m_nodeA.prev),t.m_nodeA===s.m_contactList&&(s.m_contactList=t.m_nodeA.next),t.m_nodeB.prev&&(t.m_nodeB.prev.next=t.m_nodeB.next),t.m_nodeB.next&&(t.m_nodeB.next.prev=t.m_nodeB.prev),t.m_nodeB===n.m_contactList&&(n.m_contactList=t.m_nodeB.next),t.m_manifold.pointCount>0&&!e.isSensor()&&!o.isSensor()&&(s.setAwake(!0),n.setAwake(!0));var r=e.getType(),m=o.getType(),a=U[r][m].destroyFcn;"function"==typeof a&&a(t),Q.release(t)}},{"./Manifold":6,"./Settings":7,"./collision/Distance":13,"./common/Mat22":16,"./common/Math":18,"./common/Rot":20,"./common/Transform":22,"./common/Vec2":23,"./util/Pool":48,"./util/common":50}],4:[function(t,i,e){function o(t,i){this.aabb=new m,this.fixture=t,this.childIndex=i,this.proxyId}function s(t,i,e){i.shape?(e=i,i=i.shape):"number"==typeof e&&(e={density:e}),e=n(e,a),this.m_body=t,this.m_friction=e.friction,this.m_restitution=e.restitution,this.m_density=e.density,this.m_isSensor=e.isSensor,this.m_filterGroupIndex=e.filterGroupIndex,this.m_filterCategoryBits=e.filterCategoryBits,this.m_filterMaskBits=e.filterMaskBits,this.m_shape=i,this.m_next=null,this.m_proxies=[],this.m_proxyCount=0;for(var s=this.m_shape.getChildCount(),r=0;r<s;++r)this.m_proxies[r]=new o(this,r);this.m_userData=e.userData}i.exports=s;t("./util/common");var n=t("./util/options"),r=(t("./common/Math"),t("./common/Vec2")),m=t("./collision/AABB"),a={userData:null,friction:.2,restitution:0,density:0,isSensor:!1,filterGroupIndex:0,filterCategoryBits:1,filterMaskBits:65535};s.prototype.getType=function(){return this.m_shape.getType()},s.prototype.getShape=function(){return this.m_shape},s.prototype.isSensor=function(){return this.m_isSensor},s.prototype.setSensor=function(t){t!=this.m_isSensor&&(this.m_body.setAwake(!0),this.m_isSensor=t)},s.prototype.getUserData=function(){return this.m_userData},s.prototype.setUserData=function(t){this.m_userData=t},s.prototype.getBody=function(){return this.m_body},s.prototype.getNext=function(){return this.m_next},s.prototype.getDensity=function(){return this.m_density},s.prototype.setDensity=function(t){this.m_density=t},s.prototype.getFriction=function(){return this.m_friction},s.prototype.setFriction=function(t){this.m_friction=t},s.prototype.getRestitution=function(){return this.m_restitution},s.prototype.setRestitution=function(t){this.m_restitution=t},s.prototype.testPoint=function(t){return this.m_shape.testPoint(this.m_body.getTransform(),t)},s.prototype.rayCast=function(t,i,e){return this.m_shape.rayCast(t,i,this.m_body.getTransform(),e)},s.prototype.getMassData=function(t){this.m_shape.computeMass(t,this.m_density)},s.prototype.getAABB=function(t){return this.m_proxies[t].aabb},s.prototype.createProxies=function(t,i){this.m_proxyCount=this.m_shape.getChildCount();for(var e=0;e<this.m_proxyCount;++e){var o=this.m_proxies[e];this.m_shape.computeAABB(o.aabb,i,e),o.proxyId=t.createProxy(o.aabb,o)}},s.prototype.destroyProxies=function(t){for(var i=0;i<this.m_proxyCount;++i){var e=this.m_proxies[i];t.destroyProxy(e.proxyId),e.proxyId=null}this.m_proxyCount=0},s.prototype.synchronize=function(t,i,e){for(var o=0;o<this.m_proxyCount;++o){var s=this.m_proxies[o],n=new m,a=new m;this.m_shape.computeAABB(n,i,s.childIndex),this.m_shape.computeAABB(a,e,s.childIndex),s.aabb.combine(n,a);var h=r.sub(e.p,i.p);t.moveProxy(s.proxyId,s.aabb,h)}},s.prototype.setFilterData=function(t){this.m_filterGroupIndex=t.groupIndex,this.m_filterCategoryBits=t.categoryBits,this.m_filterMaskBits=t.maskBits,this.refilter()},s.prototype.getFilterGroupIndex=function(){return this.m_filterGroupIndex},s.prototype.getFilterCategoryBits=function(){return this.m_filterCategoryBits},s.prototype.getFilterMaskBits=function(){return this.m_filterMaskBits},s.prototype.refilter=function(){if(null!=this.m_body){for(var t=this.m_body.getContactList();t;){var i=t.contact,e=i.getFixtureA(),o=i.getFixtureB();e!=this&&o!=this||i.flagForFiltering(),t=t.next}var s=this.m_body.getWorld();if(null!=s)for(var n=s.m_broadPhase,r=0;r<this.m_proxyCount;++r)n.touchProxy(this.m_proxies[r].proxyId)}},s.prototype.shouldCollide=function(t){if(t.m_filterGroupIndex==this.m_filterGroupIndex&&0!=t.m_filterGroupIndex)return t.m_filterGroupIndex>0;return 0!=(t.m_filterMaskBits&this.m_filterCategoryBits)&&0!=(t.m_filterCategoryBits&this.m_filterMaskBits)}},{"./collision/AABB":11,"./common/Math":18,"./common/Vec2":23,"./util/common":50,"./util/options":52}],5:[function(t,i,e){function o(){this.other=null,this.joint=null,this.prev=null,this.next=null}function s(t,i,e){i=t.bodyA||i,e=t.bodyB||e,n&&r.assert(i),n&&r.assert(e),n&&r.assert(i!=e),this.m_type="unknown-joint",this.m_bodyA=i,this.m_bodyB=e,this.m_index=0,this.m_collideConnected=!!t.collideConnected,this.m_prev=null,this.m_next=null,this.m_edgeA=new o,this.m_edgeB=new o,this.m_islandFlag=!1,this.m_userData=t.userData}var n=!1;i.exports=s;var r=t("./util/common");s.prototype.isActive=function(){return this.m_bodyA.isActive()&&this.m_bodyB.isActive()},s.prototype.getType=function(){return this.m_type},s.prototype.getBodyA=function(){return this.m_bodyA},s.prototype.getBodyB=function(){return this.m_bodyB},s.prototype.getNext=function(){return this.m_next},s.prototype.getUserData=function(){return this.m_userData},s.prototype.setUserData=function(t){this.m_userData=t},s.prototype.getCollideConnected=function(){return this.m_collideConnected},s.prototype.getAnchorA=function(){},s.prototype.getAnchorB=function(){},s.prototype.getReactionForce=function(t){},s.prototype.getReactionTorque=function(t){},s.prototype.shiftOrigin=function(t){},s.prototype.initVelocityConstraints=function(t){},s.prototype.solveVelocityConstraints=function(t){},s.prototype.solvePositionConstraints=function(t){}},{"./util/common":50}],6:[function(t,i,e){function o(){this.type=-1,this.localNormal=a.zero(),this.localPoint=a.zero(),this.points=[new s,new s],this.pointCount=0}function s(){this.localPoint=a.zero(),this.normalImpulse=0,this.tangentImpulse=0,this.id=new n}function n(){this.cf=new r}function r(){this.indexA,this.indexB,this.typeA,this.typeB}function m(){this.v=a.zero(),this.id=new n}t("./util/common");var a=t("./common/Vec2"),h=t("./common/Transform"),c=t("./common/Math"),_=t("./common/Rot");i.exports=o,i.exports.clipSegmentToLine=function(t,i,e,s,n){var r=0,m=a.dot(e,i[0].v)-s,h=a.dot(e,i[1].v)-s;if(m<=0&&t[r++].set(i[0]),h<=0&&t[r++].set(i[1]),m*h<0){var c=m/(m-h);t[r].v.setCombine(1-c,i[0].v,c,i[1].v),t[r].id.cf.indexA=n,t[r].id.cf.indexB=i[0].id.cf.indexB,t[r].id.cf.typeA=o.e_vertex,t[r].id.cf.typeB=o.e_face,++r}return r},i.exports.clipVertex=m,i.exports.getPointStates=function(t,i,e,o){for(var s=0;s<e.pointCount;++s){var n=e.points[s].id;t[s]=l.removeState;for(var r=0;r<o.pointCount;++r)if(o.points[r].id.key==n.key){t[s]=l.persistState;break}}for(s=0;s<o.pointCount;++s)for(n=o.points[s].id,i[s]=l.addState,r=0;r<e.pointCount;++r)if(e.points[r].id.key==n.key){i[s]=l.persistState;break}},i.exports.PointState=l,o.e_circles=0,o.e_faceA=1,o.e_faceB=2,o.e_vertex=0,o.e_face=1,o.prototype.init=function(){return this.type=-1,this.localNormal.setZero(),this.localPoint.setZero(),this.points[0].init(),this.points[1].init(),this.pointCount=0,this},s.prototype.init=function(){this.localPoint.setZero(),this.normalImpulse=0,this.tangentImpulse=0,this.id.init()},n.prototype.init=function(){this.cf.init()},Object.defineProperty(n.prototype,"key",{get:function(){return this.cf.indexA+4*this.cf.indexB+16*this.cf.typeA+64*this.cf.typeB},enumerable:!0,configurable:!0}),n.prototype.set=function(t){this.cf.set(t.cf)},r.prototype.init=function(){this.indexA=0,this.indexB=0,this.typeA=0,this.typeB=0},r.prototype.set=function(t){this.indexA=t.indexA,this.indexB=t.indexB,this.typeA=t.typeA,this.typeB=t.typeB},o.prototype.getWorldManifold=function(t,i,e,s,n){if(0!=this.pointCount){var r=(t=t||new function(){this.normal,this.points=[],this.separations=[]}).normal,m=t.points,l=t.separations;switch(this.type){case o.e_circles:r=a.neo(1,0);var u=h.mulVec2(i,this.localPoint),p=h.mulVec2(s,this.points[0].localPoint),y=a.sub(p,u);a.lengthSquared(y)>c.EPSILON*c.EPSILON&&(r.set(y),r.normalize()),m[0]=a.mid(u,p),l[0]=-n-e,m.length=1,l.length=1;break;case o.e_faceA:r=_.mulVec2(i.q,this.localNormal);for(var d=h.mulVec2(i,this.localPoint),v=0;v<this.pointCount;++v){var f=h.mulVec2(s,this.points[v].localPoint),x=a.clone(f).addMul(e-a.dot(a.sub(f,d),r),r),g=a.clone(f).subMul(n,r);m[v]=a.mid(x,g),l[v]=a.dot(a.sub(g,x),r)}m.length=this.pointCount,l.length=this.pointCount;break;case o.e_faceB:r=_.mulVec2(s.q,this.localNormal);for(d=h.mulVec2(s,this.localPoint),v=0;v<this.pointCount;++v){f=h.mulVec2(i,this.points[v].localPoint),g=a.combine(1,f,n-a.dot(a.sub(f,d),r),r),x=a.combine(1,f,-e,r);m[v]=a.mid(x,g),l[v]=a.dot(a.sub(x,g),r)}m.length=this.pointCount,l.length=this.pointCount,r.mul(-1)}return t.normal=r,t.points=m,t.separations=l,t}};var l={nullState:0,addState:1,persistState:2,removeState:3};m.prototype.set=function(t){this.v.set(t.v),this.id.set(t.id)},m.prototype.init=function(){this.v.setZero(),this.id.init()}},{"./common/Math":18,"./common/Rot":20,"./common/Transform":22,"./common/Vec2":23,"./util/common":50}],7:[function(t,i,e){var o=e;o.maxManifoldPoints=2,o.maxPolygonVertices=12,o.aabbExtension=.1,o.aabbMultiplier=2,o.linearSlop=.005,o.linearSlopSquared=o.linearSlop*o.linearSlop,o.angularSlop=2/180*Math.PI,o.polygonRadius=2*o.linearSlop,o.maxSubSteps=8,o.maxTOIContacts=32,o.maxTOIIterations=20,o.maxDistnceIterations=20,o.velocityThreshold=1,o.maxLinearCorrection=.2,o.maxAngularCorrection=8/180*Math.PI,o.maxTranslation=2,o.maxTranslationSquared=o.maxTranslation*o.maxTranslation,o.maxRotation=.5*Math.PI,o.maxRotationSquared=o.maxRotation*o.maxRotation,o.baumgarte=.2,o.toiBaugarte=.75,o.timeToSleep=.5,o.linearSleepTolerance=.01,o.linearSleepToleranceSqr=Math.pow(o.linearSleepTolerance,2),o.angularSleepTolerance=2/180*Math.PI,o.angularSleepToleranceSqr=Math.pow(o.angularSleepTolerance,2)},{}],8:[function(t,i,e){function o(){this.m_type,this.m_radius}i.exports=o;t("./common/Math");o.isValid=function(t){return!!t},o.prototype.getRadius=function(){return this.m_radius},o.prototype.getType=function(){return this.m_type},o.prototype._clone=function(){},o.prototype.getChildCount=function(){},o.prototype.testPoint=function(t,i){},o.prototype.rayCast=function(t,i,e,o){},o.prototype.computeAABB=function(t,i,e){},o.prototype.computeMass=function(t,i){},o.prototype.computeDistanceProxy=function(t){}},{"./common/Math":18}],9:[function(t,i,e){function o(t){this.dt=0,this.inv_dt=0,this.velocityIterations=0,this.positionIterations=0,this.warmStarting=!1,this.blockSolve=!0,this.inv_dt0=0,this.dtRatio=1}function s(t){this.m_world=t,this.m_stack=[],this.m_bodies=[],this.m_contacts=[],this.m_joints=[]}i.exports=s,i.exports.TimeStep=o;var n=t("./Settings"),r=t("./util/common"),m=t("./common/Vec2"),a=t("./common/Math"),h=(t("./Body"),t("./Contact"),t("./Joint"),t("./collision/TimeOfImpact")),c=h.Input,_=h.Output,l=t("./collision/Distance");l.Input,l.Output,l.Proxy,l.Cache;o.prototype.reset=function(t){this.dt>0&&(this.inv_dt0=this.inv_dt),this.dt=t,this.inv_dt=0==t?0:1/t,this.dtRatio=t*this.inv_dt0},s.prototype.clear=function(){this.m_stack.length=0,this.m_bodies.length=0,this.m_contacts.length=0,this.m_joints.length=0},s.prototype.addBody=function(t){this.m_bodies.push(t)},s.prototype.addContact=function(t){this.m_contacts.push(t)},s.prototype.addJoint=function(t){this.m_joints.push(t)},s.prototype.solveWorld=function(t){for(var i=this.m_world,e=i.m_bodyList;e;e=e.m_next)e.m_islandFlag=!1;for(var o=i.m_contactList;o;o=o.m_next)o.m_islandFlag=!1;for(var s=i.m_jointList;s;s=s.m_next)s.m_islandFlag=!1;for(var n=this.m_stack,r=i.m_bodyList;r;r=r.m_next)if(0,!r.m_islandFlag&&0!=r.isAwake()&&0!=r.isActive()&&!r.isStatic()){for(this.clear(),n.push(r),r.m_islandFlag=!0;n.length>0;){e=n.pop();if(this.addBody(e),e.setAwake(!0),!e.isStatic()){for(var m=e.m_contactList;m;m=m.next){var a=m.contact;if(!a.m_islandFlag&&(0!=a.isEnabled()&&0!=a.isTouching())){var h=a.m_fixtureA.m_isSensor,c=a.m_fixtureB.m_isSensor;if(!h&&!c){this.addContact(a),a.m_islandFlag=!0;(l=m.other).m_islandFlag||(n.push(l),l.m_islandFlag=!0)}}}for(var _=e.m_jointList;_;_=_.next)if(1!=_.joint.m_islandFlag){var l;0!=(l=_.other).isActive()&&(this.addJoint(_.joint),_.joint.m_islandFlag=!0,l.m_islandFlag||(n.push(l),l.m_islandFlag=!0))}}}this.solveIsland(t);for(var u=0;u<this.m_bodies.length;++u){(e=this.m_bodies[u]).isStatic()&&(e.m_islandFlag=!1)}}},s.prototype.solveIsland=function(t){for(var i=this.m_world,e=i.m_gravity,o=i.m_allowSleep,s=t.dt,r=0;r<this.m_bodies.length;++r){var h=this.m_bodies[r],c=m.clone(h.m_sweep.c),_=h.m_sweep.a,l=m.clone(h.m_linearVelocity),u=h.m_angularVelocity;h.m_sweep.c0.set(h.m_sweep.c),h.m_sweep.a0=h.m_sweep.a,h.isDynamic()&&(l.addMul(s*h.m_gravityScale,e),l.addMul(s*h.m_invMass,h.m_force),u+=s*h.m_invI*h.m_torque,l.mul(1/(1+s*h.m_linearDamping)),u*=1/(1+s*h.m_angularDamping)),h.c_position.c=c,h.c_position.a=_,h.c_velocity.v=l,h.c_velocity.w=u}for(r=0;r<this.m_contacts.length;++r){this.m_contacts[r].initConstraint(t)}for(r=0;r<this.m_contacts.length;++r){this.m_contacts[r].initVelocityConstraint(t)}if(t.warmStarting)for(r=0;r<this.m_contacts.length;++r){this.m_contacts[r].warmStartConstraint(t)}for(r=0;r<this.m_joints.length;++r){this.m_joints[r].initVelocityConstraints(t)}for(r=0;r<t.velocityIterations;++r){for(var p=0;p<this.m_joints.length;++p){this.m_joints[p].solveVelocityConstraints(t)}for(p=0;p<this.m_contacts.length;++p){this.m_contacts[p].solveVelocityConstraint(t)}}for(r=0;r<this.m_contacts.length;++r){this.m_contacts[r].storeConstraintImpulses(t)}for(r=0;r<this.m_bodies.length;++r){h=this.m_bodies[r],c=m.clone(h.c_position.c),_=h.c_position.a,l=m.clone(h.c_velocity.v),u=h.c_velocity.w;var y=m.mul(s,l);if(m.lengthSquared(y)>n.maxTranslationSquared){var d=n.maxTranslation/y.length();l.mul(d)}var v=s*u;if(v*v>n.maxRotationSquared){u*=d=n.maxRotation/a.abs(v)}c.addMul(s,l),_+=s*u,h.c_position.c.set(c),h.c_position.a=_,h.c_velocity.v.set(l),h.c_velocity.w=u}var f=!1;for(r=0;r<t.positionIterations;++r){var x=0;for(p=0;p<this.m_contacts.length;++p){var g=this.m_contacts[p].solvePositionConstraint(t);x=a.min(x,g)}var A=x>=-3*n.linearSlop,b=!0;for(p=0;p<this.m_joints.length;++p){var B=this.m_joints[p].solvePositionConstraints(t);b=b&&B}if(A&&b){f=!0;break}}for(r=0;r<this.m_bodies.length;++r){(h=this.m_bodies[r]).m_sweep.c.set(h.c_position.c),h.m_sweep.a=h.c_position.a,h.m_linearVelocity.set(h.c_velocity.v),h.m_angularVelocity=h.c_velocity.w,h.synchronizeTransform()}if(this.postSolveIsland(),o){var w=1/0,M=n.linearSleepToleranceSqr,C=n.angularSleepToleranceSqr;for(r=0;r<this.m_bodies.length;++r){(h=this.m_bodies[r]).isStatic()||(0==h.m_autoSleepFlag||h.m_angularVelocity*h.m_angularVelocity>C||m.lengthSquared(h.m_linearVelocity)>M?(h.m_sleepTime=0,w=0):(h.m_sleepTime+=s,w=a.min(w,h.m_sleepTime)))}if(w>=n.timeToSleep&&f)for(r=0;r<this.m_bodies.length;++r){(h=this.m_bodies[r]).setAwake(!1)}}},s.prototype.printBodies=function(t){for(var i=0;i<this.m_bodies.length;++i){var e=this.m_bodies[i];r.debug(t,e.c_position.a,e.c_position.c.x,e.c_position.c.y,e.c_velocity.w,e.c_velocity.v.x,e.c_velocity.v.y)}};var u=new o;s.prototype.solveWorldTOI=function(t){var i=this.m_world;if(i.m_stepComplete){for(var e=i.m_bodyList;e;e=e.m_next)e.m_islandFlag=!1,e.m_sweep.alpha0=0;for(var o=i.m_contactList;o;o=o.m_next)o.m_toiFlag=!1,o.m_islandFlag=!1,o.m_toiCount=0,o.m_toi=1}for(;;){var s=null,r=1;for(o=i.m_contactList;o;o=o.m_next)if(0!=o.isEnabled()&&!(o.m_toiCount>n.maxSubSteps)){var m=1;if(o.m_toiFlag)m=o.m_toi;else{var l=o.getFixtureA(),p=o.getFixtureB();if(l.isSensor()||p.isSensor())continue;var y=l.getBody(),d=p.getBody(),v=y.isAwake()&&!y.isStatic(),f=d.isAwake()&&!d.isStatic();if(0==v&&0==f)continue;var x=y.isBullet()||!y.isDynamic(),g=d.isBullet()||!d.isDynamic();if(0==x&&0==g)continue;var A=y.m_sweep.alpha0;y.m_sweep.alpha0<d.m_sweep.alpha0?(A=d.m_sweep.alpha0,y.m_sweep.advance(A)):d.m_sweep.alpha0<y.m_sweep.alpha0&&(A=y.m_sweep.alpha0,d.m_sweep.advance(A));var b=o.getChildIndexA(),B=o.getChildIndexB(),w=(y.m_sweep,d.m_sweep,new c);w.proxyA.set(l.getShape(),b),w.proxyB.set(p.getShape(),B),w.sweepA.set(y.m_sweep),w.sweepB.set(d.m_sweep),w.tMax=1;var M=new _;h(M,w);var C=M.t;m=M.state==_.e_touching?a.min(A+(1-A)*C,1):1,o.m_toi=m,o.m_toiFlag=!0}m<r&&(s=o,r=m)}if(null==s||1-10*a.EPSILON<r){i.m_stepComplete=!0;break}l=s.getFixtureA(),p=s.getFixtureB(),y=l.getBody(),d=p.getBody();var V=y.m_sweep.clone(),S=d.m_sweep.clone();if(y.advance(r),d.advance(r),s.update(i),s.m_toiFlag=!1,++s.m_toiCount,0!=s.isEnabled()&&0!=s.isTouching()){y.setAwake(!0),d.setAwake(!0),this.clear(),this.addBody(y),this.addBody(d),this.addContact(s),y.m_islandFlag=!0,d.m_islandFlag=!0,s.m_islandFlag=!0;for(var I=[y,d],z=0;z<I.length;++z){if((k=I[z]).isDynamic())for(var P=k.m_contactList;P;P=P.next){var T=P.contact;if(!T.m_islandFlag){var L=P.other;if(!L.isDynamic()||k.isBullet()||L.isBullet()){var q=T.m_fixtureA.m_isSensor,F=T.m_fixtureB.m_isSensor;if(!q&&!F){var R=L.m_sweep.clone();0==L.m_islandFlag&&L.advance(r),T.update(i),0!=T.isEnabled()&&0!=T.isTouching()?(T.m_islandFlag=!0,this.addContact(T),L.m_islandFlag||(L.m_islandFlag=!0,L.isStatic()||L.setAwake(!0),this.addBody(L))):(L.m_sweep.set(R),L.synchronizeTransform())}}}}}u.reset((1-r)*t.dt),u.dtRatio=1,u.positionIterations=20,u.velocityIterations=t.velocityIterations,u.warmStarting=!1,this.solveIslandTOI(u,y,d);for(z=0;z<this.m_bodies.length;++z){var k;if((k=this.m_bodies[z]).m_islandFlag=!1,k.isDynamic()){k.synchronizeFixtures();for(P=k.m_contactList;P;P=P.next)P.contact.m_toiFlag=!1,P.contact.m_islandFlag=!1}}if(i.findNewContacts(),i.m_subStepping){i.m_stepComplete=!1;break}}else s.setEnabled(!1),y.m_sweep.set(V),d.m_sweep.set(S),y.synchronizeTransform(),d.synchronizeTransform()}},s.prototype.solveIslandTOI=function(t,i,e){this.m_world;for(var o=0;o<this.m_bodies.length;++o){(_=this.m_bodies[o]).c_position.c.set(_.m_sweep.c),_.c_position.a=_.m_sweep.a,_.c_velocity.v.set(_.m_linearVelocity),_.c_velocity.w=_.m_angularVelocity}for(o=0;o<this.m_contacts.length;++o){this.m_contacts[o].initConstraint(t)}for(o=0;o<t.positionIterations;++o){for(var s=0,r=0;r<this.m_contacts.length;++r){var h=this.m_contacts[r].solvePositionConstraintTOI(t,i,e);s=a.min(s,h)}if(s>=-1.5*n.linearSlop)break}i.m_sweep.c0.set(i.c_position.c),i.m_sweep.a0=i.c_position.a,e.m_sweep.c0.set(e.c_position.c),e.m_sweep.a0=e.c_position.a;for(o=0;o<this.m_contacts.length;++o){this.m_contacts[o].initVelocityConstraint(t)}for(o=0;o<t.velocityIterations;++o)for(r=0;r<this.m_contacts.length;++r){this.m_contacts[r].solveVelocityConstraint(t)}var c=t.dt;for(o=0;o<this.m_bodies.length;++o){var _=this.m_bodies[o],l=m.clone(_.c_position.c),u=_.c_position.a,p=m.clone(_.c_velocity.v),y=_.c_velocity.w,d=m.mul(c,p);if(m.dot(d,d)>n.maxTranslationSquared){var v=n.maxTranslation/d.length();p.mul(v)}var f=c*y;if(f*f>n.maxRotationSquared){y*=v=n.maxRotation/a.abs(f)}l.addMul(c,p),u+=c*y,_.c_position.c=l,_.c_position.a=u,_.c_velocity.v=p,_.c_velocity.w=y,_.m_sweep.c=l,_.m_sweep.a=u,_.m_linearVelocity=p,_.m_angularVelocity=y,_.synchronizeTransform()}this.postSolveIsland()},s.prototype.postSolveIsland=function(){for(var t=new function(){this.normalImpulses=[],this.tangentImpulses=[]},i=0;i<this.m_contacts.length;++i){for(var e=this.m_contacts[i],o=0;o<e.v_points.length;++o)t.normalImpulses.push(e.v_points[o].normalImpulse),t.tangentImpulses.push(e.v_points[o].tangentImpulse);this.m_world.postSolve(e,t)}}},{"./Body":2,"./Contact":3,"./Joint":5,"./Settings":7,"./collision/Distance":13,"./collision/TimeOfImpact":15,"./common/Math":18,"./common/Vec2":23,"./util/common":50}],10:[function(t,i,e){function o(t){if(!(this instanceof o))return new o(t);t&&n.isValid(t)&&(t={gravity:t}),t=s(t,c),this.m_solver=new m(this),this.m_broadPhase=new r,this.m_contactList=null,this.m_contactCount=0,this.m_bodyList=null,this.m_bodyCount=0,this.m_jointList=null,this.m_jointCount=0,this.m_stepComplete=!0,this.m_allowSleep=t.allowSleep,this.m_gravity=n.clone(t.gravity),this.m_clearForces=!0,this.m_newFixture=!1,this.m_locked=!1,this.m_warmStarting=t.warmStarting,this.m_continuousPhysics=t.continuousPhysics,this.m_subStepping=t.subStepping,this.m_blockSolve=t.blockSolve,this.m_velocityIterations=t.velocityIterations,this.m_positionIterations=t.positionIterations,this.m_t=0,this.m_stepCount=0,this.addPair=this.createContact.bind(this)}i.exports=o;var s=t("./util/options"),n=(t("./util/common"),t("./common/Vec2")),r=t("./collision/BroadPhase"),m=t("./Solver"),a=t("./Body"),h=t("./Contact"),c={gravity:n.zero(),allowSleep:!0,warmStarting:!0,continuousPhysics:!0,subStepping:!1,blockSolve:!0,velocityIterations:8,positionIterations:3};o.prototype.getBodyList=function(){return this.m_bodyList},o.prototype.getJointList=function(){return this.m_jointList},o.prototype.getContactList=function(){return this.m_contactList},o.prototype.getBodyCount=function(){return this.m_bodyCount},o.prototype.getJointCount=function(){return this.m_jointCount},o.prototype.getContactCount=function(){return this.m_contactCount},o.prototype.setGravity=function(t){this.m_gravity=t},o.prototype.getGravity=function(){return this.m_gravity},o.prototype.isLocked=function(){return this.m_locked},o.prototype.setAllowSleeping=function(t){if(t!=this.m_allowSleep&&(this.m_allowSleep=t,0==this.m_allowSleep))for(var i=this.m_bodyList;i;i=i.m_next)i.setAwake(!0)},o.prototype.getAllowSleeping=function(){return this.m_allowSleep},o.prototype.setWarmStarting=function(t){this.m_warmStarting=t},o.prototype.getWarmStarting=function(){return this.m_warmStarting},o.prototype.setContinuousPhysics=function(t){this.m_continuousPhysics=t},o.prototype.getContinuousPhysics=function(){return this.m_continuousPhysics},o.prototype.setSubStepping=function(t){this.m_subStepping=t},o.prototype.getSubStepping=function(){return this.m_subStepping},o.prototype.setAutoClearForces=function(t){this.m_clearForces=t},o.prototype.getAutoClearForces=function(){return this.m_clearForces},o.prototype.clearForces=function(){for(var t=this.m_bodyList;t;t=t.getNext())t.m_force.setZero(),t.m_torque=0},o.prototype.queryAABB=function(t,i){var e=this.m_broadPhase;this.m_broadPhase.query(t,function(t){var o=e.getUserData(t);return i(o.fixture)})},o.prototype.rayCast=function(t,i,e){var o=this.m_broadPhase;this.m_broadPhase.rayCast({maxFraction:1,p1:t,p2:i},function(t,i){var s=o.getUserData(i),r=s.fixture,m=s.childIndex,a={};if(r.rayCast(a,t,m)){var h=a.fraction,c=n.add(n.mul(1-h,t.p1),n.mul(h,t.p2));return e(r,c,a.normal,h)}return t.maxFraction})},o.prototype.getProxyCount=function(){return this.m_broadPhase.getProxyCount()},o.prototype.getTreeHeight=function(){return this.m_broadPhase.getTreeHeight()},o.prototype.getTreeBalance=function(){return this.m_broadPhase.getTreeBalance()},o.prototype.getTreeQuality=function(){return this.m_broadPhase.getTreeQuality()},o.prototype.shiftOrigin=function(t){if(!this.m_locked){for(var i=this.m_bodyList;i;i=i.m_next)i.m_xf.p.sub(t),i.m_sweep.c0.sub(t),i.m_sweep.c.sub(t);for(var e=this.m_jointList;e;e=e.m_next)e.shiftOrigin(t);this.m_broadPhase.shiftOrigin(t)}},o.prototype.createBody=function(t,i){if(this.isLocked())return null;t&&n.isValid(t)&&(t={position:t,angle:i});var e=new a(this,t);return e.m_prev=null,e.m_next=this.m_bodyList,this.m_bodyList&&(this.m_bodyList.m_prev=e),this.m_bodyList=e,++this.m_bodyCount,e},o.prototype.createDynamicBody=function(t,i){return t?n.isValid(t)&&(t={position:t,angle:i}):t={},t.type="dynamic",this.createBody(t)},o.prototype.createKinematicBody=function(t,i){return t?n.isValid(t)&&(t={position:t,angle:i}):t={},t.type="kinematic",this.createBody(t)},o.prototype.destroyBody=function(t){if(!this.isLocked()){if(t.m_destroyed)return!1;for(var i=t.m_jointList;i;){var e=i;i=i.next,this.publish("remove-joint",e.joint),this.destroyJoint(e.joint),t.m_jointList=i}t.m_jointList=null;for(var o=t.m_contactList;o;){var s=o;o=o.next,this.destroyContact(s.contact),t.m_contactList=o}t.m_contactList=null;for(var n=t.m_fixtureList;n;){var r=n;n=n.m_next,this.publish("remove-fixture",r),r.destroyProxies(this.m_broadPhase),t.m_fixtureList=n}return t.m_fixtureList=null,t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t==this.m_bodyList&&(this.m_bodyList=t.m_next),t.m_destroyed=!0,--this.m_bodyCount,this.publish("remove-body",t),!0}},o.prototype.createJoint=function(t){if(this.isLocked())return null;if(t.m_prev=null,t.m_next=this.m_jointList,this.m_jointList&&(this.m_jointList.m_prev=t),this.m_jointList=t,++this.m_jointCount,t.m_edgeA.joint=t,t.m_edgeA.other=t.m_bodyB,t.m_edgeA.prev=null,t.m_edgeA.next=t.m_bodyA.m_jointList,t.m_bodyA.m_jointList&&(t.m_bodyA.m_jointList.prev=t.m_edgeA),t.m_bodyA.m_jointList=t.m_edgeA,t.m_edgeB.joint=t,t.m_edgeB.other=t.m_bodyA,t.m_edgeB.prev=null,t.m_edgeB.next=t.m_bodyB.m_jointList,t.m_bodyB.m_jointList&&(t.m_bodyB.m_jointList.prev=t.m_edgeB),t.m_bodyB.m_jointList=t.m_edgeB,0==t.m_collideConnected)for(var i=t.m_bodyB.getContactList();i;i=i.next)i.other==t.m_bodyA&&i.contact.flagForFiltering();return t},o.prototype.destroyJoint=function(t){if(!this.isLocked()){t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t==this.m_jointList&&(this.m_jointList=t.m_next);var i=t.m_bodyA,e=t.m_bodyB;if(i.setAwake(!0),e.setAwake(!0),t.m_edgeA.prev&&(t.m_edgeA.prev.next=t.m_edgeA.next),t.m_edgeA.next&&(t.m_edgeA.next.prev=t.m_edgeA.prev),t.m_edgeA==i.m_jointList&&(i.m_jointList=t.m_edgeA.next),t.m_edgeA.prev=null,t.m_edgeA.next=null,t.m_edgeB.prev&&(t.m_edgeB.prev.next=t.m_edgeB.next),t.m_edgeB.next&&(t.m_edgeB.next.prev=t.m_edgeB.prev),t.m_edgeB==e.m_jointList&&(e.m_jointList=t.m_edgeB.next),t.m_edgeB.prev=null,t.m_edgeB.next=null,--this.m_jointCount,0==t.m_collideConnected)for(var o=e.getContactList();o;)o.other==i&&o.contact.flagForFiltering(),o=o.next;this.publish("remove-joint",t)}};var _=new m.TimeStep;o.prototype.step=function(t,i,e){if((0|i)!==i&&(i=0),i=i||this.m_velocityIterations,e=e||this.m_positionIterations,this.m_stepCount++,this.m_newFixture&&(this.findNewContacts(),this.m_newFixture=!1),this.m_locked=!0,_.reset(t),_.velocityIterations=i,_.positionIterations=e,_.warmStarting=this.m_warmStarting,_.blockSolve=this.m_blockSolve,this.updateContacts(),this.m_stepComplete&&t>0){this.m_solver.solveWorld(_);for(var o=this.m_bodyList;o;o=o.getNext())0!=o.m_islandFlag&&(o.isStatic()||o.synchronizeFixtures());this.findNewContacts()}this.m_continuousPhysics&&t>0&&this.m_solver.solveWorldTOI(_),this.m_clearForces&&this.clearForces(),this.m_locked=!1},o.prototype.findNewContacts=function(){this.m_broadPhase.updatePairs(this.addPair)},o.prototype.createContact=function(t,i){var e=t.fixture,o=i.fixture,s=t.childIndex,n=i.childIndex,r=e.getBody(),m=o.getBody();if(r!==m){for(var a=m.getContactList();a;){if(a.other===r){var c=a.contact.getFixtureA(),_=a.contact.getFixtureB(),l=a.contact.getChildIndexA(),u=a.contact.getChildIndexB();if(c===e&&_===o&&l===s&&u===n)return;if(c===o&&_===e&&l===n&&u===s)return}a=a.next}if(!1!==m.shouldCollide(r)&&!1!==o.shouldCollide(e)){var p=h.create(e,s,o,n);null!=p&&(p.m_prev=null,null!=this.m_contactList&&(p.m_next=this.m_contactList,this.m_contactList.m_prev=p),this.m_contactList=p,++this.m_contactCount)}}},o.prototype.updateContacts=function(){for(var t,i=this.m_contactList;t=i;){i=t.getNext();var e=t.getFixtureA(),o=t.getFixtureB(),s=t.getChildIndexA(),n=t.getChildIndexB(),r=e.getBody(),m=o.getBody();if(t.m_filterFlag){if(0==m.shouldCollide(r)){this.destroyContact(t);continue}if(0==o.shouldCollide(e)){this.destroyContact(t);continue}t.m_filterFlag=!1}var a=r.isAwake()&&!r.isStatic(),h=m.isAwake()&&!m.isStatic();if(0!=a||0!=h){var c=e.m_proxies[s].proxyId,_=o.m_proxies[n].proxyId;0!=this.m_broadPhase.testOverlap(c,_)?t.update(this):this.destroyContact(t)}}},o.prototype.destroyContact=function(t){h.destroy(t,this),t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t==this.m_contactList&&(this.m_contactList=t.m_next),--this.m_contactCount},o.prototype._listeners=null,o.prototype.on=function(t,i){return"string"!=typeof t||"function"!=typeof i?this:(this._listeners||(this._listeners={}),this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(i),this)},o.prototype.off=function(t,i){if("string"!=typeof t||"function"!=typeof i)return this;var e=this._listeners&&this._listeners[t];if(!e||!e.length)return this;var o=e.indexOf(i);return o>=0&&e.splice(o,1),this},o.prototype.publish=function(t,i,e,o){var s=this._listeners&&this._listeners[t];if(!s||!s.length)return 0;for(var n=0;n<s.length;n++)s[n].call(this,i,e,o);return s.length},o.prototype.beginContact=function(t){this.publish("begin-contact",t)},o.prototype.endContact=function(t){this.publish("end-contact",t)},o.prototype.preSolve=function(t,i){this.publish("pre-solve",t,i)},o.prototype.postSolve=function(t,i){this.publish("post-solve",t,i)}},{"./Body":2,"./Contact":3,"./Solver":9,"./collision/BroadPhase":12,"./common/Vec2":23,"./util/common":50,"./util/options":52}],11:[function(t,i,e){function o(t,i){if(!(this instanceof o))return new o(t,i);this.lowerBound=n.zero(),this.upperBound=n.zero(),"object"==typeof t&&this.lowerBound.set(t),"object"==typeof i&&this.upperBound.set(i)}t("../Settings");var s=t("../common/Math"),n=t("../common/Vec2");i.exports=o,o.prototype.isValid=function(){return o.isValid(this)},o.isValid=function(t){var i=n.sub(t.upperBound,t.lowerBound);return i.x>=0&&i.y>=0&&n.isValid(t.lowerBound)&&n.isValid(t.upperBound)},o.assert=function(t){},o.prototype.getCenter=function(){return n.neo(.5*(this.lowerBound.x+this.upperBound.x),.5*(this.lowerBound.y+this.upperBound.y))},o.prototype.getExtents=function(){return n.neo(.5*(this.upperBound.x-this.lowerBound.x),.5*(this.upperBound.y-this.lowerBound.y))},o.prototype.getPerimeter=function(){return 2*(this.upperBound.x-this.lowerBound.x+this.upperBound.y-this.lowerBound.y)},o.prototype.combine=function(t,i){var e=t.lowerBound,o=t.upperBound,n=i.lowerBound,r=i.upperBound,m=s.min(e.x,n.x),a=s.min(e.y,n.y),h=s.max(r.x,o.x),c=s.max(r.y,o.y);this.lowerBound.set(m,a),this.upperBound.set(h,c)},o.prototype.combinePoints=function(t,i){this.lowerBound.set(s.min(t.x,i.x),s.min(t.y,i.y)),this.upperBound.set(s.max(t.x,i.x),s.max(t.y,i.y))},o.prototype.set=function(t){this.lowerBound.set(t.lowerBound.x,t.lowerBound.y),this.upperBound.set(t.upperBound.x,t.upperBound.y)},o.prototype.contains=function(t){var i=!0;return i=i&&this.lowerBound.x<=t.lowerBound.x,i=i&&this.lowerBound.y<=t.lowerBound.y,i=i&&t.upperBound.x<=this.upperBound.x,i=i&&t.upperBound.y<=this.upperBound.y},o.prototype.extend=function(t){o.extend(this,t)},o.extend=function(t,i){t.lowerBound.x-=i,t.lowerBound.y-=i,t.upperBound.x+=i,t.upperBound.y+=i},o.testOverlap=function(t,i){var e=i.lowerBound.x-t.upperBound.x,o=t.lowerBound.x-i.upperBound.x,s=i.lowerBound.y-t.upperBound.y,n=t.lowerBound.y-i.upperBound.y;return!(e>0||s>0||o>0||n>0)},o.areEqual=function(t,i){return n.areEqual(t.lowerBound,i.lowerBound)&&n.areEqual(t.upperBound,i.upperBound)},o.diff=function(t,i){var e=s.max(0,s.min(t.upperBound.x,i.upperBound.x)-s.max(i.lowerBound.x,t.lowerBound.x)),o=s.max(0,s.min(t.upperBound.y,i.upperBound.y)-s.max(i.lowerBound.y,t.lowerBound.y));return(t.upperBound.x-t.lowerBound.x)*(t.upperBound.y-t.lowerBound.y)+(i.upperBound.x-i.lowerBound.x)*(i.upperBound.y-i.lowerBound.y)-e*o},o.prototype.rayCast=function(t,i){for(var e=-1/0,o=1/0,r=i.p1,m=n.sub(i.p2,i.p1),a=n.abs(m),h=n.zero(),c="x";null!==c;c="x"===c?"y":null)if(a.x<s.EPSILON){if(r[c]<this.lowerBound[c]||this.upperBound[c]<r[c])return!1}else{var _=1/m[c],l=(this.lowerBound[c]-r[c])*_,u=(this.upperBound[c]-r[c])*_,p=-1;if(l>u){var y=l;l=u,u=y,p=1}if(l>e&&(h.setZero(),h[c]=p,e=l),o=s.min(o,u),e>o)return!1}return!(e<0||i.maxFraction<e)&&(t.fraction=e,t.normal=h,!0)},o.prototype.toString=function(){return JSON.stringify(this)}},{"../Settings":7,"../common/Math":18,"../common/Vec2":23}],12:[function(t,i,e){function o(){this.m_tree=new r,this.m_proxyCount=0,this.m_moveBuffer=[],this.queryCallback=this.queryCallback.bind(this)}t("../Settings"),t("../util/common");var s=t("../common/Math"),n=t("./AABB"),r=t("./DynamicTree");i.exports=o,o.prototype.getUserData=function(t){return this.m_tree.getUserData(t)},o.prototype.testOverlap=function(t,i){var e=this.m_tree.getFatAABB(t),o=this.m_tree.getFatAABB(i);return n.testOverlap(e,o)},o.prototype.getFatAABB=function(t){return this.m_tree.getFatAABB(t)},o.prototype.getProxyCount=function(){return this.m_proxyCount},o.prototype.getTreeHeight=function(){return this.m_tree.getHeight()},o.prototype.getTreeBalance=function(){return this.m_tree.getMaxBalance()},o.prototype.getTreeQuality=function(){return this.m_tree.getAreaRatio()},o.prototype.query=function(t,i){this.m_tree.query(t,i)},o.prototype.rayCast=function(t,i){this.m_tree.rayCast(t,i)},o.prototype.shiftOrigin=function(t){this.m_tree.shiftOrigin(t)},o.prototype.createProxy=function(t,i){var e=this.m_tree.createProxy(t,i);return this.m_proxyCount++,this.bufferMove(e),e},o.prototype.destroyProxy=function(t){this.unbufferMove(t),this.m_proxyCount--,this.m_tree.destroyProxy(t)},o.prototype.moveProxy=function(t,i,e){this.m_tree.moveProxy(t,i,e)&&this.bufferMove(t)},o.prototype.touchProxy=function(t){this.bufferMove(t)},o.prototype.bufferMove=function(t){this.m_moveBuffer.push(t)},o.prototype.unbufferMove=function(t){for(var i=0;i<this.m_moveBuffer.length;++i)this.m_moveBuffer[i]==t&&(this.m_moveBuffer[i]=null)},o.prototype.updatePairs=function(t){for(this.m_callback=t;this.m_moveBuffer.length>0;)if(this.m_queryProxyId=this.m_moveBuffer.pop(),null!==this.m_queryProxyId){var i=this.m_tree.getFatAABB(this.m_queryProxyId);this.m_tree.query(i,this.queryCallback)}},o.prototype.queryCallback=function(t){if(t==this.m_queryProxyId)return!0;var i=s.min(t,this.m_queryProxyId),e=s.max(t,this.m_queryProxyId),o=this.m_tree.getUserData(i),n=this.m_tree.getUserData(e);return this.m_callback(o,n),!0}},{"../Settings":7,"../common/Math":18,"../util/common":50,"./AABB":11,"./DynamicTree":14}],13:[function(t,i,e){function o(){this.proxyA=new m,this.proxyB=new m,this.transformA=null,this.transformB=null,this.useRadii=!1}function s(){this.pointA=u.zero(),this.pointB=u.zero(),this.distance,this.iterations}function n(){this.metric=0,this.indexA=[],this.indexB=[],this.count=0}function r(t,i,e){++_.gjkCalls;var o=e.proxyA,s=e.proxyB,n=e.transformA,r=e.transformB,m=new h;m.readCache(i,o,n,s,r);for(var a=m.m_v,d=c.maxDistnceIterations,v=[],f=[],x=0,g=0;g<d;){x=m.m_count;for(var A=0;A<x;++A)v[A]=a[A].indexA,f[A]=a[A].indexB;if(m.solve(),3==m.m_count)break;(S=m.getClosestPoint()).lengthSquared();var b=m.getSearchDirection();if(b.lengthSquared()<l.EPSILON*l.EPSILON)break;var B=a[m.m_count];B.indexA=o.getSupport(p.mulTVec2(n.q,u.neg(b))),B.wA=y.mulVec2(n,o.getVertex(B.indexA)),B.indexB=s.getSupport(p.mulTVec2(r.q,b)),B.wB=y.mulVec2(r,s.getVertex(B.indexB)),B.w=u.sub(B.wB,B.wA),++g,++_.gjkIters;var w=!1;for(A=0;A<x;++A)if(B.indexA==v[A]&&B.indexB==f[A]){w=!0;break}if(w)break;++m.m_count}if(_.gjkMaxIters=l.max(_.gjkMaxIters,g),m.getWitnessPoints(t.pointA,t.pointB),t.distance=u.distance(t.pointA,t.pointB),t.iterations=g,m.writeCache(i),e.useRadii){var M=o.m_radius,C=s.m_radius;if(t.distance>M+C&&t.distance>l.EPSILON){t.distance-=M+C;var V=u.sub(t.pointB,t.pointA);V.normalize(),t.pointA.addMul(M,V),t.pointB.subMul(C,V)}else{var S=u.mid(t.pointA,t.pointB);t.pointA.set(S),t.pointB.set(S),t.distance=0}}}function m(){this.m_buffer=[],this.m_vertices=[],this.m_count=0,this.m_radius=0}function a(){this.indexA,this.indexB,this.wA=u.zero(),this.wB=u.zero(),this.w=u.zero(),this.a}function h(){this.m_v1=new a,this.m_v2=new a,this.m_v3=new a,this.m_v=[this.m_v1,this.m_v2,this.m_v3],this.m_count}i.exports=r,i.exports.Input=o,i.exports.Output=s,i.exports.Proxy=m,i.exports.Cache=n;var c=t("../Settings"),_=(t("../util/common"),t("../common/stats")),l=t("../common/Math"),u=t("../common/Vec2"),p=(t("../common/Vec3"),t("../common/Mat22"),t("../common/Mat33"),t("../common/Rot")),y=(t("../common/Sweep"),t("../common/Transform"));t("../common/Velocity"),t("../common/Position");_.gjkCalls=0,_.gjkIters=0,_.gjkMaxIters=0,m.prototype.getVertexCount=function(){return this.m_count},m.prototype.getVertex=function(t){return this.m_vertices[t]},m.prototype.getSupport=function(t){for(var i=0,e=u.dot(this.m_vertices[0],t),o=0;o<this.m_count;++o){var s=u.dot(this.m_vertices[o],t);s>e&&(i=o,e=s)}return i},m.prototype.getSupportVertex=function(t){return this.m_vertices[this.getSupport(t)]},m.prototype.set=function(t,i){t.computeDistanceProxy(this,i)},a.prototype.set=function(t){this.indexA=t.indexA,this.indexB=t.indexB,this.wA=u.clone(t.wA),this.wB=u.clone(t.wB),this.w=u.clone(t.w),this.a=t.a},h.prototype.print=function(){return 3==this.m_count?["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y,this.m_v2.a,this.m_v2.wA.x,this.m_v2.wA.y,this.m_v2.wB.x,this.m_v2.wB.y,this.m_v3.a,this.m_v3.wA.x,this.m_v3.wA.y,this.m_v3.wB.x,this.m_v3.wB.y].toString():2==this.m_count?["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y,this.m_v2.a,this.m_v2.wA.x,this.m_v2.wA.y,this.m_v2.wB.x,this.m_v2.wB.y].toString():1==this.m_count?["+"+this.m_count,this.m_v1.a,this.m_v1.wA.x,this.m_v1.wA.y,this.m_v1.wB.x,this.m_v1.wB.y].toString():"+"+this.m_count},h.prototype.readCache=function(t,i,e,o,s){this.m_count=t.count;for(var n=0;n<this.m_count;++n){(c=this.m_v[n]).indexA=t.indexA[n],c.indexB=t.indexB[n];var r=i.getVertex(c.indexA),m=o.getVertex(c.indexB);c.wA=y.mulVec2(e,r),c.wB=y.mulVec2(s,m),c.w=u.sub(c.wB,c.wA),c.a=0}if(this.m_count>1){var a=t.metric,h=this.getMetric();(h<.5*a||2*a<h||h<l.EPSILON)&&(this.m_count=0)}if(0==this.m_count){var c;(c=this.m_v[0]).indexA=0,c.indexB=0;r=i.getVertex(0),m=o.getVertex(0);c.wA=y.mulVec2(e,r),c.wB=y.mulVec2(s,m),c.w=u.sub(c.wB,c.wA),c.a=1,this.m_count=1}},h.prototype.writeCache=function(t){t.metric=this.getMetric(),t.count=this.m_count;for(var i=0;i<this.m_count;++i)t.indexA[i]=this.m_v[i].indexA,t.indexB[i]=this.m_v[i].indexB},h.prototype.getSearchDirection=function(){switch(this.m_count){case 1:return u.neg(this.m_v1.w);case 2:var t=u.sub(this.m_v2.w,this.m_v1.w);return u.cross(t,u.neg(this.m_v1.w))>0?u.cross(1,t):u.cross(t,1);default:return u.zero()}},h.prototype.getClosestPoint=function(){switch(this.m_count){case 0:return u.zero();case 1:return u.clone(this.m_v1.w);case 2:return u.combine(this.m_v1.a,this.m_v1.w,this.m_v2.a,this.m_v2.w);case 3:default:return u.zero()}},h.prototype.getWitnessPoints=function(t,i){switch(this.m_count){case 0:break;case 1:t.set(this.m_v1.wA),i.set(this.m_v1.wB);break;case 2:t.setCombine(this.m_v1.a,this.m_v1.wA,this.m_v2.a,this.m_v2.wA),i.setCombine(this.m_v1.a,this.m_v1.wB,this.m_v2.a,this.m_v2.wB);break;case 3:t.setCombine(this.m_v1.a,this.m_v1.wA,this.m_v2.a,this.m_v2.wA),t.addMul(this.m_v3.a,this.m_v3.wA),i.set(t)}},h.prototype.getMetric=function(){switch(this.m_count){case 0:case 1:return 0;case 2:return u.distance(this.m_v1.w,this.m_v2.w);case 3:return u.cross(u.sub(this.m_v2.w,this.m_v1.w),u.sub(this.m_v3.w,this.m_v1.w));default:return 0}},h.prototype.solve=function(){switch(this.m_count){case 1:break;case 2:this.solve2();break;case 3:this.solve3()}},h.prototype.solve2=function(){var t=this.m_v1.w,i=this.m_v2.w,e=u.sub(i,t),o=-u.dot(t,e);if(o<=0)return this.m_v1.a=1,void(this.m_count=1);var s=u.dot(i,e);if(s<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.set(this.m_v2);var n=1/(s+o);this.m_v1.a=s*n,this.m_v2.a=o*n,this.m_count=2},h.prototype.solve3=function(){var t=this.m_v1.w,i=this.m_v2.w,e=this.m_v3.w,o=u.sub(i,t),s=u.dot(t,o),n=u.dot(i,o),r=-s,m=u.sub(e,t),a=u.dot(t,m),h=u.dot(e,m),c=-a,_=u.sub(e,i),l=u.dot(i,_),p=u.dot(e,_),y=-l,d=u.cross(o,m),v=d*u.cross(i,e),f=d*u.cross(e,t),x=d*u.cross(t,i);if(r<=0&&c<=0)return this.m_v1.a=1,void(this.m_count=1);if(n>0&&r>0&&x<=0){var g=1/(n+r);return this.m_v1.a=n*g,this.m_v2.a=r*g,void(this.m_count=2)}if(h>0&&c>0&&f<=0){var A=1/(h+c);return this.m_v1.a=h*A,this.m_v3.a=c*A,this.m_count=2,void this.m_v2.set(this.m_v3)}if(n<=0&&y<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.set(this.m_v2);if(h<=0&&p<=0)return this.m_v3.a=1,this.m_count=1,void this.m_v1.set(this.m_v3);if(p>0&&y>0&&v<=0){var b=1/(p+y);return this.m_v2.a=p*b,this.m_v3.a=y*b,this.m_count=2,void this.m_v1.set(this.m_v3)}var B=1/(v+f+x);this.m_v1.a=v*B,this.m_v2.a=f*B,this.m_v3.a=x*B,this.m_count=3},r.testOverlap=function(t,i,e,m,a,h){var c=new o;c.proxyA.set(t,i),c.proxyB.set(e,m),c.transformA=a,c.transformB=h,c.useRadii=!0;var _=new n,u=new s;return r(u,_,c),u.distance<10*l.EPSILON}},{"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../common/stats":26,"../util/common":50}],14:[function(t,i,e){function o(t){this.id=t,this.aabb=new h,this.userData=null,this.parent=null,this.child1=null,this.child2=null,this.height=-1,this.toString=function(){return this.id+": "+this.userData}}function s(){this.m_root=null,this.m_nodes={},this.m_lastProxyId=0}var n=t("../Settings"),r=(t("../util/common"),t("../util/Pool")),m=t("../common/Vec2"),a=t("../common/Math"),h=t("./AABB");i.exports=s;var c=new r({create:function(){return new h},release:function(t){t.lowerBound.setZero(),t.upperBound.setZero()}}),_=new r({create:function(){return new o}});o.prototype.isLeaf=function(){return null==this.child1},s.prototype.getUserData=function(t){var i=this.m_nodes[t];return i.userData},s.prototype.getFatAABB=function(t){var i=this.m_nodes[t];return i.aabb},s.prototype.allocateNode=function(){var t=_.allocate();return t.id=++this.m_lastProxyId,t.userData=null,t.parent=null,t.child1=null,t.child2=null,t.height=-1,this.m_nodes[t.id]=t,t},s.prototype.freeNode=function(t){_.release(t),t.height=-1,delete this.m_nodes[t.id]},s.prototype.createProxy=function(t,i){var e=this.allocateNode();return e.aabb.set(t),e.aabb.extend(n.aabbExtension),e.userData=i,e.height=0,this.insertLeaf(e),e.id},s.prototype.destroyProxy=function(t){var i=this.m_nodes[t];this.removeLeaf(i),this.freeNode(i)},s.prototype.moveProxy=function(t,i,e){var o=this.m_nodes[t];return!o.aabb.contains(i)&&(this.removeLeaf(o),o.aabb.set(i),i=o.aabb,h.extend(i,n.aabbExtension),e.x<0?i.lowerBound.x+=e.x*n.aabbMultiplier:i.upperBound.x+=e.x*n.aabbMultiplier,e.y<0?i.lowerBound.y+=e.y*n.aabbMultiplier:i.upperBound.y+=e.y*n.aabbMultiplier,this.insertLeaf(o),!0)},s.prototype.insertLeaf=function(t){if(null==this.m_root)return this.m_root=t,void(this.m_root.parent=null);for(var i=t.aabb,e=this.m_root;0==e.isLeaf();){var o=e.child1,s=e.child2,n=e.aabb.getPerimeter(),r=c.allocate();r.combine(e.aabb,i);var m=r.getPerimeter();c.release(r);var h,_=2*m,l=2*(m-n);if(o.isLeaf()){(y=c.allocate()).combine(i,o.aabb),h=y.getPerimeter()+l,c.release(y)}else{(y=c.allocate()).combine(i,o.aabb);var u=o.aabb.getPerimeter();h=y.getPerimeter()-u+l,c.release(y)}var p;if(s.isLeaf()){(y=c.allocate()).combine(i,s.aabb),p=y.getPerimeter()+l,c.release(y)}else{var y;(y=c.allocate()).combine(i,s.aabb);u=s.aabb.getPerimeter();p=y.getPerimeter()-u+l,c.release(y)}if(_<h&&_<p)break;e=h<p?o:s}var d=e,v=d.parent,f=this.allocateNode();for(f.parent=v,f.userData=null,f.aabb.combine(i,d.aabb),f.height=d.height+1,null!=v?(v.child1==d?v.child1=f:v.child2=f,f.child1=d,f.child2=t,d.parent=f,t.parent=f):(f.child1=d,f.child2=t,d.parent=f,t.parent=f,this.m_root=f),e=t.parent;null!=e;){o=(e=this.balance(e)).child1,s=e.child2;e.height=1+a.max(o.height,s.height),e.aabb.combine(o.aabb,s.aabb),e=e.parent}},s.prototype.removeLeaf=function(t){if(t!=this.m_root){var i,e=t.parent,o=e.parent;if(i=e.child1==t?e.child2:e.child1,null!=o){o.child1==e?o.child1=i:o.child2=i,i.parent=o,this.freeNode(e);for(var s=o;null!=s;){var n=(s=this.balance(s)).child1,r=s.child2;s.aabb.combine(n.aabb,r.aabb),s.height=1+a.max(n.height,r.height),s=s.parent}}else this.m_root=i,i.parent=null,this.freeNode(e)}else this.m_root=null},s.prototype.balance=function(t){var i=t;if(i.isLeaf()||i.height<2)return t;var e=i.child1,o=i.child2,s=o.height-e.height;if(s>1){var n=o.child1,r=o.child2;return o.child1=i,o.parent=i.parent,i.parent=o,null!=o.parent?o.parent.child1==t?o.parent.child1=o:o.parent.child2=o:this.m_root=o,n.height>r.height?(o.child2=n,i.child2=r,r.parent=i,i.aabb.combine(e.aabb,r.aabb),o.aabb.combine(i.aabb,n.aabb),i.height=1+a.max(e.height,r.height),o.height=1+a.max(i.height,n.height)):(o.child2=r,i.child2=n,n.parent=i,i.aabb.combine(e.aabb,n.aabb),o.aabb.combine(i.aabb,r.aabb),i.height=1+a.max(e.height,n.height),o.height=1+a.max(i.height,r.height)),o}if(s<-1){var m=e.child1,h=e.child2;return e.child1=i,e.parent=i.parent,i.parent=e,null!=e.parent?e.parent.child1==i?e.parent.child1=e:e.parent.child2=e:this.m_root=e,m.height>h.height?(e.child2=m,i.child1=h,h.parent=i,i.aabb.combine(o.aabb,h.aabb),e.aabb.combine(i.aabb,m.aabb),i.height=1+a.max(o.height,h.height),e.height=1+a.max(i.height,m.height)):(e.child2=h,i.child1=m,m.parent=i,i.aabb.combine(o.aabb,m.aabb),e.aabb.combine(i.aabb,h.aabb),i.height=1+a.max(o.height,m.height),e.height=1+a.max(i.height,h.height)),e}return i},s.prototype.getHeight=function(){return null==this.m_root?0:this.m_root.height},s.prototype.getAreaRatio=function(){if(null==this.m_root)return 0;for(var t,i=this.m_root.aabb.getPerimeter(),e=0,o=p.allocate().preorder();t=o.next();)t.height<0||(e+=t.aabb.getPerimeter());return p.release(o),e/i},s.prototype.computeHeight=function(t){var i;if((i=void 0!==t?this.m_nodes[t]:this.m_root).isLeaf())return 0;var e=ComputeHeight(i.child1),o=ComputeHeight(i.child2);return 1+a.max(e,o)},s.prototype.validateStructure=function(t){if(null!=t){this.m_root;var i=t.child1,e=t.child2;t.isLeaf()||(this.validateStructure(i),this.validateStructure(e))}},s.prototype.validateMetrics=function(t){if(null!=t){var i=t.child1,e=t.child2;if(!t.isLeaf()){var o=this.m_nodes[i].height,s=this.m_nodes[e].height;a.max(o,s);this.validateMetrics(i),this.validateMetrics(e)}}},s.prototype.validate=function(){ValidateStructure(this.m_root),ValidateMetrics(this.m_root)},s.prototype.getMaxBalance=function(){for(var t,i=0,e=p.allocate().preorder();t=e.next();)if(!(t.height<=1)){var o=a.abs(t.child2.height-t.child1.height);i=a.max(i,o)}return p.release(e),i},s.prototype.rebuildBottomUp=function(){for(var t,i=[],e=0,o=p.allocate().preorder();t=o.next();)t.height<0||(t.isLeaf()?(t.parent=null,i[e]=t,++e):this.freeNode(t));for(p.release(o);e>1;){for(var s=1/0,n=-1,r=-1,m=0;m<e;++m)for(var h=i[m].aabb,_=m+1;_<e;++_){var l=i[_].aabb,u=c.allocate();u.combine(h,l);var y=u.getPerimeter();y<s&&(n=m,r=_,s=y),c.release(u)}var d=i[n],v=i[r],f=this.allocateNode();f.child1=d,f.child2=v,f.height=1+a.max(d.height,v.height),f.aabb.combine(d.aabb,v.aabb),f.parent=null,d.parent=f,v.parent=f,i[r]=i[e-1],i[n]=f,--e}this.m_root=i[0],this.validate()},s.prototype.shiftOrigin=function(t){for(var i,e=p.allocate().preorder();i=e.next();){var o=i.aabb;o.lowerBound.x-=t.x,o.lowerBound.y-=t.y,o.upperBound.x-=t.x,o.upperBound.y-=t.y}p.release(e)},s.prototype.query=function(t,i){var e=u.allocate();for(e.push(this.m_root);e.length>0;){var o=e.pop();if(null!=o&&h.testOverlap(o.aabb,t))if(o.isLeaf()){if(0==i(o.id))return}else e.push(o.child1),e.push(o.child2)}u.release(e)},s.prototype.rayCast=function(t,i){var e=t.p1,o=t.p2,s=m.sub(o,e);s.normalize();var n=m.cross(1,s),r=m.abs(n),c=t.maxFraction,_=new h,p=m.combine(1-c,e,c,o);_.combinePoints(e,p);var y=u.allocate(),d=l.allocate();for(y.push(this.m_root);y.length>0;){var v=y.pop();if(null!=v&&0!=h.testOverlap(v.aabb,_)){var f=v.aabb.getCenter(),x=v.aabb.getExtents();if(!(a.abs(m.dot(n,m.sub(e,f)))-m.dot(r,x)>0))if(v.isLeaf()){d.p1=m.clone(t.p1),d.p2=m.clone(t.p2),d.maxFraction=c;var g=i(d,v.id);if(0==g)return;g>0&&(c=g,p=m.combine(1-c,e,c,o),_.combinePoints(e,p))}else y.push(v.child1),y.push(v.child2)}}u.release(y),l.release(d)};var l=new r({create:function(){return{}},release:function(t){}}),u=new r({create:function(){return[]},release:function(t){t.length=0}}),p=new r({create:function(){return new function(){var t=[],i=[];return{preorder:function(e){return t.length=0,t.push(e),i.length=0,i.push(0),this},next:function(){for(;t.length>0;){var e=t.length-1,o=t[e];if(0===i[e])return i[e]=1,o;if(1===i[e]&&(i[e]=2,o.child1))return t.push(o.child1),i.push(1),o.child1;if(2===i[e]&&(i[e]=3,o.child2))return t.push(o.child2),i.push(1),o.child2;t.pop(),i.pop()}},close:function(){t.length=0}}}},release:function(t){t.close()}})},{"../Settings":7,"../common/Math":18,"../common/Vec2":23,"../util/Pool":48,"../util/common":50,"./AABB":11}],15:[function(t,i,e){function o(){this.state,this.t}function s(){this.m_proxyA=new f,this.m_proxyB=new f,this.m_sweepA,this.m_sweepB,this.m_type,this.m_localPoint=_.zero(),this.m_axis=_.zero()}var n=!1;i.exports=function(t,i){var e=a.now();++h.toiCalls,t.state=o.e_unknown,t.t=i.tMax;var _=i.proxyA,l=i.proxyB,u=i.sweepA,f=i.sweepB;u.normalize(),f.normalize();var g=i.tMax,A=_.m_radius+l.m_radius,b=c.max(r.linearSlop,A-3*r.linearSlop),B=.25*r.linearSlop;n&&m.assert(b>B);var w=0,M=r.maxTOIIterations,C=0,V=new x,S=new d;for(S.proxyA=i.proxyA,S.proxyB=i.proxyB,S.useRadii=!1;;){var I=p.identity(),z=p.identity();u.getTransform(I,w),f.getTransform(z,w),S.transformA=I,S.transformB=z;var P=new v;if(y(P,V,S),P.distance<=0){t.state=o.e_overlapped,t.t=0;break}if(P.distance<b+B){t.state=o.e_touching,t.t=w;break}var T=new s;T.initialize(V,_,u,l,f,w);for(var L=!1,q=g,F=0;;){var R=T.findMinSeparation(q);if(T.indexA,T.indexB,R>b+B){t.state=o.e_separated,t.t=g,L=!0;break}if(R>b-B){w=q;break}var k=T.evaluate(w);if(T.indexA,T.indexB,k<b-B){t.state=o.e_failed,t.t=w,L=!0;break}if(k<=b+B){t.state=o.e_touching,t.t=w,L=!0;break}for(var D=0,j=w,E=q;;){var J;J=1&D?j+(b-k)*(E-j)/(R-k):.5*(j+E),++D,++h.toiRootIters;var O=T.evaluate(J);if(T.indexA,T.indexB,c.abs(O-b)<B){q=J;break}if(O>b?(j=J,k=O):(E=J,R=O),50==D)break}if(h.toiMaxRootIters=c.max(h.toiMaxRootIters,D),++F==r.maxPolygonVertices)break}if(++C,++h.toiIters,L)break;if(C==M){t.state=o.e_failed,t.t=w;break}}h.toiMaxIters=c.max(h.toiMaxIters,C);var N=a.diff(e);h.toiMaxTime=c.max(h.toiMaxTime,N),h.toiTime+=N},i.exports.Input=function(){this.proxyA=new f,this.proxyB=new f,this.sweepA=new u,this.sweepB=new u,this.tMax},i.exports.Output=o;var r=t("../Settings"),m=t("../util/common"),a=t("../util/Timer"),h=t("../common/stats"),c=t("../common/Math"),_=t("../common/Vec2"),l=(t("../common/Vec3"),t("../common/Mat22"),t("../common/Mat33"),t("../common/Rot")),u=t("../common/Sweep"),p=t("../common/Transform"),y=(t("../common/Velocity"),t("../common/Position"),t("./Distance")),d=y.Input,v=y.Output,f=y.Proxy,x=y.Cache;o.e_unknown=0,o.e_failed=1,o.e_overlapped=2,o.e_touching=3,o.e_separated=4,h.toiTime=0,h.toiMaxTime=0,h.toiCalls=0,h.toiIters=0,h.toiMaxIters=0,h.toiRootIters=0,h.toiMaxRootIters=0;s.prototype.initialize=function(t,i,e,o,s,r){this.m_proxyA=i,this.m_proxyB=o;var a=t.count;n&&m.assert(0<a&&a<3),this.m_sweepA=e,this.m_sweepB=s;var h=p.identity(),c=p.identity();if(this.m_sweepA.getTransform(h,r),this.m_sweepB.getTransform(c,r),1==a){this.m_type=1;var u=this.m_proxyA.getVertex(t.indexA[0]),y=this.m_proxyB.getVertex(t.indexB[0]),d=p.mulVec2(h,u),v=p.mulVec2(c,y);this.m_axis.setCombine(1,v,-1,d);return B=this.m_axis.normalize()}if(t.indexA[0]==t.indexA[1]){this.m_type=3;var f=o.getVertex(t.indexB[0]),x=o.getVertex(t.indexB[1]);this.m_axis=_.cross(_.sub(x,f),1),this.m_axis.normalize();var g=l.mulVec2(c.q,this.m_axis);this.m_localPoint=_.mid(f,x);v=p.mulVec2(c,this.m_localPoint),u=i.getVertex(t.indexA[0]),d=p.mulVec2(h,u);return(B=_.dot(d,g)-_.dot(v,g))<0&&(this.m_axis=_.neg(this.m_axis),B=-B),B}this.m_type=2;var A=this.m_proxyA.getVertex(t.indexA[0]),b=this.m_proxyA.getVertex(t.indexA[1]);this.m_axis=_.cross(_.sub(b,A),1),this.m_axis.normalize();g=l.mulVec2(h.q,this.m_axis);this.m_localPoint=_.mid(A,b);var B;d=p.mulVec2(h,this.m_localPoint),y=this.m_proxyB.getVertex(t.indexB[0]),v=p.mulVec2(c,y);return(B=_.dot(v,g)-_.dot(d,g))<0&&(this.m_axis=_.neg(this.m_axis),B=-B),B},s.prototype.compute=function(t,i){var e=p.identity(),o=p.identity();switch(this.m_sweepA.getTransform(e,i),this.m_sweepB.getTransform(o,i),this.m_type){case 1:if(t){var s=l.mulTVec2(e.q,this.m_axis),r=l.mulTVec2(o.q,_.neg(this.m_axis));this.indexA=this.m_proxyA.getSupport(s),this.indexB=this.m_proxyB.getSupport(r)}var a=this.m_proxyA.getVertex(this.indexA),h=this.m_proxyB.getVertex(this.indexB),c=p.mulVec2(e,a),u=p.mulVec2(o,h);return _.dot(u,this.m_axis)-_.dot(c,this.m_axis);case 2:var y=l.mulVec2(e.q,this.m_axis);c=p.mulVec2(e,this.m_localPoint);if(t){r=l.mulTVec2(o.q,_.neg(y));this.indexA=-1,this.indexB=this.m_proxyB.getSupport(r)}h=this.m_proxyB.getVertex(this.indexB),u=p.mulVec2(o,h);return _.dot(u,y)-_.dot(c,y);case 3:y=l.mulVec2(o.q,this.m_axis),u=p.mulVec2(o,this.m_localPoint);if(t){s=l.mulTVec2(e.q,_.neg(y));this.indexB=-1,this.indexA=this.m_proxyA.getSupport(s)}a=this.m_proxyA.getVertex(this.indexA),c=p.mulVec2(e,a);return _.dot(c,y)-_.dot(u,y);default:return n&&m.assert(!1),t&&(this.indexA=-1,this.indexB=-1),0}},s.prototype.findMinSeparation=function(t){return this.compute(!0,t)},s.prototype.evaluate=function(t){return this.compute(!1,t)}},{"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../common/stats":26,"../util/Timer":49,"../util/common":50,"./Distance":13}],16:[function(t,i,e){function o(t,i,e,o){"object"==typeof t&&null!==t?(this.ex=s.clone(t),this.ey=s.clone(i)):"number"==typeof t?(this.ex=s.neo(t,e),this.ey=s.neo(i,o)):(this.ex=s.zero(),this.ey=s.zero())}i.exports=o;t("../util/common"),t("./Math");var s=t("./Vec2");o.prototype.toString=function(){return JSON.stringify(this)},o.isValid=function(t){return t&&s.isValid(t.ex)&&s.isValid(t.ey)},o.assert=function(t){},o.prototype.set=function(t,i,e,o){"number"==typeof t&&"number"==typeof i&&"number"==typeof e&&"number"==typeof o?(this.ex.set(t,e),this.ey.set(i,o)):"object"==typeof t&&"object"==typeof i?(this.ex.set(t),this.ey.set(i)):"object"==typeof t&&(this.ex.set(t.ex),this.ey.set(t.ey))},o.prototype.setIdentity=function(){this.ex.x=1,this.ey.x=0,this.ex.y=0,this.ey.y=1},o.prototype.setZero=function(){this.ex.x=0,this.ey.x=0,this.ex.y=0,this.ey.y=0},o.prototype.getInverse=function(){var t=this.ex.x,i=this.ey.x,e=this.ex.y,s=this.ey.y,n=t*s-i*e;0!=n&&(n=1/n);var r=new o;return r.ex.x=n*s,r.ey.x=-n*i,r.ex.y=-n*e,r.ey.y=n*t,r},o.prototype.solve=function(t){var i=this.ex.x,e=this.ey.x,o=this.ex.y,n=this.ey.y,r=i*n-e*o;0!=r&&(r=1/r);var m=s.zero();return m.x=r*(n*t.x-e*t.y),m.y=r*(i*t.y-o*t.x),m},o.mul=function(t,i){if(i&&"x"in i&&"y"in i){var e=t.ex.x*i.x+t.ey.x*i.y,n=t.ex.y*i.x+t.ey.y*i.y;return s.neo(e,n)}if(i&&"ex"in i&&"ey"in i)return new o(s.mul(t,i.ex),s.mul(t,i.ey))},o.mulVec2=function(t,i){var e=t.ex.x*i.x+t.ey.x*i.y,o=t.ex.y*i.x+t.ey.y*i.y;return s.neo(e,o)},o.mulVec2_=function(t,i,e){var o=t.ex.x*i.x+t.ey.x*i.y,s=t.ex.y*i.x+t.ey.y*i.y;return e.set(o,s)},o.mulMat22=function(t,i){return new o(s.mul(t,i.ex),s.mul(t,i.ey))},o.mulT=function(t,i){if(i&&"x"in i&&"y"in i)return s.neo(s.dot(i,t.ex),s.dot(i,t.ey));if(i&&"ex"in i&&"ey"in i){return new o(s.neo(s.dot(t.ex,i.ex),s.dot(t.ey,i.ex)),s.neo(s.dot(t.ex,i.ey),s.dot(t.ey,i.ey)))}},o.mulTVec2=function(t,i){return s.neo(s.dot(i,t.ex),s.dot(i,t.ey))},o.mulTMat22=function(t,i){return new o(s.neo(s.dot(t.ex,i.ex),s.dot(t.ey,i.ex)),s.neo(s.dot(t.ex,i.ey),s.dot(t.ey,i.ey)))},o.abs=function(t){return new o(s.abs(t.ex),s.abs(t.ey))},o.add=function(t,i){return new o(s.add(t.ex+i.ex),s.add(t.ey+i.ey))}},{"../util/common":50,"./Math":18,"./Vec2":23}],17:[function(t,i,e){function o(t,i,e){"object"==typeof t&&null!==t?(this.ex=n.clone(t),this.ey=n.clone(i),this.ez=n.clone(e)):(this.ex=n(),this.ey=n(),this.ez=n())}i.exports=o;t("../util/common"),t("./Math");var s=t("./Vec2"),n=t("./Vec3");o.prototype.toString=function(){return JSON.stringify(this)},o.isValid=function(t){return t&&n.isValid(t.ex)&&n.isValid(t.ey)&&n.isValid(t.ez)},o.assert=function(t){},o.prototype.setZero=function(){return this.ex.setZero(),this.ey.setZero(),this.ez.setZero(),this},o.prototype.solve33=function(t){var i=n.dot(this.ex,n.cross(this.ey,this.ez));0!=i&&(i=1/i);var e=new n;return e.x=i*n.dot(t,n.cross(this.ey,this.ez)),e.y=i*n.dot(this.ex,n.cross(t,this.ez)),e.z=i*n.dot(this.ex,n.cross(this.ey,t)),e},o.prototype.solve22=function(t){var i=this.ex.x,e=this.ey.x,o=this.ex.y,n=this.ey.y,r=i*n-e*o;0!=r&&(r=1/r);var m=s.zero();return m.x=r*(n*t.x-e*t.y),m.y=r*(i*t.y-o*t.x),m},o.prototype.getInverse22=function(t){var i=this.ex.x,e=this.ey.x,o=this.ex.y,s=this.ey.y,n=i*s-e*o;0!=n&&(n=1/n),t.ex.x=n*s,t.ey.x=-n*e,t.ex.z=0,t.ex.y=-n*o,t.ey.y=n*i,t.ey.z=0,t.ez.x=0,t.ez.y=0,t.ez.z=0},o.prototype.getSymInverse33=function(t){var i=n.dot(this.ex,n.cross(this.ey,this.ez));0!=i&&(i=1/i);var e=this.ex.x,o=this.ey.x,s=this.ez.x,r=this.ey.y,m=this.ez.y,a=this.ez.z;t.ex.x=i*(r*a-m*m),t.ex.y=i*(s*m-o*a),t.ex.z=i*(o*m-s*r),t.ey.x=t.ex.y,t.ey.y=i*(e*a-s*s),t.ey.z=i*(s*o-e*m),t.ez.x=t.ex.z,t.ez.y=t.ey.z,t.ez.z=i*(e*r-o*o)},o.mul=function(t,i){if(i&&"z"in i&&"y"in i&&"x"in i){var e=t.ex.x*i.x+t.ey.x*i.y+t.ez.x*i.z,o=t.ex.y*i.x+t.ey.y*i.y+t.ez.y*i.z,r=t.ex.z*i.x+t.ey.z*i.y+t.ez.z*i.z;return new n(e,o,r)}if(i&&"y"in i&&"x"in i){e=t.ex.x*i.x+t.ey.x*i.y,o=t.ex.y*i.x+t.ey.y*i.y;return s.neo(e,o)}},o.mulVec3=function(t,i){var e=t.ex.x*i.x+t.ey.x*i.y+t.ez.x*i.z,o=t.ex.y*i.x+t.ey.y*i.y+t.ez.y*i.z,s=t.ex.z*i.x+t.ey.z*i.y+t.ez.z*i.z;return new n(e,o,s)},o.mulVec2=function(t,i){var e=t.ex.x*i.x+t.ey.x*i.y,o=t.ex.y*i.x+t.ey.y*i.y;return s.neo(e,o)},o.add=function(t,i){return new o(n.add(t.ex+i.ex),n.add(t.ey+i.ey),n.add(t.ez+i.ez))}},{"../util/common":50,"./Math":18,"./Vec2":23,"./Vec3":24}],18:[function(t,i,e){t("../util/common");var o=t("../util/create"),s=Math,n=i.exports=o(s);n.EPSILON=1e-9,n.isFinite=function(t){return"number"==typeof t&&isFinite(t)&&!isNaN(t)},n.assert=function(t){},n.invSqrt=function(t){return 1/s.sqrt(t)},n.nextPowerOfTwo=function(t){return t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,(t|=t>>16)+1},n.isPowerOfTwo=function(t){return t>0&&0==(t&t-1)},n.mod=function(t,i,e){return void 0===i?(e=1,i=0):void 0===e&&(e=i,i=0),e>i?(t=(t-i)%(e-i))+(t<0?e:i):(t=(t-e)%(i-e))+(t<=0?i:e)},n.clamp=function(t,i,e){return t<i?i:t>e?e:t},n.random=function(t,i){return void 0===t?(i=1,t=0):void 0===i&&(i=t,t=0),t==i?t:s.random()*(i-t)+t}},{"../util/common":50,"../util/create":51}],19:[function(t,i,e){function o(){this.c=s.zero(),this.a=0}i.exports=o;var s=t("./Vec2"),n=t("./Rot");o.prototype.getTransform=function(t,i){return t.q.set(this.a),t.p.set(s.sub(this.c,n.mulVec2(t.q,i))),t}},{"./Rot":20,"./Vec2":23}],20:[function(t,i,e){function o(t){if(!(this instanceof o))return new o(t);"number"==typeof t?this.setAngle(t):"object"==typeof t?this.set(t):this.setIdentity()}i.exports=o;t("../util/common");var s=t("./Vec2"),n=t("./Math");o.neo=function(t){var i=Object.create(o.prototype);return i.setAngle(t),i},o.clone=function(t){var i=Object.create(o.prototype);return i.s=t.s,i.c=t.c,i},o.identity=function(){var t=Object.create(o.prototype);return t.s=0,t.c=1,t},o.isValid=function(t){return t&&n.isFinite(t.s)&&n.isFinite(t.c)},o.assert=function(t){},o.prototype.setIdentity=function(){return this.s=0,this.c=1,this},o.prototype.set=function(t){"object"==typeof t?(this.s=t.s,this.c=t.c):(this.s=n.sin(t),this.c=n.cos(t))},o.prototype.setAngle=function(t){this.s=n.sin(t),this.c=n.cos(t)},o.prototype.getAngle=function(){return n.atan2(this.s,this.c)},o.prototype.getXAxis=function(){return s.neo(this.c,this.s)},o.prototype.getYAxis=function(){return s.neo(-this.s,this.c)},o.mul=function(t,i){if("c"in i&&"s"in i){var e=o.identity();return e.s=t.s*i.c+t.c*i.s,e.c=t.c*i.c-t.s*i.s,e}if("x"in i&&"y"in i)return s.neo(t.c*i.x-t.s*i.y,t.s*i.x+t.c*i.y)},o.mulRot=function(t,i){var e=o.identity();return e.s=t.s*i.c+t.c*i.s,e.c=t.c*i.c-t.s*i.s,e},o.mulVec2=function(t,i){return s.neo(t.c*i.x-t.s*i.y,t.s*i.x+t.c*i.y)},o.mulVec2_=function(t,i,e){return e.set(t.c*i.x-t.s*i.y,t.s*i.x+t.c*i.y)},o.mulSub=function(t,i,e){var o=t.c*(i.x-e.x)-t.s*(i.y-e.y),n=t.s*(i.x-e.y)+t.c*(i.y-e.y);return s.neo(o,n)},o.mulT=function(t,i){if("c"in i&&"s"in i){var e=o.identity();return e.s=t.c*i.s-t.s*i.c,e.c=t.c*i.c+t.s*i.s,e}if("x"in i&&"y"in i)return s.neo(t.c*i.x+t.s*i.y,-t.s*i.x+t.c*i.y)},o.mulTRot=function(t,i){var e=o.identity();return e.s=t.c*i.s-t.s*i.c,e.c=t.c*i.c+t.s*i.s,e},o.mulTRot_=function(t,i,e){var o=e.setIdentity();return o.s=t.c*i.s-t.s*i.c,o.c=t.c*i.c+t.s*i.s,o},o.mulTVec2=function(t,i){return s.neo(t.c*i.x+t.s*i.y,-t.s*i.x+t.c*i.y)},o.mulTVec2_=function(t,i,e){return e.set(t.c*i.x+t.s*i.y,-t.s*i.x+t.c*i.y)}},{"../util/common":50,"./Math":18,"./Vec2":23}],21:[function(t,i,e){function o(t,i){s&&n.assert(void 0===t),s&&n.assert(void 0===i),this.localCenter=m.zero(),this.c=m.zero(),this.a=0,this.alpha0=0,this.c0=m.zero(),this.a0=0}var s=!1;i.exports=o;var n=t("../util/common"),r=t("./Math"),m=t("./Vec2"),a=t("./Rot"),h=t("./Transform");o.prototype.setTransform=function(t){var i=h.mulVec2(t,this.localCenter);this.c.set(i),this.c0.set(i),this.a=t.q.getAngle(),this.a0=t.q.getAngle()},o.prototype.setLocalCenter=function(t,i){this.localCenter.set(t);var e=h.mulVec2(i,this.localCenter);this.c.set(e),this.c0.set(e)},o.prototype.getTransform=function(t,i){i=void 0===i?0:i,t.q.setAngle((1-i)*this.a0+i*this.a),t.p.setCombine(1-i,this.c0,i,this.c),t.p.sub(a.mulVec2(t.q,this.localCenter))},o.prototype.advance=function(t){s&&n.assert(this.alpha0<1);var i=(t-this.alpha0)/(1-this.alpha0);this.c0.setCombine(i,this.c,1-i,this.c0),this.a0=i*this.a+(1-i)*this.a0,this.alpha0=t},o.prototype.forward=function(){this.a0=this.a,this.c0.set(this.c)},o.prototype.normalize=function(){var t=r.mod(this.a0,-r.PI,+r.PI);this.a-=this.a0-t,this.a0=t},o.prototype.clone=function(){var t=new o;return t.localCenter.set(this.localCenter),t.alpha0=this.alpha0,t.a0=this.a0,t.a=this.a,t.c0.set(this.c0),t.c.set(this.c),t},o.prototype.set=function(t){this.localCenter.set(t.localCenter),this.alpha0=t.alpha0,this.a0=t.a0,this.a=t.a,this.c0.set(t.c0),this.c.set(t.c)}},{"../util/common":50,"./Math":18,"./Rot":20,"./Transform":22,"./Vec2":23}],22:[function(t,i,e){function o(t,i){if(!(this instanceof o))return new o(t,i);this.p=s.zero(),this.q=n.identity(),void 0!==t&&this.p.set(t),void 0!==i&&this.q.set(i)}i.exports=o;t("../util/common");var s=t("./Vec2"),n=t("./Rot");o.clone=function(t){var i=Object.create(o.prototype);return i.p=s.clone(t.p),i.q=n.clone(t.q),i},o.neo=function(t,i){var e=Object.create(o.prototype);return e.p=s.clone(t),e.q=n.clone(i),e},o.identity=function(){var t=Object.create(o.prototype);return t.p=s.zero(),t.q=n.identity(),t},o.prototype.setIdentity=function(){return this.p.setZero(),this.q.setIdentity(),this},o.prototype.set=function(t,i){void 0===i?(this.p.set(t.p),this.q.set(t.q)):(this.p.set(t),this.q.set(i))},o.isValid=function(t){return t&&s.isValid(t.p)&&n.isValid(t.q)},o.assert=function(t){},o.mul=function(t,i){if(Array.isArray(i)){for(var e=[],r=0;r<i.length;r++)e[r]=o.mul(t,i[r]);return e}if("x"in i&&"y"in i){var m=t.q.c*i.x-t.q.s*i.y+t.p.x,a=t.q.s*i.x+t.q.c*i.y+t.p.y;return s.neo(m,a)}if("p"in i&&"q"in i){var h=o.identity();return h.q=n.mulRot(t.q,i.q),h.p=s.add(n.mulVec2(t.q,i.p),t.p),h}},o.mulAll=function(t,i){for(var e=[],s=0;s<i.length;s++)e[s]=o.mul(t,i[s]);return e},o.mulFn=function(t){return function(i){return o.mul(t,i)}},o.mulVec2=function(t,i){var e=t.q.c*i.x-t.q.s*i.y+t.p.x,o=t.q.s*i.x+t.q.c*i.y+t.p.y;return s.neo(e,o)},o.mulVec2_=function(t,i,e){var o=t.q.c*i.x-t.q.s*i.y+t.p.x,s=t.q.s*i.x+t.q.c*i.y+t.p.y;return e.set(o,s)},o.mulXf=function(t,i){var e=o.identity();return e.q=n.mulRot(t.q,i.q),e.p=s.add(n.mulVec2(t.q,i.p),t.p),e},o.mulT=function(t,i){if("x"in i&&"y"in i){var e=i.x-t.p.x,r=i.y-t.p.y,m=t.q.c*e+t.q.s*r,a=-t.q.s*e+t.q.c*r;return s.neo(m,a)}if("p"in i&&"q"in i){var h=o.identity();return h.q.set(n.mulTRot(t.q,i.q)),h.p.set(n.mulTVec2(t.q,s.sub(i.p,t.p))),h}},o.mulTVec2=function(t,i){var e=i.x-t.p.x,o=i.y-t.p.y,n=t.q.c*e+t.q.s*o,r=-t.q.s*e+t.q.c*o;return s.neo(n,r)},o.mulTVec2_=function(t,i,e){var o=i.x-t.p.x,s=i.y-t.p.y,n=t.q.c*o+t.q.s*s,r=-t.q.s*o+t.q.c*s;return e.set(n,r)},o.mulTXf=function(t,i){var e=o.identity();return e.q.set(n.mulTRot(t.q,i.q)),e.p.set(n.mulTVec2(t.q,s.sub(i.p,t.p))),e};var r=s.zero();o.mulTXf_=function(t,i,e){return n.mulTRot_(t.q,i.q,e.q),n.mulTVec2_(t.q,s.sub(i.p,t.p,r),e.p),e}},{"../util/common":50,"./Rot":20,"./Vec2":23}],23:[function(t,i,e){function o(t,i){if(!(this instanceof o))return new o(t,i);void 0===t?(this.x=0,this.y=0):"object"==typeof t?(this.x=t.x,this.y=t.y):(this.x=t,this.y=i),s&&o.assert(this)}var s=!1;i.exports=o;var n=t("../util/common"),r=t("./Math");o.zero=function(){var t=Object.create(o.prototype);return t.x=0,t.y=0,t},o.neo=function(t,i){var e=Object.create(o.prototype);return e.x=t,e.y=i,e},o.clone=function(t){return s&&o.assert(t),o.neo(t.x,t.y)},o.prototype.toString=function(){return JSON.stringify(this)},o.isValid=function(t){return t&&r.isFinite(t.x)&&r.isFinite(t.y)},o.assert=function(t){if(s&&!o.isValid(t))throw new Error("Invalid Vec2!")},o.prototype.clone=function(){return o.clone(this)},o.prototype.setZero=function(){return this.x=0,this.y=0,this},o.prototype.set=function(t,i){return"object"==typeof t?(s&&o.assert(t),this.x=t.x,this.y=t.y):(s&&r.assert(t),s&&r.assert(i),this.x=t,this.y=i),this},o.prototype.setXY=function(t,i){return this.x=t,this.y=i,this},o.prototype.setVec2=function(t){return this.x=t.x,this.y=t.y,this},o.prototype.wSet=function(t,i,e,o){return void 0!==e||void 0!==o?this.setCombine(t,i,e,o):this.setMul(t,i)},o.prototype.setCombine=function(t,i,e,n){s&&r.assert(t),s&&o.assert(i),s&&r.assert(e),s&&o.assert(n);var m=t*i.x+e*n.x,a=t*i.y+e*n.y;return this.x=m,this.y=a,this},o.prototype.setMul=function(t,i){s&&r.assert(t),s&&o.assert(i);var e=t*i.x,n=t*i.y;return this.x=e,this.y=n,this},o.prototype.add=function(t){return s&&o.assert(t),this.x+=t.x,this.y+=t.y,this},o.prototype.wAdd=function(t,i,e,o){return void 0!==e||void 0!==o?this.addCombine(t,i,e,o):this.addMul(t,i)},o.prototype.addCombine=function(t,i,e,n){s&&r.assert(t),s&&o.assert(i),s&&r.assert(e),s&&o.assert(n);var m=t*i.x+e*n.x,a=t*i.y+e*n.y;return this.x+=m,this.y+=a,this},o.prototype.addMul=function(t,i){s&&r.assert(t),s&&o.assert(i);var e=t*i.x,n=t*i.y;return this.x+=e,this.y+=n,this},o.prototype.wSub=function(t,i,e,o){return void 0!==e||void 0!==o?this.subCombine(t,i,e,o):this.subMul(t,i)},o.prototype.subCombine=function(t,i,e,n){s&&r.assert(t),s&&o.assert(i),s&&r.assert(e),s&&o.assert(n);var m=t*i.x+e*n.x,a=t*i.y+e*n.y;return this.x-=m,this.y-=a,this},o.prototype.subMul=function(t,i){s&&r.assert(t),s&&o.assert(i);var e=t*i.x,n=t*i.y;return this.x-=e,this.y-=n,this},o.prototype.sub=function(t){return s&&o.assert(t),this.x-=t.x,this.y-=t.y,this},o.prototype.mul=function(t){return s&&r.assert(t),this.x*=t,this.y*=t,this},o.prototype.length=function(){return o.lengthOf(this)},o.prototype.lengthSquared=function(){return o.lengthSquared(this)},o.prototype.normalize=function(){var t=this.length();if(t<r.EPSILON)return 0;var i=1/t;return this.x*=i,this.y*=i,t},o.lengthOf=function(t){return s&&o.assert(t),r.sqrt(t.x*t.x+t.y*t.y)},o.lengthSquared=function(t){return s&&o.assert(t),t.x*t.x+t.y*t.y},o.distance=function(t,i){s&&o.assert(t),s&&o.assert(i);var e=t.x-i.x,n=t.y-i.y;return r.sqrt(e*e+n*n)},o.distanceSquared=function(t,i){s&&o.assert(t),s&&o.assert(i);var e=t.x-i.x,n=t.y-i.y;return e*e+n*n},o.areEqual=function(t,i){return s&&o.assert(t),s&&o.assert(i),t==i||"object"==typeof i&&null!==i&&t.x===i.x&&t.y===i.y},o.skew=function(t){return s&&o.assert(t),o.neo(-t.y,t.x)},o.dot=function(t,i){return s&&o.assert(t),s&&o.assert(i),t.x*i.x+t.y*i.y},o.cross=function(t,i){return"number"==typeof i?(s&&o.assert(t),s&&r.assert(i),o.neo(i*t.y,-i*t.x)):"number"==typeof t?(s&&r.assert(t),s&&o.assert(i),o.neo(-t*i.y,t*i.x)):(s&&o.assert(t),s&&o.assert(i),t.x*i.y-t.y*i.x)},o.crossVec2Vec2=function(t,i){return t.x*i.y-t.y*i.x},o.crossNumVec2_=function(t,i,e){return e.setXY(-t*i.y,t*i.x)},o.crossVec2Num_=function(t,i,e){return e.setXY(i*t.y,-i*t.x)},o.addCross=function(t,i,e){return"number"==typeof e?(s&&o.assert(i),s&&r.assert(e),o.neo(e*i.y+t.x,-e*i.x+t.y)):"number"==typeof i?(s&&r.assert(i),s&&o.assert(e),o.neo(-i*e.y+t.x,i*e.x+t.y)):void(s&&n.assert(!1))},o.add=function(t,i){return s&&o.assert(t),s&&o.assert(i),o.neo(t.x+i.x,t.y+i.y)},o.wAdd=function(t,i,e,s){return void 0!==e||void 0!==s?o.combine(t,i,e,s):o.mul(t,i)},o.combine=function(t,i,e,s){return o.zero().setCombine(t,i,e,s)},o.combine_=function(t,i,e,o,s){return s.setCombine(t,i,e,o)},o.sub=function(t,i){return s&&o.assert(t),s&&o.assert(i),o.neo(t.x-i.x,t.y-i.y)},o.sub_=function(t,i,e){return s&&o.assert(t),s&&o.assert(i),e.setXY(t.x-i.x,t.y-i.y)},o.mul=function(t,i){return"object"==typeof t?(s&&o.assert(t),s&&r.assert(i),o.neo(t.x*i,t.y*i)):"object"==typeof i?(s&&r.assert(t),s&&o.assert(i),o.neo(t*i.x,t*i.y)):void 0},o.mulVec2Num_=function(t,i,e){return e.setXY(t.x*i,t.y*i)},o.mulNumVec2_=function(t,i,e){return e.setXY(t*i.x,t*i.y)},o.prototype.neg=function(){return this.x=-this.x,this.y=-this.y,this},o.neg=function(t){return s&&o.assert(t),o.neo(-t.x,-t.y)},o.neg_=function(t,i){return s&&o.assert(t),i.setXY(-t.x,-t.y)},o.abs=function(t){return s&&o.assert(t),o.neo(r.abs(t.x),r.abs(t.y))},o.mid=function(t,i){return s&&o.assert(t),s&&o.assert(i),o.neo(.5*(t.x+i.x),.5*(t.y+i.y))},o.upper=function(t,i){return s&&o.assert(t),s&&o.assert(i),o.neo(r.max(t.x,i.x),r.max(t.y,i.y))},o.lower=function(t,i){return s&&o.assert(t),s&&o.assert(i),o.neo(r.min(t.x,i.x),r.min(t.y,i.y))},o.prototype.clamp=function(t){var i=this.x*this.x+this.y*this.y;if(i>t*t){var e=r.invSqrt(i);this.x*=e*t,this.y*=e*t}return this},o.clamp=function(t,i){return(t=o.neo(t.x,t.y)).clamp(i),t},o.scaleFn=function(t,i){return function(e){return o.neo(e.x*t,e.y*i)}},o.translateFn=function(t,i){return function(e){return o.neo(e.x+t,e.y+i)}}},{"../util/common":50,"./Math":18}],24:[function(t,i,e){function o(t,i,e){if(!(this instanceof o))return new o(t,i,e);void 0===t?(this.x=0,this.y=0,this.z=0):"object"==typeof t?(this.x=t.x,this.y=t.y,this.z=t.z):(this.x=t,this.y=i,this.z=e),s&&o.assert(this)}var s=!1;i.exports=o;t("../util/common");var n=t("./Math");o.neo=function(t,i,e){var s=Object.create(o.prototype);return s.x=t,s.y=i,s.z=e,s},o.clone=function(t){return s&&o.assert(t),o.neo(t.x,t.y,t.z)},o.prototype.toString=function(){return JSON.stringify(this)},o.isValid=function(t){return t&&n.isFinite(t.x)&&n.isFinite(t.y)&&n.isFinite(t.z)},o.assert=function(t){if(s&&!o.isValid(t))throw new Error("Invalid Vec3!")},o.prototype.setZero=function(){return this.x=0,this.y=0,this.z=0,this},o.prototype.set=function(t,i,e){return this.x=t,this.y=i,this.z=e,this},o.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},o.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},o.prototype.mul=function(t){return this.x*=t,this.y*=t,this.z*=t,this},o.areEqual=function(t,i){return s&&o.assert(t),s&&o.assert(i),t==i||"object"==typeof t&&null!==t&&"object"==typeof i&&null!==i&&t.x===i.x&&t.y===i.y&&t.z===i.z},o.dot=function(t,i){return t.x*i.x+t.y*i.y+t.z*i.z},o.cross=function(t,i){return new o(t.y*i.z-t.z*i.y,t.z*i.x-t.x*i.z,t.x*i.y-t.y*i.x)},o.add=function(t,i){return new o(t.x+i.x,t.y+i.y,t.z+i.z)},o.sub=function(t,i){return new o(t.x-i.x,t.y-i.y,t.z-i.z)},o.mul=function(t,i){return new o(i*t.x,i*t.y,i*t.z)},o.prototype.neg=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},o.neg=function(t){return new o(-t.x,-t.y,-t.z)}},{"../util/common":50,"./Math":18}],25:[function(t,i,e){i.exports=function(){this.v=o.zero(),this.w=0};var o=t("./Vec2")},{"./Vec2":23}],26:[function(t,i,e){e.toString=function(t){t="string"==typeof t?t:"\n";var i="";for(var e in this)"function"!=typeof this[e]&&"object"!=typeof this[e]&&(i+=e+": "+this[e]+t);return i}},{}],27:[function(t,i,e){function o(t,i,e,n,r){if(!(this instanceof o))return new o(t,i,e,n,r);if(e&&n&&"m_type"in n&&"x"in e&&"y"in e){var h=e;e=n,n=h}t=s(t,_),c.call(this,t,i,e),i=this.m_bodyA,e=this.m_bodyB,this.m_type=o.TYPE,this.m_localAnchorA=n?i.getLocalPoint(n):t.localAnchorA||a.zero(),this.m_localAnchorB=r?e.getLocalPoint(r):t.localAnchorB||a.zero(),this.m_length=m.isFinite(t.length)?t.length:a.distance(i.getWorldPoint(this.m_localAnchorA),e.getWorldPoint(this.m_localAnchorB)),this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_impulse=0,this.m_gamma=0,this.m_bias=0,this.m_u,this.m_rA,this.m_rB,this.m_localCenterA,this.m_localCenterB,this.m_invMassA,this.m_invMassB,this.m_invIA,this.m_invIB,this.m_mass}i.exports=o;var s=t("../util/options"),n=t("../util/create"),r=t("../Settings"),m=t("../common/Math"),a=t("../common/Vec2"),h=(t("../common/Vec3"),t("../common/Mat22"),t("../common/Mat33"),t("../common/Rot")),c=(t("../common/Sweep"),t("../common/Transform"),t("../common/Velocity"),t("../common/Position"),t("../Joint"));o.TYPE="distance-joint";var _={frequencyHz:0,dampingRatio:0};(o.prototype=n((o._super=c).prototype)).getLocalAnchorA=function(){return this.m_localAnchorA},o.prototype.getLocalAnchorB=function(){return this.m_localAnchorB},o.prototype.setLength=function(t){this.m_length=t},o.prototype.getLength=function(){return this.m_length},o.prototype.setFrequency=function(t){this.m_frequencyHz=t},o.prototype.getFrequency=function(){return this.m_frequencyHz},o.prototype.setDampingRatio=function(t){this.m_dampingRatio=t},o.prototype.getDampingRatio=function(){return this.m_dampingRatio},o.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)},o.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},o.prototype.getReactionForce=function(t){return a.mul(this.m_impulse,this.m_u).mul(t)},o.prototype.getReactionTorque=function(t){return 0},o.prototype.initVelocityConstraints=function(t){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter,this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=this.m_bodyA.c_position.c,e=this.m_bodyA.c_position.a,o=this.m_bodyA.c_velocity.v,s=this.m_bodyA.c_velocity.w,n=this.m_bodyB.c_position.c,c=this.m_bodyB.c_position.a,_=this.m_bodyB.c_velocity.v,l=this.m_bodyB.c_velocity.w,u=h.neo(e),p=h.neo(c);this.m_rA=h.mulVec2(u,a.sub(this.m_localAnchorA,this.m_localCenterA)),this.m_rB=h.mulVec2(p,a.sub(this.m_localAnchorB,this.m_localCenterB)),this.m_u=a.sub(a.add(n,this.m_rB),a.add(i,this.m_rA));var y=this.m_u.length();y>r.linearSlop?this.m_u.mul(1/y):this.m_u.set(0,0);var d=a.cross(this.m_rA,this.m_u),v=a.cross(this.m_rB,this.m_u),f=this.m_invMassA+this.m_invIA*d*d+this.m_invMassB+this.m_invIB*v*v;if(this.m_mass=0!=f?1/f:0,this.m_frequencyHz>0){var x=y-this.m_length,g=2*m.PI*this.m_frequencyHz,A=2*this.m_mass*this.m_dampingRatio*g,b=this.m_mass*g*g,B=t.dt;this.m_gamma=B*(A+B*b),this.m_gamma=0!=this.m_gamma?1/this.m_gamma:0,this.m_bias=x*B*b*this.m_gamma,f+=this.m_gamma,this.m_mass=0!=f?1/f:0}else this.m_gamma=0,this.m_bias=0;if(t.warmStarting){this.m_impulse*=t.dtRatio;var w=a.mul(this.m_impulse,this.m_u);o.subMul(this.m_invMassA,w),s-=this.m_invIA*a.cross(this.m_rA,w),_.addMul(this.m_invMassB,w),l+=this.m_invIB*a.cross(this.m_rB,w)}else this.m_impulse=0;this.m_bodyA.c_velocity.v.set(o),this.m_bodyA.c_velocity.w=s,this.m_bodyB.c_velocity.v.set(_),this.m_bodyB.c_velocity.w=l},o.prototype.solveVelocityConstraints=function(t){var i=this.m_bodyA.c_velocity.v,e=this.m_bodyA.c_velocity.w,o=this.m_bodyB.c_velocity.v,s=this.m_bodyB.c_velocity.w,n=a.add(i,a.cross(e,this.m_rA)),r=a.add(o,a.cross(s,this.m_rB)),m=a.dot(this.m_u,r)-a.dot(this.m_u,n),h=-this.m_mass*(m+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=h;var c=a.mul(h,this.m_u);i.subMul(this.m_invMassA,c),e-=this.m_invIA*a.cross(this.m_rA,c),o.addMul(this.m_invMassB,c),s+=this.m_invIB*a.cross(this.m_rB,c),this.m_bodyA.c_velocity.v.set(i),this.m_bodyA.c_velocity.w=e,this.m_bodyB.c_velocity.v.set(o),this.m_bodyB.c_velocity.w=s},o.prototype.solvePositionConstraints=function(t){if(this.m_frequencyHz>0)return!0;var i=this.m_bodyA.c_position.c,e=this.m_bodyA.c_position.a,o=this.m_bodyB.c_position.c,s=this.m_bodyB.c_position.a,n=h.neo(e),c=h.neo(s),_=h.mulSub(n,this.m_localAnchorA,this.m_localCenterA),l=h.mulSub(c,this.m_localAnchorB,this.m_localCenterB),u=a.sub(a.add(o,l),a.add(i,_)),p=u.normalize()-this.m_length;p=m.clamp(p,-r.maxLinearCorrection,r.maxLinearCorrection);var y=-this.m_mass*p,d=a.mul(y,u);return i.subMul(this.m_invMassA,d),e-=this.m_invIA*a.cross(_,d),o.addMul(this.m_invMassB,d),s+=this.m_invIB*a.cross(l,d),this.m_bodyA.c_position.c.set(i),this.m_bodyA.c_position.a=e,this.m_bodyB.c_position.c.set(o),this.m_bodyB.c_position.a=s,m.abs(p)<r.linearSlop}},{"../Joint":5,"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../util/create":51,"../util/options":52}],28:[function(t,i,e){function o(t,i,e,n){if(!(this instanceof o))return new o(t,i,e,n);t=s(t,_),c.call(this,t,i,e),i=this.m_bodyA,e=this.m_bodyB,this.m_type=o.TYPE,this.m_localAnchorA=n?i.getLocalPoint(n):t.localAnchorA||m.zero(),this.m_localAnchorB=n?e.getLocalPoint(n):t.localAnchorB||m.zero(),this.m_linearImpulse=m.zero(),this.m_angularImpulse=0,this.m_maxForce=t.maxForce,this.m_maxTorque=t.maxTorque,this.m_rA,this.m_rB,this.m_localCenterA,this.m_localCenterB,this.m_invMassA,this.m_invMassB,this.m_invIA,this.m_invIB,this.m_linearMass,this.m_angularMass}i.exports=o;t("../util/common");var s=t("../util/options"),n=t("../util/create"),r=(t("../Settings"),t("../common/Math")),m=t("../common/Vec2"),a=(t("../common/Vec3"),t("../common/Mat22")),h=(t("../common/Mat33"),t("../common/Rot")),c=(t("../common/Sweep"),t("../common/Transform"),t("../common/Velocity"),t("../common/Position"),t("../Joint"));o.TYPE="friction-joint";var _={maxForce:0,maxTorque:0};(o.prototype=n((o._super=c).prototype)).getLocalAnchorA=function(){return this.m_localAnchorA},o.prototype.getLocalAnchorB=function(){return this.m_localAnchorB},o.prototype.setMaxForce=function(t){this.m_maxForce=t},o.prototype.getMaxForce=function(){return this.m_maxForce},o.prototype.setMaxTorque=function(t){this.m_maxTorque=t},o.prototype.getMaxTorque=function(){return this.m_maxTorque},o.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)},o.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},o.prototype.getReactionForce=function(t){return m.mul(t,this.m_linearImpulse)},o.prototype.getReactionTorque=function(t){return t*this.m_angularImpulse},o.prototype.initVelocityConstraints=function(t){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter,this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=this.m_bodyA.c_position.a,e=this.m_bodyA.c_velocity.v,o=this.m_bodyA.c_velocity.w,s=this.m_bodyB.c_position.a,n=this.m_bodyB.c_velocity.v,r=this.m_bodyB.c_velocity.w,c=h.neo(i),_=h.neo(s);this.m_rA=h.mulVec2(c,m.sub(this.m_localAnchorA,this.m_localCenterA)),this.m_rB=h.mulVec2(_,m.sub(this.m_localAnchorB,this.m_localCenterB));var l=this.m_invMassA,u=this.m_invMassB,p=this.m_invIA,y=this.m_invIB,d=new a;if(d.ex.x=l+u+p*this.m_rA.y*this.m_rA.y+y*this.m_rB.y*this.m_rB.y,d.ex.y=-p*this.m_rA.x*this.m_rA.y-y*this.m_rB.x*this.m_rB.y,d.ey.x=d.ex.y,d.ey.y=l+u+p*this.m_rA.x*this.m_rA.x+y*this.m_rB.x*this.m_rB.x,this.m_linearMass=d.getInverse(),this.m_angularMass=p+y,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),t.warmStarting){this.m_linearImpulse.mul(t.dtRatio),this.m_angularImpulse*=t.dtRatio;var v=m.neo(this.m_linearImpulse.x,this.m_linearImpulse.y);e.subMul(l,v),o-=p*(m.cross(this.m_rA,v)+this.m_angularImpulse),n.addMul(u,v),r+=y*(m.cross(this.m_rB,v)+this.m_angularImpulse)}else this.m_linearImpulse.setZero(),this.m_angularImpulse=0;this.m_bodyA.c_velocity.v=e,this.m_bodyA.c_velocity.w=o,this.m_bodyB.c_velocity.v=n,this.m_bodyB.c_velocity.w=r},o.prototype.solveVelocityConstraints=function(t){var i=this.m_bodyA.c_velocity.v,e=this.m_bodyA.c_velocity.w,o=this.m_bodyB.c_velocity.v,s=this.m_bodyB.c_velocity.w,n=this.m_invMassA,h=this.m_invMassB,c=this.m_invIA,_=this.m_invIB,l=t.dt,u=s-e,p=-this.m_angularMass*u,y=this.m_angularImpulse,d=l*this.m_maxTorque;this.m_angularImpulse=r.clamp(this.m_angularImpulse+p,-d,d),e-=c*(p=this.m_angularImpulse-y),s+=_*p;u=m.sub(m.add(o,m.cross(s,this.m_rB)),m.add(i,m.cross(e,this.m_rA))),p=m.neg(a.mulVec2(this.m_linearMass,u)),y=this.m_linearImpulse;this.m_linearImpulse.add(p);d=l*this.m_maxForce;this.m_linearImpulse.lengthSquared()>d*d&&(this.m_linearImpulse.normalize(),this.m_linearImpulse.mul(d)),p=m.sub(this.m_linearImpulse,y),i.subMul(n,p),e-=c*m.cross(this.m_rA,p),o.addMul(h,p),s+=_*m.cross(this.m_rB,p),this.m_bodyA.c_velocity.v=i,this.m_bodyA.c_velocity.w=e,this.m_bodyB.c_velocity.v=o,this.m_bodyB.c_velocity.w=s},o.prototype.solvePositionConstraints=function(t){return!0}},{"../Joint":5,"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../util/common":50,"../util/create":51,"../util/options":52}],29:[function(t,i,e){function o(t,i,e,m,a,d){if(!(this instanceof o))return new o(t,i,e,m,a,d);t=r(t,y),l.call(this,t,i,e),i=this.m_bodyA,e=this.m_bodyB,this.m_type=o.TYPE,s&&n.assert(m.m_type===u.TYPE||m.m_type===p.TYPE),s&&n.assert(a.m_type===u.TYPE||a.m_type===p.TYPE),this.m_joint1=m||t.joint1,this.m_joint2=a||t.joint2,this.m_ratio=h.isFinite(d)?d:t.ratio,this.m_type1=this.m_joint1.getType(),this.m_type2=this.m_joint2.getType();var v,f;this.m_bodyC=this.m_joint1.getBodyA(),this.m_bodyA=this.m_joint1.getBodyB();var x=this.m_bodyA.m_xf,g=this.m_bodyA.m_sweep.a,A=this.m_bodyC.m_xf,b=this.m_bodyC.m_sweep.a;if(this.m_type1===u.TYPE){var B=this.m_joint1;this.m_localAnchorC=B.m_localAnchorA,this.m_localAnchorA=B.m_localAnchorB,this.m_referenceAngleA=B.m_referenceAngle,this.m_localAxisC=c.zero(),v=g-b-this.m_referenceAngleA}else{var w=this.m_joint1;this.m_localAnchorC=w.m_localAnchorA,this.m_localAnchorA=w.m_localAnchorB,this.m_referenceAngleA=w.m_referenceAngle,this.m_localAxisC=w.m_localXAxisA;var M=this.m_localAnchorC,C=_.mulTVec2(A.q,c.add(_.mul(x.q,this.m_localAnchorA),c.sub(x.p,A.p)));v=c.dot(C,this.m_localAxisC)-c.dot(M,this.m_localAxisC)}this.m_bodyD=this.m_joint2.getBodyA(),this.m_bodyB=this.m_joint2.getBodyB();var V=this.m_bodyB.m_xf,S=this.m_bodyB.m_sweep.a,I=this.m_bodyD.m_xf,z=this.m_bodyD.m_sweep.a;if(this.m_type2===u.TYPE){B=this.m_joint2;this.m_localAnchorD=B.m_localAnchorA,this.m_localAnchorB=B.m_localAnchorB,this.m_referenceAngleB=B.m_referenceAngle,this.m_localAxisD=c.zero(),f=S-z-this.m_referenceAngleB}else{w=this.m_joint2;this.m_localAnchorD=w.m_localAnchorA,this.m_localAnchorB=w.m_localAnchorB,this.m_referenceAngleB=w.m_referenceAngle,this.m_localAxisD=w.m_localXAxisA;var P=this.m_localAnchorD,T=_.mulTVec2(I.q,c.add(_.mul(V.q,this.m_localAnchorB),c.sub(V.p,I.p)));f=c.dot(T,this.m_localAxisD)-c.dot(P,this.m_localAxisD)}this.m_constant=v+this.m_ratio*f,this.m_impulse=0,this.m_lcA,this.m_lcB,this.m_lcC,this.m_lcD,this.m_mA,this.m_mB,this.m_mC,this.m_mD,this.m_iA,this.m_iB,this.m_iC,this.m_iD,this.m_JvAC,this.m_JvBD,this.m_JwA,this.m_JwB,this.m_JwC,this.m_JwD,this.m_mass}var s=!1;i.exports=o;var n=t("../util/common"),r=t("../util/options"),m=t("../util/create"),a=t("../Settings"),h=t("../common/Math"),c=t("../common/Vec2"),_=(t("../common/Vec3"),t("../common/Mat22"),t("../common/Mat33"),t("../common/Rot")),l=(t("../common/Sweep"),t("../common/Transform"),t("../common/Velocity"),t("../common/Position"),t("../Joint")),u=t("./RevoluteJoint"),p=t("./PrismaticJoint");o.TYPE="gear-joint";var y={ratio:1};(o.prototype=m((o._super=l).prototype)).getJoint1=function(){return this.m_joint1},o.prototype.getJoint2=function(){return this.m_joint2},o.prototype.setRatio=function(t){s&&n.assert(h.isFinite(t)),this.m_ratio=t},o.prototype.getRatio=function(){return this.m_ratio},o.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)},o.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},o.prototype.getReactionForce=function(t){return c.mul(this.m_impulse,this.m_JvAC).mul(t)},o.prototype.getReactionTorque=function(t){return t*(this.m_impulse*this.m_JwA)},o.prototype.initVelocityConstraints=function(t){this.m_lcA=this.m_bodyA.m_sweep.localCenter,this.m_lcB=this.m_bodyB.m_sweep.localCenter,this.m_lcC=this.m_bodyC.m_sweep.localCenter,this.m_lcD=this.m_bodyD.m_sweep.localCenter,this.m_mA=this.m_bodyA.m_invMass,this.m_mB=this.m_bodyB.m_invMass,this.m_mC=this.m_bodyC.m_invMass,this.m_mD=this.m_bodyD.m_invMass,this.m_iA=this.m_bodyA.m_invI,this.m_iB=this.m_bodyB.m_invI,this.m_iC=this.m_bodyC.m_invI,this.m_iD=this.m_bodyD.m_invI;var i=this.m_bodyA.c_position.a,e=this.m_bodyA.c_velocity.v,o=this.m_bodyA.c_velocity.w,s=this.m_bodyB.c_position.a,n=this.m_bodyB.c_velocity.v,r=this.m_bodyB.c_velocity.w,m=this.m_bodyC.c_position.a,a=this.m_bodyC.c_velocity.v,h=this.m_bodyC.c_velocity.w,l=this.m_bodyD.c_position.a,p=this.m_bodyD.c_velocity.v,y=this.m_bodyD.c_velocity.w,d=_.neo(i),v=_.neo(s),f=_.neo(m),x=_.neo(l);if(this.m_mass=0,this.m_type1==u.TYPE)this.m_JvAC=c.zero(),this.m_JwA=1,this.m_JwC=1,this.m_mass+=this.m_iA+this.m_iC;else{var g=_.mulVec2(f,this.m_localAxisC),A=_.mulSub(f,this.m_localAnchorC,this.m_lcC),b=_.mulSub(d,this.m_localAnchorA,this.m_lcA);this.m_JvAC=g,this.m_JwC=c.cross(A,g),this.m_JwA=c.cross(b,g),this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_type2==u.TYPE)this.m_JvBD=c.zero(),this.m_JwB=this.m_ratio,this.m_JwD=this.m_ratio,this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);else{g=_.mulVec2(x,this.m_localAxisD);var B=_.mulSub(x,this.m_localAnchorD,this.m_lcD),w=_.mulSub(v,this.m_localAnchorB,this.m_lcB);this.m_JvBD=c.mul(this.m_ratio,g),this.m_JwD=this.m_ratio*c.cross(B,g),this.m_JwB=this.m_ratio*c.cross(w,g),this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0,t.warmStarting?(e.addMul(this.m_mA*this.m_impulse,this.m_JvAC),o+=this.m_iA*this.m_impulse*this.m_JwA,n.addMul(this.m_mB*this.m_impulse,this.m_JvBD),r+=this.m_iB*this.m_impulse*this.m_JwB,a.subMul(this.m_mC*this.m_impulse,this.m_JvAC),h-=this.m_iC*this.m_impulse*this.m_JwC,p.subMul(this.m_mD*this.m_impulse,this.m_JvBD),y-=this.m_iD*this.m_impulse*this.m_JwD):this.m_impulse=0,this.m_bodyA.c_velocity.v.set(e),this.m_bodyA.c_velocity.w=o,this.m_bodyB.c_velocity.v.set(n),this.m_bodyB.c_velocity.w=r,this.m_bodyC.c_velocity.v.set(a),this.m_bodyC.c_velocity.w=h,this.m_bodyD.c_velocity.v.set(p),this.m_bodyD.c_velocity.w=y},o.prototype.solveVelocityConstraints=function(t){var i=this.m_bodyA.c_velocity.v,e=this.m_bodyA.c_velocity.w,o=this.m_bodyB.c_velocity.v,s=this.m_bodyB.c_velocity.w,n=this.m_bodyC.c_velocity.v,r=this.m_bodyC.c_velocity.w,m=this.m_bodyD.c_velocity.v,a=this.m_bodyD.c_velocity.w,h=c.dot(this.m_JvAC,i)-c.dot(this.m_JvAC,n)+c.dot(this.m_JvBD,o)-c.dot(this.m_JvBD,m);h+=this.m_JwA*e-this.m_JwC*r+(this.m_JwB*s-this.m_JwD*a);var _=-this.m_mass*h;this.m_impulse+=_,i.addMul(this.m_mA*_,this.m_JvAC),e+=this.m_iA*_*this.m_JwA,o.addMul(this.m_mB*_,this.m_JvBD),s+=this.m_iB*_*this.m_JwB,n.subMul(this.m_mC*_,this.m_JvAC),r-=this.m_iC*_*this.m_JwC,m.subMul(this.m_mD*_,this.m_JvBD),a-=this.m_iD*_*this.m_JwD,this.m_bodyA.c_velocity.v.set(i),this.m_bodyA.c_velocity.w=e,this.m_bodyB.c_velocity.v.set(o),this.m_bodyB.c_velocity.w=s,this.m_bodyC.c_velocity.v.set(n),this.m_bodyC.c_velocity.w=r,this.m_bodyD.c_velocity.v.set(m),this.m_bodyD.c_velocity.w=a},o.prototype.solvePositionConstraints=function(t){var i,e,o,s,n,r,m,h,l=this.m_bodyA.c_position.c,p=this.m_bodyA.c_position.a,y=this.m_bodyB.c_position.c,d=this.m_bodyB.c_position.a,v=this.m_bodyC.c_position.c,f=this.m_bodyC.c_position.a,x=this.m_bodyD.c_position.c,g=this.m_bodyD.c_position.a,A=_.neo(p),b=_.neo(d),B=_.neo(f),w=_.neo(g),M=0;if(this.m_type1==u.TYPE)o=c.zero(),n=1,m=1,M+=this.m_iA+this.m_iC,i=p-f-this.m_referenceAngleA;else{var C=_.mulVec2(B,this.m_localAxisC),V=_.mulSub(B,this.m_localAnchorC,this.m_lcC),S=_.mulSub(A,this.m_localAnchorA,this.m_lcA);o=C,m=c.cross(V,C),n=c.cross(S,C),M+=this.m_mC+this.m_mA+this.m_iC*m*m+this.m_iA*n*n;var I=c.sub(this.m_localAnchorC,this.m_lcC),z=_.mulTVec2(B,c.add(S,c.sub(l,v)));i=c.dot(c.sub(z,I),this.m_localAxisC)}if(this.m_type2==u.TYPE)s=c.zero(),r=this.m_ratio,h=this.m_ratio,M+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),e=d-g-this.m_referenceAngleB;else{C=_.mulVec2(w,this.m_localAxisD);var P=_.mulSub(w,this.m_localAnchorD,this.m_lcD),T=_.mulSub(b,this.m_localAnchorB,this.m_lcB);s=c.mul(this.m_ratio,C),h=this.m_ratio*c.cross(P,C),r=this.m_ratio*c.cross(T,C),M+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*h*h+this.m_iB*r*r;var L=c.sub(this.m_localAnchorD,this.m_lcD),q=_.mulTVec2(w,c.add(T,c.sub(y,x)));e=c.dot(q,this.m_localAxisD)-c.dot(L,this.m_localAxisD)}var F=i+this.m_ratio*e-this.m_constant,R=0;return M>0&&(R=-F/M),l.addMul(this.m_mA*R,o),p+=this.m_iA*R*n,y.addMul(this.m_mB*R,s),d+=this.m_iB*R*r,v.subMul(this.m_mC*R,o),f-=this.m_iC*R*m,x.subMul(this.m_mD*R,s),g-=this.m_iD*R*h,this.m_bodyA.c_position.c.set(l),this.m_bodyA.c_position.a=p,this.m_bodyB.c_position.c.set(y),this.m_bodyB.c_position.a=d,this.m_bodyC.c_position.c.set(v),this.m_bodyC.c_position.a=f,this.m_bodyD.c_position.c.set(x),this.m_bodyD.c_position.a=g,0<a.linearSlop}},{"../Joint":5,"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../util/common":50,"../util/create":51,"../util/options":52,"./PrismaticJoint":32,"./RevoluteJoint":34}],30:[function(t,i,e){function o(t,i,e){if(!(this instanceof o))return new o(t,i,e);t=s(t,_),c.call(this,t,i,e),i=this.m_bodyA,e=this.m_bodyB,this.m_type=o.TYPE,this.m_linearOffset=t.linearOffset?t.linearOffset:i.getLocalPoint(e.getPosition());var n=i.getAngle(),r=e.getAngle();this.m_angularOffset=r-n,this.m_linearImpulse=m.zero(),this.m_angularImpulse=0,this.m_maxForce=t.maxForce,this.m_maxTorque=t.maxTorque,this.m_correctionFactor=t.correctionFactor,this.m_rA,this.m_rB,this.m_localCenterA,this.m_localCenterB,this.m_linearError,this.m_angularError,this.m_invMassA,this.m_invMassB,this.m_invIA,this.m_invIB,this.m_linearMass,this.m_angularMass}i.exports=o;t("../util/common");var s=t("../util/options"),n=t("../util/create"),r=(t("../Settings"),t("../common/Math")),m=t("../common/Vec2"),a=(t("../common/Vec3"),t("../common/Mat22")),h=(t("../common/Mat33"),t("../common/Rot")),c=(t("../common/Sweep"),t("../common/Transform"),t("../common/Velocity"),t("../common/Position"),t("../Joint"));o.TYPE="motor-joint";var _={maxForce:1,maxTorque:1,correctionFactor:.3};(o.prototype=n((o._super=c).prototype)).setMaxForce=function(t){this.m_maxForce=t},o.prototype.getMaxForce=function(){return this.m_maxForce},o.prototype.setMaxTorque=function(t){this.m_maxTorque=t},o.prototype.getMaxTorque=function(){return this.m_maxTorque},o.prototype.setCorrectionFactor=function(t){this.m_correctionFactor=t},o.prototype.getCorrectionFactor=function(){return this.m_correctionFactor},o.prototype.setLinearOffset=function(t){t.x==this.m_linearOffset.x&&t.y==this.m_linearOffset.y||(this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_linearOffset=t)},o.prototype.getLinearOffset=function(){return this.m_linearOffset},o.prototype.setAngularOffset=function(t){t!=this.m_angularOffset&&(this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_angularOffset=t)},o.prototype.getAngularOffset=function(){return this.m_angularOffset},o.prototype.getAnchorA=function(){return this.m_bodyA.getPosition()},o.prototype.getAnchorB=function(){return this.m_bodyB.getPosition()},o.prototype.getReactionForce=function(t){return m.mul(t,this.m_linearImpulse)},o.prototype.getReactionTorque=function(t){return t*this.m_angularImpulse},o.prototype.initVelocityConstraints=function(t){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter,this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=this.m_bodyA.c_position.c,e=this.m_bodyA.c_position.a,o=this.m_bodyA.c_velocity.v,s=this.m_bodyA.c_velocity.w,n=this.m_bodyB.c_position.c,r=this.m_bodyB.c_position.a,c=this.m_bodyB.c_velocity.v,_=this.m_bodyB.c_velocity.w,l=h.neo(e),u=h.neo(r);this.m_rA=h.mulVec2(l,m.neg(this.m_localCenterA)),this.m_rB=h.mulVec2(u,m.neg(this.m_localCenterB));var p=this.m_invMassA,y=this.m_invMassB,d=this.m_invIA,v=this.m_invIB,f=new a;if(f.ex.x=p+y+d*this.m_rA.y*this.m_rA.y+v*this.m_rB.y*this.m_rB.y,f.ex.y=-d*this.m_rA.x*this.m_rA.y-v*this.m_rB.x*this.m_rB.y,f.ey.x=f.ex.y,f.ey.y=p+y+d*this.m_rA.x*this.m_rA.x+v*this.m_rB.x*this.m_rB.x,this.m_linearMass=f.getInverse(),this.m_angularMass=d+v,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),this.m_linearError=m.zero(),this.m_linearError.addCombine(1,n,1,this.m_rB),this.m_linearError.subCombine(1,i,1,this.m_rA),this.m_linearError.sub(h.mulVec2(l,this.m_linearOffset)),this.m_angularError=r-e-this.m_angularOffset,t.warmStarting){this.m_linearImpulse.mul(t.dtRatio),this.m_angularImpulse*=t.dtRatio;var x=m.neo(this.m_linearImpulse.x,this.m_linearImpulse.y);o.subMul(p,x),s-=d*(m.cross(this.m_rA,x)+this.m_angularImpulse),c.addMul(y,x),_+=v*(m.cross(this.m_rB,x)+this.m_angularImpulse)}else this.m_linearImpulse.setZero(),this.m_angularImpulse=0;this.m_bodyA.c_velocity.v=o,this.m_bodyA.c_velocity.w=s,this.m_bodyB.c_velocity.v=c,this.m_bodyB.c_velocity.w=_},o.prototype.solveVelocityConstraints=function(t){var i=this.m_bodyA.c_velocity.v,e=this.m_bodyA.c_velocity.w,o=this.m_bodyB.c_velocity.v,s=this.m_bodyB.c_velocity.w,n=this.m_invMassA,h=this.m_invMassB,c=this.m_invIA,_=this.m_invIB,l=t.dt,u=t.inv_dt,p=s-e+u*this.m_correctionFactor*this.m_angularError,y=-this.m_angularMass*p,d=this.m_angularImpulse,v=l*this.m_maxTorque;this.m_angularImpulse=r.clamp(this.m_angularImpulse+y,-v,v),e-=c*(y=this.m_angularImpulse-d),s+=_*y;(p=m.zero()).addCombine(1,o,1,m.cross(s,this.m_rB)),p.subCombine(1,i,1,m.cross(e,this.m_rA)),p.addMul(u*this.m_correctionFactor,this.m_linearError);y=m.neg(a.mulVec2(this.m_linearMass,p)),d=m.clone(this.m_linearImpulse);this.m_linearImpulse.add(y);v=l*this.m_maxForce;this.m_linearImpulse.clamp(v),y=m.sub(this.m_linearImpulse,d),i.subMul(n,y),e-=c*m.cross(this.m_rA,y),o.addMul(h,y),s+=_*m.cross(this.m_rB,y),this.m_bodyA.c_velocity.v=i,this.m_bodyA.c_velocity.w=e,this.m_bodyB.c_velocity.v=o,this.m_bodyB.c_velocity.w=s},o.prototype.solvePositionConstraints=function(t){return!0}},{"../Joint":5,"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../util/common":50,"../util/create":51,"../util/options":52}],31:[function(t,i,e){function o(t,i,e,m){if(!(this instanceof o))return new o(t,i,e,m);t=r(t,p),u.call(this,t,i,e),i=this.m_bodyA,e=this.m_bodyB,this.m_type=o.TYPE,s&&n.assert(a.isFinite(t.maxForce)&&t.maxForce>=0),s&&n.assert(a.isFinite(t.frequencyHz)&&t.frequencyHz>=0),s&&n.assert(a.isFinite(t.dampingRatio)&&t.dampingRatio>=0),this.m_targetA=m?h.clone(m):t.target||h.zero(),this.m_localAnchorB=l.mulTVec2(e.getTransform(),this.m_targetA),this.m_maxForce=t.maxForce,this.m_impulse=h.zero(),this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_beta=0,this.m_gamma=0,this.m_rB=h.zero(),this.m_localCenterB=h.zero(),this.m_invMassB=0,this.m_invIB=0,this.mass=new c,this.m_C=h.zero()}var s=!1;i.exports=o;var n=t("../util/common"),r=t("../util/options"),m=t("../util/create"),a=t("../common/Math"),h=t("../common/Vec2"),c=(t("../common/Vec3"),t("../common/Mat22")),_=(t("../common/Mat33"),t("../common/Rot")),l=(t("../common/Sweep"),t("../common/Transform")),u=(t("../common/Velocity"),t("../common/Position"),t("../Joint"));o.TYPE="mouse-joint";var p={maxForce:0,frequencyHz:5,dampingRatio:.7};(o.prototype=m((o._super=u).prototype)).setTarget=function(t){0==this.m_bodyB.isAwake()&&this.m_bodyB.setAwake(!0),this.m_targetA=h.clone(t)},o.prototype.getTarget=function(){return this.m_targetA},o.prototype.setMaxForce=function(t){this.m_maxForce=t},o.getMaxForce=function(){return this.m_maxForce},o.prototype.setFrequency=function(t){this.m_frequencyHz=t},o.prototype.getFrequency=function(){return this.m_frequencyHz},o.prototype.setDampingRatio=function(t){this.m_dampingRatio=t},o.prototype.getDampingRatio=function(){return this.m_dampingRatio},o.prototype.getAnchorA=function(){return h.clone(this.m_targetA)},o.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},o.prototype.getReactionForce=function(t){return h.mul(t,this.m_impulse)},o.prototype.getReactionTorque=function(t){return 0*t},o.prototype.shiftOrigin=function(t){this.m_targetA.sub(t)},o.prototype.initVelocityConstraints=function(t){this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIB=this.m_bodyB.m_invI;var i=this.m_bodyB.c_position,e=this.m_bodyB.c_velocity,o=i.c,r=i.a,m=e.v,l=e.w,u=_.neo(r),p=this.m_bodyB.getMass(),y=2*a.PI*this.m_frequencyHz,d=2*p*this.m_dampingRatio*y,v=p*(y*y),f=t.dt;s&&n.assert(d+f*v>a.EPSILON),this.m_gamma=f*(d+f*v),0!=this.m_gamma&&(this.m_gamma=1/this.m_gamma),this.m_beta=f*v*this.m_gamma,this.m_rB=_.mulVec2(u,h.sub(this.m_localAnchorB,this.m_localCenterB));var x=new c;x.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma,x.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y,x.ey.x=x.ex.y,x.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma,this.m_mass=x.getInverse(),this.m_C.set(o),this.m_C.addCombine(1,this.m_rB,-1,this.m_targetA),this.m_C.mul(this.m_beta),l*=.98,t.warmStarting?(this.m_impulse.mul(t.dtRatio),m.addMul(this.m_invMassB,this.m_impulse),l+=this.m_invIB*h.cross(this.m_rB,this.m_impulse)):this.m_impulse.setZero(),e.v.set(m),e.w=l},o.prototype.solveVelocityConstraints=function(t){var i=this.m_bodyB.c_velocity,e=h.clone(i.v),o=i.w,s=h.cross(o,this.m_rB);s.add(e),s.addCombine(1,this.m_C,this.m_gamma,this.m_impulse),s.neg();var n=c.mulVec2(this.m_mass,s),r=h.clone(this.m_impulse);this.m_impulse.add(n);var m=t.dt*this.m_maxForce;this.m_impulse.clamp(m),n=h.sub(this.m_impulse,r),e.addMul(this.m_invMassB,n),o+=this.m_invIB*h.cross(this.m_rB,n),i.v.set(e),i.w=o},o.prototype.solvePositionConstraints=function(t){return!0}},{"../Joint":5,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../util/common":50,"../util/create":51,"../util/options":52}],32:[function(t,i,e){function o(t,i,e,n,r){if(!(this instanceof o))return new o(t,i,e,n,r);t=s(t,y),u.call(this,t,i,e),i=this.m_bodyA,e=this.m_bodyB,this.m_type=o.TYPE,this.m_localAnchorA=n?i.getLocalPoint(n):t.localAnchorA||a.zero(),this.m_localAnchorB=n?e.getLocalPoint(n):t.localAnchorB||a.zero(),this.m_localXAxisA=r?i.getLocalVector(r):t.localAxisA||a.neo(1,0),this.m_localXAxisA.normalize(),this.m_localYAxisA=a.cross(1,this.m_localXAxisA),this.m_referenceAngle=m.isFinite(t.referenceAngle)?t.referenceAngle:e.getAngle()-i.getAngle(),this.m_impulse=h(),this.m_motorMass=0,this.m_motorImpulse=0,this.m_lowerTranslation=t.lowerTranslation,this.m_upperTranslation=t.upperTranslation,this.m_maxMotorForce=t.maxMotorForce,this.m_motorSpeed=t.motorSpeed,this.m_enableLimit=t.enableLimit,this.m_enableMotor=t.enableMotor,this.m_limitState=p,this.m_axis=a.zero(),this.m_perp=a.zero(),this.m_localCenterA,this.m_localCenterB,this.m_invMassA,this.m_invMassB,this.m_invIA,this.m_invIB,this.m_axis,this.m_perp,this.m_s1,this.m_s2,this.m_a1,this.m_a2,this.m_K=new _,this.m_motorMass}i.exports=o;t("../util/common");var s=t("../util/options"),n=t("../util/create"),r=t("../Settings"),m=t("../common/Math"),a=t("../common/Vec2"),h=t("../common/Vec3"),c=t("../common/Mat22"),_=t("../common/Mat33"),l=t("../common/Rot"),u=(t("../common/Sweep"),t("../common/Transform"),t("../common/Velocity"),t("../common/Position"),t("../Joint")),p=0;o.TYPE="prismatic-joint";var y={enableLimit:!1,lowerTranslation:0,upperTranslation:0,enableMotor:!1,maxMotorForce:0,motorSpeed:0};(o.prototype=n((o._super=u).prototype)).getLocalAnchorA=function(){return this.m_localAnchorA},o.prototype.getLocalAnchorB=function(){return this.m_localAnchorB},o.prototype.getLocalAxisA=function(){return this.m_localXAxisA},o.prototype.getReferenceAngle=function(){return this.m_referenceAngle},o.prototype.getJointTranslation=function(){var t=this.m_bodyA.getWorldPoint(this.m_localAnchorA),i=this.m_bodyB.getWorldPoint(this.m_localAnchorB),e=a.sub(i,t),o=this.m_bodyA.getWorldVector(this.m_localXAxisA);return a.dot(e,o)},o.prototype.getJointSpeed=function(){var t=this.m_bodyA,i=this.m_bodyB,e=l.mulVec2(t.m_xf.q,a.sub(this.m_localAnchorA,t.m_sweep.localCenter)),o=l.mulVec2(i.m_xf.q,a.sub(this.m_localAnchorB,i.m_sweep.localCenter)),s=a.add(t.m_sweep.c,e),n=a.add(i.m_sweep.c,o),r=a.sub(n,s),m=l.mulVec2(t.m_xf.q,this.m_localXAxisA),h=t.m_linearVelocity,c=i.m_linearVelocity,_=t.m_angularVelocity,u=i.m_angularVelocity;return a.dot(r,a.cross(_,m))+a.dot(m,a.sub(a.addCross(c,u,o),a.addCross(h,_,e)))},o.prototype.isLimitEnabled=function(){return this.m_enableLimit},o.prototype.enableLimit=function(t){t!=this.m_enableLimit&&(this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},o.prototype.getLowerLimit=function(){return this.m_lowerTranslation},o.prototype.getUpperLimit=function(){return this.m_upperTranslation},o.prototype.setLimits=function(t,i){t==this.m_lowerTranslation&&i==this.m_upperTranslation||(this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_lowerTranslation=t,this.m_upperTranslation=i,this.m_impulse.z=0)},o.prototype.isMotorEnabled=function(){return this.m_enableMotor},o.prototype.enableMotor=function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_enableMotor=t},o.prototype.setMotorSpeed=function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_motorSpeed=t},o.prototype.setMaxMotorForce=function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_maxMotorForce=t},o.prototype.getMotorSpeed=function(){return this.m_motorSpeed},o.prototype.getMotorForce=function(t){return t*this.m_motorImpulse},o.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)},o.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},o.prototype.getReactionForce=function(t){return a.combine(this.m_impulse.x,this.m_perp,this.m_motorImpulse+this.m_impulse.z,this.m_axis).mul(t)},o.prototype.getReactionTorque=function(t){return t*this.m_impulse.y},o.prototype.initVelocityConstraints=function(t){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter,this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=this.m_bodyA.c_position.c,e=this.m_bodyA.c_position.a,o=this.m_bodyA.c_velocity.v,s=this.m_bodyA.c_velocity.w,n=this.m_bodyB.c_position.c,h=this.m_bodyB.c_position.a,c=this.m_bodyB.c_velocity.v,_=this.m_bodyB.c_velocity.w,u=l.neo(e),y=l.neo(h),d=l.mulVec2(u,a.sub(this.m_localAnchorA,this.m_localCenterA)),v=l.mulVec2(y,a.sub(this.m_localAnchorB,this.m_localCenterB)),f=a.zero();f.addCombine(1,n,1,v),f.subCombine(1,i,1,d);var x=this.m_invMassA,g=this.m_invMassB,A=this.m_invIA,b=this.m_invIB;this.m_axis=l.mulVec2(u,this.m_localXAxisA),this.m_a1=a.cross(a.add(f,d),this.m_axis),this.m_a2=a.cross(v,this.m_axis),this.m_motorMass=x+g+A*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),this.m_perp=l.mulVec2(u,this.m_localYAxisA),this.m_s1=a.cross(a.add(f,d),this.m_perp),this.m_s2=a.cross(v,this.m_perp);a.cross(d,this.m_perp);var B=x+g+A*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,w=A*this.m_s1+b*this.m_s2,M=A*this.m_s1*this.m_a1+b*this.m_s2*this.m_a2,C=A+b;0==C&&(C=1);var V=A*this.m_a1+b*this.m_a2,S=x+g+A*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2;if(this.m_K.ex.set(B,w,M),this.m_K.ey.set(w,C,V),this.m_K.ez.set(M,V,S),this.m_enableLimit){var I=a.dot(this.m_axis,f);m.abs(this.m_upperTranslation-this.m_lowerTranslation)<2*r.linearSlop?this.m_limitState=3:I<=this.m_lowerTranslation?1!=this.m_limitState&&(this.m_limitState=1,this.m_impulse.z=0):I>=this.m_upperTranslation?2!=this.m_limitState&&(this.m_limitState=2,this.m_impulse.z=0):(this.m_limitState=p,this.m_impulse.z=0)}else this.m_limitState=p,this.m_impulse.z=0;if(0==this.m_enableMotor&&(this.m_motorImpulse=0),t.warmStarting){this.m_impulse.mul(t.dtRatio),this.m_motorImpulse*=t.dtRatio;var z=a.combine(this.m_impulse.x,this.m_perp,this.m_motorImpulse+this.m_impulse.z,this.m_axis),P=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;o.subMul(x,z),s-=A*P,c.addMul(g,z),_+=b*T}else this.m_impulse.setZero(),this.m_motorImpulse=0;this.m_bodyA.c_velocity.v.set(o),this.m_bodyA.c_velocity.w=s,this.m_bodyB.c_velocity.v.set(c),this.m_bodyB.c_velocity.w=_},o.prototype.solveVelocityConstraints=function(t){var i=this.m_bodyA.c_velocity.v,e=this.m_bodyA.c_velocity.w,o=this.m_bodyB.c_velocity.v,s=this.m_bodyB.c_velocity.w,n=this.m_invMassA,r=this.m_invMassB,c=this.m_invIA,_=this.m_invIB;if(this.m_enableMotor&&3!=this.m_limitState){var l=a.dot(this.m_axis,a.sub(o,i))+this.m_a2*s-this.m_a1*e,u=this.m_motorMass*(this.m_motorSpeed-l),y=this.m_motorImpulse,d=t.dt*this.m_maxMotorForce;this.m_motorImpulse=m.clamp(this.m_motorImpulse+u,-d,d),u=this.m_motorImpulse-y;var v=a.mul(u,this.m_axis),f=u*this.m_a1,x=u*this.m_a2;i.subMul(n,v),e-=c*f,o.addMul(r,v),s+=_*x}var g=a.zero();if(g.x+=a.dot(this.m_perp,o)+this.m_s2*s,g.x-=a.dot(this.m_perp,i)+this.m_s1*e,g.y=s-e,this.m_enableLimit&&this.m_limitState!=p){var A=0;A+=a.dot(this.m_axis,o)+this.m_a2*s,A-=a.dot(this.m_axis,i)+this.m_a1*e;l=h(g.x,g.y,A);var b=h(this.m_impulse),B=this.m_K.solve33(h.neg(l));this.m_impulse.add(B),1==this.m_limitState?this.m_impulse.z=m.max(this.m_impulse.z,0):2==this.m_limitState&&(this.m_impulse.z=m.min(this.m_impulse.z,0));var w=a.combine(-1,g,-(this.m_impulse.z-b.z),a.neo(this.m_K.ez.x,this.m_K.ez.y)),M=a.add(this.m_K.solve22(w),a.neo(b.x,b.y));this.m_impulse.x=M.x,this.m_impulse.y=M.y,B=h.sub(this.m_impulse,b);v=a.combine(B.x,this.m_perp,B.z,this.m_axis),f=B.x*this.m_s1+B.y+B.z*this.m_a1,x=B.x*this.m_s2+B.y+B.z*this.m_a2;i.subMul(n,v),e-=c*f,o.addMul(r,v),s+=_*x}else{B=this.m_K.solve22(a.neg(g));this.m_impulse.x+=B.x,this.m_impulse.y+=B.y;v=a.mul(B.x,this.m_perp),f=B.x*this.m_s1+B.y,x=B.x*this.m_s2+B.y;i.subMul(n,v),e-=c*f,o.addMul(r,v),s+=_*x}this.m_bodyA.c_velocity.v=i,this.m_bodyA.c_velocity.w=e,this.m_bodyB.c_velocity.v=o,this.m_bodyB.c_velocity.w=s},o.prototype.solvePositionConstraints=function(t){var i=this.m_bodyA.c_position.c,e=this.m_bodyA.c_position.a,o=this.m_bodyB.c_position.c,s=this.m_bodyB.c_position.a,n=l.neo(e),u=l.neo(s),p=this.m_invMassA,y=this.m_invMassB,d=this.m_invIA,v=this.m_invIB,f=l.mulVec2(n,a.sub(this.m_localAnchorA,this.m_localCenterA)),x=l.mulVec2(u,a.sub(this.m_localAnchorB,this.m_localCenterB)),g=a.sub(a.add(o,x),a.add(i,f)),A=l.mulVec2(n,this.m_localXAxisA),b=a.cross(a.add(g,f),A),B=a.cross(x,A),w=l.mulVec2(n,this.m_localYAxisA),M=a.cross(a.add(g,f),w),C=a.cross(x,w),V=h(),S=a.zero();S.x=a.dot(w,g),S.y=s-e-this.m_referenceAngle;var I=m.abs(S.x),z=m.abs(S.y),P=r.linearSlop,T=r.maxLinearCorrection,L=!1,q=0;if(this.m_enableLimit){var F=a.dot(A,g);m.abs(this.m_upperTranslation-this.m_lowerTranslation)<2*P?(q=m.clamp(F,-T,T),I=m.max(I,m.abs(F)),L=!0):F<=this.m_lowerTranslation?(q=m.clamp(F-this.m_lowerTranslation+P,-T,0),I=m.max(I,this.m_lowerTranslation-F),L=!0):F>=this.m_upperTranslation&&(q=m.clamp(F-this.m_upperTranslation-P,0,T),I=m.max(I,F-this.m_upperTranslation),L=!0)}if(L){var R=p+y+d*M*M+v*C*C,k=d*M+v*C,D=d*M*b+v*C*B;0==(O=d+v)&&(O=1);var j=d*b+v*B,E=p+y+d*b*b+v*B*B;(N=new _).ex.set(R,k,D),N.ey.set(k,O,j),N.ez.set(D,j,E);var J=h();J.x=S.x,J.y=S.y,J.z=q,V=N.solve33(h.neg(J))}else{var O;R=p+y+d*M*M+v*C*C,k=d*M+v*C;0==(O=d+v)&&(O=1);var N;(N=new c).ex.set(R,k),N.ey.set(k,O);var Y=N.solve(a.neg(S));V.x=Y.x,V.y=Y.y,V.z=0}var W=a.combine(V.x,w,V.z,A),Z=V.x*M+V.y+V.z*b,H=V.x*C+V.y+V.z*B;return i.subMul(p,W),e-=d*Z,o.addMul(y,W),s+=v*H,this.m_bodyA.c_position.c=i,this.m_bodyA.c_position.a=e,this.m_bodyB.c_position.c=o,this.m_bodyB.c_position.a=s,I<=r.linearSlop&&z<=r.angularSlop}},{"../Joint":5,"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../util/common":50,"../util/create":51,"../util/options":52}],33:[function(t,i,e){function o(t,i,e,m,a,_,p,y){if(!(this instanceof o))return new o(t,i,e,m,a,_,p,y);t=r(t,u),l.call(this,t,i,e),i=this.m_bodyA,e=this.m_bodyB,this.m_type=o.TYPE,this.m_groundAnchorA=m||(t.groundAnchorA||c.neo(-1,1)),this.m_groundAnchorB=a||(t.groundAnchorB||c.neo(1,1)),this.m_localAnchorA=_?i.getLocalPoint(_):t.localAnchorA||c.neo(-1,0),this.m_localAnchorB=p?e.getLocalPoint(p):t.localAnchorB||c.neo(1,0),this.m_lengthA=h.isFinite(t.lengthA)?t.lengthA:c.distance(_,m),this.m_lengthB=h.isFinite(t.lengthB)?t.lengthB:c.distance(p,a),this.m_ratio=h.isFinite(y)?y:t.ratio,s&&n.assert(y>h.EPSILON),this.m_constant=this.m_lengthA+this.m_ratio*this.m_lengthB,this.m_impulse=0,this.m_uA,this.m_uB,this.m_rA,this.m_rB,this.m_localCenterA,this.m_localCenterB,this.m_invMassA,this.m_invMassB,this.m_invIA,this.m_invIB,this.m_mass}var s=!1;i.exports=o;var n=t("../util/common"),r=t("../util/options"),m=t("../util/create"),a=t("../Settings"),h=t("../common/Math"),c=t("../common/Vec2"),_=(t("../common/Vec3"),t("../common/Mat22"),t("../common/Mat33"),t("../common/Rot")),l=(t("../common/Sweep"),t("../common/Transform"),t("../common/Velocity"),t("../common/Position"),t("../Joint"));o.TYPE="pulley-joint",o.MIN_PULLEY_LENGTH=2;var u={collideConnected:!0};(o.prototype=m((o._super=l).prototype)).getGroundAnchorA=function(){return this.m_groundAnchorA},o.prototype.getGroundAnchorB=function(){return this.m_groundAnchorB},o.prototype.getLengthA=function(){return this.m_lengthA},o.prototype.getLengthB=function(){return this.m_lengthB},o.prototype.getRatio=function(){return this.m_ratio},o.prototype.getCurrentLengthA=function(){var t=this.m_bodyA.getWorldPoint(this.m_localAnchorA),i=this.m_groundAnchorA;return c.distance(t,i)},o.prototype.getCurrentLengthB=function(){var t=this.m_bodyB.getWorldPoint(this.m_localAnchorB),i=this.m_groundAnchorB;return c.distance(t,i)},o.prototype.shiftOrigin=function(t){this.m_groundAnchorA.sub(t),this.m_groundAnchorB.sub(t)},o.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)},o.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},o.prototype.getReactionForce=function(t){return c.mul(this.m_impulse,this.m_uB).mul(t)},o.prototype.getReactionTorque=function(t){return 0},o.prototype.initVelocityConstraints=function(t){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter,this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=this.m_bodyA.c_position.c,e=this.m_bodyA.c_position.a,o=this.m_bodyA.c_velocity.v,s=this.m_bodyA.c_velocity.w,n=this.m_bodyB.c_position.c,r=this.m_bodyB.c_position.a,m=this.m_bodyB.c_velocity.v,h=this.m_bodyB.c_velocity.w,l=_.neo(e),u=_.neo(r);this.m_rA=_.mulVec2(l,c.sub(this.m_localAnchorA,this.m_localCenterA)),this.m_rB=_.mulVec2(u,c.sub(this.m_localAnchorB,this.m_localCenterB)),this.m_uA=c.sub(c.add(i,this.m_rA),this.m_groundAnchorA),this.m_uB=c.sub(c.add(n,this.m_rB),this.m_groundAnchorB);var p=this.m_uA.length(),y=this.m_uB.length();p>10*a.linearSlop?this.m_uA.mul(1/p):this.m_uA.setZero(),y>10*a.linearSlop?this.m_uB.mul(1/y):this.m_uB.setZero();var d=c.cross(this.m_rA,this.m_uA),v=c.cross(this.m_rB,this.m_uB),f=this.m_invMassA+this.m_invIA*d*d,x=this.m_invMassB+this.m_invIB*v*v;if(this.m_mass=f+this.m_ratio*this.m_ratio*x,this.m_mass>0&&(this.m_mass=1/this.m_mass),t.warmStarting){this.m_impulse*=t.dtRatio;var g=c.mul(-this.m_impulse,this.m_uA),A=c.mul(-this.m_ratio*this.m_impulse,this.m_uB);o.addMul(this.m_invMassA,g),s+=this.m_invIA*c.cross(this.m_rA,g),m.addMul(this.m_invMassB,A),h+=this.m_invIB*c.cross(this.m_rB,A)}else this.m_impulse=0;this.m_bodyA.c_velocity.v=o,this.m_bodyA.c_velocity.w=s,this.m_bodyB.c_velocity.v=m,this.m_bodyB.c_velocity.w=h},o.prototype.solveVelocityConstraints=function(t){var i=this.m_bodyA.c_velocity.v,e=this.m_bodyA.c_velocity.w,o=this.m_bodyB.c_velocity.v,s=this.m_bodyB.c_velocity.w,n=c.add(i,c.cross(e,this.m_rA)),r=c.add(o,c.cross(s,this.m_rB)),m=-c.dot(this.m_uA,n)-this.m_ratio*c.dot(this.m_uB,r),a=-this.m_mass*m;this.m_impulse+=a;var h=c.mul(-a,this.m_uA),_=c.mul(-this.m_ratio*a,this.m_uB);i.addMul(this.m_invMassA,h),e+=this.m_invIA*c.cross(this.m_rA,h),o.addMul(this.m_invMassB,_),s+=this.m_invIB*c.cross(this.m_rB,_),this.m_bodyA.c_velocity.v=i,this.m_bodyA.c_velocity.w=e,this.m_bodyB.c_velocity.v=o,this.m_bodyB.c_velocity.w=s},o.prototype.solvePositionConstraints=function(t){var i=this.m_bodyA.c_position.c,e=this.m_bodyA.c_position.a,o=this.m_bodyB.c_position.c,s=this.m_bodyB.c_position.a,n=_.neo(e),r=_.neo(s),m=_.mulVec2(n,c.sub(this.m_localAnchorA,this.m_localCenterA)),l=_.mulVec2(r,c.sub(this.m_localAnchorB,this.m_localCenterB)),u=c.sub(c.add(i,this.m_rA),this.m_groundAnchorA),p=c.sub(c.add(o,this.m_rB),this.m_groundAnchorB),y=u.length(),d=p.length();y>10*a.linearSlop?u.mul(1/y):u.setZero(),d>10*a.linearSlop?p.mul(1/d):p.setZero();var v=c.cross(m,u),f=c.cross(l,p),x=this.m_invMassA+this.m_invIA*v*v,g=this.m_invMassB+this.m_invIB*f*f,A=x+this.m_ratio*this.m_ratio*g;A>0&&(A=1/A);var b=this.m_constant-y-this.m_ratio*d,B=h.abs(b),w=-A*b,M=c.mul(-w,u),C=c.mul(-this.m_ratio*w,p);return i.addMul(this.m_invMassA,M),e+=this.m_invIA*c.cross(m,M),o.addMul(this.m_invMassB,C),s+=this.m_invIB*c.cross(l,C),this.m_bodyA.c_position.c=i,this.m_bodyA.c_position.a=e,this.m_bodyB.c_position.c=o,this.m_bodyB.c_position.a=s,B<a.linearSlop}},{"../Joint":5,"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../util/common":50,"../util/create":51,"../util/options":52}],34:[function(t,i,e){function o(t,i,e,n){if(!(this instanceof o))return new o(t,i,e,n);t=s(t,y),u.call(this,t,i,e),i=this.m_bodyA,e=this.m_bodyB,this.m_type=o.TYPE,this.m_localAnchorA=n?i.getLocalPoint(n):t.localAnchorA||a.zero(),this.m_localAnchorB=n?e.getLocalPoint(n):t.localAnchorB||a.zero(),this.m_referenceAngle=m.isFinite(t.referenceAngle)?t.referenceAngle:e.getAngle()-i.getAngle(),this.m_impulse=h(),this.m_motorImpulse=0,this.m_lowerAngle=t.lowerAngle,this.m_upperAngle=t.upperAngle,this.m_maxMotorTorque=t.maxMotorTorque,this.m_motorSpeed=t.motorSpeed,this.m_enableLimit=t.enableLimit,this.m_enableMotor=t.enableMotor,this.m_rA,this.m_rB,this.m_localCenterA,this.m_localCenterB,this.m_invMassA,this.m_invMassB,this.m_invIA,this.m_invIB,this.m_mass=new _,this.m_motorMass,this.m_limitState=p}i.exports=o;t("../util/common");var s=t("../util/options"),n=t("../util/create"),r=t("../Settings"),m=t("../common/Math"),a=t("../common/Vec2"),h=t("../common/Vec3"),c=t("../common/Mat22"),_=t("../common/Mat33"),l=t("../common/Rot"),u=(t("../common/Sweep"),t("../common/Transform"),t("../common/Velocity"),t("../common/Position"),t("../Joint")),p=0;o.TYPE="revolute-joint";var y={lowerAngle:0,upperAngle:0,maxMotorTorque:0,motorSpeed:0,enableLimit:!1,enableMotor:!1};(o.prototype=n((o._super=u).prototype)).getLocalAnchorA=function(){return this.m_localAnchorA},o.prototype.getLocalAnchorB=function(){return this.m_localAnchorB},o.prototype.getReferenceAngle=function(){return this.m_referenceAngle},o.prototype.getJointAngle=function(){var t=this.m_bodyA;return this.m_bodyB.m_sweep.a-t.m_sweep.a-this.m_referenceAngle},o.prototype.getJointSpeed=function(){var t=this.m_bodyA;return this.m_bodyB.m_angularVelocity-t.m_angularVelocity},o.prototype.isMotorEnabled=function(){return this.m_enableMotor},o.prototype.enableMotor=function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_enableMotor=t},o.prototype.getMotorTorque=function(t){return t*this.m_motorImpulse},o.prototype.setMotorSpeed=function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_motorSpeed=t},o.prototype.getMotorSpeed=function(){return this.m_motorSpeed},o.prototype.setMaxMotorTorque=function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_maxMotorTorque=t},o.prototype.isLimitEnabled=function(){return this.m_enableLimit},o.prototype.enableLimit=function(t){t!=this.m_enableLimit&&(this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},o.prototype.getLowerLimit=function(){return this.m_lowerAngle},o.prototype.getUpperLimit=function(){return this.m_upperAngle},o.prototype.setLimits=function(t,i){t==this.m_lowerAngle&&i==this.m_upperAngle||(this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_impulse.z=0,this.m_lowerAngle=t,this.m_upperAngle=i)},o.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)},o.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},o.prototype.getReactionForce=function(t){return a.neo(this.m_impulse.x,this.m_impulse.y).mul(t)},o.prototype.getReactionTorque=function(t){return t*this.m_impulse.z},o.prototype.initVelocityConstraints=function(t){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter,this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=this.m_bodyA.c_position.a,e=this.m_bodyA.c_velocity.v,o=this.m_bodyA.c_velocity.w,s=this.m_bodyB.c_position.a,n=this.m_bodyB.c_velocity.v,h=this.m_bodyB.c_velocity.w,c=l.neo(i),_=l.neo(s);this.m_rA=l.mulVec2(c,a.sub(this.m_localAnchorA,this.m_localCenterA)),this.m_rB=l.mulVec2(_,a.sub(this.m_localAnchorB,this.m_localCenterB));var u=this.m_invMassA,y=this.m_invMassB,d=this.m_invIA,v=this.m_invIB,f=d+v===0;if(this.m_mass.ex.x=u+y+this.m_rA.y*this.m_rA.y*d+this.m_rB.y*this.m_rB.y*v,this.m_mass.ey.x=-this.m_rA.y*this.m_rA.x*d-this.m_rB.y*this.m_rB.x*v,this.m_mass.ez.x=-this.m_rA.y*d-this.m_rB.y*v,this.m_mass.ex.y=this.m_mass.ey.x,this.m_mass.ey.y=u+y+this.m_rA.x*this.m_rA.x*d+this.m_rB.x*this.m_rB.x*v,this.m_mass.ez.y=this.m_rA.x*d+this.m_rB.x*v,this.m_mass.ex.z=this.m_mass.ez.x,this.m_mass.ey.z=this.m_mass.ez.y,this.m_mass.ez.z=d+v,this.m_motorMass=d+v,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),(0==this.m_enableMotor||f)&&(this.m_motorImpulse=0),this.m_enableLimit&&0==f){var x=s-i-this.m_referenceAngle;m.abs(this.m_upperAngle-this.m_lowerAngle)<2*r.angularSlop?this.m_limitState=3:x<=this.m_lowerAngle?(1!=this.m_limitState&&(this.m_impulse.z=0),this.m_limitState=1):x>=this.m_upperAngle?(2!=this.m_limitState&&(this.m_impulse.z=0),this.m_limitState=2):(this.m_limitState=p,this.m_impulse.z=0)}else this.m_limitState=p;if(t.warmStarting){this.m_impulse.mul(t.dtRatio),this.m_motorImpulse*=t.dtRatio;var g=a.neo(this.m_impulse.x,this.m_impulse.y);e.subMul(u,g),o-=d*(a.cross(this.m_rA,g)+this.m_motorImpulse+this.m_impulse.z),n.addMul(y,g),h+=v*(a.cross(this.m_rB,g)+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.setZero(),this.m_motorImpulse=0;this.m_bodyA.c_velocity.v=e,this.m_bodyA.c_velocity.w=o,this.m_bodyB.c_velocity.v=n,this.m_bodyB.c_velocity.w=h},o.prototype.solveVelocityConstraints=function(t){var i=this.m_bodyA.c_velocity.v,e=this.m_bodyA.c_velocity.w,o=this.m_bodyB.c_velocity.v,s=this.m_bodyB.c_velocity.w,n=this.m_invMassA,r=this.m_invMassB,c=this.m_invIA,_=this.m_invIB,l=c+_===0;if(this.m_enableMotor&&3!=this.m_limitState&&0==l){var u=s-e-this.m_motorSpeed,y=-this.m_motorMass*u,d=this.m_motorImpulse,v=t.dt*this.m_maxMotorTorque;this.m_motorImpulse=m.clamp(this.m_motorImpulse+y,-v,v),e-=c*(y=this.m_motorImpulse-d),s+=_*y}if(this.m_enableLimit&&this.m_limitState!=p&&0==l){var f=a.zero();f.addCombine(1,o,1,a.cross(s,this.m_rB)),f.subCombine(1,i,1,a.cross(e,this.m_rA));var x=s-e;u=h(f.x,f.y,x),y=h.neg(this.m_mass.solve33(u));if(3==this.m_limitState)this.m_impulse.add(y);else if(1==this.m_limitState){if(this.m_impulse.z+y.z<0){var g=a.combine(-1,f,this.m_impulse.z,a.neo(this.m_mass.ez.x,this.m_mass.ez.y)),A=this.m_mass.solve22(g);y.x=A.x,y.y=A.y,y.z=-this.m_impulse.z,this.m_impulse.x+=A.x,this.m_impulse.y+=A.y,this.m_impulse.z=0}else this.m_impulse.add(y)}else if(2==this.m_limitState){if(this.m_impulse.z+y.z>0){g=a.combine(-1,f,this.m_impulse.z,a.neo(this.m_mass.ez.x,this.m_mass.ez.y)),A=this.m_mass.solve22(g);y.x=A.x,y.y=A.y,y.z=-this.m_impulse.z,this.m_impulse.x+=A.x,this.m_impulse.y+=A.y,this.m_impulse.z=0}else this.m_impulse.add(y)}var b=a.neo(y.x,y.y);i.subMul(n,b),e-=c*(a.cross(this.m_rA,b)+y.z),o.addMul(r,b),s+=_*(a.cross(this.m_rB,b)+y.z)}else{(u=a.zero()).addCombine(1,o,1,a.cross(s,this.m_rB)),u.subCombine(1,i,1,a.cross(e,this.m_rA));y=this.m_mass.solve22(a.neg(u));this.m_impulse.x+=y.x,this.m_impulse.y+=y.y,i.subMul(n,y),e-=c*a.cross(this.m_rA,y),o.addMul(r,y),s+=_*a.cross(this.m_rB,y)}this.m_bodyA.c_velocity.v=i,this.m_bodyA.c_velocity.w=e,this.m_bodyB.c_velocity.v=o,this.m_bodyB.c_velocity.w=s},o.prototype.solvePositionConstraints=function(t){var i=this.m_bodyA.c_position.c,e=this.m_bodyA.c_position.a,o=this.m_bodyB.c_position.c,s=this.m_bodyB.c_position.a,n=l.neo(e),h=l.neo(s),_=0,u=0,y=this.m_invIA+this.m_invIB==0;if(this.m_enableLimit&&this.m_limitState!=p&&0==y){var d=s-e-this.m_referenceAngle,v=0;if(3==this.m_limitState){var f=m.clamp(d-this.m_lowerAngle,-r.maxAngularCorrection,r.maxAngularCorrection);v=-this.m_motorMass*f,_=m.abs(f)}else if(1==this.m_limitState){_=-(f=d-this.m_lowerAngle),f=m.clamp(f+r.angularSlop,-r.maxAngularCorrection,0),v=-this.m_motorMass*f}else if(2==this.m_limitState){_=f=d-this.m_upperAngle,f=m.clamp(f-r.angularSlop,0,r.maxAngularCorrection),v=-this.m_motorMass*f}e-=this.m_invIA*v,s+=this.m_invIB*v}n.set(e),h.set(s);var x=l.mulVec2(n,a.sub(this.m_localAnchorA,this.m_localCenterA)),g=l.mulVec2(h,a.sub(this.m_localAnchorB,this.m_localCenterB));(f=a.zero()).addCombine(1,o,1,g),f.subCombine(1,i,1,x),u=f.length();var A=this.m_invMassA,b=this.m_invMassB,B=this.m_invIA,w=this.m_invIB,M=new c;M.ex.x=A+b+B*x.y*x.y+w*g.y*g.y,M.ex.y=-B*x.x*x.y-w*g.x*g.y,M.ey.x=M.ex.y,M.ey.y=A+b+B*x.x*x.x+w*g.x*g.x;var C=a.neg(M.solve(f));return i.subMul(A,C),e-=B*a.cross(x,C),o.addMul(b,C),s+=w*a.cross(g,C),this.m_bodyA.c_position.c.set(i),this.m_bodyA.c_position.a=e,this.m_bodyB.c_position.c.set(o),this.m_bodyB.c_position.a=s,u<=r.linearSlop&&_<=r.angularSlop}},{"../Joint":5,"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../util/common":50,"../util/create":51,"../util/options":52}],35:[function(t,i,e){function o(t,i,e,n){if(!(this instanceof o))return new o(t,i,e,n);t=s(t,l),c.call(this,t,i,e),i=this.m_bodyA,e=this.m_bodyB,this.m_type=o.TYPE,this.m_localAnchorA=n?i.getLocalPoint(n):t.localAnchorA||a.neo(-1,0),this.m_localAnchorB=n?e.getLocalPoint(n):t.localAnchorB||a.neo(1,0),this.m_maxLength=t.maxLength,this.m_mass=0,this.m_impulse=0,this.m_length=0,this.m_state=_,this.m_u,this.m_rA,this.m_rB,this.m_localCenterA,this.m_localCenterB,this.m_invMassA,this.m_invMassB,this.m_invIA,this.m_invIB,this.m_mass}i.exports=o;var s=t("../util/options"),n=t("../util/create"),r=t("../Settings"),m=t("../common/Math"),a=t("../common/Vec2"),h=(t("../common/Vec3"),t("../common/Mat22"),t("../common/Mat33"),t("../common/Rot")),c=(t("../common/Sweep"),t("../common/Transform"),t("../common/Velocity"),t("../common/Position"),t("../Joint")),_=0;o.TYPE="rope-joint";var l={maxLength:0};(o.prototype=n((o._super=c).prototype)).getLocalAnchorA=function(){return this.m_localAnchorA},o.prototype.getLocalAnchorB=function(){return this.m_localAnchorB},o.prototype.setMaxLength=function(t){this.m_maxLength=t},o.prototype.getMaxLength=function(){return this.m_maxLength},o.prototype.getLimitState=function(){return this.m_state},o.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)},o.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},o.prototype.getReactionForce=function(t){return a.mul(this.m_impulse,this.m_u).mul(t)},o.prototype.getReactionTorque=function(t){return 0},o.prototype.initVelocityConstraints=function(t){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter,this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=this.m_bodyA.c_position.c,e=this.m_bodyA.c_position.a,o=this.m_bodyA.c_velocity.v,s=this.m_bodyA.c_velocity.w,n=this.m_bodyB.c_position.c,m=this.m_bodyB.c_position.a,c=this.m_bodyB.c_velocity.v,l=this.m_bodyB.c_velocity.w,u=h.neo(e),p=h.neo(m);this.m_rA=h.mulSub(u,this.m_localAnchorA,this.m_localCenterA),this.m_rB=h.mulSub(p,this.m_localAnchorB,this.m_localCenterB),this.m_u=a.zero(),this.m_u.addCombine(1,n,1,this.m_rB),this.m_u.subCombine(1,i,1,this.m_rA),this.m_length=this.m_u.length();var y=this.m_length-this.m_maxLength;if(this.m_state=y>0?2:_,!(this.m_length>r.linearSlop))return this.m_u.setZero(),this.m_mass=0,void(this.m_impulse=0);this.m_u.mul(1/this.m_length);var d=a.cross(this.m_rA,this.m_u),v=a.cross(this.m_rB,this.m_u),f=this.m_invMassA+this.m_invIA*d*d+this.m_invMassB+this.m_invIB*v*v;if(this.m_mass=0!=f?1/f:0,t.warmStarting){this.m_impulse*=t.dtRatio;var x=a.mul(this.m_impulse,this.m_u);o.subMul(this.m_invMassA,x),s-=this.m_invIA*a.cross(this.m_rA,x),c.addMul(this.m_invMassB,x),l+=this.m_invIB*a.cross(this.m_rB,x)}else this.m_impulse=0;this.m_bodyA.c_velocity.v.set(o),this.m_bodyA.c_velocity.w=s,this.m_bodyB.c_velocity.v.set(c),this.m_bodyB.c_velocity.w=l},o.prototype.solveVelocityConstraints=function(t){var i=this.m_bodyA.c_velocity.v,e=this.m_bodyA.c_velocity.w,o=this.m_bodyB.c_velocity.v,s=this.m_bodyB.c_velocity.w,n=a.addCross(i,e,this.m_rA),r=a.addCross(o,s,this.m_rB),h=this.m_length-this.m_maxLength,c=a.dot(this.m_u,a.sub(r,n));h<0&&(c+=t.inv_dt*h);var _=-this.m_mass*c,l=this.m_impulse;this.m_impulse=m.min(0,this.m_impulse+_),_=this.m_impulse-l;var u=a.mul(_,this.m_u);i.subMul(this.m_invMassA,u),e-=this.m_invIA*a.cross(this.m_rA,u),o.addMul(this.m_invMassB,u),s+=this.m_invIB*a.cross(this.m_rB,u),this.m_bodyA.c_velocity.v=i,this.m_bodyA.c_velocity.w=e,this.m_bodyB.c_velocity.v=o,this.m_bodyB.c_velocity.w=s},o.prototype.solvePositionConstraints=function(t){var i=this.m_bodyA.c_position.c,e=this.m_bodyA.c_position.a,o=this.m_bodyB.c_position.c,s=this.m_bodyB.c_position.a,n=h.neo(e),c=h.neo(s),_=h.mulSub(n,this.m_localAnchorA,this.m_localCenterA),l=h.mulSub(c,this.m_localAnchorB,this.m_localCenterB),u=a.zero();u.addCombine(1,o,1,l),u.subCombine(1,i,1,_);var p=u.normalize(),y=p-this.m_maxLength;y=m.clamp(y,0,r.maxLinearCorrection);var d=-this.m_mass*y,v=a.mul(d,u);return i.subMul(this.m_invMassA,v),e-=this.m_invIA*a.cross(_,v),o.addMul(this.m_invMassB,v),s+=this.m_invIB*a.cross(l,v),this.m_bodyA.c_position.c.set(i),this.m_bodyA.c_position.a=e,this.m_bodyB.c_position.c.set(o),this.m_bodyB.c_position.a=s,p-this.m_maxLength<r.linearSlop}},{"../Joint":5,"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../util/create":51,"../util/options":52}],36:[function(t,i,e){function o(t,i,e,n){if(!(this instanceof o))return new o(t,i,e,n);t=s(t,u),l.call(this,t,i,e),i=this.m_bodyA,e=this.m_bodyB,this.m_type=o.TYPE,this.m_localAnchorA=n?i.getLocalPoint(n):t.localAnchorA||a.zero(),this.m_localAnchorB=n?e.getLocalPoint(n):t.localAnchorB||a.zero(),this.m_referenceAngle=m.isFinite(t.referenceAngle)?t.referenceAngle:e.getAngle()-i.getAngle(),this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_impulse=h(),this.m_bias=0,this.m_gamma=0,this.m_rA,this.m_rB,this.m_localCenterA,this.m_localCenterB,this.m_invMassA,this.m_invMassB,this.m_invIA,this.m_invIB,this.m_mass=new c}i.exports=o;var s=t("../util/options"),n=t("../util/create"),r=t("../Settings"),m=t("../common/Math"),a=t("../common/Vec2"),h=t("../common/Vec3"),c=(t("../common/Mat22"),t("../common/Mat33")),_=t("../common/Rot"),l=(t("../common/Sweep"),t("../common/Transform"),t("../common/Velocity"),t("../common/Position"),t("../Joint"));o.TYPE="weld-joint";var u={frequencyHz:0,dampingRatio:0};(o.prototype=n((o._super=l).prototype)).getLocalAnchorA=function(){return this.m_localAnchorA},o.prototype.getLocalAnchorB=function(){return this.m_localAnchorB},o.prototype.getReferenceAngle=function(){return this.m_referenceAngle},o.prototype.setFrequency=function(t){this.m_frequencyHz=t},o.prototype.getFrequency=function(){return this.m_frequencyHz},o.prototype.setDampingRatio=function(t){this.m_dampingRatio=t},o.prototype.getDampingRatio=function(){return this.m_dampingRatio},o.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)},o.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},o.prototype.getReactionForce=function(t){return a.neo(this.m_impulse.x,this.m_impulse.y).mul(t)},o.prototype.getReactionTorque=function(t){return t*this.m_impulse.z},o.prototype.initVelocityConstraints=function(t){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter,this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=this.m_bodyA.c_position.a,e=this.m_bodyA.c_velocity.v,o=this.m_bodyA.c_velocity.w,s=this.m_bodyB.c_position.a,n=this.m_bodyB.c_velocity.v,r=this.m_bodyB.c_velocity.w,h=_.neo(i),l=_.neo(s);this.m_rA=_.mulVec2(h,a.sub(this.m_localAnchorA,this.m_localCenterA)),this.m_rB=_.mulVec2(l,a.sub(this.m_localAnchorB,this.m_localCenterB));var u=this.m_invMassA,p=this.m_invMassB,y=this.m_invIA,d=this.m_invIB,v=new c;if(v.ex.x=u+p+this.m_rA.y*this.m_rA.y*y+this.m_rB.y*this.m_rB.y*d,v.ey.x=-this.m_rA.y*this.m_rA.x*y-this.m_rB.y*this.m_rB.x*d,v.ez.x=-this.m_rA.y*y-this.m_rB.y*d,v.ex.y=v.ey.x,v.ey.y=u+p+this.m_rA.x*this.m_rA.x*y+this.m_rB.x*this.m_rB.x*d,v.ez.y=this.m_rA.x*y+this.m_rB.x*d,v.ex.z=v.ez.x,v.ey.z=v.ez.y,v.ez.z=y+d,this.m_frequencyHz>0){v.getInverse22(this.m_mass);var f=y+d,x=f>0?1/f:0,g=s-i-this.m_referenceAngle,A=2*m.PI*this.m_frequencyHz,b=2*x*this.m_dampingRatio*A,B=x*A*A,w=t.dt;this.m_gamma=w*(b+w*B),this.m_gamma=0!=this.m_gamma?1/this.m_gamma:0,this.m_bias=g*w*B*this.m_gamma,f+=this.m_gamma,this.m_mass.ez.z=0!=f?1/f:0}else 0==v.ez.z?(v.getInverse22(this.m_mass),this.m_gamma=0,this.m_bias=0):(v.getSymInverse33(this.m_mass),this.m_gamma=0,this.m_bias=0);if(t.warmStarting){this.m_impulse.mul(t.dtRatio);var M=a.neo(this.m_impulse.x,this.m_impulse.y);e.subMul(u,M),o-=y*(a.cross(this.m_rA,M)+this.m_impulse.z),n.addMul(p,M),r+=d*(a.cross(this.m_rB,M)+this.m_impulse.z)}else this.m_impulse.setZero();this.m_bodyA.c_velocity.v=e,this.m_bodyA.c_velocity.w=o,this.m_bodyB.c_velocity.v=n,this.m_bodyB.c_velocity.w=r},o.prototype.solveVelocityConstraints=function(t){var i=this.m_bodyA.c_velocity.v,e=this.m_bodyA.c_velocity.w,o=this.m_bodyB.c_velocity.v,s=this.m_bodyB.c_velocity.w,n=this.m_invMassA,r=this.m_invMassB,m=this.m_invIA,_=this.m_invIB;if(this.m_frequencyHz>0){var l=s-e,u=-this.m_mass.ez.z*(l+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=u,e-=m*u,s+=_*u;(d=a.zero()).addCombine(1,o,1,a.cross(s,this.m_rB)),d.subCombine(1,i,1,a.cross(e,this.m_rA));var p=a.neg(c.mulVec2(this.m_mass,d));this.m_impulse.x+=p.x,this.m_impulse.y+=p.y;var y=a.clone(p);i.subMul(n,y),e-=m*a.cross(this.m_rA,y),o.addMul(r,y),s+=_*a.cross(this.m_rB,y)}else{var d;(d=a.zero()).addCombine(1,o,1,a.cross(s,this.m_rB)),d.subCombine(1,i,1,a.cross(e,this.m_rA));l=s-e;var v=h(d.x,d.y,l),f=h.neg(c.mulVec3(this.m_mass,v));this.m_impulse.add(f);y=a.neo(f.x,f.y);i.subMul(n,y),e-=m*(a.cross(this.m_rA,y)+f.z),o.addMul(r,y),s+=_*(a.cross(this.m_rB,y)+f.z)}this.m_bodyA.c_velocity.v=i,this.m_bodyA.c_velocity.w=e,this.m_bodyB.c_velocity.v=o,this.m_bodyB.c_velocity.w=s},o.prototype.solvePositionConstraints=function(t){var i,e,o=this.m_bodyA.c_position.c,s=this.m_bodyA.c_position.a,n=this.m_bodyB.c_position.c,l=this.m_bodyB.c_position.a,u=_.neo(s),p=_.neo(l),y=this.m_invMassA,d=this.m_invMassB,v=this.m_invIA,f=this.m_invIB,x=_.mulVec2(u,a.sub(this.m_localAnchorA,this.m_localCenterA)),g=_.mulVec2(p,a.sub(this.m_localAnchorB,this.m_localCenterB)),A=new c;if(A.ex.x=y+d+x.y*x.y*v+g.y*g.y*f,A.ey.x=-x.y*x.x*v-g.y*g.x*f,A.ez.x=-x.y*v-g.y*f,A.ex.y=A.ey.x,A.ey.y=y+d+x.x*x.x*v+g.x*g.x*f,A.ez.y=x.x*v+g.x*f,A.ex.z=A.ez.x,A.ey.z=A.ez.y,A.ez.z=v+f,this.m_frequencyHz>0){(B=a.zero()).addCombine(1,n,1,g),B.subCombine(1,o,1,x),i=B.length(),e=0;var b=a.neg(A.solve22(B));o.subMul(y,b),s-=v*a.cross(x,b),n.addMul(d,b),l+=f*a.cross(g,b)}else{var B;(B=a.zero()).addCombine(1,n,1,g),B.subCombine(1,o,1,x);var w=l-s-this.m_referenceAngle;i=B.length(),e=m.abs(w);var M=h(B.x,B.y,w),C=h();if(A.ez.z>0)C=h.neg(A.solve33(M));else{var V=a.neg(A.solve22(B));C.set(V.x,V.y,0)}b=a.neo(C.x,C.y);o.subMul(y,b),s-=v*(a.cross(x,b)+C.z),n.addMul(d,b),l+=f*(a.cross(g,b)+C.z)}return this.m_bodyA.c_position.c=o,this.m_bodyA.c_position.a=s,this.m_bodyB.c_position.c=n,this.m_bodyB.c_position.a=l,i<=r.linearSlop&&e<=r.angularSlop}},{"../Joint":5,"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../util/create":51,"../util/options":52}],37:[function(t,i,e){function o(t,i,e,n,r){if(!(this instanceof o))return new o(t,i,e,n,r);t=s(t,_),c.call(this,t,i,e),i=this.m_bodyA,e=this.m_bodyB,this.m_type=o.TYPE,this.m_localAnchorA=n?i.getLocalPoint(n):t.localAnchorA||a.zero(),this.m_localAnchorB=n?e.getLocalPoint(n):t.localAnchorB||a.zero(),this.m_localAxis=r?i.getLocalVector(r):t.localAxisA||a.neo(1,0),this.m_localXAxisA=this.m_localAxis,this.m_localYAxisA=a.cross(1,this.m_localXAxisA),this.m_mass=0,this.m_impulse=0,this.m_motorMass=0,this.m_motorImpulse=0,this.m_springMass=0,this.m_springImpulse=0,this.m_maxMotorTorque=t.maxMotorTorque,this.m_motorSpeed=t.motorSpeed,this.m_enableMotor=t.enableMotor,this.m_frequencyHz=t.frequencyHz,this.m_dampingRatio=t.dampingRatio,this.m_bias=0,this.m_gamma=0,this.m_localCenterA,this.m_localCenterB,this.m_invMassA,this.m_invMassB,this.m_invIA,this.m_invIB,this.m_ax=a.zero(),this.m_ay=a.zero(),this.m_sAx,this.m_sBx,this.m_sAy,this.m_sBy}i.exports=o;var s=t("../util/options"),n=t("../util/create"),r=t("../Settings"),m=t("../common/Math"),a=t("../common/Vec2"),h=(t("../common/Vec3"),t("../common/Mat22"),t("../common/Mat33"),t("../common/Rot")),c=(t("../common/Sweep"),t("../common/Transform"),t("../common/Velocity"),t("../common/Position"),t("../Joint"));o.TYPE="wheel-joint";var _={enableMotor:!1,maxMotorTorque:0,motorSpeed:0,frequencyHz:2,dampingRatio:.7};(o.prototype=n((o._super=c).prototype)).getLocalAnchorA=function(){return this.m_localAnchorA},o.prototype.getLocalAnchorB=function(){return this.m_localAnchorB},o.prototype.getLocalAxisA=function(){return this.m_localXAxisA},o.prototype.getJointTranslation=function(){var t=this.m_bodyA,i=this.m_bodyB,e=t.getWorldPoint(this.m_localAnchorA),o=i.getWorldPoint(this.m_localAnchorB),s=a.sub(o,e),n=t.getWorldVector(this.m_localXAxisA);return a.dot(s,n)},o.prototype.getJointSpeed=function(){var t=this.m_bodyA.m_angularVelocity;return this.m_bodyB.m_angularVelocity-t},o.prototype.isMotorEnabled=function(){return this.m_enableMotor},o.prototype.enableMotor=function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_enableMotor=t},o.prototype.setMotorSpeed=function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_motorSpeed=t},o.prototype.getMotorSpeed=function(){return this.m_motorSpeed},o.prototype.setMaxMotorTorque=function(t){this.m_bodyA.setAwake(!0),this.m_bodyB.setAwake(!0),this.m_maxMotorTorque=t},o.prototype.getMaxMotorTorque=function(){return this.m_maxMotorTorque},o.prototype.getMotorTorque=function(t){return t*this.m_motorImpulse},o.prototype.setSpringFrequencyHz=function(t){this.m_frequencyHz=t},o.prototype.getSpringFrequencyHz=function(){return this.m_frequencyHz},o.prototype.setSpringDampingRatio=function(t){this.m_dampingRatio=t},o.prototype.getSpringDampingRatio=function(){return this.m_dampingRatio},o.prototype.getAnchorA=function(){return this.m_bodyA.getWorldPoint(this.m_localAnchorA)},o.prototype.getAnchorB=function(){return this.m_bodyB.getWorldPoint(this.m_localAnchorB)},o.prototype.getReactionForce=function(t){return a.combine(this.m_impulse,this.m_ay,this.m_springImpulse,this.m_ax).mul(t)},o.prototype.getReactionTorque=function(t){return t*this.m_motorImpulse},o.prototype.initVelocityConstraints=function(t){this.m_localCenterA=this.m_bodyA.m_sweep.localCenter,this.m_localCenterB=this.m_bodyB.m_sweep.localCenter,this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=this.m_invMassA,e=this.m_invMassB,o=this.m_invIA,s=this.m_invIB,n=this.m_bodyA.c_position.c,r=this.m_bodyA.c_position.a,c=this.m_bodyA.c_velocity.v,_=this.m_bodyA.c_velocity.w,l=this.m_bodyB.c_position.c,u=this.m_bodyB.c_position.a,p=this.m_bodyB.c_velocity.v,y=this.m_bodyB.c_velocity.w,d=h.neo(r),v=h.neo(u),f=h.mulVec2(d,a.sub(this.m_localAnchorA,this.m_localCenterA)),x=h.mulVec2(v,a.sub(this.m_localAnchorB,this.m_localCenterB));if((B=a.zero()).addCombine(1,l,1,x),B.subCombine(1,n,1,f),this.m_ay=h.mulVec2(d,this.m_localYAxisA),this.m_sAy=a.cross(a.add(B,f),this.m_ay),this.m_sBy=a.cross(x,this.m_ay),this.m_mass=i+e+o*this.m_sAy*this.m_sAy+s*this.m_sBy*this.m_sBy,this.m_mass>0&&(this.m_mass=1/this.m_mass),this.m_springMass=0,this.m_bias=0,this.m_gamma=0,this.m_frequencyHz>0){this.m_ax=h.mulVec2(d,this.m_localXAxisA),this.m_sAx=a.cross(a.add(B,f),this.m_ax),this.m_sBx=a.cross(x,this.m_ax);var g=i+e+o*this.m_sAx*this.m_sAx+s*this.m_sBx*this.m_sBx;if(g>0){this.m_springMass=1/g;var A=a.dot(B,this.m_ax),b=2*m.PI*this.m_frequencyHz,B=2*this.m_springMass*this.m_dampingRatio*b,w=this.m_springMass*b*b,M=t.dt;this.m_gamma=M*(B+M*w),this.m_gamma>0&&(this.m_gamma=1/this.m_gamma),this.m_bias=A*M*w*this.m_gamma,this.m_springMass=g+this.m_gamma,this.m_springMass>0&&(this.m_springMass=1/this.m_springMass)}}else this.m_springImpulse=0;if(this.m_enableMotor?(this.m_motorMass=o+s,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass)):(this.m_motorMass=0,this.m_motorImpulse=0),t.warmStarting){this.m_impulse*=t.dtRatio,this.m_springImpulse*=t.dtRatio,this.m_motorImpulse*=t.dtRatio;var C=a.combine(this.m_impulse,this.m_ay,this.m_springImpulse,this.m_ax),V=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse,S=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;c.subMul(this.m_invMassA,C),_-=this.m_invIA*V,p.addMul(this.m_invMassB,C),y+=this.m_invIB*S}else this.m_impulse=0,this.m_springImpulse=0,this.m_motorImpulse=0;this.m_bodyA.c_velocity.v.set(c),this.m_bodyA.c_velocity.w=_,this.m_bodyB.c_velocity.v.set(p),this.m_bodyB.c_velocity.w=y},o.prototype.solveVelocityConstraints=function(t){var i=this.m_invMassA,e=this.m_invMassB,o=this.m_invIA,s=this.m_invIB,n=this.m_bodyA.c_velocity.v,r=this.m_bodyA.c_velocity.w,h=this.m_bodyB.c_velocity.v,c=this.m_bodyB.c_velocity.w,_=a.dot(this.m_ax,h)-a.dot(this.m_ax,n)+this.m_sBx*c-this.m_sAx*r,l=-this.m_springMass*(_+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=l;var u=a.mul(l,this.m_ax),p=l*this.m_sAx,y=l*this.m_sBx;n.subMul(i,u),r-=o*p,h.addMul(e,u);_=(c+=s*y)-r-this.m_motorSpeed,l=-this.m_motorMass*_;var d=this.m_motorImpulse,v=t.dt*this.m_maxMotorTorque;this.m_motorImpulse=m.clamp(this.m_motorImpulse+l,-v,v),r-=o*(l=this.m_motorImpulse-d),c+=s*l;_=a.dot(this.m_ay,h)-a.dot(this.m_ay,n)+this.m_sBy*c-this.m_sAy*r,l=-this.m_mass*_;this.m_impulse+=l;u=a.mul(l,this.m_ay),p=l*this.m_sAy,y=l*this.m_sBy;n.subMul(i,u),r-=o*p,h.addMul(e,u),c+=s*y,this.m_bodyA.c_velocity.v.set(n),this.m_bodyA.c_velocity.w=r,this.m_bodyB.c_velocity.v.set(h),this.m_bodyB.c_velocity.w=c},o.prototype.solvePositionConstraints=function(t){var i=this.m_bodyA.c_position.c,e=this.m_bodyA.c_position.a,o=this.m_bodyB.c_position.c,s=this.m_bodyB.c_position.a,n=h.neo(e),c=h.neo(s),_=h.mulVec2(n,a.sub(this.m_localAnchorA,this.m_localCenterA)),l=h.mulVec2(c,a.sub(this.m_localAnchorB,this.m_localCenterB)),u=a.zero();u.addCombine(1,o,1,l),u.subCombine(1,i,1,_);var p,y=h.mulVec2(n,this.m_localYAxisA),d=a.cross(a.add(u,_),y),v=a.cross(l,y),f=a.dot(u,y),x=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy;p=0!=x?-f/x:0;var g=a.mul(p,y),A=p*d,b=p*v;return i.subMul(this.m_invMassA,g),e-=this.m_invIA*A,o.addMul(this.m_invMassB,g),s+=this.m_invIB*b,this.m_bodyA.c_position.c.set(i),this.m_bodyA.c_position.a=e,this.m_bodyB.c_position.c.set(o),this.m_bodyB.c_position.a=s,m.abs(f)<=r.linearSlop}},{"../Joint":5,"../Settings":7,"../common/Mat22":16,"../common/Mat33":17,"../common/Math":18,"../common/Position":19,"../common/Rot":20,"../common/Sweep":21,"../common/Transform":22,"../common/Vec2":23,"../common/Vec3":24,"../common/Velocity":25,"../util/create":51,"../util/options":52}],38:[function(t,i,e){function o(t,i,e,s){if(!(this instanceof o))return new o(t,i,e,s);o._super.call(this),this._setAsBox(t,i,e,s)}i.exports=o;t("../util/common");var s=t("../util/create"),n=t("./PolygonShape");o.prototype=s((o._super=n).prototype),o.TYPE="polygon"},{"../util/common":50,"../util/create":51,"./PolygonShape":47}],39:[function(t,i,e){function o(t,i){if(!(this instanceof o))return new o(t,i);o._super.call(this),this.m_type=o.TYPE,this.m_radius=m.polygonRadius,this.m_vertices=[],this.m_count=0,this.m_prevVertex=null,this.m_nextVertex=null,this.m_hasPrevVertex=!1,this.m_hasNextVertex=!1,t&&t.length&&(i?this._createLoop(t):this._createChain(t))}i.exports=o;t("../util/common");var s=t("../util/create"),n=(t("../util/options"),t("../common/Math"),t("../common/Transform")),r=(t("../common/Rot"),t("../common/Vec2")),m=(t("../collision/AABB"),t("../Settings")),a=t("../Shape"),h=t("./EdgeShape");o.prototype=s((o._super=a).prototype),o.TYPE="chain",o.prototype._createLoop=function(t){for(var i=1;i<t.length;++i)t[i-1],t[i];this.m_vertices.length=0,this.m_count=t.length+1;for(i=0;i<t.length;++i)this.m_vertices[i]=t[i].clone();return this.m_vertices[t.length]=t[0].clone(),this.m_prevVertex=this.m_vertices[this.m_count-2],this.m_nextVertex=this.m_vertices[1],this.m_hasPrevVertex=!0,this.m_hasNextVertex=!0,this},o.prototype._createChain=function(t){for(var i=1;i<t.length;++i)t[i-1],t[i];this.m_count=t.length;for(i=0;i<t.length;++i)this.m_vertices[i]=t[i].clone();return this.m_hasPrevVertex=!1,this.m_hasNextVertex=!1,this.m_prevVertex=null,this.m_nextVertex=null,this},o.prototype._setPrevVertex=function(t){this.m_prevVertex=t,this.m_hasPrevVertex=!0},o.prototype._setNextVertex=function(t){this.m_nextVertex=t,this.m_hasNextVertex=!0},o.prototype._clone=function(){var t=new o;return t.createChain(this.m_vertices),t.m_type=this.m_type,t.m_radius=this.m_radius,t.m_prevVertex=this.m_prevVertex,t.m_nextVertex=this.m_nextVertex,t.m_hasPrevVertex=this.m_hasPrevVertex,t.m_hasNextVertex=this.m_hasNextVertex,t},o.prototype.getChildCount=function(){return this.m_count-1},o.prototype.getChildEdge=function(t,i){t.m_type=h.TYPE,t.m_radius=this.m_radius,t.m_vertex1=this.m_vertices[i],t.m_vertex2=this.m_vertices[i+1],i>0?(t.m_vertex0=this.m_vertices[i-1],t.m_hasVertex0=!0):(t.m_vertex0=this.m_prevVertex,t.m_hasVertex0=this.m_hasPrevVertex),i<this.m_count-2?(t.m_vertex3=this.m_vertices[i+2],t.m_hasVertex3=!0):(t.m_vertex3=this.m_nextVertex,t.m_hasVertex3=this.m_hasNextVertex)},o.prototype.getVertex=function(t){return t<this.m_count?this.m_vertices[t]:this.m_vertices[0]},o.prototype.testPoint=function(t,i){return!1},o.prototype.rayCast=function(t,i,e,o){return new h(this.getVertex(o),this.getVertex(o+1)).rayCast(t,i,e,0)},o.prototype.computeAABB=function(t,i,e){var o=n.mulVec2(i,this.getVertex(e)),s=n.mulVec2(i,this.getVertex(e+1));t.combinePoints(o,s)},o.prototype.computeMass=function(t,i){t.mass=0,t.center=r.neo(),t.I=0},o.prototype.computeDistanceProxy=function(t,i){t.m_buffer[0]=this.getVertex(i),t.m_buffer[1]=this.getVertex(i+1),t.m_vertices=t.m_buffer,t.m_count=2,t.m_radius=this.m_radius}},{"../Settings":7,"../Shape":8,"../collision/AABB":11,"../common/Math":18,"../common/Rot":20,"../common/Transform":22,"../common/Vec2":23,"../util/common":50,"../util/create":51,"../util/options":52,"./EdgeShape":46}],40:[function(t,i,e){function o(t,i){if(!(this instanceof o))return new o(t,i);o._super.call(this),this.m_type=o.TYPE,this.m_p=m.zero(),this.m_radius=1,"object"==typeof t&&m.isValid(t)?(this.m_p.set(t),"number"==typeof i&&(this.m_radius=i)):"number"==typeof t&&(this.m_radius=t)}i.exports=o;t("../util/common");var s=t("../util/create"),n=(t("../util/options"),t("../common/Math")),r=(t("../common/Transform"),t("../common/Rot")),m=t("../common/Vec2"),a=(t("../collision/AABB"),t("../Settings"),t("../Shape"));o.prototype=s((o._super=a).prototype),o.TYPE="circle",o.prototype.getRadius=function(){return this.m_radius},o.prototype.getCenter=function(){return this.m_p},o.prototype.getVertex=function(t){return this.m_p},o.prototype.getVertexCount=function(t){return 1},o.prototype._clone=function(){var t=new o;return t.m_type=this.m_type,t.m_radius=this.m_radius,t.m_p=this.m_p.clone(),t},o.prototype.getChildCount=function(){return 1},o.prototype.testPoint=function(t,i){var e=m.add(t.p,r.mulVec2(t.q,this.m_p)),o=m.sub(i,e);return m.dot(o,o)<=this.m_radius*this.m_radius},o.prototype.rayCast=function(t,i,e,o){var s=m.add(e.p,r.mulVec2(e.q,this.m_p)),a=m.sub(i.p1,s),h=m.dot(a,a)-this.m_radius*this.m_radius,c=m.sub(i.p2,i.p1),_=m.dot(a,c),l=m.dot(c,c),u=_*_-l*h;if(u<0||l<n.EPSILON)return!1;var p=-(_+n.sqrt(u));return 0<=p&&p<=i.maxFraction*l&&(p/=l,t.fraction=p,t.normal=m.add(a,m.mul(p,c)),t.normal.normalize(),!0)},o.prototype.computeAABB=function(t,i,e){var o=m.add(i.p,r.mulVec2(i.q,this.m_p));t.lowerBound.set(o.x-this.m_radius,o.y-this.m_radius),t.upperBound.set(o.x+this.m_radius,o.y+this.m_radius)},o.prototype.computeMass=function(t,i){t.mass=i*n.PI*this.m_radius*this.m_radius,t.center=this.m_p,t.I=t.mass*(.5*this.m_radius*this.m_radius+m.dot(this.m_p,this.m_p))},o.prototype.computeDistanceProxy=function(t){t.m_vertices.push(this.m_p),t.m_count=1,t.m_radius=this.m_radius}},{"../Settings":7,"../Shape":8,"../collision/AABB":11,"../common/Math":18,"../common/Rot":20,"../common/Transform":22,"../common/Vec2":23,"../util/common":50,"../util/create":51,"../util/options":52}],41:[function(t,i,e){function o(t,i,e,o,s){t.pointCount=0;var n=r.mulVec2_(e,i.m_p,_),a=r.mulVec2_(s,o.m_p,l),c=m.distanceSquared(a,n),u=i.m_radius+o.m_radius;c>u*u||(t.type=h.e_circles,t.localPoint.set(i.m_p),t.localNormal.setZero(),t.pointCount=1,t.points[0].localPoint.set(o.m_p),t.points[0].id.cf.indexA=0,t.points[0].id.cf.typeA=h.e_vertex,t.points[0].id.cf.indexB=0,t.points[0].id.cf.typeB=h.e_vertex)}var s=!1,n=t("../util/common"),r=t("../common/Transform"),m=t("../common/Vec2"),a=t("../Contact"),h=t("../Manifold"),c=t("./CircleShape");a.addType(c.TYPE,c.TYPE,function(t,i,e,r,m,a,h){s&&n.assert(e.getType()==c.TYPE),s&&n.assert(a.getType()==c.TYPE),o(t,e.getShape(),i,a.getShape(),m)});var _=m.zero(),l=m.zero();e.CollideCircles=o},{"../Contact":3,"../Manifold":6,"../common/Transform":22,"../common/Vec2":23,"../util/common":50,"./CircleShape":40}],42:[function(t,i,e){var o=!1,s=t("../util/common"),n=t("../common/Math"),r=t("../common/Transform"),m=t("../common/Vec2"),a=t("../Manifold"),h=t("../Contact"),c=t("./CircleShape"),_=t("./PolygonShape");h.addType(_.TYPE,c.TYPE,function(t,i,e,h,d,v,f){o&&s.assert(e.getType()===_.TYPE),o&&s.assert(v.getType()===c.TYPE),function(t,i,e,o,s){t.pointCount=0;for(var h=r.mulVec2_(s,o.m_p,l),c=r.mulTVec2_(e,h,u),_=0,d=-1/0,v=i.m_radius+o.m_radius,f=i.m_count,x=i.m_vertices,g=i.m_normals,A=0;A<f;++A){var b=m.dot(g[A],m.sub_(c,x[A],p));if(b>v)return;b>d&&(d=b,_=A)}var B=_,w=B+1<f?B+1:0,M=x[B],C=x[w];if(d<n.EPSILON)return t.pointCount=1,t.type=a.e_faceA,t.localNormal.set(g[_]),t.localPoint.setCombine(.5,M,.5,C),t.points[0].localPoint.set(o.m_p),t.points[0].id.cf.indexA=0,t.points[0].id.cf.typeA=a.e_vertex,t.points[0].id.cf.indexB=0,void(t.points[0].id.cf.typeB=a.e_vertex);var V=m.dot(m.sub_(c,M,p),m.sub_(C,M,y)),S=m.dot(m.sub_(c,C,p),m.sub_(M,C,y));if(V<=0){if(m.distanceSquared(c,M)>v*v)return;t.pointCount=1,t.type=a.e_faceA,t.localNormal.setCombine(1,c,-1,M),t.localNormal.normalize(),t.localPoint.set(M),t.points[0].localPoint.set(o.m_p),t.points[0].id.cf.indexA=0,t.points[0].id.cf.typeA=a.e_vertex,t.points[0].id.cf.indexB=0,t.points[0].id.cf.typeB=a.e_vertex}else if(S<=0){if(m.distanceSquared(c,C)>v*v)return;t.pointCount=1,t.type=a.e_faceA,t.localNormal.setCombine(1,c,-1,C),t.localNormal.normalize(),t.localPoint.set(C),t.points[0].localPoint.set(o.m_p),t.points[0].id.cf.indexA=0,t.points[0].id.cf.typeA=a.e_vertex,t.points[0].id.cf.indexB=0,t.points[0].id.cf.typeB=a.e_vertex}else{var I=m.mid(M,C),d=m.dot(c,g[B])-m.dot(I,g[B]);if(d>v)return;t.pointCount=1,t.type=a.e_faceA,t.localNormal.set(g[B]),t.localPoint.set(I),t.points[0].localPoint.set(o.m_p),t.points[0].id.cf.indexA=0,t.points[0].id.cf.typeA=a.e_vertex,t.points[0].id.cf.indexB=0,t.points[0].id.cf.typeB=a.e_vertex}}(t,e.getShape(),i,v.getShape(),d)});var l=m.zero(),u=m.zero(),p=m.zero(),y=m.zero()},{"../Contact":3,"../Manifold":6,"../common/Math":18,"../common/Transform":22,"../common/Vec2":23,"../util/common":50,"./CircleShape":40,"./PolygonShape":47}],43:[function(t,i,e){function o(t,i,e,o,a){t.pointCount=0;var c=r.mulTVec2_(e,r.mulVec2_(a,o.m_p,A),y),_=i.m_vertex1,l=i.m_vertex2,u=m.sub_(l,_,p),b=m.dot(u,m.sub_(l,c,A)),B=m.dot(u,m.sub_(c,_,A)),w=i.m_radius+o.m_radius;if(B<=0){var M=d.setVec2(_),C=m.sub(c,M,v);if(m.dot(C,C)>w*w)return;if(i.m_hasVertex0){var V=i.m_vertex0,S=_,I=m.sub_(S,V,x);if(m.dot(I,m.sub(S,c,A))>0)return}return t.type=h.e_circles,t.localNormal.setZero(),t.localPoint.set(M),t.pointCount=1,t.points[0].localPoint.set(o.m_p),t.points[0].id.cf.indexA=0,t.points[0].id.cf.typeA=h.e_vertex,t.points[0].id.cf.indexB=0,void(t.points[0].id.cf.typeB=h.e_vertex)}if(b<=0){M=d.setVec2(l),C=m.sub_(c,M,v);if(m.dot(C,C)>w*w)return;if(i.m_hasVertex3){var z=i.m_vertex3,P=l,T=m.sub_(z,P,g);if(m.dot(T,m.sub_(c,P,A))>0)return}return t.type=h.e_circles,t.localNormal.setZero(),t.localPoint.set(M),t.pointCount=1,t.points[0].localPoint.set(o.m_p),t.points[0].id.cf.indexA=1,t.points[0].id.cf.typeA=h.e_vertex,t.points[0].id.cf.indexB=0,void(t.points[0].id.cf.typeB=h.e_vertex)}var L=m.dot(u,u);s&&n.assert(L>0);M=d.setCombine(b/L,_,B/L,l),C=m.sub_(c,M,v);if(!(m.dot(C,C)>w*w)){var q=f.setXY(-u.y,u.x);m.dot(q,m.sub_(c,_,A))<0&&q.set(-q.x,-q.y),q.normalize(),t.type=h.e_faceA,t.localNormal.set(q),t.localPoint.set(_),t.pointCount=1,t.points[0].localPoint.set(o.m_p),t.points[0].id.cf.indexA=0,t.points[0].id.cf.typeA=h.e_face,t.points[0].id.cf.indexB=0,t.points[0].id.cf.typeB=h.e_vertex}}var s=!1,n=t("../util/common"),r=t("../common/Transform"),m=t("../common/Vec2"),a=t("../Contact"),h=t("../Manifold"),c=t("./EdgeShape"),_=t("./ChainShape"),l=t("./CircleShape");a.addType(c.TYPE,l.TYPE,function(t,i,e,r,m,a,h){s&&n.assert(e.getType()==c.TYPE),s&&n.assert(a.getType()==l.TYPE),o(t,e.getShape(),i,a.getShape(),m)}),a.addType(_.TYPE,l.TYPE,function(t,i,e,r,m,a,h){s&&n.assert(e.getType()===_.TYPE),s&&n.assert(a.getType()===l.TYPE);e.getShape().getChildEdge(u,r),o(t,u,i,a.getShape(),m)});var u=new c,p=m.zero(),y=m.zero(),d=m.zero(),v=m.zero(),f=m.zero(),x=m.zero(),g=m.zero(),A=m.zero()},{"../Contact":3,"../Manifold":6,"../common/Transform":22,"../common/Vec2":23,"../util/common":50,"./ChainShape":39,"./CircleShape":40,"./EdgeShape":46}],44:[function(t,i,e){function o(){this.type,this.index,this.separation}function s(t,i,e,o,s){var n=a.mulTXf_(e,s,D),r=a.mulVec2_(n,o.m_centroid,S),l=i.m_vertex0,p=i.m_vertex1,y=i.m_vertex2,d=i.m_vertex3,v=i.m_hasVertex0,O=i.m_hasVertex3,N=h.sub_(y,p,I);N.normalize();var Y=z.setXY(N.y,-N.x),W=h.dot(Y,h.sub_(r,p,M)),Z=0,H=0,X=!1,K=!1;if(v){var G=h.sub_(p,l,P);G.normalize();var U=T.setXY(G.y,-G.x);X=h.cross(G,N)>=0,Z=h.dot(U,r)-h.dot(U,l)}if(O){var Q=h.sub_(d,y,L);Q.normalize();var $=q.set(Q.y,-Q.x);K=h.cross(N,Q)>0,H=h.dot($,r)-h.dot($,y)}var tt=0,it=F.setZero(),et=R.setZero(),ot=k.setZero();v&&O?X&&K?(tt=Z>=0||W>=0||H>=0)?(it.set(Y),et.set(U),ot.set($)):(it.setMul(-1,Y),et.setMul(-1,Y),ot.setMul(-1,Y)):X?(tt=Z>=0||W>=0&&H>=0)?(it.set(Y),et.set(U),ot.set(Y)):(it.setMul(-1,Y),et.setMul(-1,$),ot.setMul(-1,Y)):K?(tt=H>=0||Z>=0&&W>=0)?(it.set(Y),et.set(Y),ot.set($)):(it.setMul(-1,Y),et.setMul(-1,Y),ot.setMul(-1,U)):(tt=Z>=0&&W>=0&&H>=0)?(it.set(Y),et.set(Y),ot.set(Y)):(it.setMul(-1,Y),et.setMul(-1,$),ot.setMul(-1,U)):v?X?(tt=Z>=0||W>=0)?(it.set(Y),et.set(U),ot.setMul(-1,Y)):(it.setMul(-1,Y),et.set(Y),ot.setMul(-1,Y)):(tt=Z>=0&&W>=0)?(it.set(Y),et.set(Y),ot.setMul(-1,Y)):(it.setMul(-1,Y),et.set(Y),ot.setMul(-1,U)):O?K?(tt=W>=0||H>=0)?(it.set(Y),et.setMul(-1,Y),ot.set($)):(it.setMul(-1,Y),et.setMul(-1,Y),ot.set(Y)):(tt=W>=0&&H>=0)?(it.set(Y),et.setMul(-1,Y),ot.set(Y)):(it.setMul(-1,Y),et.setMul(-1,$),ot.set(Y)):(tt=W>=0)?(it.set(Y),et.setMul(-1,Y),ot.setMul(-1,Y)):(it.setMul(-1,Y),et.set(Y),ot.set(Y)),B.count=o.m_count;for(var st=0;st<o.m_count;++st)B.vertices[st]=a.mulVec2_(n,o.m_vertices[st],B.vertices[st]),B.normals[st]=c.mulVec2_(n.q,o.m_normals[st],B.normals[st]);var nt=2*_.polygonRadius;t.pointCount=0,A.type=x,A.index=tt?0:1,A.separation=1/0;for(st=0;st<B.count;++st){(mt=h.dot(it,h.sub(B.vertices[st],p,M)))<A.separation&&(A.separation=mt)}if(A.type!==f&&!(A.separation>nt)){b.type=f,b.index=-1,b.separation=-1/0;var rt=V.set(-it.y,it.x);for(st=0;st<B.count;++st){var mt,at=C.set(B.normals[st]).neg(),ht=h.dot(at,h.sub_(B.vertices[st],p,M)),ct=h.dot(at,h.sub_(B.vertices[st],y,M));if((mt=m.min(ht,ct))>nt){b.type=g,b.index=st,b.separation=mt;break}if(h.dot(at,rt)>=0){if(h.dot(h.sub_(at,ot,M),it)<-_.angularSlop)continue}else if(h.dot(h.sub_(at,et,M),it)<-_.angularSlop)continue;mt>b.separation&&(b.type=g,b.index=st,b.separation=mt)}if(!(b.type!==f&&b.separation>nt)){var _t;_t=b.type===f?A:b.separation>.98*A.separation+.001?b:A,J[0].init(),J[1].init();var lt=J;if(_t.type===x){t.type=u.e_faceA;var ut=0,pt=h.dot(it,B.normals[0]);for(st=1;st<B.count;++st){var yt=h.dot(it,B.normals[st]);yt<pt&&(pt=yt,ut=st)}var dt=ut,vt=dt+1<B.count?dt+1:0;lt[0].v.set(B.vertices[dt]),lt[0].id.cf.indexA=0,lt[0].id.cf.indexB=dt,lt[0].id.cf.typeA=u.e_face,lt[0].id.cf.typeB=u.e_vertex,lt[1].v.set(B.vertices[vt]),lt[1].id.cf.indexA=0,lt[1].id.cf.indexB=vt,lt[1].id.cf.typeA=u.e_face,lt[1].id.cf.typeB=u.e_vertex,tt?(w.i1=0,w.i2=1,w.v1.set(p),w.v2.set(y),w.normal.set(Y)):(w.i1=1,w.i2=0,w.v1.set(y),w.v2.set(p),w.normal.set(Y).neg())}else t.type=u.e_faceB,lt[0].v.set(p),lt[0].id.cf.indexA=0,lt[0].id.cf.indexB=_t.index,lt[0].id.cf.typeA=u.e_vertex,lt[0].id.cf.typeB=u.e_face,lt[1].v.set(y),lt[1].id.cf.indexA=0,lt[1].id.cf.indexB=_t.index,lt[1].id.cf.typeA=u.e_vertex,lt[1].id.cf.typeB=u.e_face,w.i1=_t.index,w.i2=w.i1+1<B.count?w.i1+1:0,w.v1.set(B.vertices[w.i1]),w.v2.set(B.vertices[w.i2]),w.normal.set(B.normals[w.i1]);w.sideNormal1.set(w.normal.y,-w.normal.x),w.sideNormal2.setMul(-1,w.sideNormal1),w.sideOffset1=h.dot(w.sideNormal1,w.v1),w.sideOffset2=h.dot(w.sideNormal2,w.v2),j[0].init(),j[1].init(),E[0].init(),E[1].init();var ft=j,xt=E;if(!(u.clipSegmentToLine(ft,lt,w.sideNormal1,w.sideOffset1,w.i1)<_.maxManifoldPoints||u.clipSegmentToLine(xt,ft,w.sideNormal2,w.sideOffset2,w.i2)<_.maxManifoldPoints)){_t.type===x?(t.localNormal.set(w.normal),t.localPoint.set(w.v1)):(t.localNormal.set(o.m_normals[w.i1]),t.localPoint.set(o.m_vertices[w.i1]));var gt=0;for(st=0;st<_.maxManifoldPoints;++st){if(h.dot(w.normal,h.sub_(xt[st].v,w.v1,M))<=nt){var At=t.points[gt];_t.type===x?(At.localPoint=a.mulTVec2_(n,xt[st].v,At.localPoint),At.id.set(xt[st].id)):(At.localPoint.set(xt[st].v),At.id.cf.typeA=xt[st].id.cf.typeB,At.id.cf.typeB=xt[st].id.cf.typeA,At.id.cf.indexA=xt[st].id.cf.indexB,At.id.cf.indexB=xt[st].id.cf.indexA),++gt}}t.pointCount=gt}}}}var n=!1,r=t("../util/common"),m=t("../common/Math"),a=t("../common/Transform"),h=t("../common/Vec2"),c=t("../common/Rot"),_=t("../Settings"),l=t("../Contact"),u=t("../Manifold"),p=t("./EdgeShape"),y=t("./ChainShape"),d=t("./PolygonShape");l.addType(p.TYPE,d.TYPE,function(t,i,e,o,m,a,h){n&&r.assert(e.getType()===p.TYPE),n&&r.assert(a.getType()===d.TYPE),s(t,e.getShape(),i,a.getShape(),m)}),l.addType(y.TYPE,d.TYPE,function(t,i,e,o,m,a,h){n&&r.assert(e.getType()===y.TYPE),n&&r.assert(a.getType()===d.TYPE);var c=e.getShape(),_=v;c.getChildEdge(_,o),s(t,_,i,a.getShape(),m)});var v=new p,f=-1,x=1,g=2,A=new o,b=new o,B=new function(){this.vertices=[],this.normals=[],this.count=0;for(var t=0;t<_.maxPolygonVertices;t++)this.vertices.push(h.zero()),this.normals.push(h.zero())},w=new function(){this.i1=-1,this.i2=-1,this.v1=h.zero(),this.v2=h.zero(),this.normal=h.zero(),this.sideNormal1=h.zero(),this.sideOffset1=0,this.sideNormal2=h.zero(),this.sideOffset2=0},M=h.zero(),C=(h.zero(),h.zero()),V=h.zero(),S=h.zero(),I=h.zero(),z=h.zero(),P=h.zero(),T=h.zero(),L=h.zero(),q=h.zero(),F=h.zero(),R=h.zero(),k=h.zero(),D=a.identity(),j=[new u.clipVertex,new u.clipVertex],E=[new u.clipVertex,new u.clipVertex],J=[new u.clipVertex,new u.clipVertex]},{"../Contact":3,"../Manifold":6,"../Settings":7,"../common/Math":18,"../common/Rot":20,"../common/Transform":22,"../common/Vec2":23,"../util/common":50,"./ChainShape":39,"./EdgeShape":46,"./PolygonShape":47}],45:[function(t,i,e){function o(t,i,e,o){for(var s=t.m_count,n=e.m_count,r=t.m_normals,c=t.m_vertices,_=e.m_vertices,l=m.mulTXf_(o,i,f),u=0,x=-1/0,g=0;g<s;++g){for(var A=a.mulVec2_(l.q,r[g],v),b=m.mulVec2_(l,c[g],d),B=1/0,w=0;w<n;++w){var M=h.dot(A,_[w])-h.dot(A,b);M<B&&(B=M)}B>x&&(x=B,u=g)}p=x,y=u}function s(t,i,e,s,l){t.pointCount=0;var u=i.m_radius+s.m_radius;o(i,e,s,l);var d=y,v=p;if(!(v>u)){o(s,l,i,e);var f=y;if(!(p>u)){var T,L,q,F,R,k;p>v+.1*c.linearSlop?(T=s,L=i,q=l,F=e,R=f,t.type=_.e_faceB,k=1):(T=i,L=s,q=e,F=l,R=d,t.type=_.e_faceA,k=0);var D=P;P[0].init(),P[1].init(),function(t,i,e,o,s,c){var l=i.m_normals,u=s.m_count,p=s.m_vertices,y=s.m_normals;n&&r.assert(0<=o&&o<i.m_count);for(var d=a.mulTVec2_(c.q,a.mulVec2_(e.q,l[o],x),g),v=0,f=1/0,A=0;A<u;++A){var b=h.dot(d,y[A]);b<f&&(f=b,v=A)}var B=v,w=B+1<u?B+1:0;t[0].v=m.mulVec2(c,p[B]),t[0].id.cf.indexA=o,t[0].id.cf.indexB=B,t[0].id.cf.typeA=_.e_face,t[0].id.cf.typeB=_.e_vertex,t[1].v=m.mulVec2(c,p[w]),t[1].id.cf.indexA=o,t[1].id.cf.indexB=w,t[1].id.cf.typeA=_.e_face,t[1].id.cf.typeB=_.e_vertex}(D,T,q,R,L,F);var j=T.m_count,E=T.m_vertices,J=R,O=R+1<j?R+1:0,N=C.set(E[J]),Y=V.set(E[O]),W=h.sub_(Y,N,w);W.normalize();var Z=h.crossVec2Num_(W,1,M),H=h.combine_(.5,N,.5,Y,A),X=a.mulVec2_(q.q,W,b),K=h.crossVec2Num_(X,1,B);N=m.mulVec2_(q,N,N),Y=m.mulVec2_(q,Y,Y);var G=h.dot(K,N),U=-h.dot(X,N)+u,Q=h.dot(X,Y)+u;I[0].init(),I[1].init(),z[0].init(),z[1].init();var $=I,tt=z;if(!(_.clipSegmentToLine($,D,h.neg_(X,S),U,J)<c.maxManifoldPoints||_.clipSegmentToLine(tt,$,X,Q,O)<c.maxManifoldPoints)){t.localNormal.set(Z),t.localPoint.set(H);for(var it=0,et=0;et<c.maxManifoldPoints;++et){if(h.dot(K,tt[et].v)-G<=u){var ot=t.points[et];if(ot.init(),ot.localPoint.set(m.mulTVec2(F,tt[et].v,S)),ot.id.set(tt[et].id),k){var st=ot.id.cf,nt=st.indexA,rt=st.indexB,mt=st.typeA,at=st.typeB;st.indexA=rt,st.indexB=nt,st.typeA=at,st.typeB=mt}++it}}t.pointCount=it}}}}var n=!1,r=t("../util/common"),m=t("../common/Transform"),a=t("../common/Rot"),h=t("../common/Vec2"),c=t("../Settings"),_=t("../Manifold"),l=t("../Contact"),u=t("./PolygonShape");i.exports=s,l.addType(u.TYPE,u.TYPE,function(t,i,e,o,m,a,h){n&&r.assert(e.getType()==u.TYPE),n&&r.assert(a.getType()==u.TYPE),s(t,e.getShape(),i,a.getShape(),m)});var p,y,d=h.zero(),v=h.zero(),f=m.identity(),x=h.zero(),g=h.zero(),A=h.zero(),b=h.zero(),B=h.zero(),w=h.zero(),M=h.zero(),C=h.zero(),V=h.zero(),S=h.zero(),I=[new _.clipVertex,new _.clipVertex],z=[new _.clipVertex,new _.clipVertex],P=[new _.clipVertex,new _.clipVertex]},{"../Contact":3,"../Manifold":6,"../Settings":7,"../common/Rot":20,"../common/Transform":22,"../common/Vec2":23,"../util/common":50,"./PolygonShape":47}],46:[function(t,i,e){function o(t,i){if(!(this instanceof o))return new o(t,i);o._super.call(this),this.m_type=o.TYPE,this.m_radius=n.polygonRadius,this.m_vertex1=t?h.clone(t):h.zero(),this.m_vertex2=i?h.clone(i):h.zero(),this.m_vertex0=h.zero(),this.m_vertex3=h.zero(),this.m_hasVertex0=!1,this.m_hasVertex3=!1}i.exports=o;var s=t("../util/create"),n=(t("../util/options"),t("../Settings")),r=t("../Shape"),m=(t("../common/Math"),t("../common/Transform")),a=t("../common/Rot"),h=t("../common/Vec2");t("../collision/AABB");o.prototype=s((o._super=r).prototype),o.TYPE="edge",o.prototype.setNext=function(t){return t?(this.m_vertex3.set(t),this.m_hasVertex3=!0):(this.m_vertex3.setZero(),this.m_hasVertex3=!1),this},o.prototype.setPrev=function(t){return t?(this.m_vertex0.set(t),this.m_hasVertex0=!0):(this.m_vertex0.setZero(),this.m_hasVertex0=!1),this},o.prototype._set=function(t,i){return this.m_vertex1.set(t),this.m_vertex2.set(i),this.m_hasVertex0=!1,this.m_hasVertex3=!1,this},o.prototype._clone=function(){var t=new o;return t.m_type=this.m_type,t.m_radius=this.m_radius,t.m_vertex1.set(this.m_vertex1),t.m_vertex2.set(this.m_vertex2),t.m_vertex0.set(this.m_vertex0),t.m_vertex3.set(this.m_vertex3),t.m_hasVertex0=this.m_hasVertex0,t.m_hasVertex3=this.m_hasVertex3,t},o.prototype.getChildCount=function(){return 1},o.prototype.testPoint=function(t,i){return!1},o.prototype.rayCast=function(t,i,e,o){var s=a.mulTVec2(e.q,h.sub(i.p1,e.p)),n=a.mulTVec2(e.q,h.sub(i.p2,e.p)),r=h.sub(n,s),m=this.m_vertex1,c=this.m_vertex2,_=h.sub(c,m),l=h.neo(_.y,-_.x);l.normalize();var u=h.dot(l,h.sub(m,s)),p=h.dot(l,r);if(0==p)return!1;var y=u/p;if(y<0||i.maxFraction<y)return!1;var d=h.add(s,h.mul(y,r)),v=h.sub(c,m),f=h.dot(v,v);if(0==f)return!1;var x=h.dot(h.sub(d,m),v)/f;return!(x<0||1<x)&&(t.fraction=y,t.normal=u>0?a.mulVec2(e.q,l).neg():a.mulVec2(e.q,l),!0)},o.prototype.computeAABB=function(t,i,e){var o=m.mulVec2(i,this.m_vertex1),s=m.mulVec2(i,this.m_vertex2);t.combinePoints(o,s),t.extend(this.m_radius)},o.prototype.computeMass=function(t,i){t.mass=0,t.center.setCombine(.5,this.m_vertex1,.5,this.m_vertex2),t.I=0},o.prototype.computeDistanceProxy=function(t){t.m_vertices.push(this.m_vertex1),t.m_vertices.push(this.m_vertex2),t.m_count=2,t.m_radius=this.m_radius}},{"../Settings":7,"../Shape":8,"../collision/AABB":11,"../common/Math":18,"../common/Rot":20,"../common/Transform":22,"../common/Vec2":23,"../util/create":51,"../util/options":52}],47:[function(t,i,e){function o(t){if(!(this instanceof o))return new o(t);o._super.call(this),this.m_type=o.TYPE,this.m_radius=_.polygonRadius,this.m_centroid=c.zero(),this.m_vertices=[],this.m_normals=[],this.m_count=0,t&&t.length&&this._set(t)}var s=!1;i.exports=o;var n=t("../util/common"),r=t("../util/create"),m=(t("../util/options"),t("../common/Math")),a=t("../common/Transform"),h=t("../common/Rot"),c=t("../common/Vec2"),_=(t("../collision/AABB"),t("../Settings")),l=t("../Shape");o.prototype=r((o._super=l).prototype),o.TYPE="polygon",o.prototype.getVertex=function(t){return s&&n.assert(0<=t&&t<this.m_count),this.m_vertices[t]},o.prototype._clone=function(){var t=new o;t.m_type=this.m_type,t.m_radius=this.m_radius,t.m_count=this.m_count,t.m_centroid.set(this.m_centroid);for(var i=0;i<this.m_count;i++)t.m_vertices.push(this.m_vertices[i].clone());for(i=0;i<this.m_normals.length;i++)t.m_normals.push(this.m_normals[i].clone());return t},o.prototype.getChildCount=function(){return 1},o.prototype._set=function(t){if(s&&n.assert(3<=t.length&&t.length<=_.maxPolygonVertices),t.length<3)this._setAsBox(1,1);else{for(var i=m.min(t.length,_.maxPolygonVertices),e=[],o=0,r=0;r<i;++r){for(var a=t[r],h=!0,l=0;l<o;++l)if(c.distanceSquared(a,e[l])<.25*_.linearSlopSquared){h=!1;break}h&&(e[o++]=a)}if((i=o)<3)return s&&n.assert(!1),void this._setAsBox(1,1);var u=0,p=e[0].x;for(r=1;r<i;++r){var y=e[r].x;(y>p||y==p&&e[r].y<e[u].y)&&(u=r,p=y)}for(var d=[],v=0,f=u;;){d[v]=f;var x=0;for(l=1;l<i;++l)if(x!=f){var g=c.sub(e[x],e[d[v]]),A=(a=c.sub(e[l],e[d[v]]),c.cross(g,a));A<0&&(x=l),0==A&&a.lengthSquared()>g.lengthSquared()&&(x=l)}else x=l;if(++v,f=x,x==u)break}if(v<3)return s&&n.assert(!1),void this._setAsBox(1,1);this.m_count=v;for(r=0;r<v;++r)this.m_vertices[r]=e[d[r]];for(r=0;r<v;++r){var b=r,B=r+1<v?r+1:0,w=c.sub(this.m_vertices[B],this.m_vertices[b]);s&&n.assert(w.lengthSquared()>m.EPSILON*m.EPSILON),this.m_normals[r]=c.cross(w,1),this.m_normals[r].normalize()}this.m_centroid=function(t,i){s&&n.assert(i>=3);for(var e=c.zero(),o=0,r=c.zero(),a=0;a<i;++a){var h=r,_=t[a],l=a+1<i?t[a+1]:t[0],u=c.sub(_,h),p=c.sub(l,h),y=.5*c.cross(u,p);o+=y,e.addMul(y*(1/3),h),e.addMul(y*(1/3),_),e.addMul(y*(1/3),l)}return s&&n.assert(o>m.EPSILON),e.mul(1/o),e}(this.m_vertices,v)}},o.prototype._setAsBox=function(t,i,e,o){if(this.m_vertices[0]=c.neo(-t,-i),this.m_vertices[1]=c.neo(t,-i),this.m_vertices[2]=c.neo(t,i),this.m_vertices[3]=c.neo(-t,i),this.m_normals[0]=c.neo(0,-1),this.m_normals[1]=c.neo(1,0),this.m_normals[2]=c.neo(0,1),this.m_normals[3]=c.neo(-1,0),this.m_count=4,c.isValid(e)){o=o||0,this.m_centroid.set(e);var s=a.identity();s.p.set(e),s.q.set(o);for(var n=0;n<this.m_count;++n)this.m_vertices[n]=a.mulVec2(s,this.m_vertices[n]),this.m_normals[n]=h.mulVec2(s.q,this.m_normals[n])}},o.prototype.testPoint=function(t,i){for(var e=h.mulTVec2(t.q,c.sub(i,t.p)),o=0;o<this.m_count;++o){if(c.dot(this.m_normals[o],c.sub(e,this.m_vertices[o]))>0)return!1}return!0},o.prototype.rayCast=function(t,i,e,o){for(var r=h.mulTVec2(e.q,c.sub(i.p1,e.p)),m=h.mulTVec2(e.q,c.sub(i.p2,e.p)),a=c.sub(m,r),_=0,l=i.maxFraction,u=-1,p=0;p<this.m_count;++p){var y=c.dot(this.m_normals[p],c.sub(this.m_vertices[p],r)),d=c.dot(this.m_normals[p],a);if(0==d){if(y<0)return!1}else d<0&&y<_*d?(_=y/d,u=p):d>0&&y<l*d&&(l=y/d);if(l<_)return!1}return s&&n.assert(0<=_&&_<=i.maxFraction),u>=0&&(t.fraction=_,t.normal=h.mulVec2(e.q,this.m_normals[u]),!0)},o.prototype.computeAABB=function(t,i,e){for(var o=1/0,s=1/0,n=-1/0,r=-1/0,h=0;h<this.m_count;++h){var c=a.mulVec2(i,this.m_vertices[h]);o=m.min(o,c.x),n=m.max(n,c.x),s=m.min(s,c.y),r=m.max(r,c.y)}t.lowerBound.set(o,s),t.upperBound.set(n,r),t.extend(this.m_radius)},o.prototype.computeMass=function(t,i){s&&n.assert(this.m_count>=3);for(var e=c.zero(),o=0,r=0,a=c.zero(),h=0;h<this.m_count;++h)a.add(this.m_vertices[h]);a.mul(1/this.m_count);for(h=0;h<this.m_count;++h){var _=c.sub(this.m_vertices[h],a),l=h+1<this.m_count?c.sub(this.m_vertices[h+1],a):c.sub(this.m_vertices[0],a),u=c.cross(_,l),p=.5*u;o+=p,e.addCombine(p*(1/3),_,p*(1/3),l);var y=_.x,d=_.y,v=l.x,f=l.y;r+=1/3*.25*u*(y*y+v*y+v*v+(d*d+f*d+f*f))}t.mass=i*o,s&&n.assert(o>m.EPSILON),e.mul(1/o),t.center.setCombine(1,e,1,a),t.I=i*r,t.I+=t.mass*(c.dot(t.center,t.center)-c.dot(e,e))},o.prototype.validate=function(){for(var t=0;t<this.m_count;++t)for(var i=t,e=t<this.m_count-1?i+1:0,o=this.m_vertices[i],s=c.sub(this.m_vertices[e],o),n=0;n<this.m_count;++n)if(n!=i&&n!=e){var r=c.sub(this.m_vertices[n],o);if(c.cross(s,r)<0)return!1}return!0},o.prototype.computeDistanceProxy=function(t){t.m_vertices=this.m_vertices,t.m_count=this.m_count,t.m_radius=this.m_radius}},{"../Settings":7,"../Shape":8,"../collision/AABB":11,"../common/Math":18,"../common/Rot":20,"../common/Transform":22,"../common/Vec2":23,"../util/common":50,"../util/create":51,"../util/options":52}],48:[function(t,i,e){i.exports=function(t){var i=[],e=t.max||1/0,o=t.create||function(){return{}},s=t.allocate||function(){},n=t.release||function(){},r=t.discard||function(){},m=0,a=0,h=0,c=0;this.max=function(t){return"number"==typeof t?(e=t,this):e},this.size=function(){return i.length},this.allocate=function(){var t;return i.length>0?t=i.shift():(m++,t=o()),a++,s(t),t},this.release=function(t){i.length<e?(h++,n(t),i.push(t)):(c++,r(t))},this.toString=function(){return" +"+m+" >"+a+" <"+h+" -"+c+" ="+i.length+"/"+e}}},{}],49:[function(t,i,e){i.exports.now=function(){return Date.now()},i.exports.diff=function(t){return Date.now()-t}},{}],50:[function(t,i,e){e.debug=function(){},e.assert=function(t,i,e){}},{}],51:[function(t,i,e){function o(){}"function"==typeof Object.create?i.exports=function(t,i){return Object.create.call(Object,t,i)}:i.exports=function(t,i){if(i)throw Error("Second argument is not supported!");if("object"!=typeof t||null===t)throw Error("Invalid prototype!");return o.prototype=t,new o}},{}],52:[function(t,i,e){Object.prototype.propertyIsEnumerable;i.exports=function(t,i){null!==t&&void 0!==t||(t={});for(var e in i)i.hasOwnProperty(e)&&void 0===t[e]&&(t[e]=i[e]);if("function"==typeof Object.getOwnPropertySymbols)for(var o=Object.getOwnPropertySymbols(i),s=0;s<o.length;s++){var n=o[s];i.propertyIsEnumerable(n)&&void 0===t[e]&&(t[n]=i[n])}return t}},{}]},{},[1])(1)});