0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-23 09:26:51 -05:00
liabru-matter-js/demo/js/matter-demo.9c6dd1.min.js
2021-02-11 22:42:32 +00:00

6 lines
No EOL
149 KiB
JavaScript

/*!
* matter-demo bundle 0.16.1 by @liabru
* http://brm.io/matter-js/
* License MIT
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("MatterDemo",[],t):"object"==typeof exports?exports.MatterDemo=t():e.MatterDemo=t()}(this,(function(){return(this.webpackJsonpMatterDemo=this.webpackJsonpMatterDemo||[]).push([[0],{"+QOk":function(e,t,n){var r=r||{};r.timescale=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Events,i=Matter.Composite,a=Matter.Composites,s=Matter.Common,c=Matter.MouseConstraint,l=Matter.Mouse,d=Matter.World,u=Matter.Bodies,p=e.create(),m=p.world,f=t.create({element:document.body,engine:p,options:{width:800,height:600,showAngleIndicator:!0}});t.run(f);var v=n.create();n.run(v,p),d.add(m,[u.rectangle(400,0,800,50,{isStatic:!0}),u.rectangle(400,600,800,50,{isStatic:!0}),u.rectangle(800,300,50,600,{isStatic:!0}),u.rectangle(0,300,50,600,{isStatic:!0})]);var g=1,y=0;o.on(p,"afterUpdate",(function(e){p.timing.timeScale+=.05*(g-p.timing.timeScale),(y+=1)>=90&&(g=g<1?1:.05,function(e){for(var t=i.allBodies(e.world),n=0;n<t.length;n++){var o=t[n];if(!o.isStatic&&o.position.y>=500){var a=.05*o.mass;r.applyForce(o,o.position,{x:(a+s.random()*a)*s.choose([1,-1]),y:-a+s.random()*-a})}}}(p),y=0)}));var x={frictionAir:0,friction:1e-4,restitution:.8};d.add(m,a.stack(20,100,15,3,20,40,(function(e,t){return u.circle(e,t,s.random(10,20),x)}))),d.add(m,a.stack(50,50,8,3,0,0,(function(e,t){switch(Math.round(s.random(0,1))){case 0:return s.random()<.8?u.rectangle(e,t,s.random(20,50),s.random(20,50),x):u.rectangle(e,t,s.random(80,120),s.random(20,30),x);case 1:return u.polygon(e,t,Math.round(s.random(4,8)),s.random(20,50),x)}})));var h=l.create(f.canvas),b=c.create(p,{mouse:h,constraint:{stiffness:.2,render:{visible:!1}}});return d.add(m,b),f.mouse=h,t.lookAt(f,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:p,runner:v,render:f,canvas:f.canvas,stop:function(){Matter.Render.stop(f),Matter.Runner.stop(v)}}},r.timescale.title="Time Scaling",r.timescale.for=">=0.14.2",e.exports=r.timescale},"+jwT":function(e,t,n){var r=r||{};r.constraints=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=(Matter.Composites,Matter.Common,Matter.Constraint),o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.World,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!0}});t.run(d);var u=n.create();n.run(u,c);var p=s.polygon(150,200,5,30),m=r.create({pointA:{x:150,y:100},bodyB:p,pointB:{x:-10,y:-10}});a.add(l,[p,m]);p=s.polygon(280,100,3,30),m=r.create({pointA:{x:280,y:120},bodyB:p,pointB:{x:-10,y:-7},stiffness:.001});a.add(l,[p,m]);p=s.polygon(400,100,4,30),m=r.create({pointA:{x:400,y:120},bodyB:p,pointB:{x:-10,y:-10},stiffness:.001,damping:.05});a.add(l,[p,m]);p=s.rectangle(600,200,200,20);var f=s.circle(550,150,20);m=r.create({pointA:{x:600,y:200},bodyB:p,length:0});a.add(l,[p,f,m]);p=s.rectangle(500,400,100,20,{collisionFilter:{group:-1}}),f=s.circle(600,400,20,{collisionFilter:{group:-1}}),m=r.create({bodyA:p,bodyB:f});a.add(l,[p,f,m]);var v=s.polygon(100,400,6,20),g=s.polygon(200,400,1,50);m=r.create({bodyA:v,pointA:{x:-10,y:-10},bodyB:g,pointB:{x:-10,y:-10}});a.add(l,[v,g,m]);v=s.polygon(300,400,4,20),g=s.polygon(400,400,3,30),m=r.create({bodyA:v,pointA:{x:-10,y:-10},bodyB:g,pointB:{x:-10,y:-7},stiffness:.001});a.add(l,[v,g,m]);v=s.polygon(500,400,6,30),g=s.polygon(600,400,7,60),m=r.create({bodyA:v,pointA:{x:-10,y:-10},bodyB:g,pointB:{x:-10,y:-10},stiffness:.001,damping:.1});a.add(l,[v,g,m]),a.add(l,[s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0})]);var y=i.create(d.canvas),x=o.create(c,{mouse:y,constraint:{angularStiffness:0,render:{visible:!1}}});return a.add(l,x),d.mouse=y,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.constraints.title="Constraints",r.constraints.for=">=0.14.2",e.exports=r.constraints},"/iAh":function(e,t,n){var r=r||{};r.svg=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Common,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.World,s=Matter.Vertices,c=Matter.Svg,l=Matter.Bodies,d=e.create(),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600}});t.run(p);var m=n.create();if(n.run(m,d),"undefined"!=typeof fetch){var f=function(e,t){return Array.prototype.slice.call(e.querySelectorAll(t))},v=function(e){return fetch(e).then((function(e){return e.text()})).then((function(e){return(new window.DOMParser).parseFromString(e,"image/svg+xml")}))};["./svg/iconmonstr-check-mark-8-icon.svg","./svg/iconmonstr-paperclip-2-icon.svg","./svg/iconmonstr-puzzle-icon.svg","./svg/iconmonstr-user-icon.svg"].forEach((function(e,t){v(e).then((function(e){var n=r.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),o=f(e,"path").map((function(e){return s.scale(c.pathToVertices(e,30),.4,.4)}));a.add(u,l.fromVertices(100+150*t,200+50*t,o,{render:{fillStyle:n,strokeStyle:n,lineWidth:1}},!0))}))})),v("./svg/svg.svg").then((function(e){var t=r.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),n=f(e,"path").map((function(e){return c.pathToVertices(e,30)}));a.add(u,l.fromVertices(400,80,n,{render:{fillStyle:t,strokeStyle:t,lineWidth:1}},!0))}))}else r.warn("Fetch is not available. Could not load SVG.");a.add(u,[l.rectangle(400,0,800,50,{isStatic:!0}),l.rectangle(400,600,800,50,{isStatic:!0}),l.rectangle(800,300,50,600,{isStatic:!0}),l.rectangle(0,300,50,600,{isStatic:!0})]);var g=i.create(p.canvas),y=o.create(d,{mouse:g,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(u,y),p.mouse=g,t.lookAt(p,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},r.svg.title="Concave SVG Paths",r.svg.for=">=0.14.2",e.exports=r.svg},"02te":function(e,t,n){var r=r||{};r.ballPool=function(){try{"undefined"!=typeof MatterWrap?Matter.use("matter-wrap"):Matter.use(n("OPlj"))}catch(e){}var e=Matter.Engine,t=Matter.Render,r=Matter.Runner,o=Matter.Composite,i=Matter.Composites,a=Matter.Common,s=Matter.MouseConstraint,c=Matter.Mouse,l=Matter.World,d=Matter.Bodies,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600,showAngleIndicator:!0}});t.run(m);var f=r.create();r.run(f,u),l.add(p,[d.rectangle(400,600,1200,50.5,{isStatic:!0,render:{fillStyle:"#060a19"}})]);var v=i.stack(100,0,10,8,10,10,(function(e,t){return d.circle(e,t,a.random(15,30),{restitution:.6,friction:.1})}));l.add(p,[v,d.polygon(200,460,3,60),d.polygon(400,460,5,60),d.rectangle(600,460,80,80)]);var g=c.create(m.canvas),y=s.create(u,{mouse:g,constraint:{stiffness:.2,render:{visible:!1}}});l.add(p,y),m.mouse=g,t.lookAt(m,{min:{x:0,y:0},max:{x:800,y:600}});for(var x=o.allBodies(p),h=0;h<x.length;h+=1)x[h].plugin.wrap={min:{x:m.bounds.min.x-100,y:m.bounds.min.y},max:{x:m.bounds.max.x+100,y:m.bounds.max.y}};return{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.ballPool.title="Ball Pool",r.ballPool.for=">=0.14.2",e.exports=r.ballPool},"0Aok":function(e,t,n){var r={};e.exports=r;n("Tgw/");var o=n("571F");r.pathToVertices=function(e,t){"undefined"==typeof window||"SVGPathSeg"in window||o.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var n,i,a,s,c,l,d,u,p,m,f,v=[],g=0,y=0,x=0;t=t||15;var h=function(e,t,n){var r=n%2==1&&n>1;if(!p||e!=p.x||t!=p.y){p&&r?(m=p.x,f=p.y):(m=0,f=0);var o={x:m+e,y:f+t};!r&&p||(p=o),v.push(o),y=m+e,x=f+t}},b=function(e){var t=e.pathSegTypeAsLetter.toUpperCase();if("Z"!==t){switch(t){case"M":case"L":case"T":case"C":case"S":case"Q":y=e.x,x=e.y;break;case"H":y=e.x;break;case"V":x=e.y}h(y,x,e.pathSegType)}};for(r._svgPathToAbsolute(e),a=e.getTotalLength(),l=[],n=0;n<e.pathSegList.numberOfItems;n+=1)l.push(e.pathSegList.getItem(n));for(d=l.concat();g<a;){if((c=l[e.getPathSegAtLength(g)])!=u){for(;d.length&&d[0]!=c;)b(d.shift());u=c}switch(c.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":s=e.getPointAtLength(g),h(s.x,s.y,0)}g+=t}for(n=0,i=d.length;n<i;++n)b(d[n]);return v},r._svgPathToAbsolute=function(e){for(var t,n,r,o,i,a,s=e.pathSegList,c=0,l=0,d=s.numberOfItems,u=0;u<d;++u){var p=s.getItem(u),m=p.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(m))"x"in p&&(c=p.x),"y"in p&&(l=p.y);else switch("x1"in p&&(r=c+p.x1),"x2"in p&&(i=c+p.x2),"y1"in p&&(o=l+p.y1),"y2"in p&&(a=l+p.y2),"x"in p&&(c+=p.x),"y"in p&&(l+=p.y),m){case"m":s.replaceItem(e.createSVGPathSegMovetoAbs(c,l),u);break;case"l":s.replaceItem(e.createSVGPathSegLinetoAbs(c,l),u);break;case"h":s.replaceItem(e.createSVGPathSegLinetoHorizontalAbs(c),u);break;case"v":s.replaceItem(e.createSVGPathSegLinetoVerticalAbs(l),u);break;case"c":s.replaceItem(e.createSVGPathSegCurvetoCubicAbs(c,l,r,o,i,a),u);break;case"s":s.replaceItem(e.createSVGPathSegCurvetoCubicSmoothAbs(c,l,i,a),u);break;case"q":s.replaceItem(e.createSVGPathSegCurvetoQuadraticAbs(c,l,r,o),u);break;case"t":s.replaceItem(e.createSVGPathSegCurvetoQuadraticSmoothAbs(c,l),u);break;case"a":s.replaceItem(e.createSVGPathSegArcAbs(c,l,p.r1,p.r2,p.angle,p.largeArcFlag,p.sweepFlag),u);break;case"z":case"Z":c=t,l=n}"M"!=m&&"m"!=m||(t=c,n=l)}}},"0kzT":function(e,t,n){var r={};e.exports=r;var o=n("m6Dm"),i=n("571F");r.create=function(e,t){for(var n=[],r=0;r<e.length;r++){var o=e[r],i={x:o.x,y:o.y,index:r,body:t,isInternal:!1};n.push(i)}return n},r.fromPath=function(e,t){var n=[];return e.replace(/L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/gi,(function(e,t,r){n.push({x:parseFloat(t),y:parseFloat(r)})})),r.create(n,t)},r.centre=function(e){for(var t,n,i,a=r.area(e,!0),s={x:0,y:0},c=0;c<e.length;c++)i=(c+1)%e.length,t=o.cross(e[c],e[i]),n=o.mult(o.add(e[c],e[i]),t),s=o.add(s,n);return o.div(s,6*a)},r.mean=function(e){for(var t={x:0,y:0},n=0;n<e.length;n++)t.x+=e[n].x,t.y+=e[n].y;return o.div(t,e.length)},r.area=function(e,t){for(var n=0,r=e.length-1,o=0;o<e.length;o++)n+=(e[r].x-e[o].x)*(e[r].y+e[o].y),r=o;return t?n/2:Math.abs(n)/2},r.inertia=function(e,t){for(var n,r,i=0,a=0,s=e,c=0;c<s.length;c++)r=(c+1)%s.length,i+=(n=Math.abs(o.cross(s[r],s[c])))*(o.dot(s[r],s[r])+o.dot(s[r],s[c])+o.dot(s[c],s[c])),a+=n;return t/6*(i/a)},r.translate=function(e,t,n){var r;if(n)for(r=0;r<e.length;r++)e[r].x+=t.x*n,e[r].y+=t.y*n;else for(r=0;r<e.length;r++)e[r].x+=t.x,e[r].y+=t.y;return e},r.rotate=function(e,t,n){if(0!==t){for(var r=Math.cos(t),o=Math.sin(t),i=0;i<e.length;i++){var a=e[i],s=a.x-n.x,c=a.y-n.y;a.x=n.x+(s*r-c*o),a.y=n.y+(s*o+c*r)}return e}},r.contains=function(e,t){for(var n=0;n<e.length;n++){var r=e[n],o=e[(n+1)%e.length];if((t.x-r.x)*(o.y-r.y)+(t.y-r.y)*(r.x-o.x)>0)return!1}return!0},r.scale=function(e,t,n,i){if(1===t&&1===n)return e;var a,s;i=i||r.centre(e);for(var c=0;c<e.length;c++)a=e[c],s=o.sub(a,i),e[c].x=i.x+s.x*t,e[c].y=i.y+s.y*n;return e},r.chamfer=function(e,t,n,r,a){t="number"==typeof t?[t]:t||[8],n=void 0!==n?n:-1,r=r||2,a=a||14;for(var s=[],c=0;c<e.length;c++){var l=e[c-1>=0?c-1:e.length-1],d=e[c],u=e[(c+1)%e.length],p=t[c<t.length?c:t.length-1];if(0!==p){var m=o.normalise({x:d.y-l.y,y:l.x-d.x}),f=o.normalise({x:u.y-d.y,y:d.x-u.x}),v=Math.sqrt(2*Math.pow(p,2)),g=o.mult(i.clone(m),p),y=o.normalise(o.mult(o.add(m,f),.5)),x=o.sub(d,o.mult(y,v)),h=n;-1===n&&(h=1.75*Math.pow(p,.32)),(h=i.clamp(h,r,a))%2==1&&(h+=1);for(var b=Math.acos(o.dot(m,f))/h,M=0;M<h;M++)s.push(o.add(o.rotate(g,b*M),x))}else s.push(d)}return s},r.clockwiseSort=function(e){var t=r.mean(e);return e.sort((function(e,n){return o.angle(t,e)-o.angle(t,n)})),e},r.isConvex=function(e){var t,n,r,o,i=0,a=e.length;if(a<3)return null;for(t=0;t<a;t++)if(r=(t+2)%a,o=(e[n=(t+1)%a].x-e[t].x)*(e[r].y-e[n].y),(o-=(e[n].y-e[t].y)*(e[r].x-e[n].x))<0?i|=1:o>0&&(i|=2),3===i)return!1;return 0!==i||null},r.hull=function(e){var t,n,r=[],i=[];for((e=e.slice(0)).sort((function(e,t){var n=e.x-t.x;return 0!==n?n:e.y-t.y})),n=0;n<e.length;n+=1){for(t=e[n];i.length>=2&&o.cross3(i[i.length-2],i[i.length-1],t)<=0;)i.pop();i.push(t)}for(n=e.length-1;n>=0;n-=1){for(t=e[n];r.length>=2&&o.cross3(r[r.length-2],r[r.length-1],t)<=0;)r.pop();r.push(t)}return r.pop(),i.pop(),r.concat(i)}},"0mtl":function(e,t,n){var r=r||{};r.catapult=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Constraint,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Bodies,l=Matter.Body,d=Matter.Vector,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600,showAngleIndicator:!0,showCollisions:!0,showVelocity:!0}});t.run(m);var f=n.create();n.run(f,u);var v=l.nextGroup(!0),g=r.stack(250,255,1,6,0,0,(function(e,t){return c.rectangle(e,t,30,30)})),y=c.rectangle(400,520,320,20,{collisionFilter:{group:v}});s.add(p,[g,y,c.rectangle(400,600,800,50.5,{isStatic:!0,render:{fillStyle:"#060a19"}}),c.rectangle(250,555,20,50,{isStatic:!0,render:{fillStyle:"#060a19"}}),c.rectangle(400,535,20,80,{isStatic:!0,collisionFilter:{group:v},render:{fillStyle:"#060a19"}}),c.circle(560,100,50,{density:.005}),o.create({bodyA:y,pointB:d.clone(y.position),stiffness:1,length:0})]);var x=a.create(m.canvas),h=i.create(u,{mouse:x,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(p,h),m.mouse=x,t.lookAt(m,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.catapult.title="Catapult",r.catapult.for=">=0.14.2",e.exports=r.catapult},"136C":function(e,t,n){var r=r||{};r.slingshot=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Events,i=Matter.Constraint,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.World,l=Matter.Bodies,d=e.create(),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600,showAngleIndicator:!0}});t.run(p);var m=n.create();n.run(m,d);var f=l.rectangle(395,600,815,50,{isStatic:!0,render:{fillStyle:"#060a19"}}),v={density:.004},g=l.polygon(170,450,8,20,v),y=i.create({pointA:{x:170,y:450},bodyB:g,stiffness:.05}),x=r.pyramid(500,300,9,10,0,0,(function(e,t){return l.rectangle(e,t,25,40)})),h=l.rectangle(610,250,200,20,{isStatic:!0,render:{fillStyle:"#060a19"}}),b=r.pyramid(550,0,5,10,0,0,(function(e,t){return l.rectangle(e,t,25,40)}));c.add(d.world,[f,x,h,b,g,y]),o.on(d,"afterUpdate",(function(){-1===w.mouse.button&&(g.position.x>190||g.position.y<430)&&(g=l.polygon(170,450,7,20,v),c.add(d.world,g),y.bodyB=g)}));var M=s.create(p.canvas),w=a.create(d,{mouse:M,constraint:{stiffness:.2,render:{visible:!1}}});return c.add(u,w),p.mouse=M,t.lookAt(p,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},r.slingshot.title="Slingshot",r.slingshot.for=">=0.14.2",e.exports=r.slingshot},"2Og8":function(e,t,n){var r={};e.exports=r;var o=n("571F");r._registry={},r.register=function(e){if(r.isPlugin(e)||o.warn("Plugin.register:",r.toString(e),"does not implement all required fields."),e.name in r._registry){var t=r._registry[e.name],n=r.versionParse(e.version).number,i=r.versionParse(t.version).number;n>i?(o.warn("Plugin.register:",r.toString(t),"was upgraded to",r.toString(e)),r._registry[e.name]=e):n<i?o.warn("Plugin.register:",r.toString(t),"can not be downgraded to",r.toString(e)):e!==t&&o.warn("Plugin.register:",r.toString(e),"is already registered to different plugin object")}else r._registry[e.name]=e;return e},r.resolve=function(e){return r._registry[r.dependencyParse(e).name]},r.toString=function(e){return"string"==typeof e?e:(e.name||"anonymous")+"@"+(e.version||e.range||"0.0.0")},r.isPlugin=function(e){return e&&e.name&&e.version&&e.install},r.isUsed=function(e,t){return e.used.indexOf(t)>-1},r.isFor=function(e,t){var n=e.for&&r.dependencyParse(e.for);return!e.for||t.name===n.name&&r.versionSatisfies(t.version,n.range)},r.use=function(e,t){if(e.uses=(e.uses||[]).concat(t||[]),0!==e.uses.length){for(var n=r.dependencies(e),i=o.topologicalSort(n),a=[],s=0;s<i.length;s+=1)if(i[s]!==e.name){var c=r.resolve(i[s]);c?r.isUsed(e,c.name)||(r.isFor(c,e)||(o.warn("Plugin.use:",r.toString(c),"is for",c.for,"but installed on",r.toString(e)+"."),c._warned=!0),c.install?c.install(e):(o.warn("Plugin.use:",r.toString(c),"does not specify an install function."),c._warned=!0),c._warned?(a.push("🔶 "+r.toString(c)),delete c._warned):a.push("✅ "+r.toString(c)),e.used.push(c.name)):a.push("❌ "+i[s])}a.length>0&&o.info(a.join(" "))}else o.warn("Plugin.use:",r.toString(e),"does not specify any dependencies to install.")},r.dependencies=function(e,t){var n=r.dependencyParse(e),i=n.name;if(!(i in(t=t||{}))){e=r.resolve(e)||e,t[i]=o.map(e.uses||[],(function(t){r.isPlugin(t)&&r.register(t);var i=r.dependencyParse(t),a=r.resolve(t);return a&&!r.versionSatisfies(a.version,i.range)?(o.warn("Plugin.dependencies:",r.toString(a),"does not satisfy",r.toString(i),"used by",r.toString(n)+"."),a._warned=!0,e._warned=!0):a||(o.warn("Plugin.dependencies:",r.toString(t),"used by",r.toString(n),"could not be resolved."),e._warned=!0),i.name}));for(var a=0;a<t[i].length;a+=1)r.dependencies(t[i][a],t);return t}},r.dependencyParse=function(e){return o.isString(e)?(/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?))?$/.test(e)||o.warn("Plugin.dependencyParse:",e,"is not a valid dependency string."),{name:e.split("@")[0],range:e.split("@")[1]||"*"}):{name:e.name,range:e.range||e.version}},r.versionParse=function(e){var t=/^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-]+)?$/;t.test(e)||o.warn("Plugin.versionParse:",e,"is not a valid version or range.");var n=t.exec(e),r=Number(n[4]),i=Number(n[5]),a=Number(n[6]);return{isRange:Boolean(n[1]||n[2]),version:n[3],range:e,operator:n[1]||n[2]||"",major:r,minor:i,patch:a,parts:[r,i,a],prerelease:n[7],number:1e8*r+1e4*i+a}},r.versionSatisfies=function(e,t){t=t||"*";var n=r.versionParse(t),o=r.versionParse(e);if(n.isRange){if("*"===n.operator||"*"===e)return!0;if(">"===n.operator)return o.number>n.number;if(">="===n.operator)return o.number>=n.number;if("~"===n.operator)return o.major===n.major&&o.minor===n.minor&&o.patch>=n.patch;if("^"===n.operator)return n.major>0?o.major===n.major&&o.number>=n.number:n.minor>0?o.minor===n.minor&&o.patch>=n.patch:o.patch===n.patch}return e===t||"*"===e}},"2oV2":function(e,t,n){var r=r||{};r.raycasting=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composite,o=Matter.Composites,i=Matter.Common,a=Matter.Query,s=Matter.MouseConstraint,c=Matter.Mouse,l=Matter.Events,d=Matter.World,u=Matter.Vertices,p=Matter.Bodies,m=e.create(),f=m.world,v=t.create({element:document.body,engine:m,options:{width:800,height:600,showAngleIndicator:!0}});t.run(v);var g=n.create();n.run(g,m);var y=o.stack(20,20,12,4,0,0,(function(e,t){switch(Math.round(i.random(0,1))){case 0:return i.random()<.8?p.rectangle(e,t,i.random(20,50),i.random(20,50)):p.rectangle(e,t,i.random(80,120),i.random(20,30));case 1:var n=Math.round(i.random(1,8));return n=3===n?4:n,p.polygon(e,t,n,i.random(20,50))}})),x=u.fromPath("50 0 63 38 100 38 69 59 82 100 50 75 18 100 31 59 0 38 37 38"),h=p.fromVertices(200,200,x);d.add(f,[y,h,p.rectangle(400,0,800,50,{isStatic:!0}),p.rectangle(400,600,800,50,{isStatic:!0}),p.rectangle(800,300,50,600,{isStatic:!0}),p.rectangle(0,300,50,600,{isStatic:!0})]),l.on(v,"afterRender",(function(){var e=M.mouse,n=v.context,o=r.allBodies(m.world),i={x:400,y:100},s=e.position,c=a.ray(o,i,s);t.startViewTransform(v),n.beginPath(),n.moveTo(i.x,i.y),n.lineTo(s.x,s.y),c.length>0?n.strokeStyle="#fff":n.strokeStyle="#555",n.lineWidth=.5,n.stroke();for(var l=0;l<c.length;l++){var d=c[l];n.rect(d.bodyA.position.x-4.5,d.bodyA.position.y-4.5,8,8)}n.fillStyle="rgba(255,165,0,0.7)",n.fill(),t.endViewTransform(v)}));var b=c.create(v.canvas),M=s.create(m,{mouse:b,constraint:{stiffness:.2,render:{visible:!1}}});return d.add(f,M),v.mouse=b,t.lookAt(v,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:m,runner:g,render:v,canvas:v.canvas,stop:function(){Matter.Render.stop(v),Matter.Runner.stop(g)}}},r.raycasting.title="Raycasting",r.raycasting.for=">=0.14.2",e.exports=r.raycasting},"3Slt":function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=n("m6Dm"),a=n("571F"),s=n("Tgw/");r._restingThresh=4,r._restingThreshTangent=6,r._positionDampen=.9,r._positionWarming=.8,r._frictionNormalMultiplier=5,r.preSolvePosition=function(e){var t,n,r;for(t=0;t<e.length;t++)(n=e[t]).isActive&&(r=n.activeContacts.length,n.collision.parentA.totalContacts+=r,n.collision.parentB.totalContacts+=r)},r.solvePosition=function(e,t){var n,o,a,s,c,l,d,u,p,m=i._temp[0],f=i._temp[1],v=i._temp[2],g=i._temp[3];for(n=0;n<e.length;n++)(o=e[n]).isActive&&!o.isSensor&&(s=(a=o.collision).parentA,c=a.parentB,l=a.normal,d=i.sub(i.add(c.positionImpulse,c.position,m),i.add(s.positionImpulse,i.sub(c.position,a.penetration,f),v),g),o.separation=i.dot(l,d));for(n=0;n<e.length;n++)(o=e[n]).isActive&&!o.isSensor&&(s=(a=o.collision).parentA,c=a.parentB,l=a.normal,p=(o.separation-o.slop)*t,(s.isStatic||c.isStatic)&&(p*=2),s.isStatic||s.isSleeping||(u=r._positionDampen/s.totalContacts,s.positionImpulse.x+=l.x*p*u,s.positionImpulse.y+=l.y*p*u),c.isStatic||c.isSleeping||(u=r._positionDampen/c.totalContacts,c.positionImpulse.x-=l.x*p*u,c.positionImpulse.y-=l.y*p*u))},r.postSolvePosition=function(e){for(var t=0;t<e.length;t++){var n=e[t];if(n.totalContacts=0,0!==n.positionImpulse.x||0!==n.positionImpulse.y){for(var a=0;a<n.parts.length;a++){var c=n.parts[a];o.translate(c.vertices,n.positionImpulse),s.update(c.bounds,c.vertices,n.velocity),c.position.x+=n.positionImpulse.x,c.position.y+=n.positionImpulse.y}n.positionPrev.x+=n.positionImpulse.x,n.positionPrev.y+=n.positionImpulse.y,i.dot(n.positionImpulse,n.velocity)<0?(n.positionImpulse.x=0,n.positionImpulse.y=0):(n.positionImpulse.x*=r._positionWarming,n.positionImpulse.y*=r._positionWarming)}}},r.preSolveVelocity=function(e){var t,n,r,o,a,s,c,l,d,u,p,m,f,v,g=i._temp[0],y=i._temp[1];for(t=0;t<e.length;t++)if((r=e[t]).isActive&&!r.isSensor)for(o=r.activeContacts,s=(a=r.collision).parentA,c=a.parentB,l=a.normal,d=a.tangent,n=0;n<o.length;n++)p=(u=o[n]).vertex,m=u.normalImpulse,f=u.tangentImpulse,0===m&&0===f||(g.x=l.x*m+d.x*f,g.y=l.y*m+d.y*f,s.isStatic||s.isSleeping||(v=i.sub(p,s.position,y),s.positionPrev.x+=g.x*s.inverseMass,s.positionPrev.y+=g.y*s.inverseMass,s.anglePrev+=i.cross(v,g)*s.inverseInertia),c.isStatic||c.isSleeping||(v=i.sub(p,c.position,y),c.positionPrev.x-=g.x*c.inverseMass,c.positionPrev.y-=g.y*c.inverseMass,c.anglePrev-=i.cross(v,g)*c.inverseInertia))},r.solveVelocity=function(e,t){for(var n=t*t,o=i._temp[0],s=i._temp[1],c=i._temp[2],l=i._temp[3],d=i._temp[4],u=i._temp[5],p=0;p<e.length;p++){var m=e[p];if(m.isActive&&!m.isSensor){var f=m.collision,v=f.parentA,g=f.parentB,y=f.normal,x=f.tangent,h=m.activeContacts,b=1/h.length;v.velocity.x=v.position.x-v.positionPrev.x,v.velocity.y=v.position.y-v.positionPrev.y,g.velocity.x=g.position.x-g.positionPrev.x,g.velocity.y=g.position.y-g.positionPrev.y,v.angularVelocity=v.angle-v.anglePrev,g.angularVelocity=g.angle-g.anglePrev;for(var M=0;M<h.length;M++){var w=h[M],S=w.vertex,A=i.sub(S,v.position,s),C=i.sub(S,g.position,c),B=i.add(v.velocity,i.mult(i.perp(A),v.angularVelocity),l),k=i.add(g.velocity,i.mult(i.perp(C),g.angularVelocity),d),R=i.sub(B,k,u),P=i.dot(y,R),I=i.dot(x,R),T=Math.abs(I),_=a.sign(I),E=(1+m.restitution)*P,F=a.clamp(m.separation+P,0,1)*r._frictionNormalMultiplier,W=I,V=1/0;T>m.friction*m.frictionStatic*F*n&&(V=T,W=a.clamp(m.friction*_*n,-V,V));var D=i.cross(A,y),O=i.cross(C,y),L=b/(v.inverseMass+g.inverseMass+v.inverseInertia*D*D+g.inverseInertia*O*O);if(E*=L,W*=L,P<0&&P*P>r._restingThresh*n)w.normalImpulse=0;else{var q=w.normalImpulse;w.normalImpulse=Math.min(w.normalImpulse+E,0),E=w.normalImpulse-q}if(I*I>r._restingThreshTangent*n)w.tangentImpulse=0;else{var j=w.tangentImpulse;w.tangentImpulse=a.clamp(w.tangentImpulse+W,-V,V),W=w.tangentImpulse-j}o.x=y.x*E+x.x*W,o.y=y.y*E+x.y*W,v.isStatic||v.isSleeping||(v.positionPrev.x+=o.x*v.inverseMass,v.positionPrev.y+=o.y*v.inverseMass,v.anglePrev+=i.cross(A,o)*v.inverseInertia),g.isStatic||g.isSleeping||(g.positionPrev.x-=o.x*g.inverseMass,g.positionPrev.y-=o.y*g.inverseMass,g.anglePrev-=i.cross(C,o)*g.inverseInertia)}}}}},"4XQC":function(e,t,n){var r=r||{};r.staticFriction=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Composites,i=Matter.Events,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.World,l=Matter.Bodies,d=e.create(),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600,showVelocity:!0}});t.run(p);var m=n.create();n.run(m,d);var f=l.rectangle(400,500,200,60,{isStatic:!0,chamfer:10,render:{fillStyle:"#060a19"}}),v=-1,g=o.stack(350,170,1,6,0,0,(function(e,t){return l.rectangle(e,t,100,50,{slop:.5,friction:1,frictionStatic:1/0})}));c.add(u,[f,g,l.rectangle(400,0,800,50,{isStatic:!0}),l.rectangle(400,600,800,50,{isStatic:!0}),l.rectangle(800,300,50,600,{isStatic:!0}),l.rectangle(0,300,50,600,{isStatic:!0})]),i.on(d,"beforeUpdate",(function(e){if(!((v+=.014)<0)){var t=400+100*Math.sin(v);r.setVelocity(f,{x:t-f.position.x,y:0}),r.setPosition(f,{x:t,y:f.position.y})}}));var y=s.create(p.canvas),x=a.create(d,{mouse:y,constraint:{stiffness:.2,render:{visible:!1}}});return c.add(u,x),p.mouse=y,t.lookAt(p,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},r.staticFriction.title="Static Friction",r.staticFriction.for=">=0.14.2",e.exports=r.staticFriction},"4d8i":function(e,t,n){var r={};e.exports=r;var o=n("yTB+"),i=n("nIFq"),a=n("571F");!function(){var e,t,n;("undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),e)||(e=function(e){n=setTimeout((function(){e(a.now())}),1e3/60)},t=function(){clearTimeout(n)});r.create=function(e){var t=a.extend({fps:60,correction:1,deltaSampleSize:60,counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,timeScalePrev:1,frameRequestId:null,isFixed:!1,enabled:!0},e);return t.delta=t.delta||1e3/t.fps,t.deltaMin=t.deltaMin||1e3/t.fps,t.deltaMax=t.deltaMax||1e3/(.5*t.fps),t.fps=1e3/t.delta,t},r.run=function(t,n){return void 0!==t.positionIterations&&(n=t,t=r.create()),function o(i){t.frameRequestId=e(o),i&&t.enabled&&r.tick(t,n,i)}(),t},r.tick=function(e,t,n){var r,a=t.timing,s=1,c={timestamp:a.timestamp};o.trigger(e,"beforeTick",c),o.trigger(t,"beforeTick",c),e.isFixed?r=e.delta:(r=n-e.timePrev||e.delta,e.timePrev=n,e.deltaHistory.push(r),e.deltaHistory=e.deltaHistory.slice(-e.deltaSampleSize),s=(r=(r=(r=Math.min.apply(null,e.deltaHistory))<e.deltaMin?e.deltaMin:r)>e.deltaMax?e.deltaMax:r)/e.delta,e.delta=r),0!==e.timeScalePrev&&(s*=a.timeScale/e.timeScalePrev),0===a.timeScale&&(s=0),e.timeScalePrev=a.timeScale,e.correction=s,e.frameCounter+=1,n-e.counterTimestamp>=1e3&&(e.fps=e.frameCounter*((n-e.counterTimestamp)/1e3),e.counterTimestamp=n,e.frameCounter=0),o.trigger(e,"tick",c),o.trigger(t,"tick",c),t.world.isModified&&t.render&&t.render.controller&&t.render.controller.clear&&t.render.controller.clear(t.render),o.trigger(e,"beforeUpdate",c),i.update(t,r,s),o.trigger(e,"afterUpdate",c),t.render&&t.render.controller&&(o.trigger(e,"beforeRender",c),o.trigger(t,"beforeRender",c),t.render.controller.world(t.render),o.trigger(e,"afterRender",c),o.trigger(t,"afterRender",c)),o.trigger(e,"afterTick",c),o.trigger(t,"afterTick",c)},r.stop=function(e){t(e.frameRequestId)},r.start=function(e,t){r.run(e,t)}}()},"52dP":function(e,t,n){var r=r||{};r.terrain=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Query,l=Matter.Svg,d=Matter.Bodies,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600}});t.run(m);var f,v=n.create();if(n.run(v,u),"undefined"!=typeof fetch){(f="./svg/terrain.svg",fetch(f).then((function(e){return e.text()})).then((function(e){return(new window.DOMParser).parseFromString(e,"image/svg+xml")}))).then((function(e){var t=function(e,t){return Array.prototype.slice.call(e.querySelectorAll(t))}(e,"path").map((function(e){return l.pathToVertices(e,30)})),n=d.fromVertices(400,350,t,{isStatic:!0,render:{fillStyle:"#060a19",strokeStyle:"#060a19",lineWidth:1}},!0);s.add(p,n);var o={frictionAir:0,friction:1e-4,restitution:.6};s.add(p,r.stack(80,100,20,20,10,10,(function(e,t){if(0===c.point([n],{x:e,y:t}).length)return d.polygon(e,t,5,12,o)})))}))}else o.warn("Fetch is not available. Could not load SVG.");var g=a.create(m.canvas),y=i.create(u,{mouse:g,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(p,y),m.mouse=g,t.lookAt(m,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:u,runner:v,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(v)}}},r.terrain.title="Terrain",r.terrain.for=">=0.14.2",e.exports=r.terrain},"571F":function(e,t){var n={};e.exports=n,function(){n._nextId=0,n._seed=0,n._nowStartTime=+new Date,n.extend=function(e,t){var r,o;"boolean"==typeof t?(r=2,o=t):(r=1,o=!0);for(var i=r;i<arguments.length;i++){var a=arguments[i];if(a)for(var s in a)o&&a[s]&&a[s].constructor===Object?e[s]&&e[s].constructor!==Object?e[s]=a[s]:(e[s]=e[s]||{},n.extend(e[s],o,a[s])):e[s]=a[s]}return e},n.clone=function(e,t){return n.extend({},t,e)},n.keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var n in e)t.push(n);return t},n.values=function(e){var t=[];if(Object.keys){for(var n=Object.keys(e),r=0;r<n.length;r++)t.push(e[n[r]]);return t}for(var o in e)t.push(e[o]);return t},n.get=function(e,t,n,r){t=t.split(".").slice(n,r);for(var o=0;o<t.length;o+=1)e=e[t[o]];return e},n.set=function(e,t,r,o,i){var a=t.split(".").slice(o,i);return n.get(e,t,0,-1)[a[a.length-1]]=r,r},n.shuffle=function(e){for(var t=e.length-1;t>0;t--){var r=Math.floor(n.random()*(t+1)),o=e[t];e[t]=e[r],e[r]=o}return e},n.choose=function(e){return e[Math.floor(n.random()*e.length)]},n.isElement=function(e){return"undefined"!=typeof HTMLElement?e instanceof HTMLElement:!!(e&&e.nodeType&&e.nodeName)},n.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},n.isFunction=function(e){return"function"==typeof e},n.isPlainObject=function(e){return"object"==typeof e&&e.constructor===Object},n.isString=function(e){return"[object String]"===toString.call(e)},n.clamp=function(e,t,n){return e<t?t:e>n?n:e},n.sign=function(e){return e<0?-1:1},n.now=function(){if("undefined"!=typeof window&&window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return new Date-n._nowStartTime},n.random=function(t,n){return n=void 0!==n?n:1,(t=void 0!==t?t:0)+e()*(n-t)};var e=function(){return n._seed=(9301*n._seed+49297)%233280,n._seed/233280};n.colorToNumber=function(e){return 3==(e=e.replace("#","")).length&&(e=e.charAt(0)+e.charAt(0)+e.charAt(1)+e.charAt(1)+e.charAt(2)+e.charAt(2)),parseInt(e,16)},n.logLevel=1,n.log=function(){console&&n.logLevel>0&&n.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},n.info=function(){console&&n.logLevel>0&&n.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},n.warn=function(){console&&n.logLevel>0&&n.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},n.nextId=function(){return n._nextId++},n.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},n.map=function(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r+=1)n.push(t(e[r]));return n},n.topologicalSort=function(e){var t=[],r=[],o=[];for(var i in e)r[i]||o[i]||n._topologicalSort(i,r,o,e,t);return t},n._topologicalSort=function(e,t,r,o,i){var a=o[e]||[];r[e]=!0;for(var s=0;s<a.length;s+=1){var c=a[s];r[c]||(t[c]||n._topologicalSort(c,t,r,o,i))}r[e]=!1,t[e]=!0,i.push(e)},n.chain=function(){for(var e=[],t=0;t<arguments.length;t+=1){var n=arguments[t];n._chained?e.push.apply(e,n._chained):e.push(n)}var r=function(){for(var t,n=new Array(arguments.length),r=0,o=arguments.length;r<o;r++)n[r]=arguments[r];for(r=0;r<e.length;r+=1){var i=e[r].apply(t,n);void 0!==i&&(t=i)}return t};return r._chained=e,r},n.chainPathBefore=function(e,t,r){return n.set(e,t,n.chain(r,n.get(e,t)))},n.chainPathAfter=function(e,t,r){return n.set(e,t,n.chain(n.get(e,t),r))}}()},"5ocS":function(e,t,n){var r=r||{};r.pyramid=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.World,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!0}});t.run(d);var u=n.create();n.run(u,c);var p=r.pyramid(100,260,15,10,0,0,(function(e,t){return s.rectangle(e,t,40,40)}));a.add(l,[p,s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0}),s.rectangle(400,605,800,50,{isStatic:!0})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.pyramid.title="Pyramid",r.pyramid.for=">=0.14.2",e.exports=r.pyramid},"6IAi":function(e,t,n){var r=r||{};r.airFriction=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.MouseConstraint,o=Matter.Mouse,i=Matter.World,a=Matter.Bodies,s=e.create(),c=s.world,l=t.create({element:document.body,engine:s,options:{width:800,height:600,showVelocity:!0}});t.run(l);var d=n.create();n.run(d,s),i.add(c,[a.rectangle(200,100,60,60,{frictionAir:.001}),a.rectangle(400,100,60,60,{frictionAir:.05}),a.rectangle(600,100,60,60,{frictionAir:.1}),a.rectangle(400,0,800,50,{isStatic:!0}),a.rectangle(400,600,800,50,{isStatic:!0}),a.rectangle(800,300,50,600,{isStatic:!0}),a.rectangle(0,300,50,600,{isStatic:!0})]);var u=o.create(l.canvas),p=r.create(s,{mouse:u,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(c,p),l.mouse=u,t.lookAt(l,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:s,runner:d,render:l,canvas:l.canvas,stop:function(){Matter.Render.stop(l),Matter.Runner.stop(d)}}},r.airFriction.title="Air Friction",r.airFriction.for=">=0.14.2",e.exports=r.airFriction},"71Xj":function(e,t,n){var r=n("akk5");e.exports={demo:function(e,t){var n=r.Demo.create({toolbar:{title:"matter-js"+(t?" ・ dev":""),url:"https://github.com/liabru/matter-js",reset:!0,source:!0,inspector:!0,tools:!0,fullscreen:!0,exampleSelect:!0},tools:{inspector:!0,gui:!0},inline:!1,preventZoom:!0,resetOnOrientation:!0,routing:!0,startExample:"mixed",examples:e});if(window.MatterDemoInstance=n,document.body.appendChild(n.dom.root),document.title="Matter.js Demo"+(t?" ・ Dev":""),r.Demo.start(n),t){var o=n.dom.buttonSource,i=o.cloneNode(!0);i.textContent="⎄",i.title="Compare",i.href="?compare",i.target="",i.className="matter-btn matter-btn-compare",i.addEventListener("click",(function(e){window.location="?compare#"+n.example.id,e.preventDefault()})),o.parentNode.insertBefore(i,o.nextSibling)}}}},"74MQ":function(e,t,n){var r=r||{};r.doublePendulum=function(){var e=Matter.Engine,t=Matter.Events,n=Matter.Render,r=Matter.Runner,o=Matter.Body,i=Matter.Composite,a=Matter.Composites,s=Matter.Constraint,c=Matter.MouseConstraint,l=Matter.Mouse,d=Matter.World,u=Matter.Bodies,p=Matter.Vector,m=e.create(),f=m.world,v=n.create({element:document.body,engine:m,options:{width:800,height:600,wireframes:!1}});n.run(v);var g=r.create();r.run(g,m);var y=o.nextGroup(!0),x=a.stack(350,160,2,1,-20,0,(function(e,t){return u.rectangle(e,t,200,25,{collisionFilter:{group:y},frictionAir:0,chamfer:5,render:{fillStyle:"transparent",lineWidth:1}})}));f.gravity.scale=.002,a.chain(x,.45,0,-.45,0,{stiffness:.9,length:0,angularStiffness:.7,render:{strokeStyle:"#4a485b"}}),i.add(x,s.create({bodyB:x.bodies[0],pointB:{x:-84,y:0},pointA:{x:x.bodies[0].position.x-84,y:x.bodies[0].position.y},stiffness:.9,length:0,render:{strokeStyle:"#4a485b"}}));var h=x.bodies[1];o.rotate(h,.3*-Math.PI,{x:h.position.x-100,y:h.position.y}),d.add(f,x);var b=[];t.on(v,"afterRender",(function(){b.unshift({position:p.clone(h.position),speed:h.speed}),n.startViewTransform(v),v.context.globalAlpha=.7;for(var e=0;e<b.length;e+=1){var t=b[e].position,r=b[e].speed,o=250+Math.round(170*(1-Math.min(1,r/10)));v.context.fillStyle="hsl("+o+", 100%, 55%)",v.context.fillRect(t.x,t.y,2,2)}v.context.globalAlpha=1,n.endViewTransform(v),b.length>2e3&&b.pop()}));var M=l.create(v.canvas),w=c.create(m,{mouse:M,constraint:{stiffness:.2,render:{visible:!1}}});return d.add(f,w),v.mouse=M,n.lookAt(v,{min:{x:0,y:0},max:{x:700,y:600}}),{engine:m,runner:g,render:v,canvas:v.canvas,stop:function(){Matter.Render.stop(v),Matter.Runner.stop(g)}}},r.doublePendulum.title="Double Pendulum",r.doublePendulum.for=">=0.14.2",e.exports=r.doublePendulum},"7MJU":function(e,t,n){var r=r||{};r.gravity=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showVelocity:!0,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l),s.add(d,[c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50.5,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]),l.world.gravity.y=-1;var m=r.stack(50,120,11,5,0,0,(function(e,t){switch(Math.round(o.random(0,1))){case 0:return o.random()<.8?c.rectangle(e,t,o.random(20,50),o.random(20,50)):c.rectangle(e,t,o.random(80,120),o.random(20,30));case 1:return c.polygon(e,t,Math.round(o.random(1,8)),o.random(20,50))}}));s.add(d,m);var f=a.create(u.canvas),v=i.create(l,{mouse:f,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,v),u.mouse=f,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.gravity.title="Reverse Gravity",r.gravity.for=">=0.14.2",e.exports=r.gravity},"9K63":function(e,t){var n={};e.exports=n,n.create=function(e){return{id:n.id(e),vertex:e,normalImpulse:0,tangentImpulse:0}},n.id=function(e){return e.body.id+"_"+e.index}},"9Nbg":function(e,t,n){var r={};e.exports=r;var o=n("wAS/"),i=n("ga9t"),a=n("571F"),s=n("IbIC"),c=n("oT59");r.stack=function(e,t,n,r,i,a,c){for(var l,d=o.create({label:"Stack"}),u=e,p=t,m=0,f=0;f<r;f++){for(var v=0,g=0;g<n;g++){var y=c(u,p,g,f,l,m);if(y){var x=y.bounds.max.y-y.bounds.min.y,h=y.bounds.max.x-y.bounds.min.x;x>v&&(v=x),s.translate(y,{x:.5*h,y:.5*x}),u=y.bounds.max.x+i,o.addBody(d,y),l=y,m+=1}else u+=i}p+=v+a,u=e}return d},r.chain=function(e,t,n,r,s,c){for(var l=e.bodies,d=1;d<l.length;d++){var u=l[d-1],p=l[d],m=u.bounds.max.y-u.bounds.min.y,f=u.bounds.max.x-u.bounds.min.x,v=p.bounds.max.y-p.bounds.min.y,g={bodyA:u,pointA:{x:f*t,y:m*n},bodyB:p,pointB:{x:(p.bounds.max.x-p.bounds.min.x)*r,y:v*s}},y=a.extend(g,c);o.addConstraint(e,i.create(y))}return e.label+=" Chain",e},r.mesh=function(e,t,n,r,s){var c,l,d,u,p,m=e.bodies;for(c=0;c<n;c++){for(l=1;l<t;l++)d=m[l-1+c*t],u=m[l+c*t],o.addConstraint(e,i.create(a.extend({bodyA:d,bodyB:u},s)));if(c>0)for(l=0;l<t;l++)d=m[l+(c-1)*t],u=m[l+c*t],o.addConstraint(e,i.create(a.extend({bodyA:d,bodyB:u},s))),r&&l>0&&(p=m[l-1+(c-1)*t],o.addConstraint(e,i.create(a.extend({bodyA:p,bodyB:u},s)))),r&&l<t-1&&(p=m[l+1+(c-1)*t],o.addConstraint(e,i.create(a.extend({bodyA:p,bodyB:u},s))))}return e.label+=" Mesh",e},r.pyramid=function(e,t,n,o,i,a,c){return r.stack(e,t,n,o,i,a,(function(t,r,a,l,d,u){var p=Math.min(o,Math.ceil(n/2)),m=d?d.bounds.max.x-d.bounds.min.x:0;if(!(l>p||a<(l=p-l)||a>n-1-l))return 1===u&&s.translate(d,{x:(a+(n%2==1?1:-1))*m,y:0}),c(e+(d?a*m:0)+a*i,r,a,l,d,u)}))},r.newtonsCradle=function(e,t,n,r,a){for(var s=o.create({label:"Newtons Cradle"}),l=0;l<n;l++){var d=c.circle(e+l*(1.9*r),t+a,r,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),u=i.create({pointA:{x:e+l*(1.9*r),y:t},bodyB:d});o.addBody(s,d),o.addConstraint(s,u)}return s},r.car=function(e,t,n,r,a){var l=s.nextGroup(!0),d=.5*-n+20,u=.5*n-20,p=o.create({label:"Car"}),m=c.rectangle(e,t,n,r,{collisionFilter:{group:l},chamfer:{radius:.5*r},density:2e-4}),f=c.circle(e+d,t+0,a,{collisionFilter:{group:l},friction:.8}),v=c.circle(e+u,t+0,a,{collisionFilter:{group:l},friction:.8}),g=i.create({bodyB:m,pointB:{x:d,y:0},bodyA:f,stiffness:1,length:0}),y=i.create({bodyB:m,pointB:{x:u,y:0},bodyA:v,stiffness:1,length:0});return o.addBody(p,m),o.addBody(p,f),o.addBody(p,v),o.addConstraint(p,g),o.addConstraint(p,y),p},r.softBody=function(e,t,n,o,i,s,l,d,u,p){u=a.extend({inertia:1/0},u),p=a.extend({stiffness:.2,render:{type:"line",anchors:!1}},p);var m=r.stack(e,t,n,o,i,s,(function(e,t){return c.circle(e,t,d,u)}));return r.mesh(m,n,o,l,p),m.label="Soft Body",m}},C3Ti:function(e,t,n){var r=r||{};r.avalanche=function(){try{"undefined"!=typeof MatterWrap?Matter.use("matter-wrap"):Matter.use(n("OPlj"))}catch(e){}var e=Matter.Engine,t=Matter.Render,r=Matter.Runner,o=Matter.Composite,i=Matter.Composites,a=Matter.Common,s=Matter.MouseConstraint,c=Matter.Mouse,l=Matter.World,d=Matter.Bodies,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600,showAngleIndicator:!0}});t.run(m);var f=r.create();r.run(f,u);var v=i.stack(20,20,20,5,0,0,(function(e,t){return d.circle(e,t,a.random(10,20),{friction:1e-5,restitution:.5,density:.001})}));l.add(p,v),l.add(p,[d.rectangle(200,150,700,20,{isStatic:!0,angle:.06*Math.PI,render:{fillStyle:"#060a19"}}),d.rectangle(500,350,700,20,{isStatic:!0,angle:.06*-Math.PI,render:{fillStyle:"#060a19"}}),d.rectangle(340,580,700,20,{isStatic:!0,angle:.04*Math.PI,render:{fillStyle:"#060a19"}})]);var g=c.create(m.canvas),y=s.create(u,{mouse:g,constraint:{stiffness:.2,render:{visible:!1}}});l.add(p,y),m.mouse=g,t.lookAt(m,o.allBodies(p));for(var x=0;x<v.bodies.length;x+=1)v.bodies[x].plugin.wrap={min:{x:m.bounds.min.x,y:m.bounds.min.y},max:{x:m.bounds.max.x,y:m.bounds.max.y}};return{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.avalanche.title="Avalanche",r.avalanche.for=">=0.14.2",e.exports=r.avalanche},"C6Q+":function(e,t,n){var r=r||{};r.events=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Events,i=Matter.Composite,a=Matter.Composites,s=Matter.Common,c=Matter.MouseConstraint,l=Matter.Mouse,d=Matter.World,u=Matter.Bodies,p=e.create(),m=p.world,f=t.create({element:document.body,engine:p,options:{width:800,height:600,wireframes:!1}});t.run(f);var v=n.create();n.run(v,p),o.on(m,"afterAdd",(function(e){})),o.on(p,"beforeUpdate",(function(e){var t=e.source;e.timestamp%5e3<50&&x(t)})),o.on(p,"collisionStart",(function(e){for(var t=e.pairs,n=0;n<t.length;n++){var r=t[n];r.bodyA.render.fillStyle="#333",r.bodyB.render.fillStyle="#333"}})),o.on(p,"collisionActive",(function(e){for(var t=e.pairs,n=0;n<t.length;n++){var r=t[n];r.bodyA.render.fillStyle="#333",r.bodyB.render.fillStyle="#333"}})),o.on(p,"collisionEnd",(function(e){for(var t=e.pairs,n=0;n<t.length;n++){var r=t[n];r.bodyA.render.fillStyle="#222",r.bodyB.render.fillStyle="#222"}}));var g={fillStyle:"#222"};d.add(m,[u.rectangle(400,0,800,50,{isStatic:!0,render:g}),u.rectangle(400,600,800,50,{isStatic:!0,render:g}),u.rectangle(800,300,50,600,{isStatic:!0,render:g}),u.rectangle(0,300,50,600,{isStatic:!0,render:g})]);var y=a.stack(70,100,9,4,50,50,(function(e,t){return u.circle(e,t,15,{restitution:1,render:g})}));d.add(m,y);var x=function(e){for(var t=i.allBodies(e.world),n=0;n<t.length;n++){var o=t[n];if(!o.isStatic&&o.position.y>=500){var a=.02*o.mass;r.applyForce(o,o.position,{x:(a+s.random()*a)*s.choose([1,-1]),y:-a+s.random()*-a})}}},h=l.create(f.canvas),b=c.create(p,{mouse:h,constraint:{stiffness:.2,render:{visible:!1}}});return d.add(m,b),f.mouse=h,o.on(b,"mousedown",(function(e){var t=e.mouse.position;console.log("mousedown at "+t.x+" "+t.y),x(p)})),o.on(b,"mouseup",(function(e){var t=e.mouse.position;console.log("mouseup at "+t.x+" "+t.y)})),o.on(b,"startdrag",(function(e){console.log("startdrag",e)})),o.on(b,"enddrag",(function(e){console.log("enddrag",e)})),t.lookAt(f,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:p,runner:v,render:f,canvas:f.canvas,stop:function(){Matter.Render.stop(f),Matter.Runner.stop(v)}}},r.events.title="Events",r.events.for=">=0.14.2",e.exports=r.events},Czbd:function(e,t,n){var r=r||{};r.softBody=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.World,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!1}});t.run(d);var u=n.create();n.run(u,c);var p={friction:.05,frictionStatic:.1,render:{visible:!0}};a.add(l,[r.softBody(250,100,5,5,0,0,!0,18,p),r.softBody(400,300,8,3,0,0,!0,15,p),r.softBody(250,400,4,4,0,0,!0,15,p),s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.9,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.softBody.title="Soft Body",r.softBody.for=">=0.14.2",e.exports=r.softBody},DeYi:function(e,t,n){var r=r||{};r.friction=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.MouseConstraint,o=Matter.Mouse,i=Matter.World,a=Matter.Bodies,s=e.create(),c=s.world,l=t.create({element:document.body,engine:s,options:{width:800,height:600,showVelocity:!0}});t.run(l);var d=n.create();n.run(d,s),i.add(c,[a.rectangle(400,0,800,50,{isStatic:!0}),a.rectangle(400,600,800,50,{isStatic:!0}),a.rectangle(800,300,50,600,{isStatic:!0}),a.rectangle(0,300,50,600,{isStatic:!0})]),i.add(c,[a.rectangle(300,180,700,20,{isStatic:!0,angle:.06*Math.PI,render:{fillStyle:"#060a19"}}),a.rectangle(300,70,40,40,{friction:.001})]),i.add(c,[a.rectangle(300,350,700,20,{isStatic:!0,angle:.06*Math.PI,render:{fillStyle:"#060a19"}}),a.rectangle(300,250,40,40,{friction:5e-4})]),i.add(c,[a.rectangle(300,520,700,20,{isStatic:!0,angle:.06*Math.PI,render:{fillStyle:"#060a19"}}),a.rectangle(300,430,40,40,{friction:0})]);var u=o.create(l.canvas),p=r.create(s,{mouse:u,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(c,p),l.mouse=u,t.lookAt(l,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:s,runner:d,render:l,canvas:l.canvas,stop:function(){Matter.Render.stop(l),Matter.Runner.stop(d)}}},r.friction.title="Friction",r.friction.for=">=0.14.2",e.exports=r.friction},DqtB:function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=n("m6Dm");r.collides=function(e,t,n){var a,s,c,l,d=!1;if(n){var u=e.parent,p=t.parent,m=u.speed*u.speed+u.angularSpeed*u.angularSpeed+p.speed*p.speed+p.angularSpeed*p.angularSpeed;d=n&&n.collided&&m<.2,l=n}else l={collided:!1,bodyA:e,bodyB:t};if(n&&d){var f=l.axisBody,v=f===e?t:e,g=[f.axes[n.axisNumber]];if(c=r._overlapAxes(f.vertices,v.vertices,g),l.reused=!0,c.overlap<=0)return l.collided=!1,l}else{if((a=r._overlapAxes(e.vertices,t.vertices,e.axes)).overlap<=0)return l.collided=!1,l;if((s=r._overlapAxes(t.vertices,e.vertices,t.axes)).overlap<=0)return l.collided=!1,l;a.overlap<s.overlap?(c=a,l.axisBody=e):(c=s,l.axisBody=t),l.axisNumber=c.axisNumber}l.bodyA=e.id<t.id?e:t,l.bodyB=e.id<t.id?t:e,l.collided=!0,l.depth=c.overlap,l.parentA=l.bodyA.parent,l.parentB=l.bodyB.parent,e=l.bodyA,t=l.bodyB,i.dot(c.axis,i.sub(t.position,e.position))<0?l.normal={x:c.axis.x,y:c.axis.y}:l.normal={x:-c.axis.x,y:-c.axis.y},l.tangent=i.perp(l.normal),l.penetration=l.penetration||{},l.penetration.x=l.normal.x*l.depth,l.penetration.y=l.normal.y*l.depth;var y=r._findSupports(e,t,l.normal),x=[];if(o.contains(e.vertices,y[0])&&x.push(y[0]),o.contains(e.vertices,y[1])&&x.push(y[1]),x.length<2){var h=r._findSupports(t,e,i.neg(l.normal));o.contains(t.vertices,h[0])&&x.push(h[0]),x.length<2&&o.contains(t.vertices,h[1])&&x.push(h[1])}return x.length<1&&(x=[y[0]]),l.supports=x,l},r._overlapAxes=function(e,t,n){for(var o,a,s=i._temp[0],c=i._temp[1],l={overlap:Number.MAX_VALUE},d=0;d<n.length;d++){if(a=n[d],r._projectToAxis(s,e,a),r._projectToAxis(c,t,a),(o=Math.min(s.max-c.min,c.max-s.min))<=0)return l.overlap=o,l;o<l.overlap&&(l.overlap=o,l.axis=a,l.axisNumber=d)}return l},r._projectToAxis=function(e,t,n){for(var r=i.dot(t[0],n),o=r,a=1;a<t.length;a+=1){var s=i.dot(t[a],n);s>o?o=s:s<r&&(r=s)}e.min=r,e.max=o},r._findSupports=function(e,t,n){for(var r,o,a,s,c=Number.MAX_VALUE,l=i._temp[0],d=t.vertices,u=e.position,p=0;p<d.length;p++)o=d[p],l.x=o.x-u.x,l.y=o.y-u.y,(r=-i.dot(n,l))<c&&(c=r,a=o);return o=d[a.index-1>=0?a.index-1:d.length-1],l.x=o.x-u.x,l.y=o.y-u.y,c=-i.dot(n,l),s=o,o=d[(a.index+1)%d.length],l.x=o.x-u.x,l.y=o.y-u.y,(r=-i.dot(n,l))<c&&(s=o),[a,s]}},EUdY:function(e,t,n){var r=r||{};r.stress=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.World,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600}});t.run(d);var u=n.create();n.run(u,c);var p=r.stack(90,50,18,15,0,0,(function(e,t){return s.rectangle(e,t,35,35)}));a.add(l,[p,s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.stress.title="Stress",r.stress.for=">=0.14.2",e.exports=r.stress},I5nt:function(e,t,n){var r={};e.exports=r;var o=n("571F");r.create=function(e){var t={};return e||o.log("Mouse.create: element was undefined, defaulting to document.body","warn"),t.element=e||document.body,t.absolute={x:0,y:0},t.position={x:0,y:0},t.mousedownPosition={x:0,y:0},t.mouseupPosition={x:0,y:0},t.offset={x:0,y:0},t.scale={x:1,y:1},t.wheelDelta=0,t.button=-1,t.pixelRatio=parseInt(t.element.getAttribute("data-pixel-ratio"),10)||1,t.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},t.mousemove=function(e){var n=r._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&(t.button=0,e.preventDefault()),t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.sourceEvents.mousemove=e},t.mousedown=function(e){var n=r._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches?(t.button=0,e.preventDefault()):t.button=e.button,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.mousedownPosition.x=t.position.x,t.mousedownPosition.y=t.position.y,t.sourceEvents.mousedown=e},t.mouseup=function(e){var n=r._getRelativeMousePosition(e,t.element,t.pixelRatio);e.changedTouches&&e.preventDefault(),t.button=-1,t.absolute.x=n.x,t.absolute.y=n.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y,t.mouseupPosition.x=t.position.x,t.mouseupPosition.y=t.position.y,t.sourceEvents.mouseup=e},t.mousewheel=function(e){t.wheelDelta=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),e.preventDefault()},r.setElement(t,t.element),t},r.setElement=function(e,t){e.element=t,t.addEventListener("mousemove",e.mousemove),t.addEventListener("mousedown",e.mousedown),t.addEventListener("mouseup",e.mouseup),t.addEventListener("mousewheel",e.mousewheel),t.addEventListener("DOMMouseScroll",e.mousewheel),t.addEventListener("touchmove",e.mousemove),t.addEventListener("touchstart",e.mousedown),t.addEventListener("touchend",e.mouseup)},r.clearSourceEvents=function(e){e.sourceEvents.mousemove=null,e.sourceEvents.mousedown=null,e.sourceEvents.mouseup=null,e.sourceEvents.mousewheel=null,e.wheelDelta=0},r.setOffset=function(e,t){e.offset.x=t.x,e.offset.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},r.setScale=function(e,t){e.scale.x=t.x,e.scale.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},r._getRelativeMousePosition=function(e,t,n){var r,o,i=t.getBoundingClientRect(),a=document.documentElement||document.body.parentNode||document.body,s=void 0!==window.pageXOffset?window.pageXOffset:a.scrollLeft,c=void 0!==window.pageYOffset?window.pageYOffset:a.scrollTop,l=e.changedTouches;return l?(r=l[0].pageX-i.left-s,o=l[0].pageY-i.top-c):(r=e.pageX-i.left-s,o=e.pageY-i.top-c),{x:r/(t.clientWidth/(t.width||t.clientWidth)*n),y:o/(t.clientHeight/(t.height||t.clientHeight)*n)}}},IOLg:function(e,t,n){var r=r||{};r.concave=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Vertices,l=Matter.Bodies,d=e.create(),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600}});t.run(p);var m=n.create();n.run(m,d),s.add(u,[l.rectangle(400,0,800,50,{isStatic:!0}),l.rectangle(400,600,800,50,{isStatic:!0}),l.rectangle(800,300,50,600,{isStatic:!0}),l.rectangle(0,300,50,600,{isStatic:!0})]);var f=c.fromPath("40 0 40 20 100 20 100 80 40 80 40 100 0 50"),v=c.fromPath("100 0 75 50 100 100 25 100 0 50 25 0"),g=c.fromPath("50 0 63 38 100 38 69 59 82 100 50 75 18 100 31 59 0 38 37 38"),y=c.fromPath("35 7 19 17 14 38 14 58 25 79 45 85 65 84 65 66 46 67 34 59 30 44 33 29 45 23 66 23 66 7 53 7"),x=r.stack(50,50,6,4,10,10,(function(e,t){var n=o.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]);return l.fromVertices(e,t,o.choose([f,v,g,y]),{render:{fillStyle:n,strokeStyle:n,lineWidth:1}},!0)}));s.add(u,x);var h=a.create(p.canvas),b=i.create(d,{mouse:h,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(u,b),p.mouse=h,t.lookAt(p,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},r.concave.title="Concave",r.concave.for=">=0.14.2",e.exports=r.concave},IbIC:function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=n("m6Dm"),a=n("yw0d"),s=(n("lWug"),n("571F")),c=n("Tgw/"),l=n("JKEF");!function(){r._inertiaScale=4,r._nextCollidingGroupId=1,r._nextNonCollidingGroupId=-1,r._nextCategory=1,r.create=function(t){var n={id:s.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:o.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,strokeStyle:null,fillStyle:null,lineWidth:null,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0}},events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inertia:0,_original:null},r=s.extend(n,t);return e(r,t),r},r.nextGroup=function(e){return e?r._nextNonCollidingGroupId--:r._nextCollidingGroupId++},r.nextCategory=function(){return r._nextCategory=r._nextCategory<<1,r._nextCategory};var e=function(e,t){t=t||{},r.set(e,{bounds:e.bounds||c.create(e.vertices),positionPrev:e.positionPrev||i.clone(e.position),anglePrev:e.anglePrev||e.angle,vertices:e.vertices,parts:e.parts||[e],isStatic:e.isStatic,isSleeping:e.isSleeping,parent:e.parent||e}),o.rotate(e.vertices,e.angle,e.position),l.rotate(e.axes,e.angle),c.update(e.bounds,e.vertices,e.velocity),r.set(e,{axes:t.axes||e.axes,area:t.area||e.area,mass:t.mass||e.mass,inertia:t.inertia||e.inertia});var n=e.isStatic?"#14151f":s.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),a=e.isStatic?"#555":"#ccc",d=e.isStatic&&null===e.render.fillStyle?1:0;e.render.fillStyle=e.render.fillStyle||n,e.render.strokeStyle=e.render.strokeStyle||a,e.render.lineWidth=e.render.lineWidth||d,e.render.sprite.xOffset+=-(e.bounds.min.x-e.position.x)/(e.bounds.max.x-e.bounds.min.x),e.render.sprite.yOffset+=-(e.bounds.min.y-e.position.y)/(e.bounds.max.y-e.bounds.min.y)};r.set=function(e,t,n){var o;for(o in"string"==typeof t&&(o=t,(t={})[o]=n),t)if(Object.prototype.hasOwnProperty.call(t,o))switch(n=t[o],o){case"isStatic":r.setStatic(e,n);break;case"isSleeping":a.set(e,n);break;case"mass":r.setMass(e,n);break;case"density":r.setDensity(e,n);break;case"inertia":r.setInertia(e,n);break;case"vertices":r.setVertices(e,n);break;case"position":r.setPosition(e,n);break;case"angle":r.setAngle(e,n);break;case"velocity":r.setVelocity(e,n);break;case"angularVelocity":r.setAngularVelocity(e,n);break;case"parts":r.setParts(e,n);break;case"centre":r.setCentre(e,n);break;default:e[o]=n}},r.setStatic=function(e,t){for(var n=0;n<e.parts.length;n++){var r=e.parts[n];r.isStatic=t,t?(r._original={restitution:r.restitution,friction:r.friction,mass:r.mass,inertia:r.inertia,density:r.density,inverseMass:r.inverseMass,inverseInertia:r.inverseInertia},r.restitution=0,r.friction=1,r.mass=r.inertia=r.density=1/0,r.inverseMass=r.inverseInertia=0,r.positionPrev.x=r.position.x,r.positionPrev.y=r.position.y,r.anglePrev=r.angle,r.angularVelocity=0,r.speed=0,r.angularSpeed=0,r.motion=0):r._original&&(r.restitution=r._original.restitution,r.friction=r._original.friction,r.mass=r._original.mass,r.inertia=r._original.inertia,r.density=r._original.density,r.inverseMass=r._original.inverseMass,r.inverseInertia=r._original.inverseInertia,r._original=null)}},r.setMass=function(e,t){var n=e.inertia/(e.mass/6);e.inertia=n*(t/6),e.inverseInertia=1/e.inertia,e.mass=t,e.inverseMass=1/e.mass,e.density=e.mass/e.area},r.setDensity=function(e,t){r.setMass(e,t*e.area),e.density=t},r.setInertia=function(e,t){e.inertia=t,e.inverseInertia=1/e.inertia},r.setVertices=function(e,t){t[0].body===e?e.vertices=t:e.vertices=o.create(t,e),e.axes=l.fromVertices(e.vertices),e.area=o.area(e.vertices),r.setMass(e,e.density*e.area);var n=o.centre(e.vertices);o.translate(e.vertices,n,-1),r.setInertia(e,r._inertiaScale*o.inertia(e.vertices,e.mass)),o.translate(e.vertices,e.position),c.update(e.bounds,e.vertices,e.velocity)},r.setParts=function(e,t,n){var i;for(t=t.slice(0),e.parts.length=0,e.parts.push(e),e.parent=e,i=0;i<t.length;i++){var a=t[i];a!==e&&(a.parent=e,e.parts.push(a))}if(1!==e.parts.length){if(n=void 0===n||n){var s=[];for(i=0;i<t.length;i++)s=s.concat(t[i].vertices);o.clockwiseSort(s);var c=o.hull(s),l=o.centre(c);r.setVertices(e,c),o.translate(e.vertices,l)}var d=r._totalProperties(e);e.area=d.area,e.parent=e,e.position.x=d.centre.x,e.position.y=d.centre.y,e.positionPrev.x=d.centre.x,e.positionPrev.y=d.centre.y,r.setMass(e,d.mass),r.setInertia(e,d.inertia),r.setPosition(e,d.centre)}},r.setCentre=function(e,t,n){n?(e.positionPrev.x+=t.x,e.positionPrev.y+=t.y,e.position.x+=t.x,e.position.y+=t.y):(e.positionPrev.x=t.x-(e.position.x-e.positionPrev.x),e.positionPrev.y=t.y-(e.position.y-e.positionPrev.y),e.position.x=t.x,e.position.y=t.y)},r.setPosition=function(e,t){var n=i.sub(t,e.position);e.positionPrev.x+=n.x,e.positionPrev.y+=n.y;for(var r=0;r<e.parts.length;r++){var a=e.parts[r];a.position.x+=n.x,a.position.y+=n.y,o.translate(a.vertices,n),c.update(a.bounds,a.vertices,e.velocity)}},r.setAngle=function(e,t){var n=t-e.angle;e.anglePrev+=n;for(var r=0;r<e.parts.length;r++){var a=e.parts[r];a.angle+=n,o.rotate(a.vertices,n,e.position),l.rotate(a.axes,n),c.update(a.bounds,a.vertices,e.velocity),r>0&&i.rotateAbout(a.position,n,e.position,a.position)}},r.setVelocity=function(e,t){e.positionPrev.x=e.position.x-t.x,e.positionPrev.y=e.position.y-t.y,e.velocity.x=t.x,e.velocity.y=t.y,e.speed=i.magnitude(e.velocity)},r.setAngularVelocity=function(e,t){e.anglePrev=e.angle-t,e.angularVelocity=t,e.angularSpeed=Math.abs(e.angularVelocity)},r.translate=function(e,t){r.setPosition(e,i.add(e.position,t))},r.rotate=function(e,t,n){if(n){var o=Math.cos(t),i=Math.sin(t),a=e.position.x-n.x,s=e.position.y-n.y;r.setPosition(e,{x:n.x+(a*o-s*i),y:n.y+(a*i+s*o)}),r.setAngle(e,e.angle+t)}else r.setAngle(e,e.angle+t)},r.scale=function(e,t,n,i){var a=0,s=0;i=i||e.position;for(var d=0;d<e.parts.length;d++){var u=e.parts[d];o.scale(u.vertices,t,n,i),u.axes=l.fromVertices(u.vertices),u.area=o.area(u.vertices),r.setMass(u,e.density*u.area),o.translate(u.vertices,{x:-u.position.x,y:-u.position.y}),r.setInertia(u,r._inertiaScale*o.inertia(u.vertices,u.mass)),o.translate(u.vertices,{x:u.position.x,y:u.position.y}),d>0&&(a+=u.area,s+=u.inertia),u.position.x=i.x+(u.position.x-i.x)*t,u.position.y=i.y+(u.position.y-i.y)*n,c.update(u.bounds,u.vertices,e.velocity)}e.parts.length>1&&(e.area=a,e.isStatic||(r.setMass(e,e.density*a),r.setInertia(e,s))),e.circleRadius&&(t===n?e.circleRadius*=t:e.circleRadius=null)},r.update=function(e,t,n,r){var a=Math.pow(t*n*e.timeScale,2),s=1-e.frictionAir*n*e.timeScale,d=e.position.x-e.positionPrev.x,u=e.position.y-e.positionPrev.y;e.velocity.x=d*s*r+e.force.x/e.mass*a,e.velocity.y=u*s*r+e.force.y/e.mass*a,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.position.x+=e.velocity.x,e.position.y+=e.velocity.y,e.angularVelocity=(e.angle-e.anglePrev)*s*r+e.torque/e.inertia*a,e.anglePrev=e.angle,e.angle+=e.angularVelocity,e.speed=i.magnitude(e.velocity),e.angularSpeed=Math.abs(e.angularVelocity);for(var p=0;p<e.parts.length;p++){var m=e.parts[p];o.translate(m.vertices,e.velocity),p>0&&(m.position.x+=e.velocity.x,m.position.y+=e.velocity.y),0!==e.angularVelocity&&(o.rotate(m.vertices,e.angularVelocity,e.position),l.rotate(m.axes,e.angularVelocity),p>0&&i.rotateAbout(m.position,e.angularVelocity,e.position,m.position)),c.update(m.bounds,m.vertices,e.velocity)}},r.applyForce=function(e,t,n){e.force.x+=n.x,e.force.y+=n.y;var r=t.x-e.position.x,o=t.y-e.position.y;e.torque+=r*n.y-o*n.x},r._totalProperties=function(e){for(var t={mass:0,area:0,inertia:0,centre:{x:0,y:0}},n=1===e.parts.length?0:1;n<e.parts.length;n++){var r=e.parts[n],o=r.mass!==1/0?r.mass:1;t.mass+=o,t.area+=r.area,t.inertia+=r.inertia,t.centre=i.add(t.centre,i.mult(r.position,o))}return t.centre=i.div(t.centre,t.mass),t}}()},Inl5:function(e,t,n){var r={};e.exports=r;var o=n("wAS/"),i=(n("ga9t"),n("571F"));r.create=function(e){var t=o.create(),n={label:"World",gravity:{x:0,y:1,scale:.001},bounds:{min:{x:-1/0,y:-1/0},max:{x:1/0,y:1/0}}};return i.extend(t,n,e)}},JBRW:function(e,t,n){e.exports={airFriction:n("6IAi"),avalanche:n("C3Ti"),ballPool:n("02te"),bridge:n("wycb"),broadphase:n("O3vJ"),car:n("Me0I"),catapult:n("0mtl"),chains:n("ZUN1"),circleStack:n("zc7U"),cloth:n("siNf"),collisionFiltering:n("Zo9v"),compositeManipulation:n("a3OZ"),compound:n("djnZ"),compoundStack:n("JbtQ"),concave:n("IOLg"),constraints:n("+jwT"),doublePendulum:n("74MQ"),events:n("C6Q+"),friction:n("DeYi"),gravity:n("7MJU"),gyro:n("k7Ch"),manipulation:n("VZUp"),mixed:n("ibhy"),newtonsCradle:n("xoNv"),ragdoll:n("c7us"),pyramid:n("5ocS"),raycasting:n("2oV2"),restitution:n("ZRMD"),rounded:n("elWf"),sensors:n("yWqE"),sleeping:n("LHSH"),slingshot:n("136C"),softBody:n("Czbd"),sprites:n("tlRp"),stack:n("ZpbE"),staticFriction:n("4XQC"),stress:n("EUdY"),stress2:n("Qnbh"),svg:n("/iAh"),terrain:n("52dP"),timescale:n("+QOk"),views:n("MhOg"),wreckingBall:n("LS1c")}},JKEF:function(e,t,n){var r={};e.exports=r;var o=n("m6Dm"),i=n("571F");r.fromVertices=function(e){for(var t={},n=0;n<e.length;n++){var r=(n+1)%e.length,a=o.normalise({x:e[r].y-e[n].y,y:e[n].x-e[r].x}),s=0===a.y?1/0:a.x/a.y;t[s=s.toFixed(3).toString()]=a}return i.values(t)},r.rotate=function(e,t){if(0!==t)for(var n=Math.cos(t),r=Math.sin(t),o=0;o<e.length;o++){var i,a=e[o];i=a.x*n-a.y*r,a.y=a.x*r+a.y*n,a.x=i}}},JbtQ:function(e,t,n){var r=r||{};r.compoundStack=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Composites,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l);var m=o.stack(100,283,12,6,0,0,(function(e,t){var n=c.rectangle(e,t,50,10),o=c.rectangle(e,t,10,50,{render:n.render});return r.create({parts:[n,o]})}));s.add(d,[m,c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0}),c.rectangle(400,609,800,50,{isStatic:!0})]);var f=a.create(u.canvas),v=i.create(l,{mouse:f,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,v),u.mouse=f,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.compoundStack.title="Compound Stack",r.compoundStack.for=">=0.14.2",e.exports=r.compoundStack},LHSH:function(e,t,n){var r=r||{};r.sleeping=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.Events,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.World,l=Matter.Bodies,d=e.create({enableSleeping:!0}),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600,showAngleIndicator:!0}});t.run(p);var m=n.create();n.run(m,d),c.add(u,[l.rectangle(400,0,800,50,{isStatic:!0}),l.rectangle(400,600,800,50,{isStatic:!0}),l.rectangle(800,300,50,600,{isStatic:!0}),l.rectangle(0,300,50,600,{isStatic:!0})]);var f=r.stack(50,50,12,3,0,0,(function(e,t){switch(Math.round(o.random(0,1))){case 0:return o.random()<.8?l.rectangle(e,t,o.random(20,50),o.random(20,50)):l.rectangle(e,t,o.random(80,120),o.random(20,30));case 1:return l.polygon(e,t,Math.round(o.random(1,8)),o.random(20,50))}}));c.add(u,f);for(var v=0;v<f.bodies.length;v++)i.on(f.bodies[v],"sleepStart sleepEnd",(function(e){console.log("body id",this.id,"sleeping:",this.isSleeping)}));var g=s.create(p.canvas),y=a.create(d,{mouse:g,constraint:{stiffness:.2,render:{visible:!1}}});return c.add(u,y),p.mouse=g,t.lookAt(p,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},r.sleeping.title="Sleeping",r.sleeping.for=">=0.14.2",e.exports=r.sleeping},LJ2B:function(e,t,n){var r={};e.exports=r;var o=n("wAS/"),i=n("571F");r.create=function(e){return i.extend({extended:!1,narrowDetections:0,narrowphaseTests:0,narrowReuse:0,narrowReuseCount:0,midphaseTests:0,broadphaseTests:0,narrowEff:1e-4,midEff:1e-4,broadEff:1e-4,collisions:0,buckets:0,bodies:0,pairs:0},!1,e)},r.reset=function(e){e.extended&&(e.narrowDetections=0,e.narrowphaseTests=0,e.narrowReuse=0,e.narrowReuseCount=0,e.midphaseTests=0,e.broadphaseTests=0,e.narrowEff=0,e.midEff=0,e.broadEff=0,e.collisions=0,e.buckets=0,e.pairs=0,e.bodies=0)},r.update=function(e,t){if(e.extended){var n=t.world,r=o.allBodies(n);e.collisions=e.narrowDetections,e.pairs=t.pairs.list.length,e.bodies=r.length,e.midEff=(e.narrowDetections/(e.midphaseTests||1)).toFixed(2),e.narrowEff=(e.narrowDetections/(e.narrowphaseTests||1)).toFixed(2),e.broadEff=(1-e.broadphaseTests/(r.length||1)).toFixed(2),e.narrowReuse=(e.narrowReuseCount/(e.narrowphaseTests||1)).toFixed(2)}}},LS1c:function(e,t,n){var r=r||{};r.wreckingBall=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.World,s=Matter.Constraint,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l);var m=r.stack(400,175,5,10,0,0,(function(e,t){return c.rectangle(e,t,40,40)}));a.add(d,[m,c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var f=c.circle(100,400,50,{density:.04,frictionAir:.005});a.add(d,f),a.add(d,s.create({pointA:{x:300,y:100},bodyB:f}));var v=i.create(u.canvas),g=o.create(l,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(d,g),u.mouse=v,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.wreckingBall.title="Wrecking Ball",r.wreckingBall.for=">=0.14.2",e.exports=r.wreckingBall},Me0I:function(e,t,n){var r=r||{};r.car=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.World,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!0,showCollisions:!0}});t.run(d);var u=n.create();n.run(u,c),a.add(l,[s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0})]);var p=.9;a.add(l,r.car(150,100,150*p,30*p,30*p)),p=.8,a.add(l,r.car(350,300,150*p,30*p,30*p)),a.add(l,[s.rectangle(200,150,400,20,{isStatic:!0,angle:.06*Math.PI,render:{fillStyle:"#060a19"}}),s.rectangle(500,350,650,20,{isStatic:!0,angle:.06*-Math.PI,render:{fillStyle:"#060a19"}}),s.rectangle(300,560,600,20,{isStatic:!0,angle:.04*Math.PI,render:{fillStyle:"#060a19"}})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.car.title="Car",r.car.for=">=0.14.2",e.exports=r.car},MhOg:function(e,t,n){var r=r||{};r.views=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Events,o=Matter.Composites,i=Matter.Common,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.World,l=Matter.Vector,d=Matter.Bounds,u=Matter.Bodies,p=e.create(),m=p.world,f=t.create({element:document.body,engine:p,options:{width:800,height:600,hasBounds:!0,showAngleIndicator:!0}});t.run(f);var v=n.create();n.run(v,p);var g=s.create(f.canvas),y=a.create(p,{mouse:g,constraint:{stiffness:.2,render:{visible:!1}}});c.add(m,y),f.mouse=g;var x=o.stack(20,20,15,4,0,0,(function(e,t){switch(Math.round(i.random(0,1))){case 0:return i.random()<.8?u.rectangle(e,t,i.random(20,50),i.random(20,50)):u.rectangle(e,t,i.random(80,120),i.random(20,30));case 1:var n=Math.round(i.random(1,8));return n=3===n?4:n,u.polygon(e,t,n,i.random(20,50))}}));c.add(m,[x,u.rectangle(400,0,800,50,{isStatic:!0}),u.rectangle(400,600,800,50,{isStatic:!0}),u.rectangle(800,300,50,600,{isStatic:!0}),u.rectangle(0,300,50,600,{isStatic:!0})]);var h={x:.5*f.options.width,y:.5*f.options.height};m.bounds.min.x=-300,m.bounds.min.y=-300,m.bounds.max.x=1100,m.bounds.max.y=900;var b=1,M={x:1,y:1};return r.on(p,"beforeTick",(function(){var e,t=p.world,n=y.mouse,r=-.1*n.wheelDelta;0!==r&&(r<0&&M.x>=.6||r>0&&M.x<=1.4)&&(b+=r),Math.abs(M.x-b)>.01&&(r=.2*(b-M.x),M.x+=r,M.y+=r,f.bounds.max.x=f.bounds.min.x+f.options.width*M.x,f.bounds.max.y=f.bounds.min.y+f.options.height*M.y,e={x:f.options.width*r*-.5,y:f.options.height*r*-.5},d.translate(f.bounds,e),s.setScale(n,M),s.setOffset(n,f.bounds.min));var o=l.sub(n.absolute,h),i=l.magnitude(o);if(i>50){var a=l.normalise(o),c=Math.min(10,2e-4*Math.pow(i-50,2));e=l.mult(a,c),f.bounds.min.x+e.x<t.bounds.min.x&&(e.x=t.bounds.min.x-f.bounds.min.x),f.bounds.max.x+e.x>t.bounds.max.x&&(e.x=t.bounds.max.x-f.bounds.max.x),f.bounds.min.y+e.y<t.bounds.min.y&&(e.y=t.bounds.min.y-f.bounds.min.y),f.bounds.max.y+e.y>t.bounds.max.y&&(e.y=t.bounds.max.y-f.bounds.max.y),d.translate(f.bounds,e),s.setOffset(n,f.bounds.min)}})),{engine:p,runner:v,render:f,canvas:f.canvas,stop:function(){Matter.Render.stop(f),Matter.Runner.stop(v)}}},r.views.title="Views",r.views.for=">=0.14.2",e.exports=r.views},NDQ1:function(e,t,n){var r={};e.exports=r;var o=n("m6Dm"),i=n("DqtB"),a=n("Tgw/"),s=n("oT59"),c=n("0kzT");r.collides=function(e,t){for(var n=[],r=0;r<t.length;r++){var o=t[r];if(a.overlaps(o.bounds,e.bounds))for(var s=1===o.parts.length?0:1;s<o.parts.length;s++){var c=o.parts[s];if(a.overlaps(c.bounds,e.bounds)){var l=i.collides(c,e);if(l.collided){n.push(l);break}}}}return n},r.ray=function(e,t,n,i){i=i||1e-100;for(var a=o.angle(t,n),c=o.magnitude(o.sub(t,n)),l=.5*(n.x+t.x),d=.5*(n.y+t.y),u=s.rectangle(l,d,c,i,{angle:a}),p=r.collides(u,e),m=0;m<p.length;m+=1){var f=p[m];f.body=f.bodyB=f.bodyA}return p},r.region=function(e,t,n){for(var r=[],o=0;o<e.length;o++){var i=e[o],s=a.overlaps(i.bounds,t);(s&&!n||!s&&n)&&r.push(i)}return r},r.point=function(e,t){for(var n=[],r=0;r<e.length;r++){var o=e[r];if(a.contains(o.bounds,t))for(var i=1===o.parts.length?0:1;i<o.parts.length;i++){var s=o.parts[i];if(a.contains(s.bounds,t)&&c.contains(s.vertices,t)){n.push(o);break}}}return n}},O3vJ:function(e,t,n){var r=r||{};r.broadphase=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!0,showBroadphase:!0}});t.run(u);var p=n.create();n.run(p,l),s.add(d,[c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var m=r.stack(20,20,12,5,0,0,(function(e,t){switch(Math.round(o.random(0,1))){case 0:return o.random()<.8?c.rectangle(e,t,o.random(20,50),o.random(20,50)):c.rectangle(e,t,o.random(80,120),o.random(20,30));case 1:return c.polygon(e,t,Math.round(o.random(1,8)),o.random(20,50))}}));s.add(d,m);var f=a.create(u.canvas),v=i.create(l,{mouse:f,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,v),u.mouse=f,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.broadphase.title="Broadphase",r.broadphase.for=">=0.14.2",e.exports=r.broadphase},Qnbh:function(e,t,n){var r=r||{};r.stress2=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.World,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600}});t.run(d);var u=n.create();n.run(u,c);var p=r.stack(100,125,25,18,0,0,(function(e,t){return s.rectangle(e,t,25,25)}));a.add(l,[p,s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.stress2.title="Stress 2",r.stress2.for=">=0.14.2",e.exports=r.stress2},Sq1W:function(e,t,n){var r={};e.exports=r;var o=n("t8gT"),i=n("ix+/"),a=n("571F");r.create=function(e){var t={controller:r,detector:i.collisions,buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return a.extend(t,e)},r.update=function(e,t,n,o){var i,a,s,c,l,d=n.world,u=e.buckets,p=!1,m=n.metrics;for(m.broadphaseTests=0,i=0;i<t.length;i++){var f=t[i];if((!f.isSleeping||o)&&!(f.bounds.max.x<d.bounds.min.x||f.bounds.min.x>d.bounds.max.x||f.bounds.max.y<d.bounds.min.y||f.bounds.min.y>d.bounds.max.y)){var v=r._getRegion(e,f);if(!f.region||v.id!==f.region.id||o){m.broadphaseTests+=1,f.region&&!o||(f.region=v);var g=r._regionUnion(v,f.region);for(a=g.startCol;a<=g.endCol;a++)for(s=g.startRow;s<=g.endRow;s++){c=u[l=r._getBucketId(a,s)];var y=a>=v.startCol&&a<=v.endCol&&s>=v.startRow&&s<=v.endRow,x=a>=f.region.startCol&&a<=f.region.endCol&&s>=f.region.startRow&&s<=f.region.endRow;!y&&x&&x&&c&&r._bucketRemoveBody(e,c,f),(f.region===v||y&&!x||o)&&(c||(c=r._createBucket(u,l)),r._bucketAddBody(e,c,f))}f.region=v,p=!0}}}p&&(e.pairsList=r._createActivePairsList(e))},r.clear=function(e){e.buckets={},e.pairs={},e.pairsList=[]},r._regionUnion=function(e,t){var n=Math.min(e.startCol,t.startCol),o=Math.max(e.endCol,t.endCol),i=Math.min(e.startRow,t.startRow),a=Math.max(e.endRow,t.endRow);return r._createRegion(n,o,i,a)},r._getRegion=function(e,t){var n=t.bounds,o=Math.floor(n.min.x/e.bucketWidth),i=Math.floor(n.max.x/e.bucketWidth),a=Math.floor(n.min.y/e.bucketHeight),s=Math.floor(n.max.y/e.bucketHeight);return r._createRegion(o,i,a,s)},r._createRegion=function(e,t,n,r){return{id:e+","+t+","+n+","+r,startCol:e,endCol:t,startRow:n,endRow:r}},r._getBucketId=function(e,t){return"C"+e+"R"+t},r._createBucket=function(e,t){return e[t]=[]},r._bucketAddBody=function(e,t,n){for(var r=0;r<t.length;r++){var i=t[r];if(!(n.id===i.id||n.isStatic&&i.isStatic)){var a=o.id(n,i),s=e.pairs[a];s?s[2]+=1:e.pairs[a]=[n,i,1]}}t.push(n)},r._bucketRemoveBody=function(e,t,n){t.splice(a.indexOf(t,n),1);for(var r=0;r<t.length;r++){var i=t[r],s=o.id(n,i),c=e.pairs[s];c&&(c[2]-=1)}},r._createActivePairsList=function(e){var t,n,r=[];t=a.keys(e.pairs);for(var o=0;o<t.length;o++)(n=e.pairs[t[o]])[2]>0?r.push(n):delete e.pairs[t[o]];return r}},"Tgw/":function(e,t){var n={};e.exports=n,n.create=function(e){var t={min:{x:0,y:0},max:{x:0,y:0}};return e&&n.update(t,e),t},n.update=function(e,t,n){e.min.x=1/0,e.max.x=-1/0,e.min.y=1/0,e.max.y=-1/0;for(var r=0;r<t.length;r++){var o=t[r];o.x>e.max.x&&(e.max.x=o.x),o.x<e.min.x&&(e.min.x=o.x),o.y>e.max.y&&(e.max.y=o.y),o.y<e.min.y&&(e.min.y=o.y)}n&&(n.x>0?e.max.x+=n.x:e.min.x+=n.x,n.y>0?e.max.y+=n.y:e.min.y+=n.y)},n.contains=function(e,t){return t.x>=e.min.x&&t.x<=e.max.x&&t.y>=e.min.y&&t.y<=e.max.y},n.overlaps=function(e,t){return e.min.x<=t.max.x&&e.max.x>=t.min.x&&e.max.y>=t.min.y&&e.min.y<=t.max.y},n.translate=function(e,t){e.min.x+=t.x,e.max.x+=t.x,e.min.y+=t.y,e.max.y+=t.y},n.shift=function(e,t){var n=e.max.x-e.min.x,r=e.max.y-e.min.y;e.min.x=t.x,e.max.x=t.x+n,e.min.y=t.y,e.max.y=t.y+r}},VZUp:function(e,t,n){var r=r||{};r.manipulation=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Events,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAxes:!0,showCollisions:!0,showConvexHulls:!0}});t.run(u);var p=n.create();n.run(p,l);var m=c.rectangle(100,200,50,50,{isStatic:!0,render:{fillStyle:"#060a19"}}),f=c.rectangle(200,200,50,50),v=c.rectangle(300,200,50,50),g=c.rectangle(400,200,50,50),y=c.rectangle(550,200,50,50),x=c.rectangle(700,200,50,50),h=c.circle(400,100,25,{render:{fillStyle:"#060a19"}}),b=c.rectangle(600,200,120,50,{render:{fillStyle:"#060a19"}}),M=c.rectangle(660,200,50,190,{render:{fillStyle:"#060a19"}}),w=r.create({parts:[b,M],isStatic:!0});s.add(d,[m,f,v,g,y,x,h,w]),s.add(d,[c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var S=0,A=1.01;o.on(l,"beforeUpdate",(function(e){40===(S+=1)&&r.setStatic(h,!0),A>1&&(r.scale(x,A,A),r.scale(w,.995,.995),y.vertices[0].x-=.2,y.vertices[0].y-=.2,y.vertices[1].x+=.2,y.vertices[1].y-=.2,r.setVertices(y,y.vertices));var t=300+100*Math.sin(.002*l.timing.timestamp);r.setVelocity(m,{x:0,y:t-m.position.y}),r.setPosition(m,{x:100,y:t}),r.setVelocity(w,{x:0,y:t-w.position.y}),r.setAngularVelocity(w,.02),r.setPosition(w,{x:600,y:t}),r.rotate(w,.02),S>=90&&(r.setVelocity(f,{x:0,y:-10}),r.setAngle(v,.26*-Math.PI),r.setAngularVelocity(g,.2),S=0,A=1)}));var C=a.create(u.canvas),B=i.create(l,{mouse:C,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,B),u.mouse=C,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.manipulation.title="Manipulation",r.manipulation.for=">=0.14.2",e.exports=r.manipulation},ZRMD:function(e,t,n){var r=r||{};r.restitution=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.MouseConstraint,o=Matter.Mouse,i=Matter.World,a=Matter.Bodies,s=e.create(),c=s.world,l=t.create({element:document.body,engine:s,options:{width:800,height:600,showAngleIndicator:!0,showCollisions:!0,showVelocity:!0}});t.run(l);var d=n.create();n.run(d,s);var u=.9;i.add(c,[a.rectangle(100,150,50,50,{restitution:u}),a.rectangle(220,150,50,50,{restitution:u,angle:.15*-Math.PI}),a.rectangle(340,150,50,50,{restitution:u,angle:.25*-Math.PI}),a.circle(460,150,25,{restitution:u}),a.rectangle(700,150,180,20,{restitution:u,angle:.5*-Math.PI}),a.rectangle(400,0,800,50,{isStatic:!0}),a.rectangle(400,600,800,50,{isStatic:!0}),a.rectangle(800,300,50,600,{isStatic:!0}),a.rectangle(0,300,50,600,{isStatic:!0})]);var p=o.create(l.canvas),m=r.create(s,{mouse:p,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(c,m),l.mouse=p,t.lookAt(l,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:s,runner:d,render:l,canvas:l.canvas,stop:function(){Matter.Render.stop(l),Matter.Runner.stop(d)}}},r.restitution.title="Restitution",r.restitution.for=">=0.14.2",e.exports=r.restitution},ZUN1:function(e,t,n){var r=r||{};r.chains=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Composite,i=Matter.Composites,a=Matter.Constraint,s=Matter.MouseConstraint,c=Matter.Mouse,l=Matter.World,d=Matter.Bodies,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600,showAngleIndicator:!0,showCollisions:!0,showVelocity:!0}});t.run(m);var f=n.create();n.run(f,u);var v=r.nextGroup(!0),g=i.stack(100,50,8,1,10,10,(function(e,t){return d.rectangle(e,t,50,20,{collisionFilter:{group:v}})}));i.chain(g,.5,0,-.5,0,{stiffness:.8,length:2,render:{type:"line"}}),o.add(g,a.create({bodyB:g.bodies[0],pointB:{x:-25,y:0},pointA:{x:g.bodies[0].position.x,y:g.bodies[0].position.y},stiffness:.5})),v=r.nextGroup(!0);var y=i.stack(350,50,10,1,10,10,(function(e,t){return d.circle(e,t,20,{collisionFilter:{group:v}})}));i.chain(y,.5,0,-.5,0,{stiffness:.8,length:2,render:{type:"line"}}),o.add(y,a.create({bodyB:y.bodies[0],pointB:{x:-20,y:0},pointA:{x:y.bodies[0].position.x,y:y.bodies[0].position.y},stiffness:.5})),v=r.nextGroup(!0);var x=i.stack(600,50,13,1,10,10,(function(e,t){return d.rectangle(e-20,t,50,20,{collisionFilter:{group:v},chamfer:5})}));i.chain(x,.3,0,-.3,0,{stiffness:1,length:0}),o.add(x,a.create({bodyB:x.bodies[0],pointB:{x:-20,y:0},pointA:{x:x.bodies[0].position.x,y:x.bodies[0].position.y},stiffness:.5})),l.add(p,[g,y,x,d.rectangle(400,600,1200,50.5,{isStatic:!0})]);var h=c.create(m.canvas),b=s.create(u,{mouse:h,constraint:{stiffness:.2,render:{visible:!1}}});return l.add(p,b),m.mouse=h,t.lookAt(m,{min:{x:0,y:0},max:{x:700,y:600}}),{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.chains.title="Chains",r.chains.for=">=0.14.2",e.exports=r.chains},Zo9v:function(e,t,n){var r=r||{};r.collisionFiltering=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=(Matter.Composite,Matter.Composites),o=(Matter.Common,Matter.MouseConstraint),i=Matter.Mouse,a=Matter.World,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,wireframes:!1}});t.run(d);var u=n.create();n.run(u,c);var p="#f55a3c",m="#063e7b",f="#f5d259";a.add(l,s.rectangle(400,600,900,50,{isStatic:!0,render:{fillStyle:"transparent",lineWidth:1}})),a.add(l,r.stack(275,100,5,9,10,10,(function(e,t,n,r){var o=2,i=p;return r>5?(o=8,i=m):r>2&&(o=4,i=f),s.circle(e,t,20,{collisionFilter:{category:o},render:{strokeStyle:i,fillStyle:"transparent",lineWidth:1}})}))),a.add(l,s.circle(310,40,30,{collisionFilter:{mask:5},render:{fillStyle:f}})),a.add(l,s.circle(400,40,30,{collisionFilter:{mask:3},render:{fillStyle:p}})),a.add(l,s.circle(480,40,30,{collisionFilter:{mask:9},render:{fillStyle:m}}));var v=i.create(d.canvas),g=o.create(c,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,g),d.mouse=v,g.collisionFilter.mask=13,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.collisionFiltering.title="Collision Filtering",r.collisionFiltering.for=">=0.14.2",e.exports=r.collisionFiltering},ZpbE:function(e,t,n){var r=r||{};r.stack=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.World,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!0}});t.run(d);var u=n.create();n.run(u,c);var p=r.stack(200,380.75,10,5,0,0,(function(e,t){return s.rectangle(e,t,40,40)}));a.add(l,[p,s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0}),s.rectangle(400,606,800,50.5,{isStatic:!0})]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.stack.title="Stack",r.stack.for=">=0.14.2",e.exports=r.stack},"a+ms":function(e,t,n){var r=n("akk5"),o=n("lniP"),i=n("lniP");e.exports={compare:function(e,t){var n=r.Demo.create({toolbar:{title:"matter-js ・ "+(t?"dev":"")+" ・ comparing to "+i.version,url:"https://github.com/liabru/matter-js",reset:!0,source:!0,inspector:!0,tools:!0,fullscreen:!0,exampleSelect:!0},tools:{inspector:!0,gui:!0},inline:!1,preventZoom:!0,resetOnOrientation:!0,routing:!0,startExample:"mixed",examples:e}),a=r.Demo.create({toolbar:{title:"matter-js-compare-build",reset:!1,source:!1,inspector:!1,tools:!1,fullscreen:!1,exampleSelect:!1},tools:{inspector:!1,gui:!1},inline:!1,preventZoom:!0,resetOnOrientation:!0,routing:!1,startExample:"mixed",examples:e.map((function(e){return Matter.Common.extend({},e)}))});i.Runner.run=function(){},i.Render.run=function(){},o.Runner._tick=o.Runner.tick,o.Render._world=o.Render.world,i.Mouse._setElement=i.Mouse.setElement,r.Demo._setExample=r.Demo.setExample,r.Demo.setExample=function(e,t){i.Common._nextId=i.Common._seed=0,o.Common._nextId=o.Common._seed=0,i.Plugin._registry=o.Plugin._registry,i.use.apply(null,o.used),window.Matter=o,r.Demo._setExample(n,n.examples.find((function(e){return e.name===t.name})));var s=parseFloat(window.location.search.split("=")[1]),c=0;o.Runner.tick=function(e,t,n){if(-1!==c){if(c>=s)return console.info("Demo.Compare: ran "+c+" ticks, timestamp is now "+t.timing.timestamp.toFixed(2)),void(c=-1);c+=1;var r=a.example.instance;return e.isFixed=r.runner.isFixed=!0,e.delta=r.runner.delta=1e3/60,window.Matter=i,i.Runner.tick(r.runner,r.engine,n),window.Matter=o,o.Runner._tick(e,t,n)}},o.Render.world=function(e){return window.Matter=i,i.Render.world(a.example.instance.render),window.Matter=o,o.Render._world(e)},i.Mouse.setElement=function(e){return i.Mouse._setElement(e,n.example.instance.render.canvas)},window.Matter=i,r.Demo._setExample(a,a.examples.find((function(e){return e.name===t.name}))),window.Matter=o},r.Demo._reset=r.Demo.reset,r.Demo.reset=function(e){i.Common._nextId=i.Common._seed=0,o.Common._nextId=o.Common._seed=0,window.Matter=i,r.Demo._reset(a),window.Matter=o,r.Demo._reset(n)},document.body.appendChild(n.dom.root),document.body.appendChild(a.dom.root),r.Demo.start(n),document.title="Matter.js Compare"+(t?" ・ Dev":""),console.info("Demo.Compare: matter-js@"+o.version+" with matter-js@"+i.version)}}},a3OZ:function(e,t,n){var r=r||{};r.compositeManipulation=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Events,o=Matter.Composite,i=Matter.Composites,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.World,l=Matter.Bodies,d=e.create(),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600,showAngleIndicator:!0}});t.run(p);var m=n.create();n.run(m,d),c.add(u,[l.rectangle(400,0,800,50,{isStatic:!0}),l.rectangle(400,600,800,50,{isStatic:!0}),l.rectangle(800,300,50,600,{isStatic:!0}),l.rectangle(0,300,50,600,{isStatic:!0})]);var f=i.stack(200,200,4,4,0,0,(function(e,t){return l.rectangle(e,t,40,40)}));c.add(u,f),u.gravity.y=0,r.on(d,"afterUpdate",(function(e){var t=d.timing.timestamp;o.translate(f,{x:2*Math.sin(.001*t),y:0}),o.rotate(f,.01*Math.sin(.001*t),{x:300,y:300});var n=1+.01*Math.sin(.001*t);o.scale(f,n,n,{x:300,y:300})}));var v=s.create(p.canvas),g=a.create(d,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return c.add(u,g),p.mouse=v,t.lookAt(p,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},r.compositeManipulation.title="Composite Manipulation",r.compositeManipulation.for=">=0.14.2",e.exports=r.compositeManipulation},c7us:function(e,t,n){var r=r||{};r.ragdoll=function(){var e=Matter.Engine,t=Matter.Events,n=Matter.Render,o=Matter.Runner,i=Matter.Body,a=Matter.Common,s=Matter.Composite,c=Matter.Composites,l=(Matter.Constraint,Matter.MouseConstraint),d=Matter.Mouse,u=Matter.World,p=Matter.Bodies,m=(Matter.Vector,e.create()),f=m.world,v=n.create({element:document.body,engine:m,options:{width:800,height:600,showAngleIndicator:!0}});n.run(v);var g=o.create();o.run(g,m);for(var y=(v.bounds.max.y-v.bounds.min.y)/50,x=c.stack(0,0,y+2,1,0,0,(function(e,t,n){return p.rectangle(e-50,t+50*n,100,1e3,{isStatic:!0,render:{fillStyle:"#060a19",strokeStyle:"#ffffff",lineWidth:1}})})),h=c.stack(300,0,15,3,10,10,(function(e,t,n){var r=Math.round(a.random(1,8)),o={render:{fillStyle:a.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"])}};switch(Math.round(a.random(0,1))){case 0:return a.random()<.8?p.rectangle(e,t,a.random(25,50),a.random(25,50),o):p.rectangle(e,t,a.random(80,120),a.random(25,30),o);case 1:return p.polygon(e,t,r,a.random(25,50),o)}})),b=s.create(),M=0;M<1;M+=1){var w=r.ragdoll.ragdoll(200,-1e3*M,1.3);s.add(b,w)}u.add(f,[x,h,b]);var S=1,A=0;t.on(m,"afterUpdate",(function(e){-1===C.button?m.timing.timeScale+=.05*(S-m.timing.timeScale):m.timing.timeScale=1,(A+=1)>=90&&(S=S<1?1:.05,A=0);for(var t=0;t<x.bodies.length;t+=1){var n=x.bodies[t];i.translate(n,{x:-.5*m.timing.timeScale,y:-.5*m.timing.timeScale}),n.position.x<-50&&(i.setPosition(n,{x:50*(x.bodies.length-1),y:25+v.bounds.max.y+.5*(n.bounds.max.y-n.bounds.min.y)}),i.setVelocity(n,{x:0,y:0}))}for(t=0;t<b.composites.length;t+=1){var r=b.composites[t];(o=s.bounds(r)).min.y>v.bounds.max.y+100&&s.translate(r,{x:.9*-o.min.x,y:-v.bounds.max.y-400})}for(t=0;t<h.bodies.length;t+=1){var o;(o=(n=h.bodies[t]).bounds).min.y>v.bounds.max.y+100&&i.translate(n,{x:-o.min.x,y:-v.bounds.max.y-300})}}));var C=d.create(v.canvas),B=l.create(m,{mouse:C,constraint:{stiffness:.6,length:0,angularStiffness:0,render:{visible:!1}}});return u.add(f,B),v.mouse=C,n.lookAt(v,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:m,runner:g,render:v,canvas:v.canvas,stop:function(){Matter.Render.stop(v),Matter.Runner.stop(g)}}},r.ragdoll.ragdoll=function(e,t,n,r){n=void 0===n?1:n;var o=Matter.Body,i=Matter.Bodies,a=Matter.Constraint,s=Matter.Composite,c=Matter.Common,l=c.extend({label:"head",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:[15*n,15*n,15*n,15*n]},render:{fillStyle:"#FFBC42"}},r),d=c.extend({label:"chest",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:[20*n,20*n,26*n,26*n]},render:{fillStyle:"#E0A423"}},r),u=c.extend({label:"left-arm",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:10*n},render:{fillStyle:"#FFBC42"}},r),p=c.extend({},u,{render:{fillStyle:"#E59B12"}}),m=c.extend({label:"right-arm",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:10*n},render:{fillStyle:"#FFBC42"}},r),f=c.extend({},m,{render:{fillStyle:"#E59B12"}}),v=c.extend({label:"left-leg",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:10*n},render:{fillStyle:"#FFBC42"}},r),g=c.extend({},v,{render:{fillStyle:"#E59B12"}}),y=c.extend({label:"right-leg",collisionFilter:{group:o.nextGroup(!0)},chamfer:{radius:10*n},render:{fillStyle:"#FFBC42"}},r),x=c.extend({},y,{render:{fillStyle:"#E59B12"}}),h=i.rectangle(e,t-60*n,34*n,40*n,l),b=i.rectangle(e,t,55*n,80*n,d),M=i.rectangle(e+39*n,t-15*n,20*n,40*n,m),w=i.rectangle(e+39*n,t+25*n,20*n,60*n,f),S=i.rectangle(e-39*n,t-15*n,20*n,40*n,u),A=i.rectangle(e-39*n,t+25*n,20*n,60*n,p),C=i.rectangle(e-20*n,t+57*n,20*n,40*n,v),B=i.rectangle(e-20*n,t+97*n,20*n,60*n,g),k=i.rectangle(e+20*n,t+57*n,20*n,40*n,y),R=i.rectangle(e+20*n,t+97*n,20*n,60*n,x),P=a.create({bodyA:b,pointA:{x:24*n,y:-23*n},pointB:{x:0,y:-8*n},bodyB:M,stiffness:.6,render:{visible:!1}}),I=a.create({bodyA:b,pointA:{x:-24*n,y:-23*n},pointB:{x:0,y:-8*n},bodyB:S,stiffness:.6,render:{visible:!1}}),T=a.create({bodyA:b,pointA:{x:-10*n,y:30*n},pointB:{x:0,y:-10*n},bodyB:C,stiffness:.6,render:{visible:!1}}),_=a.create({bodyA:b,pointA:{x:10*n,y:30*n},pointB:{x:0,y:-10*n},bodyB:k,stiffness:.6,render:{visible:!1}}),E=a.create({bodyA:M,bodyB:w,pointA:{x:0,y:15*n},pointB:{x:0,y:-25*n},stiffness:.6,render:{visible:!1}}),F=a.create({bodyA:S,bodyB:A,pointA:{x:0,y:15*n},pointB:{x:0,y:-25*n},stiffness:.6,render:{visible:!1}}),W=a.create({bodyA:C,bodyB:B,pointA:{x:0,y:20*n},pointB:{x:0,y:-20*n},stiffness:.6,render:{visible:!1}}),V=a.create({bodyA:k,bodyB:R,pointA:{x:0,y:20*n},pointB:{x:0,y:-20*n},stiffness:.6,render:{visible:!1}}),D=a.create({bodyA:h,pointA:{x:0,y:25*n},pointB:{x:0,y:-35*n},bodyB:b,stiffness:.6,render:{visible:!1}}),O=a.create({bodyA:B,bodyB:R,stiffness:.01,render:{visible:!1}});return s.create({bodies:[b,h,A,S,w,M,B,R,C,k],constraints:[F,E,I,P,D,W,V,T,_,O]})},r.ragdoll.title="Ragdoll",r.ragdoll.for=">=0.14.2",e.exports=r.ragdoll},djnZ:function(e,t,n){var r=r||{};r.compound=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Constraint,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAxes:!0,showConvexHulls:!0}});t.run(u);var p=n.create();n.run(p,l);var m=200,f=200,v=200,g=c.rectangle(f,v,m,m/5),y=c.rectangle(f,v,m/5,m,{render:g.render}),x=r.create({parts:[g,y]});m=150,f=400,v=300;var h=c.circle(f,v,30),b=c.circle(f+m,v,30),M=c.circle(f+m,v+m,30),w=c.circle(f,v+m,30),S=r.create({parts:[h,b,M,w]}),A=o.create({pointA:{x:400,y:100},bodyB:S,pointB:{x:0,y:0}});s.add(d,[x,S,A,c.rectangle(400,600,800,50.5,{isStatic:!0})]);var C=a.create(u.canvas),B=i.create(l,{mouse:C,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,B),u.mouse=C,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.compound.title="Compound Bodies",r.compound.for=">=0.14.2",e.exports=r.compound},elWf:function(e,t,n){var r=r||{};r.rounded=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.MouseConstraint,o=Matter.Mouse,i=Matter.World,a=Matter.Bodies,s=e.create(),c=s.world,l=t.create({element:document.body,engine:s,options:{width:800,height:600,showAxes:!0}});t.run(l);var d=n.create();n.run(d,s),i.add(c,[a.rectangle(400,0,800,50,{isStatic:!0}),a.rectangle(400,600,800,50,{isStatic:!0}),a.rectangle(800,300,50,600,{isStatic:!0}),a.rectangle(0,300,50,600,{isStatic:!0})]),i.add(c,[a.rectangle(200,200,100,100,{chamfer:{radius:20}}),a.rectangle(300,200,100,100,{chamfer:{radius:[90,0,0,0]}}),a.rectangle(400,200,200,200,{chamfer:{radius:[150,20,40,20]}}),a.rectangle(200,200,200,200,{chamfer:{radius:[150,20,150,20]}}),a.rectangle(300,200,200,50,{chamfer:{radius:[25,25,0,0]}}),a.polygon(200,100,8,80,{chamfer:{radius:30}}),a.polygon(300,100,5,80,{chamfer:{radius:[10,40,20,40,10]}}),a.polygon(400,200,3,50,{chamfer:{radius:[20,0,20]}})]);var u=o.create(l.canvas),p=r.create(s,{mouse:u,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(c,p),l.mouse=u,t.lookAt(l,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:s,runner:d,render:l,canvas:l.canvas,stop:function(){Matter.Render.stop(l),Matter.Runner.stop(d)}}},r.rounded.title="Rounded Corners (Chamfering)",r.rounded.for=">=0.14.2",e.exports=r.rounded},ga9t:function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=n("m6Dm"),a=n("yw0d"),s=n("Tgw/"),c=n("JKEF"),l=n("571F");r._warming=.4,r._torqueDampen=1,r._minLength=1e-6,r.create=function(e){var t=e;t.bodyA&&!t.pointA&&(t.pointA={x:0,y:0}),t.bodyB&&!t.pointB&&(t.pointB={x:0,y:0});var n=t.bodyA?i.add(t.bodyA.position,t.pointA):t.pointA,r=t.bodyB?i.add(t.bodyB.position,t.pointB):t.pointB,o=i.magnitude(i.sub(n,r));t.length=void 0!==t.length?t.length:o,t.id=t.id||l.nextId(),t.label=t.label||"Constraint",t.type="constraint",t.stiffness=t.stiffness||(t.length>0?1:.7),t.damping=t.damping||0,t.angularStiffness=t.angularStiffness||0,t.angleA=t.bodyA?t.bodyA.angle:t.angleA,t.angleB=t.bodyB?t.bodyB.angle:t.angleB,t.plugin={};var a={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===t.length&&t.stiffness>.1?(a.type="pin",a.anchors=!1):t.stiffness<.9&&(a.type="spring"),t.render=l.extend(a,t.render),t},r.preSolveAll=function(e){for(var t=0;t<e.length;t+=1){var n=e[t],r=n.constraintImpulse;n.isStatic||0===r.x&&0===r.y&&0===r.angle||(n.position.x+=r.x,n.position.y+=r.y,n.angle+=r.angle)}},r.solveAll=function(e,t){for(var n=0;n<e.length;n+=1){var o=e[n],i=!o.bodyA||o.bodyA&&o.bodyA.isStatic,a=!o.bodyB||o.bodyB&&o.bodyB.isStatic;(i||a)&&r.solve(e[n],t)}for(n=0;n<e.length;n+=1)i=!(o=e[n]).bodyA||o.bodyA&&o.bodyA.isStatic,a=!o.bodyB||o.bodyB&&o.bodyB.isStatic,i||a||r.solve(e[n],t)},r.solve=function(e,t){var n=e.bodyA,o=e.bodyB,a=e.pointA,s=e.pointB;if(n||o){n&&!n.isStatic&&(i.rotate(a,n.angle-e.angleA,a),e.angleA=n.angle),o&&!o.isStatic&&(i.rotate(s,o.angle-e.angleB,s),e.angleB=o.angle);var c=a,l=s;if(n&&(c=i.add(n.position,a)),o&&(l=i.add(o.position,s)),c&&l){var d=i.sub(c,l),u=i.magnitude(d);u<r._minLength&&(u=r._minLength);var p,m,f,v,g,y=(u-e.length)/u,x=e.stiffness<1?e.stiffness*t:e.stiffness,h=i.mult(d,y*x),b=(n?n.inverseMass:0)+(o?o.inverseMass:0),M=b+((n?n.inverseInertia:0)+(o?o.inverseInertia:0));if(e.damping){var w=i.create();f=i.div(d,u),g=i.sub(o&&i.sub(o.position,o.positionPrev)||w,n&&i.sub(n.position,n.positionPrev)||w),v=i.dot(f,g)}n&&!n.isStatic&&(m=n.inverseMass/b,n.constraintImpulse.x-=h.x*m,n.constraintImpulse.y-=h.y*m,n.position.x-=h.x*m,n.position.y-=h.y*m,e.damping&&(n.positionPrev.x-=e.damping*f.x*v*m,n.positionPrev.y-=e.damping*f.y*v*m),p=i.cross(a,h)/M*r._torqueDampen*n.inverseInertia*(1-e.angularStiffness),n.constraintImpulse.angle-=p,n.angle-=p),o&&!o.isStatic&&(m=o.inverseMass/b,o.constraintImpulse.x+=h.x*m,o.constraintImpulse.y+=h.y*m,o.position.x+=h.x*m,o.position.y+=h.y*m,e.damping&&(o.positionPrev.x+=e.damping*f.x*v*m,o.positionPrev.y+=e.damping*f.y*v*m),p=i.cross(s,h)/M*r._torqueDampen*o.inverseInertia*(1-e.angularStiffness),o.constraintImpulse.angle+=p,o.angle+=p)}}},r.postSolveAll=function(e){for(var t=0;t<e.length;t++){var n=e[t],l=n.constraintImpulse;if(!(n.isStatic||0===l.x&&0===l.y&&0===l.angle)){a.set(n,!1);for(var d=0;d<n.parts.length;d++){var u=n.parts[d];o.translate(u.vertices,l),d>0&&(u.position.x+=l.x,u.position.y+=l.y),0!==l.angle&&(o.rotate(u.vertices,l.angle,n.position),c.rotate(u.axes,l.angle),d>0&&i.rotateAbout(u.position,l.angle,n.position,u.position)),s.update(u.bounds,u.vertices,n.velocity)}l.angle*=r._warming,l.x*=r._warming,l.y*=r._warming}}},r.pointAWorld=function(e){return{x:(e.bodyA?e.bodyA.position.x:0)+e.pointA.x,y:(e.bodyA?e.bodyA.position.y:0)+e.pointA.y}},r.pointBWorld=function(e){return{x:(e.bodyB?e.bodyB.position.x:0)+e.pointB.x,y:(e.bodyB?e.bodyB.position.y:0)+e.pointB.y}}},i6yt:function(e,t,n){var r={};e.exports=r;var o=n("Tgw/"),i=n("wAS/"),a=n("571F"),s=n("yTB+"),c=n("m6Dm");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout((function(){e(a.now())}),1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),r.create=function(e){a.warn("RenderPixi.create: Matter.RenderPixi is deprecated (see docs)");var t={controller:r,engine:null,element:null,frameRequestId:null,canvas:null,renderer:null,container:null,spriteContainer:null,pixiOptions:null,options:{width:800,height:600,background:"#fafafa",wireframeBackground:"#222",hasBounds:!1,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1}},n=a.extend(t,e),o=!n.options.wireframes&&"transparent"===n.options.background;return n.pixiOptions=n.pixiOptions||{view:n.canvas,transparent:o,antialias:!0,backgroundColor:e.background},n.mouse=e.mouse,n.engine=e.engine,n.renderer=n.renderer||new PIXI.WebGLRenderer(n.options.width,n.options.height,n.pixiOptions),n.container=n.container||new PIXI.Container,n.spriteContainer=n.spriteContainer||new PIXI.Container,n.canvas=n.canvas||n.renderer.view,n.bounds=n.bounds||{min:{x:0,y:0},max:{x:n.options.width,y:n.options.height}},s.on(n.engine,"beforeUpdate",(function(){r.clear(n)})),n.textures={},n.sprites={},n.primitives={},n.container.addChild(n.spriteContainer),a.isElement(n.element)?n.element.appendChild(n.canvas):a.warn('No "render.element" passed, "render.canvas" was not inserted into document.'),n.canvas.oncontextmenu=function(){return!1},n.canvas.onselectstart=function(){return!1},n},r.run=function(t){!function n(o){t.frameRequestId=e(n),r.world(t)}()},r.stop=function(e){t(e.frameRequestId)},r.clear=function(e){for(var t=e.container,n=e.spriteContainer;t.children[0];)t.removeChild(t.children[0]);for(;n.children[0];)n.removeChild(n.children[0]);var r=e.sprites["bg-0"];e.textures={},e.sprites={},e.primitives={},e.sprites["bg-0"]=r,r&&t.addChildAt(r,0),e.container.addChild(e.spriteContainer),e.currentBackground=null,t.scale.set(1,1),t.position.set(0,0)},r.setBackground=function(e,t){if(e.currentBackground!==t){var n=t.indexOf&&-1!==t.indexOf("#"),r=e.sprites["bg-0"];if(n){var o=a.colorToNumber(t);e.renderer.backgroundColor=o,r&&e.container.removeChild(r)}else if(!r){var i=d(e,t);(r=e.sprites["bg-0"]=new PIXI.Sprite(i)).position.x=0,r.position.y=0,e.container.addChildAt(r,0)}e.currentBackground=t}},r.world=function(e){var t,n=e.engine.world,a=e.renderer,s=e.container,l=e.options,d=i.allBodies(n),u=i.allConstraints(n),p=[];l.wireframes?r.setBackground(e,l.wireframeBackground):r.setBackground(e,l.background);var m=e.bounds.max.x-e.bounds.min.x,f=e.bounds.max.y-e.bounds.min.y,v=m/e.options.width,g=f/e.options.height;if(l.hasBounds){for(t=0;t<d.length;t++){var y=d[t];y.render.sprite.visible=o.overlaps(y.bounds,e.bounds)}for(t=0;t<u.length;t++){var x=u[t],h=x.bodyA,b=x.bodyB,M=x.pointA,w=x.pointB;h&&(M=c.add(h.position,x.pointA)),b&&(w=c.add(b.position,x.pointB)),M&&w&&((o.contains(e.bounds,M)||o.contains(e.bounds,w))&&p.push(x))}s.scale.set(1/v,1/g),s.position.set(-e.bounds.min.x*(1/v),-e.bounds.min.y*(1/g))}else p=u;for(t=0;t<d.length;t++)r.body(e,d[t]);for(t=0;t<p.length;t++)r.constraint(e,p[t]);a.render(s)},r.constraint=function(e,t){e.engine;var n=t.bodyA,r=t.bodyB,o=t.pointA,i=t.pointB,s=e.container,c=t.render,l="c-"+t.id,d=e.primitives[l];d||(d=e.primitives[l]=new PIXI.Graphics),c.visible&&t.pointA&&t.pointB?(-1===a.indexOf(s.children,d)&&s.addChild(d),d.clear(),d.beginFill(0,0),d.lineStyle(c.lineWidth,a.colorToNumber(c.strokeStyle),1),n?d.moveTo(n.position.x+o.x,n.position.y+o.y):d.moveTo(o.x,o.y),r?d.lineTo(r.position.x+i.x,r.position.y+i.y):d.lineTo(i.x,i.y),d.endFill()):d.clear()},r.body=function(e,t){e.engine;var r=t.render;if(r.visible)if(r.sprite&&r.sprite.texture){var o="b-"+t.id,i=e.sprites[o],s=e.spriteContainer;i||(i=e.sprites[o]=n(e,t)),-1===a.indexOf(s.children,i)&&s.addChild(i),i.position.x=t.position.x,i.position.y=t.position.y,i.rotation=t.angle,i.scale.x=r.sprite.xScale||1,i.scale.y=r.sprite.yScale||1}else{var c="b-"+t.id,d=e.primitives[c],u=e.container;d||((d=e.primitives[c]=l(e,t)).initialAngle=t.angle),-1===a.indexOf(u.children,d)&&u.addChild(d),d.position.x=t.position.x,d.position.y=t.position.y,d.rotation=t.angle-d.initialAngle}};var n=function(e,t){var n=t.render.sprite.texture,r=d(e,n),o=new PIXI.Sprite(r);return o.anchor.x=t.render.sprite.xOffset,o.anchor.y=t.render.sprite.yOffset,o},l=function(e,t){var n,r=t.render,o=e.options,i=new PIXI.Graphics,s=a.colorToNumber(r.fillStyle),c=a.colorToNumber(r.strokeStyle),l=a.colorToNumber(r.strokeStyle),d=a.colorToNumber("#bbb"),u=a.colorToNumber("#CD5C5C");i.clear();for(var p=t.parts.length>1?1:0;p<t.parts.length;p++){n=t.parts[p],o.wireframes?(i.beginFill(0,0),i.lineStyle(1,d,1)):(i.beginFill(s,1),i.lineStyle(r.lineWidth,c,1)),i.moveTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y);for(var m=1;m<n.vertices.length;m++)i.lineTo(n.vertices[m].x-t.position.x,n.vertices[m].y-t.position.y);i.lineTo(n.vertices[0].x-t.position.x,n.vertices[0].y-t.position.y),i.endFill(),(o.showAngleIndicator||o.showAxes)&&(i.beginFill(0,0),o.wireframes?i.lineStyle(1,u,1):i.lineStyle(1,l),i.moveTo(n.position.x-t.position.x,n.position.y-t.position.y),i.lineTo((n.vertices[0].x+n.vertices[n.vertices.length-1].x)/2-t.position.x,(n.vertices[0].y+n.vertices[n.vertices.length-1].y)/2-t.position.y),i.endFill())}return i},d=function(e,t){var n=e.textures[t];return n||(n=e.textures[t]=PIXI.Texture.fromImage(t)),n}}()},ibhy:function(e,t,n){var r=r||{};r.mixed=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l);var m=r.stack(20,20,10,5,0,0,(function(e,t){var n=Math.round(o.random(1,8)),r=null;switch((n=3===n?4:n)>2&&o.random()>.7&&(r={radius:10}),Math.round(o.random(0,1))){case 0:return o.random()<.8?c.rectangle(e,t,o.random(25,50),o.random(25,50),{chamfer:r}):c.rectangle(e,t,o.random(80,120),o.random(25,30),{chamfer:r});case 1:return c.polygon(e,t,n,o.random(25,50),{chamfer:r})}}));s.add(d,m),s.add(d,[c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]);var f=a.create(u.canvas),v=i.create(l,{mouse:f,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,v),u.mouse=f,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.mixed.title="Mixed Shapes",r.mixed.for=">=0.14.2",e.exports=r.mixed},"ix+/":function(e,t,n){var r={};e.exports=r;var o=n("DqtB"),i=n("t8gT"),a=n("Tgw/");r.collisions=function(e,t){for(var n=[],s=t.pairs.table,c=t.metrics,l=0;l<e.length;l++){var d=e[l][0],u=e[l][1];if((!d.isStatic&&!d.isSleeping||!u.isStatic&&!u.isSleeping)&&r.canCollide(d.collisionFilter,u.collisionFilter)&&(c.midphaseTests+=1,a.overlaps(d.bounds,u.bounds)))for(var p=d.parts.length>1?1:0;p<d.parts.length;p++)for(var m=d.parts[p],f=u.parts.length>1?1:0;f<u.parts.length;f++){var v=u.parts[f];if(m===d&&v===u||a.overlaps(m.bounds,v.bounds)){var g,y=s[i.id(m,v)];g=y&&y.isActive?y.collision:null;var x=o.collides(m,v,g);c.narrowphaseTests+=1,x.reused&&(c.narrowReuseCount+=1),x.collided&&(n.push(x),c.narrowDetections+=1)}}}return n},r.canCollide=function(e,t){return e.group===t.group&&0!==e.group?e.group>0:0!=(e.mask&t.category)&&0!=(t.mask&e.category)}},k7Ch:function(e,t,n){var r=r||{};r.gyro=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!0}});t.run(u);var p=n.create();n.run(p,l);var m=r.stack(20,20,10,5,0,0,(function(e,t){var n=Math.round(o.random(1,8)),r=null;switch((n=3===n?4:n)>2&&o.random()>.7&&(r={radius:10}),Math.round(o.random(0,1))){case 0:return o.random()<.8?c.rectangle(e,t,o.random(25,50),o.random(25,50),{chamfer:r}):c.rectangle(e,t,o.random(80,120),o.random(25,30),{chamfer:r});case 1:return c.polygon(e,t,n,o.random(25,50),{chamfer:r})}}));if(s.add(d,[m,c.rectangle(400,0,800,50,{isStatic:!0}),c.rectangle(400,600,800,50,{isStatic:!0}),c.rectangle(800,300,50,600,{isStatic:!0}),c.rectangle(0,300,50,600,{isStatic:!0})]),"undefined"!=typeof window){var f=function(e){var t=void 0!==window.orientation?window.orientation:0,n=l.world.gravity;0===t?(n.x=o.clamp(e.gamma,-90,90)/90,n.y=o.clamp(e.beta,-90,90)/90):180===t?(n.x=o.clamp(e.gamma,-90,90)/90,n.y=o.clamp(-e.beta,-90,90)/90):90===t?(n.x=o.clamp(e.beta,-90,90)/90,n.y=o.clamp(-e.gamma,-90,90)/90):-90===t&&(n.x=o.clamp(-e.beta,-90,90)/90,n.y=o.clamp(e.gamma,-90,90)/90)};window.addEventListener("deviceorientation",f)}var v=a.create(u.canvas),g=i.create(l,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,g),u.mouse=v,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p),"undefined"!=typeof window&&window.removeEventListener("deviceorientation",f)}}},r.gyro.title="Gyroscope",r.gyro.for=">=0.14.2",e.exports=r.gyro},lWug:function(e,t,n){var r={};e.exports=r;var o=n("571F"),i=n("wAS/"),a=n("Tgw/"),s=n("yTB+"),c=n("Sq1W"),l=n("m6Dm"),d=n("I5nt");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout((function(){e(o.now())}),1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),r.create=function(e){var t={controller:r,engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,options:{width:800,height:600,pixelRatio:1,background:"#14151f",wireframeBackground:"#14151f",hasBounds:!!e.bounds,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,showMousePosition:!1}},i=o.extend(t,e);return i.canvas&&(i.canvas.width=i.options.width||i.canvas.width,i.canvas.height=i.options.height||i.canvas.height),i.mouse=e.mouse,i.engine=e.engine,i.canvas=i.canvas||n(i.options.width,i.options.height),i.context=i.canvas.getContext("2d"),i.textures={},i.bounds=i.bounds||{min:{x:0,y:0},max:{x:i.canvas.width,y:i.canvas.height}},1!==i.options.pixelRatio&&r.setPixelRatio(i,i.options.pixelRatio),o.isElement(i.element)?i.element.appendChild(i.canvas):i.canvas.parentNode||o.log("Render.create: options.element was undefined, render.canvas was created but not appended","warn"),i},r.run=function(t){!function n(o){t.frameRequestId=e(n),r.world(t)}()},r.stop=function(e){t(e.frameRequestId)},r.setPixelRatio=function(e,t){var n=e.options,r=e.canvas;"auto"===t&&(t=u(r)),n.pixelRatio=t,r.setAttribute("data-pixel-ratio",t),r.width=n.width*t,r.height=n.height*t,r.style.width=n.width+"px",r.style.height=n.height+"px"},r.lookAt=function(e,t,n,r){r=void 0===r||r,t=o.isArray(t)?t:[t],n=n||{x:0,y:0};for(var i={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},a=0;a<t.length;a+=1){var s=t[a],c=s.bounds?s.bounds.min:s.min||s.position||s,l=s.bounds?s.bounds.max:s.max||s.position||s;c&&l&&(c.x<i.min.x&&(i.min.x=c.x),l.x>i.max.x&&(i.max.x=l.x),c.y<i.min.y&&(i.min.y=c.y),l.y>i.max.y&&(i.max.y=l.y))}var u=i.max.x-i.min.x+2*n.x,p=i.max.y-i.min.y+2*n.y,m=e.canvas.height,f=e.canvas.width/m,v=u/p,g=1,y=1;v>f?y=v/f:g=f/v,e.options.hasBounds=!0,e.bounds.min.x=i.min.x,e.bounds.max.x=i.min.x+u*g,e.bounds.min.y=i.min.y,e.bounds.max.y=i.min.y+p*y,r&&(e.bounds.min.x+=.5*u-u*g*.5,e.bounds.max.x+=.5*u-u*g*.5,e.bounds.min.y+=.5*p-p*y*.5,e.bounds.max.y+=.5*p-p*y*.5),e.bounds.min.x-=n.x,e.bounds.max.x-=n.x,e.bounds.min.y-=n.y,e.bounds.max.y-=n.y,e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.canvas.width,y:(e.bounds.max.y-e.bounds.min.y)/e.canvas.height}),d.setOffset(e.mouse,e.bounds.min))},r.startViewTransform=function(e){var t=e.bounds.max.x-e.bounds.min.x,n=e.bounds.max.y-e.bounds.min.y,r=t/e.options.width,o=n/e.options.height;e.context.setTransform(e.options.pixelRatio/r,0,0,e.options.pixelRatio/o,0,0),e.context.translate(-e.bounds.min.x,-e.bounds.min.y)},r.endViewTransform=function(e){e.context.setTransform(e.options.pixelRatio,0,0,e.options.pixelRatio,0,0)},r.world=function(e){var t,n=e.engine,o=n.world,u=e.canvas,p=e.context,f=e.options,v=i.allBodies(o),g=i.allConstraints(o),y=f.wireframes?f.wireframeBackground:f.background,x=[],h=[],b={timestamp:n.timing.timestamp};if(s.trigger(e,"beforeRender",b),e.currentBackground!==y&&m(e,y),p.globalCompositeOperation="source-in",p.fillStyle="transparent",p.fillRect(0,0,u.width,u.height),p.globalCompositeOperation="source-over",f.hasBounds){for(t=0;t<v.length;t++){var M=v[t];a.overlaps(M.bounds,e.bounds)&&x.push(M)}for(t=0;t<g.length;t++){var w=g[t],S=w.bodyA,A=w.bodyB,C=w.pointA,B=w.pointB;S&&(C=l.add(S.position,w.pointA)),A&&(B=l.add(A.position,w.pointB)),C&&B&&((a.contains(e.bounds,C)||a.contains(e.bounds,B))&&h.push(w))}r.startViewTransform(e),e.mouse&&(d.setScale(e.mouse,{x:(e.bounds.max.x-e.bounds.min.x)/e.options.width,y:(e.bounds.max.y-e.bounds.min.y)/e.options.height}),d.setOffset(e.mouse,e.bounds.min))}else h=g,x=v,1!==e.options.pixelRatio&&e.context.setTransform(e.options.pixelRatio,0,0,e.options.pixelRatio,0,0);!f.wireframes||n.enableSleeping&&f.showSleeping?r.bodies(e,x,p):(f.showConvexHulls&&r.bodyConvexHulls(e,x,p),r.bodyWireframes(e,x,p)),f.showBounds&&r.bodyBounds(e,x,p),(f.showAxes||f.showAngleIndicator)&&r.bodyAxes(e,x,p),f.showPositions&&r.bodyPositions(e,x,p),f.showVelocity&&r.bodyVelocity(e,x,p),f.showIds&&r.bodyIds(e,x,p),f.showSeparations&&r.separations(e,n.pairs.list,p),f.showCollisions&&r.collisions(e,n.pairs.list,p),f.showVertexNumbers&&r.vertexNumbers(e,x,p),f.showMousePosition&&r.mousePosition(e,e.mouse,p),r.constraints(h,p),f.showBroadphase&&n.broadphase.controller===c&&r.grid(e,n.broadphase,p),f.showDebug&&r.debug(e,p),f.hasBounds&&r.endViewTransform(e),s.trigger(e,"afterRender",b)},r.debug=function(e,t){var n=t,r=e.engine,o=r.world,a=r.metrics,s=e.options,l=i.allBodies(o),d=" ";if(r.timing.timestamp-(e.debugTimestamp||0)>=500){var u="";a.timing&&(u+="fps: "+Math.round(a.timing.fps)+d),a.extended&&(a.timing&&(u+="delta: "+a.timing.delta.toFixed(3)+d,u+="correction: "+a.timing.correction.toFixed(3)+d),u+="bodies: "+l.length+d,r.broadphase.controller===c&&(u+="buckets: "+a.buckets+d),u+="\n",u+="collisions: "+a.collisions+d,u+="pairs: "+r.pairs.list.length+d,u+="broad: "+a.broadEff+d,u+="mid: "+a.midEff+d,u+="narrow: "+a.narrowEff+d),e.debugString=u,e.debugTimestamp=r.timing.timestamp}if(e.debugString){n.font="12px Arial",s.wireframes?n.fillStyle="rgba(255,255,255,0.5)":n.fillStyle="rgba(0,0,0,0.5)";for(var p=e.debugString.split("\n"),m=0;m<p.length;m++)n.fillText(p[m],50,50+18*m)}},r.constraints=function(e,t){for(var n=t,r=0;r<e.length;r++){var i=e[r];if(i.render.visible&&i.pointA&&i.pointB){var a,s,c=i.bodyA,d=i.bodyB;if(a=c?l.add(c.position,i.pointA):i.pointA,"pin"===i.render.type)n.beginPath(),n.arc(a.x,a.y,3,0,2*Math.PI),n.closePath();else{if(s=d?l.add(d.position,i.pointB):i.pointB,n.beginPath(),n.moveTo(a.x,a.y),"spring"===i.render.type)for(var u,p=l.sub(s,a),m=l.perp(l.normalise(p)),f=Math.ceil(o.clamp(i.length/5,12,20)),v=1;v<f;v+=1)u=v%2==0?1:-1,n.lineTo(a.x+p.x*(v/f)+m.x*u*4,a.y+p.y*(v/f)+m.y*u*4);n.lineTo(s.x,s.y)}i.render.lineWidth&&(n.lineWidth=i.render.lineWidth,n.strokeStyle=i.render.strokeStyle,n.stroke()),i.render.anchors&&(n.fillStyle=i.render.strokeStyle,n.beginPath(),n.arc(a.x,a.y,3,0,2*Math.PI),n.arc(s.x,s.y,3,0,2*Math.PI),n.closePath(),n.fill())}}},r.bodyShadows=function(e,t,n){for(var r=n,o=(e.engine,0);o<t.length;o++){var i=t[o];if(i.render.visible){if(i.circleRadius)r.beginPath(),r.arc(i.position.x,i.position.y,i.circleRadius,0,2*Math.PI),r.closePath();else{r.beginPath(),r.moveTo(i.vertices[0].x,i.vertices[0].y);for(var a=1;a<i.vertices.length;a++)r.lineTo(i.vertices[a].x,i.vertices[a].y);r.closePath()}var s=i.position.x-.5*e.options.width,c=i.position.y-.2*e.options.height,l=Math.abs(s)+Math.abs(c);r.shadowColor="rgba(0,0,0,0.15)",r.shadowOffsetX=.05*s,r.shadowOffsetY=.05*c,r.shadowBlur=1+12*Math.min(1,l/1e3),r.fill(),r.shadowColor=null,r.shadowOffsetX=null,r.shadowOffsetY=null,r.shadowBlur=null}}},r.bodies=function(e,t,n){var r,o,i,a,s=n,c=(e.engine,e.options),l=c.showInternalEdges||!c.wireframes;for(i=0;i<t.length;i++)if((r=t[i]).render.visible)for(a=r.parts.length>1?1:0;a<r.parts.length;a++)if((o=r.parts[a]).render.visible){if(c.showSleeping&&r.isSleeping?s.globalAlpha=.5*o.render.opacity:1!==o.render.opacity&&(s.globalAlpha=o.render.opacity),o.render.sprite&&o.render.sprite.texture&&!c.wireframes){var d=o.render.sprite,u=p(e,d.texture);s.translate(o.position.x,o.position.y),s.rotate(o.angle),s.drawImage(u,u.width*-d.xOffset*d.xScale,u.height*-d.yOffset*d.yScale,u.width*d.xScale,u.height*d.yScale),s.rotate(-o.angle),s.translate(-o.position.x,-o.position.y)}else{if(o.circleRadius)s.beginPath(),s.arc(o.position.x,o.position.y,o.circleRadius,0,2*Math.PI);else{s.beginPath(),s.moveTo(o.vertices[0].x,o.vertices[0].y);for(var m=1;m<o.vertices.length;m++)!o.vertices[m-1].isInternal||l?s.lineTo(o.vertices[m].x,o.vertices[m].y):s.moveTo(o.vertices[m].x,o.vertices[m].y),o.vertices[m].isInternal&&!l&&s.moveTo(o.vertices[(m+1)%o.vertices.length].x,o.vertices[(m+1)%o.vertices.length].y);s.lineTo(o.vertices[0].x,o.vertices[0].y),s.closePath()}c.wireframes?(s.lineWidth=1,s.strokeStyle="#bbb",s.stroke()):(s.fillStyle=o.render.fillStyle,o.render.lineWidth&&(s.lineWidth=o.render.lineWidth,s.strokeStyle=o.render.strokeStyle,s.stroke()),s.fill())}s.globalAlpha=1}},r.bodyWireframes=function(e,t,n){var r,o,i,a,s,c=n,l=e.options.showInternalEdges;for(c.beginPath(),i=0;i<t.length;i++)if((r=t[i]).render.visible)for(s=r.parts.length>1?1:0;s<r.parts.length;s++){for(o=r.parts[s],c.moveTo(o.vertices[0].x,o.vertices[0].y),a=1;a<o.vertices.length;a++)!o.vertices[a-1].isInternal||l?c.lineTo(o.vertices[a].x,o.vertices[a].y):c.moveTo(o.vertices[a].x,o.vertices[a].y),o.vertices[a].isInternal&&!l&&c.moveTo(o.vertices[(a+1)%o.vertices.length].x,o.vertices[(a+1)%o.vertices.length].y);c.lineTo(o.vertices[0].x,o.vertices[0].y)}c.lineWidth=1,c.strokeStyle="#bbb",c.stroke()},r.bodyConvexHulls=function(e,t,n){var r,o,i,a=n;for(a.beginPath(),o=0;o<t.length;o++)if((r=t[o]).render.visible&&1!==r.parts.length){for(a.moveTo(r.vertices[0].x,r.vertices[0].y),i=1;i<r.vertices.length;i++)a.lineTo(r.vertices[i].x,r.vertices[i].y);a.lineTo(r.vertices[0].x,r.vertices[0].y)}a.lineWidth=1,a.strokeStyle="rgba(255,255,255,0.2)",a.stroke()},r.vertexNumbers=function(e,t,n){var r,o,i,a=n;for(r=0;r<t.length;r++){var s=t[r].parts;for(i=s.length>1?1:0;i<s.length;i++){var c=s[i];for(o=0;o<c.vertices.length;o++)a.fillStyle="rgba(255,255,255,0.2)",a.fillText(r+"_"+o,c.position.x+.8*(c.vertices[o].x-c.position.x),c.position.y+.8*(c.vertices[o].y-c.position.y))}}},r.mousePosition=function(e,t,n){var r=n;r.fillStyle="rgba(255,255,255,0.8)",r.fillText(t.position.x+" "+t.position.y,t.position.x+5,t.position.y-5)},r.bodyBounds=function(e,t,n){var r=n,o=(e.engine,e.options);r.beginPath();for(var i=0;i<t.length;i++){if(t[i].render.visible)for(var a=t[i].parts,s=a.length>1?1:0;s<a.length;s++){var c=a[s];r.rect(c.bounds.min.x,c.bounds.min.y,c.bounds.max.x-c.bounds.min.x,c.bounds.max.y-c.bounds.min.y)}}o.wireframes?r.strokeStyle="rgba(255,255,255,0.08)":r.strokeStyle="rgba(0,0,0,0.1)",r.lineWidth=1,r.stroke()},r.bodyAxes=function(e,t,n){var r,o,i,a,s=n,c=(e.engine,e.options);for(s.beginPath(),o=0;o<t.length;o++){var l=t[o],d=l.parts;if(l.render.visible)if(c.showAxes)for(i=d.length>1?1:0;i<d.length;i++)for(r=d[i],a=0;a<r.axes.length;a++){var u=r.axes[a];s.moveTo(r.position.x,r.position.y),s.lineTo(r.position.x+20*u.x,r.position.y+20*u.y)}else for(i=d.length>1?1:0;i<d.length;i++)for(r=d[i],a=0;a<r.axes.length;a++)s.moveTo(r.position.x,r.position.y),s.lineTo((r.vertices[0].x+r.vertices[r.vertices.length-1].x)/2,(r.vertices[0].y+r.vertices[r.vertices.length-1].y)/2)}c.wireframes?(s.strokeStyle="indianred",s.lineWidth=1):(s.strokeStyle="rgba(255, 255, 255, 0.4)",s.globalCompositeOperation="overlay",s.lineWidth=2),s.stroke(),s.globalCompositeOperation="source-over"},r.bodyPositions=function(e,t,n){var r,o,i,a,s=n,c=(e.engine,e.options);for(s.beginPath(),i=0;i<t.length;i++)if((r=t[i]).render.visible)for(a=0;a<r.parts.length;a++)o=r.parts[a],s.arc(o.position.x,o.position.y,3,0,2*Math.PI,!1),s.closePath();for(c.wireframes?s.fillStyle="indianred":s.fillStyle="rgba(0,0,0,0.5)",s.fill(),s.beginPath(),i=0;i<t.length;i++)(r=t[i]).render.visible&&(s.arc(r.positionPrev.x,r.positionPrev.y,2,0,2*Math.PI,!1),s.closePath());s.fillStyle="rgba(255,165,0,0.8)",s.fill()},r.bodyVelocity=function(e,t,n){var r=n;r.beginPath();for(var o=0;o<t.length;o++){var i=t[o];i.render.visible&&(r.moveTo(i.position.x,i.position.y),r.lineTo(i.position.x+2*(i.position.x-i.positionPrev.x),i.position.y+2*(i.position.y-i.positionPrev.y)))}r.lineWidth=3,r.strokeStyle="cornflowerblue",r.stroke()},r.bodyIds=function(e,t,n){var r,o,i=n;for(r=0;r<t.length;r++)if(t[r].render.visible){var a=t[r].parts;for(o=a.length>1?1:0;o<a.length;o++){var s=a[o];i.font="12px Arial",i.fillStyle="rgba(255,255,255,0.5)",i.fillText(s.id,s.position.x+10,s.position.y-10)}}},r.collisions=function(e,t,n){var r,o,i,a,s=n,c=e.options;for(s.beginPath(),i=0;i<t.length;i++)if((r=t[i]).isActive)for(o=r.collision,a=0;a<r.activeContacts.length;a++){var l=r.activeContacts[a].vertex;s.rect(l.x-1.5,l.y-1.5,3.5,3.5)}for(c.wireframes?s.fillStyle="rgba(255,255,255,0.7)":s.fillStyle="orange",s.fill(),s.beginPath(),i=0;i<t.length;i++)if((r=t[i]).isActive&&(o=r.collision,r.activeContacts.length>0)){var d=r.activeContacts[0].vertex.x,u=r.activeContacts[0].vertex.y;2===r.activeContacts.length&&(d=(r.activeContacts[0].vertex.x+r.activeContacts[1].vertex.x)/2,u=(r.activeContacts[0].vertex.y+r.activeContacts[1].vertex.y)/2),o.bodyB===o.supports[0].body||!0===o.bodyA.isStatic?s.moveTo(d-8*o.normal.x,u-8*o.normal.y):s.moveTo(d+8*o.normal.x,u+8*o.normal.y),s.lineTo(d,u)}c.wireframes?s.strokeStyle="rgba(255,165,0,0.7)":s.strokeStyle="orange",s.lineWidth=1,s.stroke()},r.separations=function(e,t,n){var r,o,i,a,s,c=n,l=e.options;for(c.beginPath(),s=0;s<t.length;s++)if((r=t[s]).isActive){i=(o=r.collision).bodyA;var d=1;(a=o.bodyB).isStatic||i.isStatic||(d=.5),a.isStatic&&(d=0),c.moveTo(a.position.x,a.position.y),c.lineTo(a.position.x-o.penetration.x*d,a.position.y-o.penetration.y*d),d=1,a.isStatic||i.isStatic||(d=.5),i.isStatic&&(d=0),c.moveTo(i.position.x,i.position.y),c.lineTo(i.position.x+o.penetration.x*d,i.position.y+o.penetration.y*d)}l.wireframes?c.strokeStyle="rgba(255,165,0,0.5)":c.strokeStyle="orange",c.stroke()},r.grid=function(e,t,n){var r=n;e.options.wireframes?r.strokeStyle="rgba(255,180,0,0.1)":r.strokeStyle="rgba(255,180,0,0.5)",r.beginPath();for(var i=o.keys(t.buckets),a=0;a<i.length;a++){var s=i[a];if(!(t.buckets[s].length<2)){var c=s.split(/C|R/);r.rect(.5+parseInt(c[1],10)*t.bucketWidth,.5+parseInt(c[2],10)*t.bucketHeight,t.bucketWidth,t.bucketHeight)}}r.lineWidth=1,r.stroke()},r.inspector=function(e,t){e.engine;var n,r=e.selected,o=e.render,i=o.options;if(i.hasBounds){var a=o.bounds.max.x-o.bounds.min.x,s=o.bounds.max.y-o.bounds.min.y,c=a/o.options.width,l=s/o.options.height;t.scale(1/c,1/l),t.translate(-o.bounds.min.x,-o.bounds.min.y)}for(var d=0;d<r.length;d++){var u=r[d].data;switch(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.9)",t.setLineDash([1,2]),u.type){case"body":n=u.bounds,t.beginPath(),t.rect(Math.floor(n.min.x-3),Math.floor(n.min.y-3),Math.floor(n.max.x-n.min.x+6),Math.floor(n.max.y-n.min.y+6)),t.closePath(),t.stroke();break;case"constraint":var p=u.pointA;u.bodyA&&(p=u.pointB),t.beginPath(),t.arc(p.x,p.y,10,0,2*Math.PI),t.closePath(),t.stroke()}t.setLineDash([]),t.translate(-.5,-.5)}null!==e.selectStart&&(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.6)",t.fillStyle="rgba(255,165,0,0.1)",n=e.selectBounds,t.beginPath(),t.rect(Math.floor(n.min.x),Math.floor(n.min.y),Math.floor(n.max.x-n.min.x),Math.floor(n.max.y-n.min.y)),t.closePath(),t.stroke(),t.fill(),t.translate(-.5,-.5)),i.hasBounds&&t.setTransform(1,0,0,1,0,0)};var n=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n.oncontextmenu=function(){return!1},n.onselectstart=function(){return!1},n},u=function(e){var t=e.getContext("2d");return(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)},p=function(e,t){var n=e.textures[t];return n||((n=e.textures[t]=new Image).src=t,n)},m=function(e,t){var n=t;/(jpg|gif|png)$/.test(t)&&(n="url("+t+")"),e.canvas.style.background=n,e.canvas.style.backgroundSize="contain",e.currentBackground=t}}()},lniP:function(e,t,n){var r=e.exports=n("pm/U");r.Body=n("IbIC"),r.Composite=n("wAS/"),r.World=n("Inl5"),r.Contact=n("9K63"),r.Detector=n("ix+/"),r.Grid=n("Sq1W"),r.Pairs=n("ttsO"),r.Pair=n("t8gT"),r.Query=n("NDQ1"),r.Resolver=n("3Slt"),r.SAT=n("DqtB"),r.Constraint=n("ga9t"),r.MouseConstraint=n("q4y7"),r.Common=n("571F"),r.Engine=n("nIFq"),r.Events=n("yTB+"),r.Mouse=n("I5nt"),r.Runner=n("4d8i"),r.Sleeping=n("yw0d"),r.Plugin=n("2Og8"),r.Metrics=n("LJ2B"),r.Bodies=n("oT59"),r.Composites=n("9Nbg"),r.Axes=n("JKEF"),r.Bounds=n("Tgw/"),r.Svg=n("0Aok"),r.Vector=n("m6Dm"),r.Vertices=n("0kzT"),r.Render=n("lWug"),r.RenderPixi=n("i6yt"),r.World.add=r.Composite.add,r.World.remove=r.Composite.remove,r.World.addComposite=r.Composite.addComposite,r.World.addBody=r.Composite.addBody,r.World.addConstraint=r.Composite.addConstraint,r.World.clear=r.Composite.clear,r.Engine.run=r.Runner.run},m6Dm:function(e,t){var n={};e.exports=n,n.create=function(e,t){return{x:e||0,y:t||0}},n.clone=function(e){return{x:e.x,y:e.y}},n.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},n.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},n.rotate=function(e,t,n){var r=Math.cos(t),o=Math.sin(t);n||(n={});var i=e.x*r-e.y*o;return n.y=e.x*o+e.y*r,n.x=i,n},n.rotateAbout=function(e,t,n,r){var o=Math.cos(t),i=Math.sin(t);r||(r={});var a=n.x+((e.x-n.x)*o-(e.y-n.y)*i);return r.y=n.y+((e.x-n.x)*i+(e.y-n.y)*o),r.x=a,r},n.normalise=function(e){var t=n.magnitude(e);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}},n.dot=function(e,t){return e.x*t.x+e.y*t.y},n.cross=function(e,t){return e.x*t.y-e.y*t.x},n.cross3=function(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)},n.add=function(e,t,n){return n||(n={}),n.x=e.x+t.x,n.y=e.y+t.y,n},n.sub=function(e,t,n){return n||(n={}),n.x=e.x-t.x,n.y=e.y-t.y,n},n.mult=function(e,t){return{x:e.x*t,y:e.y*t}},n.div=function(e,t){return{x:e.x/t,y:e.y/t}},n.perp=function(e,t){return{x:(t=!0===t?-1:1)*-e.y,y:t*e.x}},n.neg=function(e){return{x:-e.x,y:-e.y}},n.angle=function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)},n._temp=[n.create(),n.create(),n.create(),n.create(),n.create(),n.create()]},nIFq:function(e,t,n){var r={};e.exports=r;var o=n("Inl5"),i=n("yw0d"),a=n("3Slt"),s=n("lWug"),c=n("ttsO"),l=n("LJ2B"),d=n("Sq1W"),u=n("yTB+"),p=n("wAS/"),m=n("ga9t"),f=n("571F"),v=n("IbIC");r.create=function(e,t){t=(t=f.isElement(e)?t:e)||{},((e=f.isElement(e)?e:null)||t.render)&&f.warn("Engine.create: engine.render is deprecated (see docs)");var n={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},timing:{timestamp:0,timeScale:1},broadphase:{controller:d}},r=f.extend(n,t);if(e||r.render){var i={element:e,controller:s};r.render=f.extend(i,r.render)}return r.render&&r.render.controller&&(r.render=r.render.controller.create(r.render)),r.render&&(r.render.engine=r),r.world=t.world||o.create(r.world),r.pairs=c.create(),r.broadphase=r.broadphase.controller.create(r.broadphase),r.metrics=r.metrics||{extended:!1},r.metrics=l.create(r.metrics),r},r.update=function(e,t,n){t=t||1e3/60,n=n||1;var o,s=e.world,d=e.timing,f=e.broadphase,v=[];d.timestamp+=t*d.timeScale;var g={timestamp:d.timestamp};u.trigger(e,"beforeUpdate",g);var y=p.allBodies(s),x=p.allConstraints(s);for(l.reset(e.metrics),e.enableSleeping&&i.update(y,d.timeScale),r._bodiesApplyGravity(y,s.gravity),r._bodiesUpdate(y,t,d.timeScale,n,s.bounds),m.preSolveAll(y),o=0;o<e.constraintIterations;o++)m.solveAll(x,d.timeScale);m.postSolveAll(y),f.controller?(s.isModified&&f.controller.clear(f),f.controller.update(f,y,e,s.isModified),v=f.pairsList):v=y,s.isModified&&p.setModified(s,!1,!1,!0);var h=f.detector(v,e),b=e.pairs,M=d.timestamp;for(c.update(b,h,M),c.removeOld(b,M),e.enableSleeping&&i.afterCollisions(b.list,d.timeScale),b.collisionStart.length>0&&u.trigger(e,"collisionStart",{pairs:b.collisionStart}),a.preSolvePosition(b.list),o=0;o<e.positionIterations;o++)a.solvePosition(b.list,d.timeScale);for(a.postSolvePosition(y),m.preSolveAll(y),o=0;o<e.constraintIterations;o++)m.solveAll(x,d.timeScale);for(m.postSolveAll(y),a.preSolveVelocity(b.list),o=0;o<e.velocityIterations;o++)a.solveVelocity(b.list,d.timeScale);return b.collisionActive.length>0&&u.trigger(e,"collisionActive",{pairs:b.collisionActive}),b.collisionEnd.length>0&&u.trigger(e,"collisionEnd",{pairs:b.collisionEnd}),l.update(e.metrics,e),r._bodiesClearForces(y),u.trigger(e,"afterUpdate",g),e},r.merge=function(e,t){if(f.extend(e,t),t.world){e.world=t.world,r.clear(e);for(var n=p.allBodies(e.world),o=0;o<n.length;o++){var a=n[o];i.set(a,!1),a.id=f.nextId()}}},r.clear=function(e){var t=e.world;c.clear(e.pairs);var n=e.broadphase;if(n.controller){var r=p.allBodies(t);n.controller.clear(n),n.controller.update(n,r,e,!0)}},r._bodiesClearForces=function(e){for(var t=0;t<e.length;t++){var n=e[t];n.force.x=0,n.force.y=0,n.torque=0}},r._bodiesApplyGravity=function(e,t){var n=void 0!==t.scale?t.scale:.001;if((0!==t.x||0!==t.y)&&0!==n)for(var r=0;r<e.length;r++){var o=e[r];o.isStatic||o.isSleeping||(o.force.y+=o.mass*t.y*n,o.force.x+=o.mass*t.x*n)}},r._bodiesUpdate=function(e,t,n,r,o){for(var i=0;i<e.length;i++){var a=e[i];a.isStatic||a.isSleeping||v.update(a,t,n,r)}}},oT59:function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=n("571F"),a=n("IbIC"),s=n("Tgw/"),c=n("m6Dm");r._decompWarned=!1,r.rectangle=function(e,t,n,r,s){s=s||{};var c={label:"Rectangle Body",position:{x:e,y:t},vertices:o.fromPath("L 0 0 L "+n+" 0 L "+n+" "+r+" L 0 "+r)};if(s.chamfer){var l=s.chamfer;c.vertices=o.chamfer(c.vertices,l.radius,l.quality,l.qualityMin,l.qualityMax),delete s.chamfer}return a.create(i.extend({},c,s))},r.trapezoid=function(e,t,n,r,s,c){c=c||{};var l,d=n*(s*=.5),u=d+(1-2*s)*n,p=u+d;l=s<.5?"L 0 0 L "+d+" "+-r+" L "+u+" "+-r+" L "+p+" 0":"L 0 0 L "+u+" "+-r+" L "+p+" 0";var m={label:"Trapezoid Body",position:{x:e,y:t},vertices:o.fromPath(l)};if(c.chamfer){var f=c.chamfer;m.vertices=o.chamfer(m.vertices,f.radius,f.quality,f.qualityMin,f.qualityMax),delete c.chamfer}return a.create(i.extend({},m,c))},r.circle=function(e,t,n,o,a){o=o||{};var s={label:"Circle Body",circleRadius:n};a=a||25;var c=Math.ceil(Math.max(10,Math.min(a,n)));return c%2==1&&(c+=1),r.polygon(e,t,c,n,i.extend({},s,o))},r.polygon=function(e,t,n,s,c){if(c=c||{},n<3)return r.circle(e,t,s,c);for(var l=2*Math.PI/n,d="",u=.5*l,p=0;p<n;p+=1){var m=u+p*l,f=Math.cos(m)*s,v=Math.sin(m)*s;d+="L "+f.toFixed(3)+" "+v.toFixed(3)+" "}var g={label:"Polygon Body",position:{x:e,y:t},vertices:o.fromPath(d)};if(c.chamfer){var y=c.chamfer;g.vertices=o.chamfer(g.vertices,y.radius,y.quality,y.qualityMin,y.qualityMax),delete c.chamfer}return a.create(i.extend({},g,c))},r.fromVertices=function(e,t,l,d,u,p,m,f){var v,g,y,x,h,b,M,w,S,A,C;try{v=n("Dded")}catch(e){v=null}for(g=Boolean(v&&v.quickDecomp),d=d||{},x=[],u=void 0!==u&&u,p=void 0!==p?p:.01,m=void 0!==m?m:10,f=void 0!==f?f:.01,i.isArray(l[0])||(l=[l]),A=0;A<l.length;A+=1)if(b=l[A],!!(h=o.isConvex(b))||g||r._decompWarned||(i.warn("Could not resolve the expected 'poly-decomp' package for concave vertices in 'Bodies.fromVertices'"),i.warn("Try 'npm install poly-decomp --save' or as a global e.g. 'window.decomp'"),r._decompWarned=!0),h||!g)b=h?o.clockwiseSort(b):o.hull(b),x.push({position:{x:e,y:t},vertices:b});else{var B=b.map((function(e){return[e.x,e.y]}));v.makeCCW(B),!1!==p&&v.removeCollinearPoints(B,p),!1!==f&&v.removeDuplicatePoints&&v.removeDuplicatePoints(B,f);var k=v.quickDecomp(B);for(M=0;M<k.length;M++){var R=k[M].map((function(e){return{x:e[0],y:e[1]}}));m>0&&o.area(R)<m||x.push({position:o.centre(R),vertices:R})}}for(M=0;M<x.length;M++)x[M]=a.create(i.extend(x[M],d));if(u)for(M=0;M<x.length;M++){var P=x[M];for(w=M+1;w<x.length;w++){var I=x[w];if(s.overlaps(P.bounds,I.bounds)){var T=P.vertices,_=I.vertices;for(S=0;S<P.vertices.length;S++)for(C=0;C<I.vertices.length;C++){var E=c.magnitudeSquared(c.sub(T[(S+1)%T.length],_[C])),F=c.magnitudeSquared(c.sub(T[S],_[(C+1)%_.length]));E<5&&F<5&&(T[S].isInternal=!0,_[C].isInternal=!0)}}}}return x.length>1?(y=a.create(i.extend({parts:x.slice(0)},d)),a.setPosition(y,{x:e,y:t}),y):x[0]}},"pm/U":function(e,t,n){var r={};e.exports=r;var o=n("2Og8"),i=n("571F");r.name="matter-js",r.version="*",r.uses=[],r.used=[],r.use=function(){o.use(r,Array.prototype.slice.call(arguments))},r.before=function(e,t){return e=e.replace(/^Matter./,""),i.chainPathBefore(r,e,t)},r.after=function(e,t){return e=e.replace(/^Matter./,""),i.chainPathAfter(r,e,t)}},q4y7:function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=n("yw0d"),a=n("I5nt"),s=n("yTB+"),c=n("ix+/"),l=n("ga9t"),d=n("wAS/"),u=n("571F"),p=n("Tgw/");r.create=function(e,t){var n=(e?e.mouse:null)||(t?t.mouse:null);n||(e&&e.render&&e.render.canvas?n=a.create(e.render.canvas):t&&t.element?n=a.create(t.element):(n=a.create(),u.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var o={type:"mouseConstraint",mouse:n,element:null,body:null,constraint:l.create({label:"Mouse Constraint",pointA:n.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),collisionFilter:{category:1,mask:4294967295,group:0}},i=u.extend(o,t);return s.on(e,"beforeUpdate",(function(){var t=d.allBodies(e.world);r.update(i,t),r._triggerEvents(i)})),i},r.update=function(e,t){var n=e.mouse,r=e.constraint,a=e.body;if(0===n.button){if(r.bodyB)i.set(r.bodyB,!1),r.pointA=n.position;else for(var l=0;l<t.length;l++)if(a=t[l],p.contains(a.bounds,n.position)&&c.canCollide(a.collisionFilter,e.collisionFilter))for(var d=a.parts.length>1?1:0;d<a.parts.length;d++){var u=a.parts[d];if(o.contains(u.vertices,n.position)){r.pointA=n.position,r.bodyB=e.body=a,r.pointB={x:n.position.x-a.position.x,y:n.position.y-a.position.y},r.angleB=a.angle,i.set(a,!1),s.trigger(e,"startdrag",{mouse:n,body:a});break}}}else r.bodyB=e.body=null,r.pointB=null,a&&s.trigger(e,"enddrag",{mouse:n,body:a})},r._triggerEvents=function(e){var t=e.mouse,n=t.sourceEvents;n.mousemove&&s.trigger(e,"mousemove",{mouse:t}),n.mousedown&&s.trigger(e,"mousedown",{mouse:t}),n.mouseup&&s.trigger(e,"mouseup",{mouse:t}),a.clearSourceEvents(t)}},siNf:function(e,t,n){var r=r||{};r.cloth=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Composites,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600}});t.run(u);var p=n.create();n.run(p,l);for(var m={friction:1e-5,collisionFilter:{group:r.nextGroup(!0)},render:{visible:!1}},f=o.softBody(200,200,20,12,5,5,!1,8,m,{stiffness:.06}),v=0;v<20;v++)f.bodies[v].isStatic=!0;s.add(d,[f,c.circle(300,500,80,{isStatic:!0,render:{fillStyle:"#060a19"}}),c.rectangle(500,480,80,80,{isStatic:!0,render:{fillStyle:"#060a19"}}),c.rectangle(400,609,800,50,{isStatic:!0})]);var g=a.create(u.canvas),y=i.create(l,{mouse:g,constraint:{stiffness:.98,render:{visible:!1}}});return s.add(d,y),u.mouse=g,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.cloth.title="Cloth",r.cloth.for=">=0.14.2",e.exports=r.cloth},t8gT:function(e,t,n){var r={};e.exports=r;var o=n("9K63");r.create=function(e,t){var n=e.bodyA,o=e.bodyB,i=e.parentA,a=e.parentB,s={id:r.id(n,o),bodyA:n,bodyB:o,contacts:{},activeContacts:[],separation:0,isActive:!0,confirmedActive:!0,isSensor:n.isSensor||o.isSensor,timeCreated:t,timeUpdated:t,inverseMass:i.inverseMass+a.inverseMass,friction:Math.min(i.friction,a.friction),frictionStatic:Math.max(i.frictionStatic,a.frictionStatic),restitution:Math.max(i.restitution,a.restitution),slop:Math.max(i.slop,a.slop)};return r.update(s,e,t),s},r.update=function(e,t,n){var i=e.contacts,a=t.supports,s=e.activeContacts,c=t.parentA,l=t.parentB;if(e.collision=t,e.inverseMass=c.inverseMass+l.inverseMass,e.friction=Math.min(c.friction,l.friction),e.frictionStatic=Math.max(c.frictionStatic,l.frictionStatic),e.restitution=Math.max(c.restitution,l.restitution),e.slop=Math.max(c.slop,l.slop),s.length=0,t.collided){for(var d=0;d<a.length;d++){var u=a[d],p=o.id(u),m=i[p];m?s.push(m):s.push(i[p]=o.create(u))}e.separation=t.depth,r.setActive(e,!0,n)}else!0===e.isActive&&r.setActive(e,!1,n)},r.setActive=function(e,t,n){t?(e.isActive=!0,e.timeUpdated=n):(e.isActive=!1,e.activeContacts.length=0)},r.id=function(e,t){return e.id<t.id?"A"+e.id+"B"+t.id:"A"+t.id+"B"+e.id}},tlRp:function(e,t,n){var r=r||{};r.sprites=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=Matter.Bodies,l=e.create(),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showAngleIndicator:!1,wireframes:!1}});t.run(u);var p=n.create();n.run(p,l);var m={isStatic:!0};d.bodies=[],s.add(d,[c.rectangle(400,-10,820.5,50.5,m),c.rectangle(400,610,820.5,50.5,m),c.rectangle(810,300,50.5,620.5,m),c.rectangle(-10,300,50.5,620.5,m)]);var f=r.stack(20,20,10,4,0,0,(function(e,t){return o.random()>.35?c.rectangle(e,t,64,64,{render:{strokeStyle:"#ffffff",sprite:{texture:"./img/box.png"}}}):c.circle(e,t,46,{density:5e-4,frictionAir:.06,restitution:.3,friction:.01,render:{sprite:{texture:"./img/ball.png"}}})}));s.add(d,f);var v=a.create(u.canvas),g=i.create(l,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,g),u.mouse=v,t.lookAt(u,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:l,runner:p,render:u,canvas:u.canvas,stop:function(){Matter.Render.stop(u),Matter.Runner.stop(p)}}},r.sprites.title="Sprites",r.sprites.for=">=0.14.2",e.exports=r.sprites},ttsO:function(e,t,n){var r={};e.exports=r;var o=n("t8gT"),i=n("571F");r._pairMaxIdleLife=1e3,r.create=function(e){return i.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},e)},r.update=function(e,t,n){var r,i,a,s,c=e.list,l=e.table,d=e.collisionStart,u=e.collisionEnd,p=e.collisionActive;for(d.length=0,u.length=0,p.length=0,s=0;s<c.length;s++)c[s].confirmedActive=!1;for(s=0;s<t.length;s++)(r=t[s]).collided&&((a=l[i=o.id(r.bodyA,r.bodyB)])?(a.isActive?p.push(a):d.push(a),o.update(a,r,n),a.confirmedActive=!0):(a=o.create(r,n),l[i]=a,d.push(a),c.push(a)));for(s=0;s<c.length;s++)(a=c[s]).isActive&&!a.confirmedActive&&(o.setActive(a,!1,n),u.push(a))},r.removeOld=function(e,t){var n,o,i,a,s=e.list,c=e.table,l=[];for(a=0;a<s.length;a++)(o=(n=s[a]).collision).bodyA.isSleeping||o.bodyB.isSleeping?n.timeUpdated=t:t-n.timeUpdated>r._pairMaxIdleLife&&l.push(a);for(a=0;a<l.length;a++)delete c[(n=s[i=l[a]-a]).id],s.splice(i,1)},r.clear=function(e){return e.table={},e.list.length=0,e.collisionStart.length=0,e.collisionActive.length=0,e.collisionEnd.length=0,e}},uZME:function(e,t,n){var r=n("lniP"),o=n("JBRW"),i=n("a+ms").compare,a=n("71Xj").demo;window.decomp=n("Dded"),window.pathseg=n("v5Dj"),window.MatterTools=n("akk5"),window.Matter=r;var s=r.Common.keys(o).map((function(e){return{id:e,sourceLink:"https://github.com/liabru/matter-js/blob/master/examples/"+e+".js",name:o[e].title,init:o[e]}}));window.location.search.indexOf("compare")>=0?i(s,false):a(s,false)},"wAS/":function(e,t,n){var r={};e.exports=r;var o=n("yTB+"),i=n("571F"),a=n("Tgw/"),s=n("IbIC");r.create=function(e){return i.extend({id:i.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite",plugin:{}},e)},r.setModified=function(e,t,n,o){if(e.isModified=t,n&&e.parent&&r.setModified(e.parent,t,n,o),o)for(var i=0;i<e.composites.length;i++){var a=e.composites[i];r.setModified(a,t,n,o)}},r.add=function(e,t){var n=[].concat(t);o.trigger(e,"beforeAdd",{object:t});for(var a=0;a<n.length;a++){var s=n[a];switch(s.type){case"body":if(s.parent!==s){i.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}r.addBody(e,s);break;case"constraint":r.addConstraint(e,s);break;case"composite":r.addComposite(e,s);break;case"mouseConstraint":r.addConstraint(e,s.constraint)}}return o.trigger(e,"afterAdd",{object:t}),e},r.remove=function(e,t,n){var i=[].concat(t);o.trigger(e,"beforeRemove",{object:t});for(var a=0;a<i.length;a++){var s=i[a];switch(s.type){case"body":r.removeBody(e,s,n);break;case"constraint":r.removeConstraint(e,s,n);break;case"composite":r.removeComposite(e,s,n);break;case"mouseConstraint":r.removeConstraint(e,s.constraint)}}return o.trigger(e,"afterRemove",{object:t}),e},r.addComposite=function(e,t){return e.composites.push(t),t.parent=e,r.setModified(e,!0,!0,!1),e},r.removeComposite=function(e,t,n){var o=i.indexOf(e.composites,t);if(-1!==o&&(r.removeCompositeAt(e,o),r.setModified(e,!0,!0,!1)),n)for(var a=0;a<e.composites.length;a++)r.removeComposite(e.composites[a],t,!0);return e},r.removeCompositeAt=function(e,t){return e.composites.splice(t,1),r.setModified(e,!0,!0,!1),e},r.addBody=function(e,t){return e.bodies.push(t),r.setModified(e,!0,!0,!1),e},r.removeBody=function(e,t,n){var o=i.indexOf(e.bodies,t);if(-1!==o&&(r.removeBodyAt(e,o),r.setModified(e,!0,!0,!1)),n)for(var a=0;a<e.composites.length;a++)r.removeBody(e.composites[a],t,!0);return e},r.removeBodyAt=function(e,t){return e.bodies.splice(t,1),r.setModified(e,!0,!0,!1),e},r.addConstraint=function(e,t){return e.constraints.push(t),r.setModified(e,!0,!0,!1),e},r.removeConstraint=function(e,t,n){var o=i.indexOf(e.constraints,t);if(-1!==o&&r.removeConstraintAt(e,o),n)for(var a=0;a<e.composites.length;a++)r.removeConstraint(e.composites[a],t,!0);return e},r.removeConstraintAt=function(e,t){return e.constraints.splice(t,1),r.setModified(e,!0,!0,!1),e},r.clear=function(e,t,n){if(n)for(var o=0;o<e.composites.length;o++)r.clear(e.composites[o],t,!0);return t?e.bodies=e.bodies.filter((function(e){return e.isStatic})):e.bodies.length=0,e.constraints.length=0,e.composites.length=0,r.setModified(e,!0,!0,!1),e},r.allBodies=function(e){for(var t=[].concat(e.bodies),n=0;n<e.composites.length;n++)t=t.concat(r.allBodies(e.composites[n]));return t},r.allConstraints=function(e){for(var t=[].concat(e.constraints),n=0;n<e.composites.length;n++)t=t.concat(r.allConstraints(e.composites[n]));return t},r.allComposites=function(e){for(var t=[].concat(e.composites),n=0;n<e.composites.length;n++)t=t.concat(r.allComposites(e.composites[n]));return t},r.get=function(e,t,n){var o,i;switch(n){case"body":o=r.allBodies(e);break;case"constraint":o=r.allConstraints(e);break;case"composite":o=r.allComposites(e).concat(e)}return o?0===(i=o.filter((function(e){return e.id.toString()===t.toString()}))).length?null:i[0]:null},r.move=function(e,t,n){return r.remove(e,t),r.add(n,t),e},r.rebase=function(e){for(var t=r.allBodies(e).concat(r.allConstraints(e)).concat(r.allComposites(e)),n=0;n<t.length;n++)t[n].id=i.nextId();return r.setModified(e,!0,!0,!1),e},r.translate=function(e,t,n){for(var o=n?r.allBodies(e):e.bodies,i=0;i<o.length;i++)s.translate(o[i],t);return r.setModified(e,!0,!0,!1),e},r.rotate=function(e,t,n,o){for(var i=Math.cos(t),a=Math.sin(t),c=o?r.allBodies(e):e.bodies,l=0;l<c.length;l++){var d=c[l],u=d.position.x-n.x,p=d.position.y-n.y;s.setPosition(d,{x:n.x+(u*i-p*a),y:n.y+(u*a+p*i)}),s.rotate(d,t)}return r.setModified(e,!0,!0,!1),e},r.scale=function(e,t,n,o,i){for(var a=i?r.allBodies(e):e.bodies,c=0;c<a.length;c++){var l=a[c],d=l.position.x-o.x,u=l.position.y-o.y;s.setPosition(l,{x:o.x+d*t,y:o.y+u*n}),s.scale(l,t,n)}return r.setModified(e,!0,!0,!1),e},r.bounds=function(e){for(var t=r.allBodies(e),n=[],o=0;o<t.length;o+=1){var i=t[o];n.push(i.bounds.min,i.bounds.max)}return a.create(n)}},wycb:function(e,t,n){var r=r||{};r.bridge=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Composites,i=Matter.Common,a=Matter.Constraint,s=Matter.MouseConstraint,c=Matter.Mouse,l=Matter.World,d=Matter.Bodies,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600,showAngleIndicator:!0}});t.run(m);var f=n.create();n.run(f,u);var v=r.nextGroup(!0),g=o.stack(160,290,15,1,0,0,(function(e,t){return d.rectangle(e-20,t,53,20,{collisionFilter:{group:v},chamfer:5,density:.005,frictionAir:.05,render:{fillStyle:"#060a19"}})}));o.chain(g,.3,0,-.3,0,{stiffness:1,length:0,render:{visible:!1}});var y=o.stack(250,50,6,3,0,0,(function(e,t){return d.rectangle(e,t,50,50,i.random(20,40))}));l.add(p,[g,y,d.rectangle(30,490,220,380,{isStatic:!0,chamfer:{radius:20}}),d.rectangle(770,490,220,380,{isStatic:!0,chamfer:{radius:20}}),a.create({pointA:{x:140,y:300},bodyB:g.bodies[0],pointB:{x:-25,y:0},length:2,stiffness:.9}),a.create({pointA:{x:660,y:300},bodyB:g.bodies[g.bodies.length-1],pointB:{x:25,y:0},length:2,stiffness:.9})]);var x=c.create(m.canvas),h=s.create(u,{mouse:x,constraint:{stiffness:.1,render:{visible:!1}}});return l.add(p,h),m.mouse=x,t.lookAt(m,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:u,runner:f,render:m,canvas:m.canvas,stop:function(){Matter.Render.stop(m),Matter.Runner.stop(f)}}},r.bridge.title="Bridge",r.bridge.for=">=0.14.2",e.exports=r.bridge},xoNv:function(e,t,n){var r=r||{};r.newtonsCradle=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Body,o=Matter.Composites,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.World,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showVelocity:!0}});t.run(d);var u=n.create();n.run(u,c);var p=o.newtonsCradle(280,100,5,30,200);s.add(l,p),r.translate(p.bodies[0],{x:-180,y:-100}),p=o.newtonsCradle(280,380,7,20,140),s.add(l,p),r.translate(p.bodies[0],{x:-140,y:-100});var m=a.create(d.canvas),f=i.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:50},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.newtonsCradle.title="Newton's Cradle",r.newtonsCradle.for=">=0.14.2",e.exports=r.newtonsCradle},"yTB+":function(e,t,n){var r={};e.exports=r;var o=n("571F");r.on=function(e,t,n){for(var r,o=t.split(" "),i=0;i<o.length;i++)r=o[i],e.events=e.events||{},e.events[r]=e.events[r]||[],e.events[r].push(n);return n},r.off=function(e,t,n){if(t){"function"==typeof t&&(n=t,t=o.keys(e.events).join(" "));for(var r=t.split(" "),i=0;i<r.length;i++){var a=e.events[r[i]],s=[];if(n&&a)for(var c=0;c<a.length;c++)a[c]!==n&&s.push(a[c]);e.events[r[i]]=s}}else e.events={}},r.trigger=function(e,t,n){var r,i,a,s,c=e.events;if(c&&o.keys(c).length>0){n||(n={}),r=t.split(" ");for(var l=0;l<r.length;l++)if(a=c[i=r[l]]){(s=o.clone(n,!1)).name=i,s.source=e;for(var d=0;d<a.length;d++)a[d].apply(e,[s])}}}},yWqE:function(e,t,n){var r=r||{};r.sensors=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Events,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.World,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,wireframes:!1}});t.run(d);var u=n.create();n.run(u,c);var p="#f55a3c",m="#f5d259",f=s.rectangle(400,300,500,50,{isSensor:!0,isStatic:!0,render:{strokeStyle:p,fillStyle:"transparent",lineWidth:1}});a.add(l,[f,s.rectangle(400,600,800,50,{isStatic:!0,render:{fillStyle:"#060a19",lineWidth:0}})]),a.add(l,s.circle(400,40,30,{render:{strokeStyle:m,fillStyle:"transparent",lineWidth:1}})),r.on(c,"collisionStart",(function(e){for(var t=e.pairs,n=0,r=t.length;n!=r;++n){var o=t[n];o.bodyA===f?o.bodyB.render.strokeStyle=p:o.bodyB===f&&(o.bodyA.render.strokeStyle=p)}})),r.on(c,"collisionEnd",(function(e){for(var t=e.pairs,n=0,r=t.length;n!=r;++n){var o=t[n];o.bodyA===f?o.bodyB.render.strokeStyle=m:o.bodyB===f&&(o.bodyA.render.strokeStyle=m)}}));var v=i.create(d.canvas),g=o.create(c,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,g),d.mouse=v,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.sensors.title="Sensors",r.sensors.for=">=0.14.2",e.exports=r.sensors},yw0d:function(e,t,n){var r={};e.exports=r;var o=n("yTB+");r._motionWakeThreshold=.18,r._motionSleepThreshold=.08,r._minBias=.9,r.update=function(e,t){for(var n=t*t*t,o=0;o<e.length;o++){var i=e[o],a=i.speed*i.speed+i.angularSpeed*i.angularSpeed;if(0===i.force.x&&0===i.force.y){var s=Math.min(i.motion,a),c=Math.max(i.motion,a);i.motion=r._minBias*s+(1-r._minBias)*c,i.sleepThreshold>0&&i.motion<r._motionSleepThreshold*n?(i.sleepCounter+=1,i.sleepCounter>=i.sleepThreshold&&r.set(i,!0)):i.sleepCounter>0&&(i.sleepCounter-=1)}else r.set(i,!1)}},r.afterCollisions=function(e,t){for(var n=t*t*t,o=0;o<e.length;o++){var i=e[o];if(i.isActive){var a=i.collision,s=a.bodyA.parent,c=a.bodyB.parent;if(!(s.isSleeping&&c.isSleeping||s.isStatic||c.isStatic)&&(s.isSleeping||c.isSleeping)){var l=s.isSleeping&&!s.isStatic?s:c,d=l===s?c:s;!l.isStatic&&d.motion>r._motionWakeThreshold*n&&r.set(l,!1)}}}},r.set=function(e,t){var n=e.isSleeping;t?(e.isSleeping=!0,e.sleepCounter=e.sleepThreshold,e.positionImpulse.x=0,e.positionImpulse.y=0,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.anglePrev=e.angle,e.speed=0,e.angularSpeed=0,e.motion=0,n||o.trigger(e,"sleepStart")):(e.isSleeping=!1,e.sleepCounter=0,n&&o.trigger(e,"sleepEnd"))}},zc7U:function(e,t,n){var r=r||{};r.circleStack=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Composites,o=Matter.MouseConstraint,i=Matter.Mouse,a=Matter.World,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showAngleIndicator:!0}});t.run(d);var u=n.create();n.run(u,c);var p=r.stack(100,179,10,10,20,0,(function(e,t){return s.circle(e,t,20)}));a.add(l,[s.rectangle(400,0,800,50,{isStatic:!0}),s.rectangle(400,600,800,50,{isStatic:!0}),s.rectangle(800,300,50,600,{isStatic:!0}),s.rectangle(0,300,50,600,{isStatic:!0}),p]);var m=i.create(d.canvas),f=o.create(c,{mouse:m,constraint:{stiffness:.2,render:{visible:!1}}});return a.add(l,f),d.mouse=m,t.lookAt(d,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:c,runner:u,render:d,canvas:d.canvas,stop:function(){Matter.Render.stop(d),Matter.Runner.stop(u)}}},r.circleStack.title="Circle Stack",r.circleStack.for=">=0.14.2",e.exports=r.circleStack}},[["uZME",1,2,3,4,5]]])}));