You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6 lines
2.1 KiB
JavaScript

2 years ago
/*!
* matter-wrap 0.2.0 by Liam Brummitt 2017-07-04
* https://github.com/liabru/matter-wrap
* License MIT
*/
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("matter-js")):"function"==typeof define&&define.amd?define(["matter-js"],e):"object"==typeof exports?exports.MatterWrap=e(require("matter-js")):n.MatterWrap=e(n.Matter)}(this,function(n){return function(n){function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var t={};return e.m=n,e.c=t,e.i=function(n){return n},e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:r})},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},e.p="/libs",e(e.s=1)}([function(e,t){e.exports=n},function(n,e,t){"use strict";var r=t(0),o={name:"matter-wrap",version:"0.1.3",for:"matter-js@^0.12.0",install:function(n){n.after("Engine.update",function(){o.Engine.update(this)})},Engine:{update:function(n){for(var e=n.world,t=r.Composite.allBodies(e),i=r.Composite.allComposites(e),u=0;u<t.length;u+=1){var a=t[u];a.plugin.wrap&&o.Body.wrap(a,a.plugin.wrap)}for(u=0;u<i.length;u+=1){var p=i[u];p.plugin.wrap&&o.Composite.wrap(p,p.plugin.wrap)}}},Bounds:{wrap:function(n,e){var t=null,r=null;if("undefined"!=typeof e.min.x&&"undefined"!=typeof e.max.x&&(n.min.x>e.max.x?t=e.min.x-n.max.x:n.max.x<e.min.x&&(t=e.max.x-n.min.x)),"undefined"!=typeof e.min.y&&"undefined"!=typeof e.max.y&&(n.min.y>e.max.y?r=e.min.y-n.max.y:n.max.y<e.min.y&&(r=e.max.y-n.min.y)),null!==t||null!==r)return{x:t||0,y:r||0}}},Body:{wrap:function(n,e){var t=o.Bounds.wrap(n.bounds,e);return t&&r.Body.translate(n,t),t}},Composite:{bounds:function(n){for(var e=r.Composite.allBodies(n),t=[],o=0;o<e.length;o+=1){var i=e[o];t.push(i.bounds.min,i.bounds.max)}return r.Bounds.create(t)},wrap:function(n,e){var t=o.Bounds.wrap(o.Composite.bounds(n),e);return t&&r.Composite.translate(n,t),t}}};r.Plugin.register(o),n.exports=o}])});