/*! * matter-demo bundle 0.18.0 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.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),i.add(p,[d.rectangle(400,0,800,50,{isStatic:!0}),d.rectangle(400,600,800,50,{isStatic:!0}),d.rectangle(800,300,50,600,{isStatic:!0}),d.rectangle(0,300,50,600,{isStatic:!0})]);var v=1,g=0;o.on(u,"afterUpdate",(function(e){u.timing.timeScale+=.05*(v-u.timing.timeScale),(g+=1)>=90&&(v=v<1?1:.05,function(e){for(var t=i.allBodies(e.world),n=0;n=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})}}}(u),g=0)}));var y={frictionAir:0,friction:1e-4,restitution:.8};i.add(p,a.stack(20,100,15,3,20,40,(function(e,t){return d.circle(e,t,s.random(10,20),y)}))),i.add(p,a.stack(50,50,8,3,0,0,(function(e,t){switch(Math.round(s.random(0,1))){case 0:return s.random()<.8?d.rectangle(e,t,s.random(20,50),s.random(20,50),y):d.rectangle(e,t,s.random(80,120),s.random(20,30),y);case 1:return d.polygon(e,t,Math.round(s.random(4,8)),s.random(20,50),y)}})));var x=l.create(m.canvas),h=c.create(u,{mouse:x,constraint:{stiffness:.2,render:{visible:!1}}});return i.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.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.Composite,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,r=Matter.Runner,o=Matter.Common,i=Matter.MouseConstraint,a=Matter.Mouse,s=Matter.Composite,c=Matter.Vertices,l=Matter.Svg,d=Matter.Bodies;o.setDecomp(n("Dded"));var u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600}});t.run(m);var f=r.create();if(r.run(f,u),"undefined"!=typeof fetch){var v=function(e,t){return Array.prototype.slice.call(e.querySelectorAll(t))},g=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){g(e).then((function(e){var n=o.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),r=v(e,"path").map((function(e){return c.scale(l.pathToVertices(e,30),.4,.4)}));s.add(p,d.fromVertices(100+150*t,200+50*t,r,{render:{fillStyle:n,strokeStyle:n,lineWidth:1}},!0))}))})),g("./svg/svg.svg").then((function(e){var t=o.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),n=v(e,"path").map((function(e){return l.pathToVertices(e,30)}));s.add(p,d.fromVertices(400,80,n,{render:{fillStyle:t,strokeStyle:t,lineWidth:1}},!0))}))}else o.warn("Fetch is not available. Could not load SVG.");s.add(p,[d.rectangle(400,0,800,50,{isStatic:!0}),d.rectangle(400,600,800,50,{isStatic:!0}),d.rectangle(800,300,50,600,{isStatic:!0}),d.rectangle(0,300,50,600,{isStatic:!0})]);var y=a.create(m.canvas),x=i.create(u,{mouse:y,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(p,x),m.mouse=y,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.svg.title="Concave SVG Paths",r.svg.for=">0.16.1",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.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=r.create();r.run(m,d),o.add(u,[l.rectangle(400,600,1200,50.5,{isStatic:!0,render:{fillStyle:"#060a19"}})]);var f=i.stack(100,0,10,8,10,10,(function(e,t){return l.circle(e,t,a.random(15,30),{restitution:.6,friction:.1})}));o.add(u,[f,l.polygon(200,460,3,60),l.polygon(400,460,5,60),l.rectangle(600,460,80,80)]);var v=c.create(p.canvas),g=s.create(d,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});o.add(u,g),p.mouse=v,t.lookAt(p,{min:{x:0,y:0},max:{x:800,y:600}});for(var y=o.allBodies(u),x=0;x1;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}},M=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;n0)return!1;a=n}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=0?c-1:e.length-1],d=e[c],u=e[(c+1)%e.length],p=t[c0&&(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=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.Composite,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.Composite,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"}}),M=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,M,g,y]),o.on(d,"afterUpdate",(function(){-1===S.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 b=s.create(p.canvas),S=a.create(d,{mouse:b,constraint:{stiffness:.2,render:{visible:!1}}});return c.add(u,S),p.mouse=b,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-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;s0&&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=|>)?\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,r=Matter.Runner,o=Matter.Composite,i=Matter.Composites,a=Matter.Common,s=Matter.Query,c=Matter.MouseConstraint,l=Matter.Mouse,d=Matter.Events,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=r.create();r.run(g,m);var y=i.stack(20,20,12,4,0,0,(function(e,t){switch(Math.round(a.random(0,1))){case 0:return a.random()<.8?p.rectangle(e,t,a.random(20,50),a.random(20,50)):p.rectangle(e,t,a.random(80,120),a.random(20,30));case 1:var n=Math.round(a.random(1,8));return n=3===n?4:n,p.polygon(e,t,n,a.random(20,50))}}));a.setDecomp(n("Dded"));var 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);o.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})]);var M=[],b={x:400,y:100};d.on(m,"afterUpdate",(function(){var e=w.mouse,t=o.allBodies(m.world),n=e.position||{x:100,y:600};M=s.ray(t,b,n)})),d.on(v,"afterRender",(function(){var e=w.mouse,n=v.context,r=e.position||{x:100,y:600};t.startViewTransform(v),n.beginPath(),n.moveTo(b.x,b.y),n.lineTo(r.x,r.y),M.length>0?n.strokeStyle="#fff":n.strokeStyle="#555",n.lineWidth=.5,n.stroke();for(var o=0;o0.16.1",e.exports=r.raycasting},"3Slt":function(e,t,n){var r={};e.exports=r;var o=n("0kzT"),i=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,o=e.length;for(t=0;tH||-W>H?(o=W>0?W:-W,(n=m.friction*(W>0?1:-1)*s)<-o?n=-o:n>o&&(n=o)):(n=W,o=u);var G=I*M-E*h,U=_*M-T*h,N=A/(B+v.inverseInertia*G*G+g.inverseInertia*U*U),z=(1+m.restitution)*O*N;if(n*=N,O*O>c&&O<0)R.normalImpulse=0;else{var Z=R.normalImpulse;R.normalImpulse+=z,R.normalImpulse=Math.min(R.normalImpulse,0),z=R.normalImpulse-Z}if(W*W>d)R.tangentImpulse=0;else{var Q=R.tangentImpulse;R.tangentImpulse+=n,R.tangentImpulse<-o&&(R.tangentImpulse=-o),R.tangentImpulse>o&&(R.tangentImpulse=o),n=R.tangentImpulse-Q}var X=h*z+b*n,Y=M*z+S*n;v.isStatic||v.isSleeping||(v.positionPrev.x+=X*v.inverseMass,v.positionPrev.y+=Y*v.inverseMass,v.anglePrev+=(I*Y-E*X)*v.inverseInertia),g.isStatic||g.isSleeping||(g.positionPrev.x-=X*g.inverseMass,g.positionPrev.y-=Y*g.inverseMass,g.anglePrev-=(_*Y-T*X)*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.Composite,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),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.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(e,"beforeUpdate",c),i.update(t,r,s),o.trigger(e,"afterUpdate",c),o.trigger(e,"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,r=Matter.Runner,o=Matter.Composites,i=Matter.Common,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.Composite,l=Matter.Query,d=Matter.Svg,u=Matter.Bodies;i.setDecomp(n("Dded"));var p=e.create(),m=p.world,f=t.create({element:document.body,engine:p,options:{width:800,height:600}});t.run(f);var v,g=r.create();if(r.run(g,p),"undefined"!=typeof fetch){(v="./svg/terrain.svg",fetch(v).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 d.pathToVertices(e,30)})),n=u.fromVertices(400,350,t,{isStatic:!0,render:{fillStyle:"#060a19",strokeStyle:"#060a19",lineWidth:1}},!0);c.add(m,n);var r={frictionAir:0,friction:1e-4,restitution:.6};c.add(m,o.stack(80,100,20,20,10,10,(function(e,t){if(0===l.point([n],{x:e,y:t}).length)return u.polygon(e,t,5,12,r)})))}))}else i.warn("Fetch is not available. Could not load SVG.");var y=s.create(f.canvas),x=a.create(p,{mouse:y,constraint:{stiffness:.2,render:{visible:!1}}});return c.add(m,x),f.mouse=y,t.lookAt(f,{min:{x:0,y:0},max:{x:800,y:600}}),{engine:p,runner:g,render:f,canvas:f.canvas,stop:function(){Matter.Render.stop(f),Matter.Runner.stop(g)}}},r.terrain.title="Terrain",r.terrain.for=">0.16.1",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._warnedOnce={},n._decomp=null,n.extend=function(e,t){var r,o;"boolean"==typeof t?(r=2,o=t):(r=1,o=!0);for(var i=r;i0;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 en?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 Date.now?Date.now():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.warnOnce=function(){var e=Array.prototype.slice.call(arguments).join(" ");n._warnedOnce[e]||(n.warn(e),n._warnedOnce[e]=!0)},n.deprecated=function(e,t,r){e[t]=n.chain((function(){n.warnOnce("🔅 deprecated 🔅",r)}),e[t])},n.nextId=function(){return n._nextId++},n.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n=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.Composite,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":""),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),Matter.before("Render.create",(function(e){e.options.showDebug=!0}))}r.Demo.start(n)}}},"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.Bodies,u=Matter.Vector,p=e.create(),m=p.world,f=n.create({element:document.body,engine:p,options:{width:800,height:600,wireframes:!1}});n.run(f);var v=r.create();r.run(v,p);var g=o.nextGroup(!0),y=a.stack(350,160,2,1,-20,0,(function(e,t){return d.rectangle(e,t,200,25,{collisionFilter:{group:g},frictionAir:0,chamfer:5,render:{fillStyle:"transparent",lineWidth:1}})}));p.gravity.scale=.002,a.chain(y,.45,0,-.45,0,{stiffness:.9,length:0,angularStiffness:.7,render:{strokeStyle:"#4a485b"}}),i.add(y,s.create({bodyB:y.bodies[0],pointB:{x:-84,y:0},pointA:{x:y.bodies[0].position.x-84,y:y.bodies[0].position.y},stiffness:.9,length:0,render:{strokeStyle:"#4a485b"}}));var x=y.bodies[1];o.rotate(x,.3*-Math.PI,{x:x.position.x-100,y:x.position.y}),i.add(m,y);var h=[];t.on(f,"afterRender",(function(){h.unshift({position:u.clone(x.position),speed:x.speed}),n.startViewTransform(f),f.context.globalAlpha=.7;for(var e=0;e2e3&&h.pop()}));var M=l.create(f.canvas),b=c.create(p,{mouse:M,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(m,b),f.mouse=M,n.lookAt(f,{min:{x:0,y:0},max:{x:700,y:600}}),{engine:p,runner:v,render:f,canvas:f.canvas,stop:function(){Matter.Render.stop(f),Matter.Runner.stop(v)}}},r.doublePendulum.title="Double Pendulum",r.doublePendulum.for=">0.16.1",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.Composite,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.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.16.1",e.exports=r.gravity},"9K63":function(e,t){var n={};e.exports=n,n.create=function(e){return{vertex:e,normalImpulse:0,tangentImpulse:0}}},"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"),l=a.deprecated;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;fv&&(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;d0)for(l=0;l0&&(p=m[l-1+(c-1)*t],o.addConstraint(e,i.create(a.extend({bodyA:p,bodyB:u},s)))),r&&lp||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=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.Bodies,u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600,wireframes:!1}});t.run(m);var f=n.create();n.run(f,u),o.on(p,"afterAdd",(function(e){})),o.on(u,"beforeUpdate",(function(e){var t=e.source;e.timestamp%5e3<50&&y(t)})),o.on(u,"collisionStart",(function(e){for(var t=e.pairs,n=0;n=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})}}},x=l.create(m.canvas),h=c.create(u,{mouse:x,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(p,h),m.mouse=x,o.on(h,"mousedown",(function(e){var t=e.mouse.position;console.log("mousedown at "+t.x+" "+t.y),y(u)})),o.on(h,"mouseup",(function(e){var t=e.mouse.position;console.log("mouseup at "+t.x+" "+t.y)})),o.on(h,"startdrag",(function(e){console.log("startdrag",e)})),o.on(h,"enddrag",(function(e){console.log("enddrag",e)})),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.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,o=(Matter.Composites,Matter.MouseConstraint),i=Matter.Mouse,a=Matter.Composite,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.softBody(250,100,5,5,0,0,!0,18,p),r.softBody.softBody(400,300,8,3,0,0,!0,15,p),r.softBody.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",r.softBody.softBody=function(e,t,n,r,o,i,a,s,c,l){var d=Matter.Common,u=Matter.Composites,p=Matter.Bodies;c=d.extend({inertia:1/0},c),l=d.extend({stiffness:.2,render:{type:"line",anchors:!1}},l);var m=u.stack(e,t,n,r,o,i,(function(e,t){return p.circle(e,t,s,c)}));return u.mesh(m,n,r,a,l),m.label="Soft Body",m},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.Composite,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("Z/YF"),i=n("571F").deprecated;r.collides=function(e,t){return o.collides(e,t)},i(r,"collides","SAT.collides ➤ replaced by Collision.collides")},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.Composite,s=Matter.Bodies,c=e.create(),l=c.world,d=t.create({element:document.body,engine:c,options:{width:800,height:600,showStats:!0,showPerformance:!0}});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},H5X8:function(e,t,n){var r=r||{};r.stress3=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.Composite,c=Matter.Bodies,l=e.create({positionIterations:10,velocityIterations:10}),d=l.world,u=t.create({element:document.body,engine:l,options:{width:800,height:600,showStats:!0,showPerformance:!0}});t.run(u);var p=n.create({isFixed:!0});n.run(p,l);var m=.3,f=r.stack(40,40,38,18,0,0,(function(e,t){var n=Math.round(o.random(1,8));switch(Math.round(o.random(0,1))){case 0:return o.random()<.8?c.rectangle(e,t,o.random(25,50)*m,o.random(25,50)*m):c.rectangle(e,t,o.random(80,120)*m,o.random(25,30)*m);case 1:return c.polygon(e,t,n,o.random(25,50)*m)}}));s.add(d,f),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 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.stress3.title="Stress 3",r.stress3.for=">=0.14.2",e.exports=r.stress3},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,r=Matter.Runner,o=Matter.Composites,i=Matter.Common,a=Matter.MouseConstraint,s=Matter.Mouse,c=Matter.Composite,l=Matter.Vertices,d=Matter.Bodies;i.setDecomp(n("Dded"));var u=e.create(),p=u.world,m=t.create({element:document.body,engine:u,options:{width:800,height:600}});t.run(m);var f=r.create();r.run(f,u),c.add(p,[d.rectangle(400,0,800,50,{isStatic:!0}),d.rectangle(400,600,800,50,{isStatic:!0}),d.rectangle(800,300,50,600,{isStatic:!0}),d.rectangle(0,300,50,600,{isStatic:!0})]);var v=l.fromPath("40 0 40 20 100 20 100 80 40 80 40 100 0 50"),g=l.fromPath("100 0 75 50 100 100 25 100 0 50 25 0"),y=l.fromPath("50 0 63 38 100 38 69 59 82 100 50 75 18 100 31 59 0 38 37 38"),x=l.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"),h=o.stack(50,50,6,4,10,10,(function(e,t){var n=i.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]);return d.fromVertices(e,t,i.choose([v,g,y,x]),{render:{fillStyle:n,strokeStyle:n,lineWidth:1}},!0)}));c.add(p,h);var M=s.create(m.canvas),b=a.create(u,{mouse:M,constraint:{stiffness:.2,render:{visible:!1}}});return c.add(p,b),m.mouse=M,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.concave.title="Concave",r.concave.for=">0.16.1",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;n0&&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;d0&&(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;p0&&(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=0.14.2",e.exports=r.sleeping},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.Composite,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,o=(Matter.Composites,Matter.MouseConstraint),i=Matter.Mouse,a=Matter.Composite,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.car(150,100,150*p,30*p,30*p)),p=.8,a.add(l,r.car.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",r.car.car=function(e,t,n,r,o){var i=Matter.Body,a=Matter.Bodies,s=Matter.Composite,c=Matter.Constraint,l=i.nextGroup(!0),d=.5*-n+20,u=.5*n-20,p=s.create({label:"Car"}),m=a.rectangle(e,t,n,r,{collisionFilter:{group:l},chamfer:{radius:.5*r},density:2e-4}),f=a.circle(e+d,t+0,o,{collisionFilter:{group:l},friction:.8}),v=a.circle(e+u,t+0,o,{collisionFilter:{group:l},friction:.8}),g=c.create({bodyB:m,pointB:{x:d,y:0},bodyA:f,stiffness:1,length:0}),y=c.create({bodyB:m,pointB:{x:u,y:0},bodyA:v,stiffness:1,length:0});return s.addBody(p,m),s.addBody(p,f),s.addBody(p,v),s.addConstraint(p,g),s.addConstraint(p,y),p},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.Composite,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,10,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={x:-300,y:-300},b={x:1100,y:900},S=1,w={x:1,y:1};return r.on(f,"beforeRender",(function(){p.world;var e,t=y.mouse,n=-.1*t.wheelDelta;0!==n&&(n<0&&w.x>=.6||n>0&&w.x<=1.4)&&(S+=n),Math.abs(w.x-S)>.01&&(n=.2*(S-w.x),w.x+=n,w.y+=n,f.bounds.max.x=f.bounds.min.x+f.options.width*w.x,f.bounds.max.y=f.bounds.min.y+f.options.height*w.y,e={x:f.options.width*n*-.5,y:f.options.height*n*-.5},d.translate(f.bounds,e),s.setScale(t,w),s.setOffset(t,f.bounds.min));var r=l.sub(t.absolute,h),o=l.magnitude(r);if(o>50){var i=l.normalise(r),a=Math.min(10,2e-4*Math.pow(o-50,2));e=l.mult(i,a),f.bounds.min.x+e.xb.x&&(e.x=b.x-f.bounds.max.x),f.bounds.min.y+e.yb.y&&(e.y=b.y-f.bounds.max.y),d.translate(f.bounds,e),s.setOffset(t,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("Z/YF"),a=n("Tgw/"),s=n("oT59"),c=n("0kzT");r.collides=function(e,t){for(var n=[],r=t.length,o=e.bounds,s=i.collides,c=a.overlaps,l=0;ld.bounds.max.x||m.bounds.max.yd.bounds.max.y))){var f=r._getRegion(e,m);if(!m.region||f.id!==m.region.id||o){m.region&&!o||(m.region=f);var v=r._regionUnion(f,m.region);for(a=v.startCol;a<=v.endCol;a++)for(s=v.startRow;s<=v.endRow;s++){c=u[l=r._getBucketId(a,s)];var g=a>=f.startCol&&a<=f.endCol&&s>=f.startRow&&s<=f.endRow,y=a>=m.region.startCol&&a<=m.region.endCol&&s>=m.region.startRow&&s<=m.region.endRow;!g&&y&&y&&c&&r._bucketRemoveBody(e,c,m),(m.region===f||g&&!y||o)&&(c||(c=r._createBucket(u,l)),r._bucketAddBody(e,c,m))}m.region=f,p=!0}}}p&&(e.pairsList=r._createActivePairsList(e))},a(r,"update","Grid.update ➤ replaced by Matter.Detector"),r.clear=function(e){e.buckets={},e.pairs={},e.pairsList=[]},a(r,"clear","Grid.clear ➤ replaced by Matter.Detector"),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){var r,i=e.pairs,a=o.id,s=t.length;for(r=0;r0?s.push(t):delete r[o[n]];return s}},"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;re.max.x&&(e.max.x=o.x),o.xe.max.y&&(e.max.y=o.y),o.y0?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.Composite,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"}}),M=c.rectangle(600,200,120,50,{render:{fillStyle:"#060a19"}}),b=c.rectangle(660,200,50,190,{render:{fillStyle:"#060a19"}}),S=r.create({parts:[M,b],isStatic:!0});s.add(d,[m,f,v,g,y,x,h,S]),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 w=0,C=1.01;o.on(p,"afterTick",(function(e){40===(w+=1)&&r.setStatic(h,!0),C>1&&(r.scale(x,C,C),r.scale(S,.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(S,{x:0,y:t-S.position.y}),r.setAngularVelocity(S,.02),r.setPosition(S,{x:600,y:t}),r.rotate(S,.02),w>=90&&(r.setVelocity(f,{x:0,y:-10}),r.setAngle(v,.26*-Math.PI),r.setAngularVelocity(g,.2),w=0,C=1)}));var A=a.create(u.canvas),B=i.create(l,{mouse:A,constraint:{stiffness:.2,render:{visible:!1}}});return s.add(d,B),u.mouse=A,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},Vyp4:function(e,t,n){var r=r||{};r.remove=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.Composite,c=Matter.Bodies,l=Matter.Events,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=null,v=0,g=function(){return r.stack(20,20,10,5,0,0,(function(e,t){var n=Math.round(o.random(1,8)),r=null;switch(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})}}))};l.on(d,"afterUpdate",(function(){f&&v<=50?v+=1:(v=0,f&&s.remove(u,f),f=g(),s.add(u,f))})),s.add(u,g()),s.add(u,[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 y=a.create(p.canvas),x=i.create(d,{mouse:y,constraint:{stiffness:.2,render:{visible:!1}}});return s.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.remove.title="Composite Remove",r.remove.for=">=0.14.2",e.exports=r.remove},"Z/YF":function(e,t,n){var r={};e.exports=r;var o,i,a,s=n("0kzT"),c=n("t8gT");o=[],i={overlap:0,axis:null},a={overlap:0,axis:null},r.create=function(e,t){return{pair:null,collided:!1,bodyA:e,bodyB:t,parentA:e.parent,parentB:t.parent,depth:0,normal:{x:0,y:0},tangent:{x:0,y:0},penetration:{x:0,y:0},supports:[]}},r.collides=function(e,t,n){if(r._overlapAxes(i,e.vertices,t.vertices,e.axes),i.overlap<=0)return null;if(r._overlapAxes(a,t.vertices,e.vertices,t.axes),a.overlap<=0)return null;var o,l,d=n&&n.table[c.id(e,t)];d?o=d.collision:((o=r.create(e,t)).collided=!0,o.bodyA=e.idC?C=s:sA?A=s:so?o=a:a=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.Bodies,d=e.create(),u=d.world,p=t.create({element:document.body,engine:d,options:{width:800,height:600,showAngleIndicator:!0,showCollisions:!0,showVelocity:!0}});t.run(p);var m=n.create();n.run(m,d);var f=r.nextGroup(!0),v=i.stack(100,50,8,1,10,10,(function(e,t){return l.rectangle(e,t,50,20,{collisionFilter:{group:f}})}));i.chain(v,.5,0,-.5,0,{stiffness:.8,length:2,render:{type:"line"}}),o.add(v,a.create({bodyB:v.bodies[0],pointB:{x:-25,y:0},pointA:{x:v.bodies[0].position.x,y:v.bodies[0].position.y},stiffness:.5})),f=r.nextGroup(!0);var g=i.stack(350,50,10,1,10,10,(function(e,t){return l.circle(e,t,20,{collisionFilter:{group:f}})}));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:-20,y:0},pointA:{x:g.bodies[0].position.x,y:g.bodies[0].position.y},stiffness:.5})),f=r.nextGroup(!0);var y=i.stack(600,50,13,1,10,10,(function(e,t){return l.rectangle(e-20,t,50,20,{collisionFilter:{group:f},chamfer:5})}));i.chain(y,.3,0,-.3,0,{stiffness:1,length:0}),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})),o.add(u,[v,g,y,l.rectangle(400,600,1200,50.5,{isStatic:!0})]);var x=c.create(p.canvas),h=s.create(d,{mouse:x,constraint:{stiffness:.2,render:{visible:!1}}});return o.add(u,h),p.mouse=x,t.lookAt(p,{min:{x:0,y:0},max:{x:700,y:600}}),{engine:d,runner:m,render:p,canvas:p.canvas,stop:function(){Matter.Render.stop(p),Matter.Runner.stop(m)}}},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,o=Matter.Composites,i=(Matter.Common,Matter.MouseConstraint),a=Matter.Mouse,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";r.add(l,s.rectangle(400,600,900,50,{isStatic:!0,render:{fillStyle:"transparent",lineWidth:1}})),r.add(l,o.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}})}))),r.add(l,s.circle(310,40,30,{collisionFilter:{mask:5},render:{fillStyle:f}})),r.add(l,s.circle(400,40,30,{collisionFilter:{mask:3},render:{fillStyle:p}})),r.add(l,s.circle(480,40,30,{collisionFilter:{mask:9},render:{fillStyle:m}}));var v=a.create(d.canvas),g=i.create(c,{mouse:v,constraint:{stiffness:.2,render:{visible:!1}}});return r.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.Composite,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:!1,tools:!1,fullscreen:!0,exampleSelect:!0},tools:{inspector:!1,gui:!1},inline:!1,preventZoom:!0,resetOnOrientation:!0,routing:!0,startExample:!1,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:!1,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.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),o.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=i.stack(200,200,4,4,0,0,(function(e,t){return c.rectangle(e,t,40,40)}));o.add(d,m),l.gravity.y=0,r.on(l,"afterUpdate",(function(e){var t=l.timing.timestamp;o.translate(m,{x:2*Math.sin(.001*t),y:0}),o.rotate(m,.01*Math.sin(.001*t),{x:300,y:300});var n=1+.01*Math.sin(.001*t);o.scale(m,n,n,{x:300,y:300})}));var f=s.create(u.canvas),v=a.create(l,{mouse:f,constraint:{stiffness:.2,render:{visible:!1}}});return o.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.compositeManipulation.title="Composite Manipulation",r.compositeManipulation.for=">0.16.1",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.Bodies,p=(Matter.Vector,e.create()),m=p.world,f=n.create({element:document.body,engine:p,options:{width:800,height:600,showAngleIndicator:!0}});n.run(f);var v=o.create();o.run(v,p);for(var g=(f.bounds.max.y-f.bounds.min.y)/50,y=c.stack(0,0,g+2,1,0,0,(function(e,t,n){return u.rectangle(e-50,t+50*n,100,1e3,{isStatic:!0,render:{fillStyle:"#060a19",strokeStyle:"#ffffff",lineWidth:1}})})),x=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?u.rectangle(e,t,a.random(25,50),a.random(25,50),o):u.rectangle(e,t,a.random(80,120),a.random(25,30),o);case 1:return u.polygon(e,t,r,a.random(25,50),o)}})),h=s.create(),M=0;M<1;M+=1){var b=r.ragdoll.ragdoll(200,-1e3*M,1.3);s.add(h,b)}s.add(m,[y,x,h]);var S=1,w=0;t.on(p,"afterUpdate",(function(e){-1===C.button?p.timing.timeScale+=.05*(S-p.timing.timeScale):p.timing.timeScale=1,(w+=1)>=90&&(S=S<1?1:.05,w=0);for(var t=0;tf.bounds.max.y+100&&s.translate(r,{x:.9*-o.min.x,y:-f.bounds.max.y-400})}for(t=0;tf.bounds.max.y+100&&i.translate(n,{x:-o.min.x,y:-f.bounds.max.y-300})}}));var C=d.create(f.canvas),A=l.create(p,{mouse:C,constraint:{stiffness:.6,length:0,angularStiffness:0,render:{visible:!1}}});return s.add(m,A),f.mouse=C,n.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.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),M=i.rectangle(e,t,55*n,80*n,d),b=i.rectangle(e+39*n,t-15*n,20*n,40*n,m),S=i.rectangle(e+39*n,t+25*n,20*n,60*n,f),w=i.rectangle(e-39*n,t-15*n,20*n,40*n,u),C=i.rectangle(e-39*n,t+25*n,20*n,60*n,p),A=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:M,pointA:{x:24*n,y:-23*n},pointB:{x:0,y:-8*n},bodyB:b,stiffness:.6,render:{visible:!1}}),I=a.create({bodyA:M,pointA:{x:-24*n,y:-23*n},pointB:{x:0,y:-8*n},bodyB:w,stiffness:.6,render:{visible:!1}}),E=a.create({bodyA:M,pointA:{x:-10*n,y:30*n},pointB:{x:0,y:-10*n},bodyB:A,stiffness:.6,render:{visible:!1}}),_=a.create({bodyA:M,pointA:{x:10*n,y:30*n},pointB:{x:0,y:-10*n},bodyB:k,stiffness:.6,render:{visible:!1}}),T=a.create({bodyA:b,bodyB:S,pointA:{x:0,y:15*n},pointB:{x:0,y:-25*n},stiffness:.6,render:{visible:!1}}),F=a.create({bodyA:w,bodyB:C,pointA:{x:0,y:15*n},pointB:{x:0,y:-25*n},stiffness:.6,render:{visible:!1}}),V=a.create({bodyA:A,bodyB:B,pointA:{x:0,y:20*n},pointB:{x:0,y:-20*n},stiffness:.6,render:{visible:!1}}),D=a.create({bodyA:k,bodyB:R,pointA:{x:0,y:20*n},pointB:{x:0,y:-20*n},stiffness:.6,render:{visible:!1}}),L=a.create({bodyA:h,pointA:{x:0,y:25*n},pointB:{x:0,y:-35*n},bodyB:M,stiffness:.6,render:{visible:!1}}),O=a.create({bodyA:B,bodyB:R,stiffness:.01,render:{visible:!1}});return s.create({bodies:[M,h,C,w,S,b,B,R,A,k],constraints:[F,T,I,P,L,V,D,E,_,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.Composite,a=Matter.MouseConstraint,s=Matter.Mouse,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),M=c.circle(f+m,v,30),b=c.circle(f+m,v+m,30),S=c.circle(f,v+m,30),w=r.create({parts:[h,M,b,S]}),C=o.create({pointA:{x:400,y:100},bodyB:w,pointB:{x:0,y:0}});i.add(d,[x,w,C,c.rectangle(400,600,800,50.5,{isStatic:!0})]);var A=s.create(u.canvas),B=a.create(l,{mouse:A,constraint:{stiffness:.2,render:{visible:!1}}});return i.add(d,B),u.mouse=A,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.Composite,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;t0&&(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}}},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.Composite,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>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("571F"),i=n("Z/YF");r.create=function(e){return o.extend({bodies:[],pairs:null},e)},r.setBodies=function(e,t){e.bodies=t.slice(0)},r.clear=function(e){e.bodies=[]},r.collisions=function(e){var t,n,o=[],a=e.pairs,s=e.bodies,c=s.length,l=r.canCollide,d=i.collides;for(s.sort(r._compareBoundsX),t=0;tm)break;if(!(fk.max.y)&&(!g||!h.isStatic&&!h.isSleeping)&&l(u.collisionFilter,h.collisionFilter)){var M=h.parts.length;if(x&&1===M)(A=d(u,h,a))&&o.push(A);else for(var b=M>1?1:0,S=y>1?1:0;Sk.max.x||p.max.xk.max.y||(A=d(w,B,a))&&o.push(A)}}}}return o},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)},r._compareBoundsX=function(e,t){return e.bounds.min.x-t.bounds.min.x}},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.Composite,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>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.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("m6Dm"),l=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._goodFps=30,r._goodDelta=1e3/60,r.create=function(e){var t={controller:r,engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,timing:{historySize:60,delta:0,deltaHistory:[],lastTime:0,lastTimestamp:0,lastElapsed:0,timestampElapsed:0,timestampElapsedHistory:[],engineDeltaHistory:[],engineElapsedHistory:[],elapsedHistory:[]},options:{width:800,height:600,pixelRatio:1,background:"#14151f",wireframeBackground:"#14151f",hasBounds:!!e.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showStats:!1,showPerformance:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},n=o.extend(t,e);return n.canvas&&(n.canvas.width=n.options.width||n.canvas.width,n.canvas.height=n.options.height||n.canvas.height),n.mouse=e.mouse,n.engine=e.engine,n.canvas=n.canvas||u(n.options.width,n.options.height),n.context=n.canvas.getContext("2d"),n.textures={},n.bounds=n.bounds||{min:{x:0,y:0},max:{x:n.canvas.width,y:n.canvas.height}},n.options.showBroadphase=!1,1!==n.options.pixelRatio&&r.setPixelRatio(n,n.options.pixelRatio),o.isElement(n.element)?n.element.appendChild(n.canvas):n.canvas.parentNode||o.log("Render.create: options.element was undefined, render.canvas was created but not appended","warn"),n},r.run=function(t){!function o(i){t.frameRequestId=e(o),n(t,i),r.world(t,i),(t.options.showStats||t.options.showDebug)&&r.stats(t,t.context,i),(t.options.showPerformance||t.options.showDebug)&&r.performance(t,t.context,i)}()},r.stop=function(e){t(e.frameRequestId)},r.setPixelRatio=function(e,t){var n=e.options,r=e.canvas;"auto"===t&&(t=p(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;ai.max.x&&(i.max.x=d.x),c.yi.max.y&&(i.max.y=d.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&&(l.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}),l.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,t){var n,d=o.now(),u=e.engine,p=u.world,m=e.canvas,v=e.context,g=e.options,y=e.timing,x=i.allBodies(p),h=i.allConstraints(p),M=g.wireframes?g.wireframeBackground:g.background,b=[],S=[],w={timestamp:u.timing.timestamp};if(s.trigger(e,"beforeRender",w),e.currentBackground!==M&&f(e,M),v.globalCompositeOperation="source-in",v.fillStyle="transparent",v.fillRect(0,0,m.width,m.height),v.globalCompositeOperation="source-over",g.hasBounds){for(n=0;n1?1:0;a1?1:0;s1?1:0;i1?1:0;s1?1:0;i1?1:0;i1?1:0;o0)){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;s0&&c.trigger(e,"collisionStart",{pairs:g.collisionStart}),i.preSolvePosition(g.list),m=0;m0&&c.trigger(e,"collisionActive",{pairs:g.collisionActive}),g.collisionEnd.length>0&&c.trigger(e,"collisionEnd",{pairs:g.collisionEnd}),r._bodiesClearForces(M),c.trigger(e,"afterUpdate",h),e.timing.lastElapsed=u.now()-p,e},r.merge=function(e,t){if(u.extend(e,t),t.world){e.world=t.world,r.clear(e);for(var n=l.allBodies(e.world),i=0;i0&&o.area(B)1?(f=a.create(i.extend({parts:v.slice(0)},r)),a.setPosition(f,{x:e,y:t}),f):v[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;l1?1:0;d=0.14.2",r.cloth.cloth=function(e,t,n,r,o,i,a,s,c,l){var d=Matter.Body,u=Matter.Bodies,p=Matter.Common,m=Matter.Composites,f=d.nextGroup(!0);c=p.extend({inertia:1/0,friction:1e-5,collisionFilter:{group:f},render:{visible:!1}},c),l=p.extend({stiffness:.06,render:{type:"line",anchors:!1}},l);var v=m.stack(e,t,n,r,o,i,(function(e,t){return u.circle(e,t,s,c)}));return m.mesh(v,n,r,a,l),v.label="Cloth Body",v},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={id:r.id(n,o),bodyA:n,bodyB:o,collision:e,contacts:[],activeContacts:[],separation:0,isActive:!0,confirmedActive:!0,isSensor:n.isSensor||o.isSensor,timeCreated:t,timeUpdated:t,inverseMass:0,friction:0,frictionStatic:0,restitution:0,slop:0};return r.update(i,e,t),i},r.update=function(e,t,n){var r=e.contacts,i=t.supports,a=e.activeContacts,s=t.parentA,c=t.parentB,l=s.vertices.length;e.isActive=!0,e.timeUpdated=n,e.collision=t,e.separation=t.depth,e.inverseMass=s.inverseMass+c.inverseMass,e.friction=s.frictionc.frictionStatic?s.frictionStatic:c.frictionStatic,e.restitution=s.restitution>c.restitution?s.restitution:c.restitution,e.slop=s.slop>c.slop?s.slop:c.slop,t.pair=e,a.length=0;for(var d=0;d.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.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=c.length,d=e.table,u=t.length,p=e.collisionStart,m=e.collisionEnd,f=e.collisionActive;for(p.length=0,m.length=0,f.length=0,s=0;s=0?i(s,false):a(s,false)},vSND:function(e,t,n){var r=r||{};r.stats=function(){var e=Matter.Engine,t=Matter.Render,n=Matter.Runner,r=Matter.Common,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,showStats:!0,showPerformance:!0}});t.run(u);var p=n.create();n.run(p,l);var m=o.stack(70,30,13,9,5,5,(function(e,t){return c.circle(e,t,10+20*r.random())}));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})]);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.stats.title="Stats & Performance",r.stats.for=">=0.16.1",e.exports=r.stats},"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:{},cache:{allBodies:null,allConstraints:null,allComposites:null}},e)},r.setModified=function(e,t,n,o){if(e.isModified=t,t&&e.cache&&(e.cache.allBodies=null,e.cache.allConstraints=null,e.cache.allComposites=null),n&&e.parent&&r.setModified(e.parent,t,n,o),o)for(var i=0;i=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,o=Matter.Body,i=(Matter.Composites,Matter.MouseConstraint),a=Matter.Mouse,s=Matter.Composite,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=r.newtonsCradle.newtonsCradle(280,100,5,30,200);s.add(l,p),o.translate(p.bodies[0],{x:-180,y:-100}),p=r.newtonsCradle.newtonsCradle(280,380,7,20,140),s.add(l,p),o.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",r.newtonsCradle.newtonsCradle=function(e,t,n,r,o){for(var i=Matter.Composite,a=Matter.Constraint,s=Matter.Bodies,c=i.create({label:"Newtons Cradle"}),l=0;l0){n||(n={}),r=t.split(" ");for(var l=0;l=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;o0&&i.motion=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;or._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.Composite,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]]])}));