diff --git a/README.md b/README.md
index 339e835..c3f3b23 100644
--- a/README.md
+++ b/README.md
@@ -58,6 +58,7 @@
diff --git a/demo/js/lib/matter-dev.min.js b/demo/js/lib/matter-dev.min.js
new file mode 100644
index 0000000..2141420
--- /dev/null
+++ b/demo/js/lib/matter-dev.min.js
@@ -0,0 +1,9 @@
+/**
+* matter-dev.min.js 0.8.0-dev 2015-12-28
+* http://brm.io/matter-js/
+* License: MIT
+*/
+
+!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Matter=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g
0&&f.rotateAbout(g.position,c,a.position,g.position)}},d.setVelocity=function(a,b){a.positionPrev.x=a.position.x-b.x,a.positionPrev.y=a.position.y-b.y,a.velocity.x=b.x,a.velocity.y=b.y,a.speed=f.magnitude(a.velocity)},d.setAngularVelocity=function(a,b){a.anglePrev=a.angle-b,a.angularVelocity=b,a.angularSpeed=Math.abs(a.angularVelocity)},d.translate=function(a,b){d.setPosition(a,f.add(a.position,b))},d.rotate=function(a,b){d.setAngle(a,a.angle+b)},d.scale=function(a,b,c,f){for(var g=0;g0&&(n.position.x+=a.velocity.x,n.position.y+=a.velocity.y),0!==a.angularVelocity&&(e.rotate(n.vertices,a.angularVelocity,a.position),j.rotate(n.axes,a.angularVelocity),m>0&&f.rotateAbout(n.position,a.angularVelocity,a.position,n.position)),i.update(n.bounds,n.vertices,a.velocity)}},d.applyForce=function(a,b,c){a.force.x+=c.x,a.force.y+=c.y;var d={x:b.x-a.position.x,y:b.y-a.position.y};a.torque+=(d.x*c.y-d.y*c.x)*a.inverseInertia};var l=function(a){for(var b={mass:0,area:0,inertia:0,centre:{x:0,y:0}},c=1===a.parts.length?0:1;c1?1:0;m1?1:0;o0:0!==(a.mask&b.category)&&0!==(b.mask&a.category)}}()},{"../geometry/Bounds":24,"./Pair":7,"./SAT":11}],6:[function(a,b,c){var d={};b.exports=d;var e=a("./Pair"),f=a("./Detector"),g=a("../core/Common");!function(){d.create=function(a){var b={controller:d,detector:f.collisions,buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return g.extend(b,a)},d.update=function(c,d,e,f){var g,m,n,o,p,q=e.world,r=c.buckets,s=!1,t=e.metrics;for(t.broadphaseTests=0,g=0;gq.bounds.width||u.bounds.max.y<0||u.bounds.min.y>q.bounds.height)){var v=b(c,u);if(!u.region||v.id!==u.region.id||f){t.broadphaseTests+=1,(!u.region||f)&&(u.region=v);var w=a(v,u.region);for(m=w.startCol;m<=w.endCol;m++)for(n=w.startRow;n<=w.endRow;n++){p=h(m,n),o=r[p];var x=m>=v.startCol&&m<=v.endCol&&n>=v.startRow&&n<=v.endRow,y=m>=u.region.startCol&&m<=u.region.endCol&&n>=u.region.startRow&&n<=u.region.endRow;!x&&y&&y&&o&&k(c,o,u),(u.region===v||x&&!y||f)&&(o||(o=i(r,p)),j(c,o,u))}u.region=v,s=!0}}}s&&(c.pairsList=l(c))},d.clear=function(a){a.buckets={},a.pairs={},a.pairsList=[]};var a=function(a,b){var d=Math.min(a.startCol,b.startCol),e=Math.max(a.endCol,b.endCol),f=Math.min(a.startRow,b.startRow),g=Math.max(a.endRow,b.endRow);return c(d,e,f,g)},b=function(a,b){var d=b.bounds,e=Math.floor(d.min.x/a.bucketWidth),f=Math.floor(d.max.x/a.bucketWidth),g=Math.floor(d.min.y/a.bucketHeight),h=Math.floor(d.max.y/a.bucketHeight);return c(e,f,g,h)},c=function(a,b,c,d){return{id:a+","+b+","+c+","+d,startCol:a,endCol:b,startRow:c,endRow:d}},h=function(a,b){return a+","+b},i=function(a,b){var c=a[b]=[];return c},j=function(a,b,c){for(var d=0;d0?d.push(c):delete a.pairs[b[e]];return d}}()},{"../core/Common":14,"./Detector":5,"./Pair":7}],7:[function(a,b,c){var d={};b.exports=d;var e=a("./Contact");!function(){d.create=function(a,b){var c=a.bodyA,e=a.bodyB,f=a.parentA,g=a.parentB,h={id:d.id(c,e),bodyA:c,bodyB:e,contacts:{},activeContacts:[],separation:0,isActive:!0,isSensor:c.isSensor||e.isSensor,timeCreated:b,timeUpdated:b,inverseMass:f.inverseMass+g.inverseMass,friction:Math.min(f.friction,g.friction),frictionStatic:Math.max(f.frictionStatic,g.frictionStatic),restitution:Math.max(f.restitution,g.restitution),slop:Math.max(f.slop,g.slop)};return d.update(h,a,b),h},d.update=function(a,b,c){var f=a.contacts,g=b.supports,h=a.activeContacts,i=b.parentA,j=b.parentB;if(a.collision=b,a.inverseMass=i.inverseMass+j.inverseMass,a.friction=Math.min(i.friction,j.friction),a.frictionStatic=Math.max(i.frictionStatic,j.frictionStatic),a.restitution=Math.max(i.restitution,j.restitution),a.slop=Math.max(i.slop,j.slop),h.length=0,b.collided){for(var k=0;ka&&j.push(g);for(g=0;gn.friction*n.frictionStatic*I*c&&(J=n.friction*G*c,K=F);var L=f.cross(y,r),M=f.cross(z,r),N=p.inverseMass+q.inverseMass+p.inverseInertia*L*L+q.inverseInertia*M*M;if(H*=u/N,J*=u/(1+N),0>D&&D*D>d._restingThresh*c)w.normalImpulse=0,w.tangentImpulse=0;else{var O=w.normalImpulse;w.normalImpulse=Math.min(w.normalImpulse+H,0),H=w.normalImpulse-O;var P=w.tangentImpulse;w.tangentImpulse=g.clamp(w.tangentImpulse+J,-K,K),J=w.tangentImpulse-P}e.x=r.x*H+s.x*J,e.y=r.y*H+s.y*J,p.isStatic||p.isSleeping||(p.positionPrev.x+=e.x*p.inverseMass,p.positionPrev.y+=e.y*p.inverseMass,p.anglePrev+=f.cross(y,e)*p.inverseInertia),q.isStatic||q.isSleeping||(q.positionPrev.x-=e.x*q.inverseMass,q.positionPrev.y-=e.y*q.inverseMass,q.anglePrev-=f.cross(z,e)*q.inverseInertia)}}}}}()},{"../core/Common":14,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],11:[function(a,b,c){var d={};b.exports=d;var e=a("../geometry/Vertices"),f=a("../geometry/Vector");!function(){d.collides=function(b,d,g){var h,i,j,k,l=g,m=!1;if(l){var n=b.parent,o=d.parent,p=n.speed*n.speed+n.angularSpeed*n.angularSpeed+o.speed*o.speed+o.angularSpeed*o.angularSpeed;m=l&&l.collided&&.2>p,k=l}else k={collided:!1,bodyA:b,bodyB:d};if(l&&m){var q=k.axisBody,r=q===b?d:b,s=[q.axes[l.axisNumber]];if(j=a(q.vertices,r.vertices,s),k.reused=!0,j.overlap<=0)return k.collided=!1,k}else{if(h=a(b.vertices,d.vertices,b.axes),h.overlap<=0)return k.collided=!1,k;if(i=a(d.vertices,b.vertices,d.axes),i.overlap<=0)return k.collided=!1,k;h.overlap0&&(k.normal=f.neg(k.normal)),k.tangent=f.perp(k.normal),k.penetration={x:k.normal.x*k.depth,y:k.normal.y*k.depth};var t=c(b,d,k.normal),u=k.supports||[];if(u.length=0,e.contains(b.vertices,t[0])&&u.push(t[0]),e.contains(b.vertices,t[1])&&u.push(t[1]),u.length<2){var v=c(d,b,f.neg(k.normal));e.contains(d.vertices,v[0])&&u.push(v[0]),u.length<2&&e.contains(d.vertices,v[1])&&u.push(v[1])}return u.length<1&&(u=[t[0]]),k.supports=u,k};var a=function(a,c,d){for(var e,g,h=f._temp[0],i=f._temp[1],j={overlap:Number.MAX_VALUE},k=0;k=e)return j.overlap=e,j;ee?e=h:d>h&&(d=h)}a.min=d,a.max=e},c=function(a,b,c){for(var d,e,g,h,i=Number.MAX_VALUE,j=f._temp[0],k=b.vertices,l=a.position,m=0;md&&(i=d,g=e);var n=g.index-1>=0?g.index-1:k.length-1;e=k[n],j.x=e.x-l.x,j.y=e.y-l.y,i=-f.dot(c,j),h=e;var o=(g.index+1)%k.length;return e=k[o],j.x=e.x-l.x,j.y=e.y-l.y,d=-f.dot(c,j),i>d&&(h=e),[g,h]}}()},{"../geometry/Vector":26,"../geometry/Vertices":27}],12:[function(a,b,c){var d={};b.exports=d;var e=a("../geometry/Vertices"),f=a("../geometry/Vector"),g=a("../core/Sleeping"),h=a("../geometry/Bounds"),i=a("../geometry/Axes"),j=a("../core/Common");!function(){var a=1e-6,b=.001;d.create=function(b){var c=b;c.bodyA&&!c.pointA&&(c.pointA={x:0,y:0}),c.bodyB&&!c.pointB&&(c.pointB={x:0,y:0});var d=c.bodyA?f.add(c.bodyA.position,c.pointA):c.pointA,e=c.bodyB?f.add(c.bodyB.position,c.pointB):c.pointB,g=f.magnitude(f.sub(d,e));c.length=c.length||g||a;var h={visible:!0,lineWidth:2,strokeStyle:"#666"};return c.render=j.extend(h,c.render),c.id=c.id||j.nextId(),c.label=c.label||"Constraint",c.type="constraint",c.stiffness=c.stiffness||1,c.angularStiffness=c.angularStiffness||0,c.angleA=c.bodyA?c.bodyA.angle:c.angleA,c.angleB=c.bodyB?c.bodyB.angle:c.angleB,c},d.solveAll=function(a,b){for(var c=0;c0&&(B=0);var C,D={x:q.x*B,y:q.y*B};e&&!e.isStatic&&(C=f.cross(u,D)*e.inverseInertia*(1-c.angularStiffness),g.set(e,!1),C=j.clamp(C,-.01,.01),e.constraintImpulse.x-=r.x,e.constraintImpulse.y-=r.y,e.constraintImpulse.angle+=C,e.position.x-=r.x,e.position.y-=r.y,e.angle+=C),h&&!h.isStatic&&(C=f.cross(v,D)*h.inverseInertia*(1-c.angularStiffness),g.set(h,!1),C=j.clamp(C,-.01,.01),h.constraintImpulse.x+=r.x,h.constraintImpulse.y+=r.y,h.constraintImpulse.angle-=C,h.position.x+=r.x,h.position.y+=r.y,h.angle-=C)}}},d.postSolveAll=function(a){for(var b=0;b0&&(j.position.x+=d.x,j.position.y+=d.y),0!==d.angle&&(e.rotate(j.vertices,d.angle,c.position),i.rotate(j.axes,d.angle),g>0&&f.rotateAbout(j.position,d.angle,c.position,j.position)),h.update(j.bounds,j.vertices)}d.angle=0,d.x=0,d.y=0}}}()},{"../core/Common":14,"../core/Sleeping":20,"../geometry/Axes":23,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],13:[function(a,b,c){var d={};b.exports=d;var e=a("../geometry/Vertices"),f=a("../core/Sleeping"),g=a("../core/Mouse"),h=a("../core/Events"),i=a("../collision/Detector"),j=a("./Constraint"),k=a("../body/Composite"),l=a("../core/Common"),m=a("../geometry/Bounds");!function(){d.create=function(b,c){var e=(b?b.mouse:null)||(c?c.mouse:null);!e&&b&&b.render&&b.render.canvas?e=g.create(b.render.canvas):(e=g.create(),l.log("MouseConstraint.create: options.mouse was undefined, engine.render.canvas was undefined, may not function as expected","warn"));var f=j.create({label:"Mouse Constraint",pointA:e.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),i={type:"mouseConstraint",mouse:e,body:null,constraint:f,collisionFilter:{category:1,mask:4294967295,group:0}},m=l.extend(i,c);return h.on(b,"tick",function(){var c=k.allBodies(b.world);d.update(m,c),a(m)}),m},d.update=function(a,b){var c=a.mouse,d=a.constraint,g=a.body;if(0===c.button){if(d.bodyB)f.set(d.bodyB,!1),d.pointA=c.position;else for(var j=0;j1?1:0;k>16)+d,f=(c>>8&255)+d,g=(255&c)+d;return"#"+(16777216+65536*(255>e?1>e?0:e:255)+256*(255>f?1>f?0:f:255)+(255>g?1>g?0:g:255)).toString(16).slice(1)},d.shuffle=function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(d.random()*(b+1)),e=a[b];a[b]=a[c],a[c]=e}return a},d.choose=function(a){return a[Math.floor(d.random()*a.length)]},d.isElement=function(a){try{return a instanceof HTMLElement}catch(b){return"object"==typeof a&&1===a.nodeType&&"object"==typeof a.style&&"object"==typeof a.ownerDocument}},d.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a);
+},d.clamp=function(a,b,c){return b>a?b:a>c?c:a},d.sign=function(a){return 0>a?-1:1},d.now=function(){var a=window.performance||{};return a.now=function(){return a.now||a.webkitNow||a.msNow||a.oNow||a.mozNow||function(){return+new Date}}(),a.now()},d.random=function(b,c){return b="undefined"!=typeof b?b:0,c="undefined"!=typeof c?c:1,b+a()*(c-b)},d.colorToNumber=function(a){return a=a.replace("#",""),3==a.length&&(a=a.charAt(0)+a.charAt(0)+a.charAt(1)+a.charAt(1)+a.charAt(2)+a.charAt(2)),parseInt(a,16)},d.log=function(a,b){if(console&&console.log&&console.warn)switch(b){case"warn":console.warn("Matter.js:",a);break;case"error":console.log("Matter.js:",a)}},d.nextId=function(){return d._nextId++},d.indexOf=function(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0;c0&&l.trigger(d,"collisionStart",{pairs:w.collisionStart}),g.preSolvePosition(w.list),k=0;k0&&l.trigger(d,"collisionActive",{pairs:w.collisionActive}),w.collisionEnd.length>0&&l.trigger(d,"collisionEnd",{pairs:w.collisionEnd}),j.update(d.metrics,d),a(t),o.isModified&&m.setModified(o,!1,!1,!0),l.trigger(d,"afterUpdate",s),d},d.merge=function(a,b){if(o.extend(a,b),b.world){a.world=b.world,d.clear(a);for(var c=m.allBodies(a.world),e=0;ea.deltaMax?a.deltaMax:d,h=d/a.delta,a.delta=d),0!==a.timeScalePrev&&(h*=g.timeScale/a.timeScalePrev),0===g.timeScale&&(h=0),a.timeScalePrev=g.timeScale,a.correction=h,a.frameCounter+=1,c-a.counterTimestamp>=1e3&&(a.fps=a.frameCounter*((c-a.counterTimestamp)/1e3),a.counterTimestamp=c,a.frameCounter=0),e.trigger(a,"tick",i),e.trigger(b,"tick",i),b.world.isModified&&b.render&&b.render.controller&&b.render.controller.clear&&b.render.controller.clear(b.render),e.trigger(a,"beforeUpdate",i),f.update(b,d,h),e.trigger(a,"afterUpdate",i),b.render&&b.render.controller&&(e.trigger(a,"beforeRender",i),e.trigger(b,"beforeRender",i),b.render.controller.world(b),e.trigger(a,"afterRender",i),e.trigger(b,"afterRender",i)),e.trigger(a,"afterTick",i),e.trigger(b,"afterTick",i)},d.stop=function(a){b(a.frameRequestId)}}()},{"./Common":14,"./Engine":15,"./Events":16}],20:[function(a,b,c){var d={};b.exports=d;var e=a("./Events");!function(){d._motionWakeThreshold=.18,d._motionSleepThreshold=.08,d._minBias=.9,d.update=function(a,b){for(var c=b*b*b,e=0;e0&&f.motion=f.sleepThreshold&&d.set(f,!0)):f.sleepCounter>0&&(f.sleepCounter-=1)}else d.set(f,!1)}},d.afterCollisions=function(a,b){for(var c=b*b*b,e=0;ed._motionWakeThreshold*c&&d.set(j,!1)}}}},d.set=function(a,b){var c=a.isSleeping;b?(a.isSleeping=!0,a.sleepCounter=a.sleepThreshold,a.positionImpulse.x=0,a.positionImpulse.y=0,a.positionPrev.x=a.position.x,a.positionPrev.y=a.position.y,a.anglePrev=a.angle,a.speed=0,a.angularSpeed=0,a.motion=0,c||e.trigger(a,"sleepStart")):(a.isSleeping=!1,a.sleepCounter=0,c&&e.trigger(a,"sleepEnd"))}}()},{"./Events":16}],21:[function(a,b,c){var d={};b.exports=d;var e=a("../geometry/Vertices"),f=a("../core/Common"),g=a("../body/Body"),h=a("../geometry/Bounds"),i=a("../geometry/Vector");!function(){d.rectangle=function(a,b,c,d,h){h=h||{};var i={label:"Rectangle Body",position:{x:a,y:b},vertices:e.fromPath("L 0 0 L "+c+" 0 L "+c+" "+d+" L 0 "+d)};if(h.chamfer){var j=h.chamfer;i.vertices=e.chamfer(i.vertices,j.radius,j.quality,j.qualityMin,j.qualityMax),delete h.chamfer}return g.create(f.extend({},i,h))},d.trapezoid=function(a,b,c,d,h,i){i=i||{},h*=.5;var j=(1-2*h)*c,k=c*h,l=k+j,m=l+k,n={label:"Trapezoid Body",position:{x:a,y:b},vertices:e.fromPath("L 0 0 L "+k+" "+-d+" L "+l+" "+-d+" L "+m+" 0")};if(i.chamfer){var o=i.chamfer;n.vertices=e.chamfer(n.vertices,o.radius,o.quality,o.qualityMin,o.qualityMax),delete i.chamfer}return g.create(f.extend({},n,i))},d.circle=function(a,b,c,e,f){e=e||{},e.label="Circle Body",f=f||25;var g=Math.ceil(Math.max(10,Math.min(f,c)));return g%2===1&&(g+=1),e.circleRadius=c,d.polygon(a,b,g,c,e)},d.polygon=function(a,b,c,h,i){if(i=i||{},3>c)return d.circle(a,b,h,i);for(var j=2*Math.PI/c,k="",l=.5*j,m=0;c>m;m+=1){var n=l+m*j,o=Math.cos(n)*h,p=Math.sin(n)*h;k+="L "+o.toFixed(3)+" "+p.toFixed(3)+" "}var q={label:"Polygon Body",position:{x:a,y:b},vertices:e.fromPath(k)};if(i.chamfer){var r=i.chamfer;q.vertices=e.chamfer(q.vertices,r.radius,r.quality,r.qualityMin,r.qualityMax),delete i.chamfer}return g.create(f.extend({},q,i))},d.fromVertices=function(a,b,c,d,j,k,l){var m,n,o,p,q,r,s,t,u;for(d=d||{},n=[],j="undefined"!=typeof j?j:!1,k="undefined"!=typeof k?k:.01,l="undefined"!=typeof l?l:10,window.decomp||f.log("Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.","warn"),f.isArray(c[0])||(c=[c]),t=0;t0&&e.area(y)E&&z>F&&(C[s].isInternal=!0,D[u].isInternal=!0)}}}}}return n.length>1?(m=g.create(f.extend({parts:n.slice(0)},d)),g.setPosition(m,{x:a,y:b}),m):n[0]}}()},{"../body/Body":1,"../core/Common":14,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],22:[function(a,b,c){var d={};b.exports=d;var e=a("../body/Composite"),f=a("../constraint/Constraint"),g=a("../core/Common"),h=a("../body/Body"),i=a("./Bodies");!function(){d.stack=function(a,b,c,d,f,g,i){for(var j,k=e.create({label:"Stack"}),l=a,m=b,n=0,o=0;d>o;o++){for(var p=0,q=0;c>q;q++){var r=i(l,m,q,o,j,n);if(r){var s=r.bounds.max.y-r.bounds.min.y,t=r.bounds.max.x-r.bounds.min.x;s>p&&(p=s),h.translate(r,{x:.5*t,y:.5*s}),l=r.bounds.max.x+f,e.addBody(k,r),j=r,n+=1}else l+=f}m+=p+g,l=a}return k},d.chain=function(a,b,c,d,h,i){for(var j=a.bodies,k=1;ki;i++){for(j=1;b>j;j++)k=n[j-1+i*b],l=n[j+i*b],e.addConstraint(a,f.create(g.extend({bodyA:k,bodyB:l},h)));if(i>0)for(j=0;b>j;j++)k=n[j+(i-1)*b],l=n[j+i*b],e.addConstraint(a,f.create(g.extend({bodyA:k,bodyB:l},h))),d&&j>0&&(m=n[j-1+(i-1)*b],e.addConstraint(a,f.create(g.extend({bodyA:m,bodyB:l},h)))),d&&b-1>j&&(m=n[j+1+(i-1)*b],e.addConstraint(a,f.create(g.extend({bodyA:m,bodyB:l},h))))}return a.label+=" Mesh",a},d.pyramid=function(a,b,c,e,f,g,i){return d.stack(a,b,c,e,f,g,function(b,d,g,j,k,l){var m=Math.min(e,Math.ceil(c/2)),n=k?k.bounds.max.x-k.bounds.min.x:0;if(!(j>m)){j=m-j;var o=j,p=c-1-j;if(!(o>g||g>p)){1===l&&h.translate(k,{x:(g+(c%2===1?1:-1))*n,y:0});var q=k?g*n:0;return i(a+q+g*f,d,g,j,k,l)}}})},d.newtonsCradle=function(a,b,c,d,g){for(var h=e.create({label:"Newtons Cradle"}),j=0;c>j;j++){var k=1.9,l=i.circle(a+j*(d*k),b+g,d,{inertia:99999,restitution:1,friction:0,frictionAir:1e-4,slop:.01}),m=f.create({pointA:{x:a+j*(d*k),y:b},bodyB:l});e.addBody(h,l),e.addConstraint(h,m)}return h},d.car=function(a,b,c,d,g){var j=h.nextGroup(!0),k=-20,l=.5*-c+k,m=.5*c-k,n=0,o=e.create({label:"Car"}),p=i.trapezoid(a,b,c,d,.3,{collisionFilter:{group:j},friction:.01,chamfer:{radius:10}}),q=i.circle(a+l,b+n,g,{collisionFilter:{group:j},restitution:.5,friction:.9,frictionStatic:10,slop:.5,density:.01}),r=i.circle(a+m,b+n,g,{collisionFilter:{group:j},restitution:.5,friction:.9,frictionStatic:10,slop:.5,density:.01}),s=f.create({bodyA:p,pointA:{x:l,y:n},bodyB:q,stiffness:.5}),t=f.create({bodyA:p,pointA:{x:m,y:n},bodyB:r,stiffness:.5});return e.addBody(o,p),e.addBody(o,q),e.addBody(o,r),e.addConstraint(o,s),e.addConstraint(o,t),o},d.softBody=function(a,b,c,e,f,h,j,k,l,m){l=g.extend({inertia:1/0},l),m=g.extend({stiffness:.4},m);var n=d.stack(a,b,c,e,f,h,function(a,b){return i.circle(a,b,k,l)});return d.mesh(n,c,e,j,m),n.label="Soft Body",n}}()},{"../body/Body":1,"../body/Composite":2,"../constraint/Constraint":12,"../core/Common":14,"./Bodies":21}],23:[function(a,b,c){var d={};b.exports=d;var e=a("../geometry/Vector"),f=a("../core/Common");!function(){d.fromVertices=function(a){for(var b={},c=0;ca.max.x&&(a.max.x=e.x),e.xa.max.y&&(a.max.y=e.y),e.y0?a.max.x+=c.x:a.min.x+=c.x,c.y>0?a.max.y+=c.y:a.min.y+=c.y)},d.contains=function(a,b){return b.x>=a.min.x&&b.x<=a.max.x&&b.y>=a.min.y&&b.y<=a.max.y},d.overlaps=function(a,b){return a.min.x<=b.max.x&&a.max.x>=b.min.x&&a.max.y>=b.min.y&&a.min.y<=b.max.y},d.translate=function(a,b){a.min.x+=b.x,a.max.x+=b.x,a.min.y+=b.y,a.max.y+=b.y},d.shift=function(a,b){var c=a.max.x-a.min.x,d=a.max.y-a.min.y;a.min.x=b.x,a.max.x=b.x+c,a.min.y=b.y,a.max.y=b.y+d}}()},{}],25:[function(a,b,c){var d={};b.exports=d;a("../geometry/Bounds");!function(){d.pathToVertices=function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p=[],q=0,r=0,s=0;c=c||15;var t=function(a,b,c){var d=c%2===1&&c>1;if(!l||a!=l.x||b!=l.y){l&&d?(n=l.x,o=l.y):(n=0,o=0);var e={x:n+a,y:o+b};(d||!l)&&(l=e),p.push(e),r=n+a,s=o+b}},u=function(a){var b=a.pathSegTypeAsLetter.toUpperCase();if("Z"!==b){switch(b){case"M":case"L":case"T":case"C":case"S":case"Q":r=a.x,s=a.y;break;case"H":r=a.x;break;case"V":s=a.y}t(r,s,a.pathSegType)}};for(a(b),f=b.getTotalLength(),i=[],d=0;dq;){if(m=b.getPathSegAtLength(q),h=i[m],h!=k){for(;j.length&&j[0]!=h;)u(j.shift());k=h}switch(h.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":g=b.getPointAtLength(q),t(g.x,g.y,0)}q+=c}for(d=0,e=j.length;e>d;++d)u(j[d]);return p};var a=function(a){for(var b,c,d,e,f,g,h=a.pathSegList,i=0,j=0,k=h.numberOfItems,l=0;k>l;++l){var m=h.getItem(l),n=m.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(n))"x"in m&&(i=m.x),"y"in m&&(j=m.y);else switch("x1"in m&&(d=i+m.x1),"x2"in m&&(f=i+m.x2),"y1"in m&&(e=j+m.y1),"y2"in m&&(g=j+m.y2),"x"in m&&(i+=m.x),"y"in m&&(j+=m.y),n){case"m":h.replaceItem(a.createSVGPathSegMovetoAbs(i,j),l);break;case"l":h.replaceItem(a.createSVGPathSegLinetoAbs(i,j),l);break;case"h":h.replaceItem(a.createSVGPathSegLinetoHorizontalAbs(i),l);break;case"v":h.replaceItem(a.createSVGPathSegLinetoVerticalAbs(j),l);break;case"c":h.replaceItem(a.createSVGPathSegCurvetoCubicAbs(i,j,d,e,f,g),l);break;case"s":h.replaceItem(a.createSVGPathSegCurvetoCubicSmoothAbs(i,j,f,g),l);break;case"q":h.replaceItem(a.createSVGPathSegCurvetoQuadraticAbs(i,j,d,e),l);break;case"t":h.replaceItem(a.createSVGPathSegCurvetoQuadraticSmoothAbs(i,j),l);break;case"a":h.replaceItem(a.createSVGPathSegArcAbs(i,j,m.r1,m.r2,m.angle,m.largeArcFlag,m.sweepFlag),l);break;case"z":case"Z":i=b,j=c}("M"==n||"m"==n)&&(b=i,c=j)}}}()},{"../geometry/Bounds":24}],26:[function(a,b,c){var d={};b.exports=d,function(){d.create=function(a,b){return{x:a||0,y:b||0}},d.clone=function(a){return{x:a.x,y:a.y}},d.magnitude=function(a){return Math.sqrt(a.x*a.x+a.y*a.y)},d.magnitudeSquared=function(a){return a.x*a.x+a.y*a.y},d.rotate=function(a,b){var c=Math.cos(b),d=Math.sin(b);return{x:a.x*c-a.y*d,y:a.x*d+a.y*c}},d.rotateAbout=function(a,b,c,d){var e=Math.cos(b),f=Math.sin(b);d||(d={});var g=c.x+((a.x-c.x)*e-(a.y-c.y)*f);return d.y=c.y+((a.x-c.x)*f+(a.y-c.y)*e),d.x=g,d},d.normalise=function(a){var b=d.magnitude(a);return 0===b?{x:0,y:0}:{x:a.x/b,y:a.y/b}},d.dot=function(a,b){return a.x*b.x+a.y*b.y},d.cross=function(a,b){return a.x*b.y-a.y*b.x},d.cross3=function(a,b,c){return(b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x)},d.add=function(a,b,c){return c||(c={}),c.x=a.x+b.x,c.y=a.y+b.y,c},d.sub=function(a,b,c){return c||(c={}),c.x=a.x-b.x,c.y=a.y-b.y,c},d.mult=function(a,b){return{x:a.x*b,y:a.y*b}},d.div=function(a,b){return{x:a.x/b,y:a.y/b}},d.perp=function(a,b){return b=b===!0?-1:1,{x:b*-a.y,y:b*a.x}},d.neg=function(a){return{x:-a.x,y:-a.y}},d.angle=function(a,b){return Math.atan2(b.y-a.y,b.x-a.x)},d._temp=[d.create(),d.create(),d.create(),d.create(),d.create(),d.create()]}()},{}],27:[function(a,b,c){var d={};b.exports=d;var e=a("../geometry/Vector"),f=a("../core/Common");!function(){d.create=function(a,b){for(var c=[],d=0;d0)return!1}return!0},d.scale=function(a,b,c,f){if(1===b&&1===c)return a;f=f||d.centre(a);for(var g,h,i=0;i=0?i-1:a.length-1],k=a[i],l=a[(i+1)%a.length],m=b[iw;w++)h.push(e.add(e.rotate(q,v*w),s))}else h.push(k)}return h},d.clockwiseSort=function(a){var b=d.mean(a);return a.sort(function(a,c){return e.angle(b,a)-e.angle(b,c)}),a},d.isConvex=function(a){var b,c,d,e,f=0,g=a.length;if(3>g)return null;for(b=0;g>b;b++)if(c=(b+1)%g,d=(b+2)%g,e=(a[c].x-a[b].x)*(a[d].y-a[c].y),e-=(a[c].y-a[b].y)*(a[d].x-a[c].x),0>e?f|=1:e>0&&(f|=2),3===f)return!1;return 0!==f?!0:null},d.hull=function(a){var b,c,d=[],f=[];for(a=a.slice(0),a.sort(function(a,b){var c=a.x-b.x;return 0!==c?c:a.y-b.y}),c=0;c=2&&e.cross3(f[f.length-2],f[f.length-1],b)<=0;)f.pop();f.push(b)}for(c=a.length-1;c>=0;c--){for(b=a[c];d.length>=2&&e.cross3(d[d.length-2],d[d.length-1],b)<=0;)d.pop();d.push(b)}return d.pop(),f.pop(),d.concat(f)}}()},{"../core/Common":14,"../geometry/Vector":26}],28:[function(a,b,c){var d=b.exports={};d.Body=a("../body/Body"),d.Composite=a("../body/Composite"),d.World=a("../body/World"),d.Contact=a("../collision/Contact"),d.Detector=a("../collision/Detector"),d.Grid=a("../collision/Grid"),d.Pairs=a("../collision/Pairs"),d.Pair=a("../collision/Pair"),d.Query=a("../collision/Query"),d.Resolver=a("../collision/Resolver"),d.SAT=a("../collision/SAT"),d.Constraint=a("../constraint/Constraint"),d.MouseConstraint=a("../constraint/MouseConstraint"),d.Common=a("../core/Common"),d.Engine=a("../core/Engine"),d.Events=a("../core/Events"),d.Mouse=a("../core/Mouse"),d.Runner=a("../core/Runner"),d.Sleeping=a("../core/Sleeping"),d.Metrics=a("../core/Metrics"),d.Bodies=a("../factory/Bodies"),d.Composites=a("../factory/Composites"),d.Axes=a("../geometry/Axes"),d.Bounds=a("../geometry/Bounds"),d.Svg=a("../geometry/Svg"),d.Vector=a("../geometry/Vector"),d.Vertices=a("../geometry/Vertices"),d.Render=a("../render/Render"),d.RenderPixi=a("../render/RenderPixi"),d.World.add=d.Composite.add,d.World.remove=d.Composite.remove,d.World.addComposite=d.Composite.addComposite,d.World.addBody=d.Composite.addBody,d.World.addConstraint=d.Composite.addConstraint,d.World.clear=d.Composite.clear,d.Engine.run=d.Runner.run},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Contact":4,"../collision/Detector":5,"../collision/Grid":6,"../collision/Pair":7,"../collision/Pairs":8,"../collision/Query":9,"../collision/Resolver":10,"../collision/SAT":11,"../constraint/Constraint":12,"../constraint/MouseConstraint":13,"../core/Common":14,"../core/Engine":15,"../core/Events":16,"../core/Metrics":17,"../core/Mouse":18,"../core/Runner":19,"../core/Sleeping":20,"../factory/Bodies":21,"../factory/Composites":22,"../geometry/Axes":23,"../geometry/Bounds":24,"../geometry/Svg":25,"../geometry/Vector":26,"../geometry/Vertices":27,"../render/Render":29,"../render/RenderPixi":30}],29:[function(a,b,c){var d={};b.exports=d;var e=a("../core/Common"),f=a("../body/Composite"),g=a("../geometry/Bounds"),h=a("../core/Events"),i=a("../collision/Grid");!function(){d.create=function(b){var c={controller:d,element:null,canvas:null,options:{width:800,height:600,pixelRatio:1,background:"#fafafa",wireframeBackground:"#222",hasBounds:!1,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1,showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1}},f=e.extend(c,b);return f.canvas=f.canvas||a(f.options.width,f.options.height),f.context=f.canvas.getContext("2d"),f.textures={},f.bounds=f.bounds||{min:{x:0,y:0},max:{x:f.options.width,y:f.options.height}},1!==f.options.pixelRatio&&d.setPixelRatio(f,f.options.pixelRatio),e.isElement(f.element)?f.element.appendChild(f.canvas):e.log("Render.create: options.element was undefined, render.canvas was created but not appended","warn"),f},d.setPixelRatio=function(a,c){var d=a.options,e=a.canvas;"auto"===c&&(c=b(e)),d.pixelRatio=c,e.setAttribute("data-pixel-ratio",c),e.width=d.width*c,e.height=d.height*c,e.style.width=d.width+"px",e.style.height=d.height+"px",a.context.scale(c,c)},d.world=function(a){var b,c=a.render,e=a.world,k=c.canvas,l=c.context,m=c.options,n=f.allBodies(e),o=f.allConstraints(e),p=m.wireframes?m.wireframeBackground:m.background,q=[],r=[],s={timestamp:a.timing.timestamp};if(h.trigger(c,"beforeRender",s),c.currentBackground!==p&&j(c,p),l.globalCompositeOperation="source-in",l.fillStyle="transparent",l.fillRect(0,0,k.width,k.height),l.globalCompositeOperation="source-over",m.hasBounds){var t=c.bounds.max.x-c.bounds.min.x,u=c.bounds.max.y-c.bounds.min.y,v=t/m.width,w=u/m.height;for(b=0;b=500){var l="";l+="fps: "+Math.round(g.timing.fps)+k,g.extended&&(l+="delta: "+g.timing.delta.toFixed(3)+k,l+="correction: "+g.timing.correction.toFixed(3)+k,l+="bodies: "+j.length+k,a.broadphase.controller===i&&(l+="buckets: "+g.buckets+k),l+="\n",l+="collisions: "+g.collisions+k,l+="pairs: "+a.pairs.list.length+k,l+="broad: "+g.broadEff+k,l+="mid: "+g.midEff+k,l+="narrow: "+g.narrowEff+k),e.debugString=l,e.debugTimestamp=a.timing.timestamp}if(e.debugString){c.font="12px Arial",h.wireframes?c.fillStyle="rgba(255,255,255,0.5)":c.fillStyle="rgba(0,0,0,0.5)";for(var m=e.debugString.split("\n"),n=0;n1?1:0;i1?1:0;h1?1:0;f1?1:0;j1?1:0;f1?1:0;f1?1:0;e0)){var l=d.activeContacts[0].vertex.x,m=d.activeContacts[0].vertex.y;2===d.activeContacts.length&&(l=(d.activeContacts[0].vertex.x+d.activeContacts[1].vertex.x)/2,m=(d.activeContacts[0].vertex.y+d.activeContacts[1].vertex.y)/2),e.bodyB===e.supports[0].body||e.bodyA.isStatic===!0?h.moveTo(l-8*e.normal.x,m-8*e.normal.y):h.moveTo(l+8*e.normal.x,m+8*e.normal.y),h.lineTo(l,m)}i.wireframes?h.strokeStyle="rgba(255,165,0,0.7)":h.strokeStyle="orange",h.lineWidth=1,h.stroke()},d.separations=function(a,b,c){var d,e,f,g,h,i=c,j=a.render.options;for(i.beginPath(),h=0;h1?1:0;m