},{"../package.json":7,"./collision/AABB":8,"./collision/Broadphase":9,"./collision/GridBroadphase":10,"./collision/NaiveBroadphase":11,"./collision/Narrowphase":12,"./collision/SAPBroadphase":13,"./constraints/Constraint":14,"./constraints/DistanceConstraint":15,"./constraints/GearConstraint":16,"./constraints/LockConstraint":17,"./constraints/PrismaticConstraint":18,"./constraints/RevoluteConstraint":19,"./equations/AngleLockEquation":20,"./equations/ContactEquation":21,"./equations/Equation":22,"./equations/FrictionEquation":23,"./equations/RotationalVelocityEquation":25,"./events/EventEmitter":26,"./material/ContactMaterial":27,"./material/Material":28,"./math/vec2":30,"./objects/Body":31,"./objects/Spring":32,"./shapes/Capsule":34,"./shapes/Circle":35,"./shapes/Convex":36,"./shapes/Heightfield":37,"./shapes/Line":38,"./shapes/Particle":39,"./shapes/Plane":40,"./shapes/Rectangle":41,"./shapes/Shape":42,"./solver/GSSolver":43,"./solver/Solver":44,"./utils/Utils":45,"./world/World":49}],34:[function(a,b){functionc(a,b){this.length=a||1,this.radius=b||1,d.call(this,d.CAPSULE)}vard=a("./Shape"),e=a("../math/vec2");b.exports=c,c.prototype=newd,c.prototype.computeMomentOfInertia=function(a){varb=this.radius,c=this.length+b,d=2*b;returna*(d*d+c*c)/12},c.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius+this.length/2},c.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius+2*this.radius*this.length};varf=e.create();c.prototype.computeAABB=function(a,b,c){vard=this.radius;e.set(f,this.length,0),e.rotate(f,f,c),e.set(a.upperBound,Math.max(f[0]+d,-f[0]+d),Math.max(f[1]+d,-f[1]+d)),e.set(a.lowerBound,Math.min(f[0]-d,-f[0]-d),Math.min(f[1]-d,-f[1]-d)),e.add(a.lowerBound,a.lowerBound,b),e.add(a.upperBound,a.upperBound,b)}},{"../math/vec2":30,"./Shape":42}],35:[function(a,b){functionc(a){this.radius=a||1,d.call(this,d.CIRCLE)}vard=a("./Shape"),e=a("../math/vec2");b.exports=c,c.prototype=newd,c.prototype.computeMomentOfInertia=function(a){varb=this.radius;returna*b*b/2},c.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},c.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius},c.prototype.computeAABB=function(a,b){varc=this.radius;e.set(a.upperBound,c,c),e.set(a.lowerBound,-c,-c),b&&(e.add(a.lowerBound,a.lowerBound,b),e.add(a.upperBound,a.upperBound,b))}},{"../math/vec2":30,"./Shape":42}],36:[function(a,b){functionc(a){this.vertices=[];for(varb=0;b<a.length;b++){varc=e.create();e.copy(c,a[b]),this.vertices.push(c)}if(this.centerOfMass=e.fromValues(0,0),this.triangles=[],this.vertices.length&&(this.updateTriangles(),this.updateCenterOfMass()),this.boundingRadius=0,d.call(this,d.CONVEX),this.updateBoundingRadius(),this.updateArea(),this.area<0)thrownewError("Convex vertices must be given in conter-clockwise winding.")}{vard=a("./Shape"),e=a("../math/vec2"),f=a("../math/polyk");a("poly-decomp")}b.exports=c,c.prototype=newd,c.prototype.updateTriangles=function(){this.triangles.length=0;for(vara=[],b=0;b<this.vertices.length;b++){varc=this.vertices[b];a.push(c[0],c[1])}for(vard=f.Triangulate(a),b=0;b<d.length;b+=3){vare=d[b],g=d[b+1],h=d[b+2];this.triangles.push([e,g,h])}};{varg=e.create(),h=e.create(),i=e.create(),j=e.create(),k=e.create();e.create(),e.create(),e.create(),e.create()}c.prototype.updateCenterOfMass=function(){vara=this.triangles,b=this.vertices,d=this.centerOfMass,f=g,l=i,m=j,n=k,o=h;e.set(d,0,0);for(varp=0,q=0;q!==a.length;q++){varr=a[q],l=b[r[0]],m=b[r[1]],n=b[r[2]];e.centroid(f,l,m,n);vars=c.triangleArea(l,m,n);p+=s,e.scale(o,f,s),e.add(d,d,o)}e.scale(d,d,1/p)},c.prototype.computeMomentOfInertia=function(a){for(varb=0,c=0,d=this.vertices.length,f=d-1,g=0;d>g;f=g,g++){varh=this.vertices[f],i=this.vertices[g],j=Math.abs(e.crossLength(h,i)),k=e.dot(i,i)+e.dot(i,h)+e.dot(h,h);b+=j*k,c+=j}returna/6*(b/c)},c.prototype.updateBoundingRadius=function(){for(vara=this.vertices,b=0,c=0;c!==a.length;c++){vard=e.squaredLength(a[c]);d>b&&(b=d)}this.boundingRadius=Math.sqrt(b)},c.triangleArea=function(a,b,c){retu
if(!H)returnthis.error="instance.springs["+r+"] references instance.body["+d.bodyA+"], which does not exist.",!1;if(!I)returnthis.error="instance.springs["+r+"] references instance.body["+d.bodyB+"], which does not exist.",!1;vare=newu(H,I,{stiffness:d.stiffness,damping:d.damping,restLength:d.restLength,localAnchorA:d.localAnchorA,localAnchorB:d.localAnchorB});c.addSpring(e)}for(varr=0;r<a.contactMaterials.length;r++){vart=a.contactMaterials[r],J=h[t.materialA+""],K=h[t.materialB+""];if(!J)returnthis.error="Reference to material id "+t.materialA+": material not found",!1;if(!K)returnthis.error="Reference to material id "+t.materialB+": material not found",!1;varL=neww(J,K,{friction:t.friction,restitution:t.restitution,stiffness:t.stiffness,relaxation:t.relaxation,frictionStiffness:t.frictionStiffness,frictionRelaxation:t.frictionRelaxation});L.id=t.id,c.addContactMaterial(L)}vart=a.defaultContactMaterial,J=c.defaultMaterial,K=c.defaultMaterial,L=neww(J,K,{friction:t.friction,restitution:t.restitution,stiffness:t.stiffness,relaxation:t.relaxation,frictionStiffness:t.frictionStiffness,frictionRelaxation:t.frictionRelaxation});L.id=t.id,c.defaultContactMaterial=L;for(varr=0;r<a.distanceConstraints.length;r++){varM=a.distanceConstraints[r];c.addConstraint(newx(f[M.bodyA],f[M.bodyB],M.distance,{maxForce:M.maxForce,collideConnected:M.collideConnected}))}for(varr=0;r<a.revoluteConstraints.length;r++){varM=a.revoluteConstraints[r],N=newA(f[M.bodyA],M.pivotA,f[M.bodyB],M.pivotB,{maxForce:M.maxForce,collideConnected:M.collideConnected});M.motorEnabled&&N.enableMotor(),N.setMotorSpeed(M.motorSpeed),N.lowerLimit=M.lowerLimit,N.upperLimit=M.upperLimit,N.lowerLimitEnabled=M.lowerLimitEnabled,N.upperLimitEnabled=M.upperLimitEnabled,c.addConstraint(N)}for(varr=0;r<a.prismaticConstraints.length;r++){varM=a.prismaticConstraints[r],O=newB(f[M.bodyA],f[M.bodyB],{maxForce:M.maxForce,localAxisA:M.localAxisA,localAnchorA:M.localAnchorA,localAnchorB:M.localAnchorB,collideConnected:M.collideConnected});O.motorSpeed=M.motorSpeed,c.addConstraint(O)}for(varr=0;r<a.lockConstraints.length;r++){varM=a.lockConstraints[r];c.addConstraint(newz(f[M.bodyA],f[M.bodyB],{maxForce:M.maxForce,localOffsetB:M.localOffsetB,localAngleB:M.localAngleB,collideConnected:M.collideConnected}))}for(varr=0;r<a.gearConstraints.length;r++){varM=a.gearConstraints[r];c.addConstraint(newC(f[M.bodyA],f[M.bodyB],{maxForce:M.maxForce,angle:M.angle,ratio:M.ratio,collideConnected:M.collideConnected}))}return!0},c.prototype.clear=function(){this.time=0,this.fixedStepTime=0,this.solver&&this.solver.equations.length&&this.solver.removeAllEquations();for(vara=this.constraints,b=a.length-1;b>=0;b--)this.removeConstraint(a[b]);for(vard=this.bodies,b=d.length-1;b>=0;b--)this.removeBody(d[b]);for(vare=this.springs,b=e.length-1;b>=0;b--)this.removeSpring(e[b]);for(varf=this.contactMaterials,b=f.length-1;b>=0;b--)this.removeContactMaterial(f[b]);c.apply(this)},c.prototype.clone=function(){vara=newc;returna.fromJSON(this.toJSON()),a};varQ=j.create(),R=j.fromValues(0,0),S=j.fromValues(0,0);c.prototype.hitTest=function(a,b,c){c=c||0;vard=news({position:a}),e=newq,f=a,g=0,h=Q,i=R,l=S;d.addShape(e);for(varn=this.narrowphase,r=[],t=0,u=b.length;t!==u;t++)for(varv=b[t],w=0,x=v.shapes.length;w!==x;w++){vary=v.shapes[w],z=v.shapeOffsets[w]||i,A=v.shapeAngles[w]||0;j.rotate(h,z,v.angle),j.add(h,h,v.position);varB=A+v.angle;(yinstanceofk&&n.circleParticle(v,y,h,B,d,e,f,g,!0)||yinstanceofm&&n.particleConvex(d,e,f,g,v,y,h,B,!0)||yinstanceofo&&n.particlePlane(d,e,f,g,v,y,h,B,!0)||yinstanceofp&&n.particleCapsule(d,e,f,g,v,y,h,B,!0)||yinstanceofq&&j.squaredLength(j.sub(l,h,a))<c*c)&&r.push(v)}returnr},c.prototype.setGlobalEquationParameters=function(a){a=a||{};for(varb=0;b!==this.constraints.length;b++)for(varc=this.constraints[b],d=0;d!==c.equations.length;d++){vare=c.equations[d];"undefined"!=typeofa.stiffness&&(e.stiffness=a.stiffness),"undefined"!=typeofa.relaxation&&(e.relaxation=a.relaxation),e.needsUpdate=!0}for(varb=0;b!==this.contactMateria