0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-12-23 13:19:01 -05:00

release 0.9.1

This commit is contained in:
liabru 2016-02-15 21:24:17 +00:00
parent 4d65dd19a6
commit b11b4def9a
5 changed files with 43 additions and 15 deletions

View file

@ -1,3 +1,30 @@
<a name="0.9.1"></a>
## 0.9.1 (2016-02-15)
* added default for delta parameter in Engine.update, closes #200 ([490d232](https://github.com/liabru/matter-js/commit/490d232)), closes [#200](https://github.com/liabru/matter-js/issues/200)
* added docs for body.render.opacity ([adcb610](https://github.com/liabru/matter-js/commit/adcb610))
* added SVGPathSeg polyfill, closes #196 ([8fcb893](https://github.com/liabru/matter-js/commit/8fcb893)), closes [#196](https://github.com/liabru/matter-js/issues/196)
* Adding the opacity attribute to be able to draw semi-transarent sprites ([5b755a1](https://github.com/liabru/matter-js/commit/5b755a1))
* allow passing of pixi objects to Matter.RenderPixi at creation, closes #193 ([dbdabcc](https://github.com/liabru/matter-js/commit/dbdabcc)), closes [#193](https://github.com/liabru/matter-js/issues/193)
* change main reference in package.json ([633c305](https://github.com/liabru/matter-js/commit/633c305))
* Changed bounds checking MIN_VALUE to -MAX_VALUE. Fixes #202 ([dd5e260](https://github.com/liabru/matter-js/commit/dd5e260)), closes [#202](https://github.com/liabru/matter-js/issues/202)
* fix issue with Bodies.circle label option, closes #195 ([e7e8c26](https://github.com/liabru/matter-js/commit/e7e8c26)), closes [#195](https://github.com/liabru/matter-js/issues/195)
* fix lint issue ([b4e875b](https://github.com/liabru/matter-js/commit/b4e875b))
* fixed build issue ([bb3d43f](https://github.com/liabru/matter-js/commit/bb3d43f))
* fixed rendering of angle indicators ([aaffee3](https://github.com/liabru/matter-js/commit/aaffee3))
* fixed rendering of compound bodies ([99dd6c5](https://github.com/liabru/matter-js/commit/99dd6c5))
* fixes to body opacity rendering ([8ac06b2](https://github.com/liabru/matter-js/commit/8ac06b2))
* Merge branch 'master' of https://github.com/ma1069/matter-js into ma1069-master ([c99e6af](https://github.com/liabru/matter-js/commit/c99e6af))
* Merge pull request #199 from kevinboudot/master ([34fa27a](https://github.com/liabru/matter-js/commit/34fa27a))
* remove redundant console.log from gulpfile ([b5006e3](https://github.com/liabru/matter-js/commit/b5006e3))
* Update README.md ([1bfb758](https://github.com/liabru/matter-js/commit/1bfb758))
* updated edge build ([cc80837](https://github.com/liabru/matter-js/commit/cc80837))
* updated test refs ([cfdc0b3](https://github.com/liabru/matter-js/commit/cfdc0b3))
* updated test refs ([4d65dd1](https://github.com/liabru/matter-js/commit/4d65dd1))
<a name="0.9.0"></a>
# 0.9.0 (2016-01-16)

View file

@ -1,6 +1,6 @@
{
"name": "Matter",
"version": "0.9.0",
"version": "0.9.1",
"homepage": "https://github.com/liabru/matter-js",
"authors": [
"Liam Brummitt <liam@brm.io> (http://brm.io/)"

View file

@ -1,5 +1,5 @@
/**
* matter-js master by @liabru 2016-02-07
* matter-js 0.9.1 by @liabru 2016-02-15
* http://brm.io/matter-js/
* License MIT
*/
@ -4442,11 +4442,12 @@ var Body = require('../body/Body');
* Triggers `collisionStart`, `collisionActive` and `collisionEnd` events.
* @method update
* @param {engine} engine
* @param {number} delta
* @param {number} [correction]
* @param {number} [delta=16.666]
* @param {number} [correction=1]
*/
Engine.update = function(engine, delta, correction) {
correction = (typeof correction !== 'undefined') ? correction : 1;
delta = delta || 1000 / 60;
correction = correction || 1;
var world = engine.world,
timing = engine.timing,
@ -5698,10 +5699,13 @@ var Vector = require('../geometry/Vector');
*/
Bodies.circle = function(x, y, radius, options, maxSides) {
options = options || {};
options.label = 'Circle Body';
var circle = {
label: 'Circle Body',
circleRadius: radius
};
// approximate circles with polygons until true circles implemented in SAT
maxSides = maxSides || 25;
var sides = Math.ceil(Math.max(10, Math.min(maxSides, radius)));
@ -5709,10 +5713,7 @@ var Vector = require('../geometry/Vector');
if (sides % 2 === 1)
sides += 1;
// flag for better rendering
options.circleRadius = radius;
return Bodies.polygon(x, y, sides, radius, options);
return Bodies.polygon(x, y, sides, radius, Common.extend({}, circle, options));
};
/**

6
build/matter.min.js vendored
View file

@ -1,5 +1,5 @@
/**
* matter-js master by @liabru 2016-02-07
* matter-js 0.9.1 by @liabru 2016-02-15
* http://brm.io/matter-js/
* License MIT
*/
@ -35,7 +35,7 @@ s.constraintImpulse.x+=y.x,s.constraintImpulse.y+=y.y,s.constraintImpulse.angle-
n.pointA=o.position,n.bodyB=e.body=s,n.pointB={x:o.position.x-s.position.x,y:o.position.y-s.position.y},n.angleB=s.angle,r.set(s,!1),a.trigger(e,"startdrag",{mouse:o,body:s});break}}}else n.bodyB=e.body=null,n.pointB=null,s&&a.trigger(e,"enddrag",{mouse:o,body:s})};var e=function(e){var t=e.mouse,o=t.sourceEvents;o.mousemove&&a.trigger(e,"mousemove",{mouse:t}),o.mousedown&&a.trigger(e,"mousedown",{mouse:t}),o.mouseup&&a.trigger(e,"mouseup",{mouse:t}),s.clearSourceEvents(t)}}()},{"../body/Composite":2,"../collision/Detector":5,"../core/Common":14,"../core/Events":16,"../core/Mouse":18,"../core/Sleeping":20,"../geometry/Bounds":24,"../geometry/Vertices":27,"./Constraint":12}],14:[function(e,t,o){var n={};t.exports=n,function(){n._nextId=0,n._seed=0,n.extend=function(e,t){var o,i,r;"boolean"==typeof t?(o=2,r=t):(o=1,r=!0),i=Array.prototype.slice.call(arguments,o);for(var s=0;s<i.length;s++){var a=i[s];if(a)for(var l in a)r&&a[l]&&a[l].constructor===Object?e[l]&&e[l].constructor!==Object?e[l]=a[l]:(e[l]=e[l]||{},
n.extend(e[l],r,a[l])):e[l]=a[l]}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 o in e)t.push(o);return t},n.values=function(e){var t=[];if(Object.keys){for(var o=Object.keys(e),n=0;n<o.length;n++)t.push(e[o[n]]);return t}for(var i in e)t.push(e[i]);return t},n.shadeColor=function(e,t){var o=parseInt(e.slice(1),16),n=Math.round(2.55*t),i=(o>>16)+n,r=(o>>8&255)+n,s=(255&o)+n;return"#"+(16777216+65536*(255>i?1>i?0:i:255)+256*(255>r?1>r?0:r:255)+(255>s?1>s?0:s:255)).toString(16).slice(1)},n.shuffle=function(e){for(var t=e.length-1;t>0;t--){var o=Math.floor(n.random()*(t+1)),i=e[t];e[t]=e[o],e[o]=i}return e},n.choose=function(e){return e[Math.floor(n.random()*e.length)]},n.isElement=function(e){try{return e instanceof HTMLElement}catch(t){return"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument}},n.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e);
},n.clamp=function(e,t,o){return t>e?t:e>o?o:e},n.sign=function(e){return 0>e?-1:1},n.now=function(){var e=window.performance||{};return e.now=function(){return e.now||e.webkitNow||e.msNow||e.oNow||e.mozNow||function(){return+new Date}}(),e.now()},n.random=function(t,o){return t="undefined"!=typeof t?t:0,o="undefined"!=typeof o?o:1,t+e()*(o-t)},n.colorToNumber=function(e){return e=e.replace("#",""),3==e.length&&(e=e.charAt(0)+e.charAt(0)+e.charAt(1)+e.charAt(1)+e.charAt(2)+e.charAt(2)),parseInt(e,16)},n.log=function(e,t){if(console&&console.log&&console.warn)switch(t){case"warn":console.warn("Matter.js:",e);break;case"error":console.log("Matter.js:",e)}},n.nextId=function(){return n._nextId++},n.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var o=0;o<e.length;o++)if(e[o]===t)return o;return-1};var e=function(){return n._seed=(9301*n._seed+49297)%233280,n._seed/233280}}()},{}],15:[function(e,t,o){var n={};t.exports=n;var i=e("../body/World"),r=e("./Sleeping"),s=e("../collision/Resolver"),a=e("../render/Render"),l=e("../collision/Pairs"),c=(e("./Metrics"),
e("../collision/Grid")),d=e("./Events"),u=e("../body/Composite"),p=e("../constraint/Constraint"),v=e("./Common"),f=e("../body/Body");!function(){n.create=function(e,t){t=v.isElement(e)?t:e,e=v.isElement(e)?e:null;var o={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],timing:{timestamp:0,timeScale:1},broadphase:{controller:c}},n=v.extend(o,t);if(e||n.render){var r={element:e,controller:a};n.render=v.extend(r,n.render)}return n.render&&n.render.controller&&(n.render=n.render.controller.create(n.render)),n.world=i.create(n.world),n.pairs=l.create(),n.broadphase=n.broadphase.controller.create(n.broadphase),n.metrics=n.metrics||{extended:!1},n},n.update=function(n,i,a){a="undefined"!=typeof a?a:1;var c,v=n.world,f=n.timing,y=n.broadphase,m=[];f.timestamp+=i*f.timeScale;var g={timestamp:f.timestamp};d.trigger(n,"beforeUpdate",g);var x=u.allBodies(v),h=u.allConstraints(v);for(n.enableSleeping&&r.update(x,f.timeScale),t(x,v.gravity),o(x,i,f.timeScale,a,v.bounds),
e("../collision/Grid")),d=e("./Events"),u=e("../body/Composite"),p=e("../constraint/Constraint"),v=e("./Common"),f=e("../body/Body");!function(){n.create=function(e,t){t=v.isElement(e)?t:e,e=v.isElement(e)?e:null;var o={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],timing:{timestamp:0,timeScale:1},broadphase:{controller:c}},n=v.extend(o,t);if(e||n.render){var r={element:e,controller:a};n.render=v.extend(r,n.render)}return n.render&&n.render.controller&&(n.render=n.render.controller.create(n.render)),n.world=i.create(n.world),n.pairs=l.create(),n.broadphase=n.broadphase.controller.create(n.broadphase),n.metrics=n.metrics||{extended:!1},n},n.update=function(n,i,a){i=i||1e3/60,a=a||1;var c,v=n.world,f=n.timing,y=n.broadphase,m=[];f.timestamp+=i*f.timeScale;var g={timestamp:f.timestamp};d.trigger(n,"beforeUpdate",g);var x=u.allBodies(v),h=u.allConstraints(v);for(n.enableSleeping&&r.update(x,f.timeScale),t(x,v.gravity),o(x,i,f.timeScale,a,v.bounds),
c=0;c<n.constraintIterations;c++)p.solveAll(h,f.timeScale);p.postSolveAll(x),y.controller?(v.isModified&&y.controller.clear(y),y.controller.update(y,x,n,v.isModified),m=y.pairsList):m=x;var b=y.detector(m,n),S=n.pairs,C=f.timestamp;for(l.update(S,b,C),l.removeOld(S,C),n.enableSleeping&&r.afterCollisions(S.list,f.timeScale),S.collisionStart.length>0&&d.trigger(n,"collisionStart",{pairs:S.collisionStart}),s.preSolvePosition(S.list),c=0;c<n.positionIterations;c++)s.solvePosition(S.list,f.timeScale);for(s.postSolvePosition(x),s.preSolveVelocity(S.list),c=0;c<n.velocityIterations;c++)s.solveVelocity(S.list,f.timeScale);return S.collisionActive.length>0&&d.trigger(n,"collisionActive",{pairs:S.collisionActive}),S.collisionEnd.length>0&&d.trigger(n,"collisionEnd",{pairs:S.collisionEnd}),e(x),v.isModified&&u.setModified(v,!1,!1,!0),d.trigger(n,"afterUpdate",g),n},n.merge=function(e,t){if(v.extend(e,t),t.world){e.world=t.world,n.clear(e);for(var o=u.allBodies(e.world),i=0;i<o.length;i++){var s=o[i];
r.set(s,!1),s.id=v.nextId()}}},n.clear=function(e){var t=e.world;l.clear(e.pairs);var o=e.broadphase;if(o.controller){var n=u.allBodies(t);o.controller.clear(o),o.controller.update(o,n,e,!0)}};var e=function(e){for(var t=0;t<e.length;t++){var o=e[t];o.force.x=0,o.force.y=0,o.torque=0}},t=function(e,t){var o="undefined"!=typeof t.scale?t.scale:.001;if((0!==t.x||0!==t.y)&&0!==o)for(var n=0;n<e.length;n++){var i=e[n];i.isStatic||i.isSleeping||(i.force.y+=i.mass*t.y*o,i.force.x+=i.mass*t.x*o)}},o=function(e,t,o,n,i){for(var r=0;r<e.length;r++){var s=e[r];s.isStatic||s.isSleeping||f.update(s,t,o,n)}}}()},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Grid":6,"../collision/Pairs":8,"../collision/Resolver":10,"../constraint/Constraint":12,"../render/Render":29,"./Common":14,"./Events":16,"./Metrics":17,"./Sleeping":20}],16:[function(e,t,o){var n={};t.exports=n;var i=e("./Common");!function(){n.on=function(e,t,o){for(var n,i=t.split(" "),r=0;r<i.length;r++)n=i[r],e.events=e.events||{},
e.events[n]=e.events[n]||[],e.events[n].push(o);return o},n.off=function(e,t,o){if(!t)return void(e.events={});"function"==typeof t&&(o=t,t=i.keys(e.events).join(" "));for(var n=t.split(" "),r=0;r<n.length;r++){var s=e.events[n[r]],a=[];if(o&&s)for(var l=0;l<s.length;l++)s[l]!==o&&a.push(s[l]);e.events[n[r]]=a}},n.trigger=function(e,t,o){var n,r,s,a;if(e.events){o||(o={}),n=t.split(" ");for(var l=0;l<n.length;l++)if(r=n[l],s=e.events[r]){a=i.clone(o,!1),a.name=r,a.source=e;for(var c=0;c<s.length;c++)s[c].apply(e,[a])}}}}()},{"./Common":14}],17:[function(e,t,o){},{"../body/Composite":2,"./Common":14}],18:[function(e,t,o){var n={};t.exports=n;var i=e("../core/Common");!function(){n.create=function(t){var o={};return t||i.log("Mouse.create: element was undefined, defaulting to document.body","warn"),o.element=t||document.body,o.absolute={x:0,y:0},o.position={x:0,y:0},o.mousedownPosition={x:0,y:0},o.mouseupPosition={x:0,y:0},o.offset={x:0,y:0},o.scale={x:1,y:1},o.wheelDelta=0,o.button=-1,o.pixelRatio=o.element.getAttribute("data-pixel-ratio")||1,
@ -45,7 +45,7 @@ o.sourceEvents.mouseup=t},o.mousewheel=function(e){o.wheelDelta=Math.max(-1,Math
frameCounter:0,deltaHistory:[],timePrev:null,timeScalePrev:1,frameRequestId:null,isFixed:!1,enabled:!0},o=s.extend(t,e);return o.delta=o.delta||1e3/o.fps,o.deltaMin=o.deltaMin||1e3/o.fps,o.deltaMax=o.deltaMax||1e3/(.5*o.fps),o.fps=1e3/o.delta,o},n.run=function(t,o){return"undefined"!=typeof t.positionIterations&&(o=t,t=n.create()),function i(r){t.frameRequestId=e(i),r&&t.enabled&&n.tick(t,o,r)}(),t},n.tick=function(e,t,o){var n,s=t.timing,a=1,l={timestamp:s.timestamp};i.trigger(e,"beforeTick",l),i.trigger(t,"beforeTick",l),e.isFixed?n=e.delta:(n=o-e.timePrev||e.delta,e.timePrev=o,e.deltaHistory.push(n),e.deltaHistory=e.deltaHistory.slice(-e.deltaSampleSize),n=Math.min.apply(null,e.deltaHistory),n=n<e.deltaMin?e.deltaMin:n,n=n>e.deltaMax?e.deltaMax:n,a=n/e.delta,e.delta=n),0!==e.timeScalePrev&&(a*=s.timeScale/e.timeScalePrev),0===s.timeScale&&(a=0),e.timeScalePrev=s.timeScale,e.correction=a,e.frameCounter+=1,o-e.counterTimestamp>=1e3&&(e.fps=e.frameCounter*((o-e.counterTimestamp)/1e3),e.counterTimestamp=o,
e.frameCounter=0),i.trigger(e,"tick",l),i.trigger(t,"tick",l),t.world.isModified&&t.render&&t.render.controller&&t.render.controller.clear&&t.render.controller.clear(t.render),i.trigger(e,"beforeUpdate",l),r.update(t,n,a),i.trigger(e,"afterUpdate",l),t.render&&t.render.controller&&(i.trigger(e,"beforeRender",l),i.trigger(t,"beforeRender",l),t.render.controller.world(t),i.trigger(e,"afterRender",l),i.trigger(t,"afterRender",l)),i.trigger(e,"afterTick",l),i.trigger(t,"afterTick",l)},n.stop=function(e){t(e.frameRequestId)},n.start=function(e,t){n.run(e,t)}}()},{"./Common":14,"./Engine":15,"./Events":16}],20:[function(e,t,o){var n={};t.exports=n;var i=e("./Events");!function(){n._motionWakeThreshold=.18,n._motionSleepThreshold=.08,n._minBias=.9,n.update=function(e,t){for(var o=t*t*t,i=0;i<e.length;i++){var r=e[i],s=r.speed*r.speed+r.angularSpeed*r.angularSpeed;if(0===r.force.x&&0===r.force.y){var a=Math.min(r.motion,s),l=Math.max(r.motion,s);r.motion=n._minBias*a+(1-n._minBias)*l,r.sleepThreshold>0&&r.motion<n._motionSleepThreshold*o?(r.sleepCounter+=1,
r.sleepCounter>=r.sleepThreshold&&n.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else n.set(r,!1)}},n.afterCollisions=function(e,t){for(var o=t*t*t,i=0;i<e.length;i++){var r=e[i];if(r.isActive){var s=r.collision,a=s.bodyA.parent,l=s.bodyB.parent;if(!(a.isSleeping&&l.isSleeping||a.isStatic||l.isStatic)&&(a.isSleeping||l.isSleeping)){var c=a.isSleeping&&!a.isStatic?a:l,d=c===a?l:a;!c.isStatic&&d.motion>n._motionWakeThreshold*o&&n.set(c,!1)}}}},n.set=function(e,t){var o=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,o||i.trigger(e,"sleepStart")):(e.isSleeping=!1,e.sleepCounter=0,o&&i.trigger(e,"sleepEnd"))}}()},{"./Events":16}],21:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../core/Common"),s=e("../body/Body"),a=e("../geometry/Bounds"),l=e("../geometry/Vector");!function(){n.rectangle=function(e,t,o,n,a){
a=a||{};var l={label:"Rectangle Body",position:{x:e,y:t},vertices:i.fromPath("L 0 0 L "+o+" 0 L "+o+" "+n+" L 0 "+n)};if(a.chamfer){var c=a.chamfer;l.vertices=i.chamfer(l.vertices,c.radius,c.quality,c.qualityMin,c.qualityMax),delete a.chamfer}return s.create(r.extend({},l,a))},n.trapezoid=function(e,t,o,n,a,l){l=l||{},a*=.5;var c,d=(1-2*a)*o,u=o*a,p=u+d,v=p+u;c=.5>a?"L 0 0 L "+u+" "+-n+" L "+p+" "+-n+" L "+v+" 0":"L 0 0 L "+p+" "+-n+" L "+v+" 0";var f={label:"Trapezoid Body",position:{x:e,y:t},vertices:i.fromPath(c)};if(l.chamfer){var y=l.chamfer;f.vertices=i.chamfer(f.vertices,y.radius,y.quality,y.qualityMin,y.qualityMax),delete l.chamfer}return s.create(r.extend({},f,l))},n.circle=function(e,t,o,i,r){i=i||{},i.label="Circle Body",r=r||25;var s=Math.ceil(Math.max(10,Math.min(r,o)));return s%2===1&&(s+=1),i.circleRadius=o,n.polygon(e,t,s,o,i)},n.polygon=function(e,t,o,a,l){if(l=l||{},3>o)return n.circle(e,t,a,l);for(var c=2*Math.PI/o,d="",u=.5*c,p=0;o>p;p+=1){var v=u+p*c,f=Math.cos(v)*a,y=Math.sin(v)*a;
a=a||{};var l={label:"Rectangle Body",position:{x:e,y:t},vertices:i.fromPath("L 0 0 L "+o+" 0 L "+o+" "+n+" L 0 "+n)};if(a.chamfer){var c=a.chamfer;l.vertices=i.chamfer(l.vertices,c.radius,c.quality,c.qualityMin,c.qualityMax),delete a.chamfer}return s.create(r.extend({},l,a))},n.trapezoid=function(e,t,o,n,a,l){l=l||{},a*=.5;var c,d=(1-2*a)*o,u=o*a,p=u+d,v=p+u;c=.5>a?"L 0 0 L "+u+" "+-n+" L "+p+" "+-n+" L "+v+" 0":"L 0 0 L "+p+" "+-n+" L "+v+" 0";var f={label:"Trapezoid Body",position:{x:e,y:t},vertices:i.fromPath(c)};if(l.chamfer){var y=l.chamfer;f.vertices=i.chamfer(f.vertices,y.radius,y.quality,y.qualityMin,y.qualityMax),delete l.chamfer}return s.create(r.extend({},f,l))},n.circle=function(e,t,o,i,s){i=i||{};var a={label:"Circle Body",circleRadius:o};s=s||25;var l=Math.ceil(Math.max(10,Math.min(s,o)));return l%2===1&&(l+=1),n.polygon(e,t,l,o,r.extend({},a,i))},n.polygon=function(e,t,o,a,l){if(l=l||{},3>o)return n.circle(e,t,a,l);for(var c=2*Math.PI/o,d="",u=.5*c,p=0;o>p;p+=1){var v=u+p*c,f=Math.cos(v)*a,y=Math.sin(v)*a;
d+="L "+f.toFixed(3)+" "+y.toFixed(3)+" "}var m={label:"Polygon Body",position:{x:e,y:t},vertices:i.fromPath(d)};if(l.chamfer){var g=l.chamfer;m.vertices=i.chamfer(m.vertices,g.radius,g.quality,g.qualityMin,g.qualityMax),delete l.chamfer}return s.create(r.extend({},m,l))},n.fromVertices=function(e,t,o,n,c,d,u){var p,v,f,y,m,g,x,h,b;for(n=n||{},v=[],c="undefined"!=typeof c?c:!1,d="undefined"!=typeof d?d:.01,u="undefined"!=typeof u?u:10,window.decomp||r.log("Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.","warn"),r.isArray(o[0])||(o=[o]),h=0;h<o.length;h+=1)if(y=o[h],f=i.isConvex(y),f||!window.decomp)y=f?i.clockwiseSort(y):i.hull(y),v.push({position:{x:e,y:t},vertices:y});else{var S=new decomp.Polygon;for(m=0;m<y.length;m++)S.vertices.push([y[m].x,y[m].y]);S.makeCCW(),d!==!1&&S.removeCollinearPoints(d);var C=S.quickDecomp();for(m=0;m<C.length;m++){var w=C[m],A=[];for(g=0;g<w.vertices.length;g++)A.push({x:w.vertices[g][0],y:w.vertices[g][1]
});u>0&&i.area(A)<u||v.push({position:i.centre(A),vertices:A})}}for(m=0;m<v.length;m++)v[m]=s.create(r.extend(v[m],n));if(c){var B=5;for(m=0;m<v.length;m++){var P=v[m];for(g=m+1;g<v.length;g++){var M=v[g];if(a.overlaps(P.bounds,M.bounds)){var k=P.vertices,I=M.vertices;for(x=0;x<P.vertices.length;x++)for(b=0;b<M.vertices.length;b++){var T=l.magnitudeSquared(l.sub(k[(x+1)%k.length],I[b])),V=l.magnitudeSquared(l.sub(k[x],I[(b+1)%I.length]));B>T&&B>V&&(k[x].isInternal=!0,I[b].isInternal=!0)}}}}}return v.length>1?(p=s.create(r.extend({parts:v.slice(0)},n)),s.setPosition(p,{x:e,y:t}),p):v[0]}}()},{"../body/Body":1,"../core/Common":14,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],22:[function(e,t,o){var n={};t.exports=n;var i=e("../body/Composite"),r=e("../constraint/Constraint"),s=e("../core/Common"),a=e("../body/Body"),l=e("./Bodies");!function(){n.stack=function(e,t,o,n,r,s,l){for(var c,d=i.create({label:"Stack"}),u=e,p=t,v=0,f=0;n>f;f++){for(var y=0,m=0;o>m;m++){
var g=l(u,p,m,f,c,v);if(g){var x=g.bounds.max.y-g.bounds.min.y,h=g.bounds.max.x-g.bounds.min.x;x>y&&(y=x),a.translate(g,{x:.5*h,y:.5*x}),u=g.bounds.max.x+r,i.addBody(d,g),c=g,v+=1}else u+=r}p+=y+s,u=e}return d},n.chain=function(e,t,o,n,a,l){for(var c=e.bodies,d=1;d<c.length;d++){var u=c[d-1],p=c[d],v=u.bounds.max.y-u.bounds.min.y,f=u.bounds.max.x-u.bounds.min.x,y=p.bounds.max.y-p.bounds.min.y,m=p.bounds.max.x-p.bounds.min.x,g={bodyA:u,pointA:{x:f*t,y:v*o},bodyB:p,pointB:{x:m*n,y:y*a}},x=s.extend(g,l);i.addConstraint(e,r.create(x))}return e.label+=" Chain",e},n.mesh=function(e,t,o,n,a){var l,c,d,u,p,v=e.bodies;for(l=0;o>l;l++){for(c=1;t>c;c++)d=v[c-1+l*t],u=v[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a)));if(l>0)for(c=0;t>c;c++)d=v[c+(l-1)*t],u=v[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a))),n&&c>0&&(p=v[c-1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a)))),n&&t-1>c&&(p=v[c+1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u

View file

@ -1,6 +1,6 @@
{
"name": "matter-js",
"version": "0.9.0",
"version": "0.9.1",
"license": "MIT",
"homepage": "http://brm.io/matter-js/",
"author": "Liam Brummitt <liam@brm.io> (http://brm.io/)",