0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-23 09:26:51 -05:00

fix decomp import in Bodies.fromVertices

This commit is contained in:
liabru 2019-09-14 18:59:01 +01:00
parent 9ef9d020c4
commit 94e9614436
2 changed files with 2 additions and 21 deletions

View file

@ -535,19 +535,4 @@ module.exports = Common;
func func
)); ));
}; };
/**
* Used to require external libraries outside of the bundle.
* It first looks for the `globalName` on the environment's global namespace.
* If the global is not found, it will fall back to using the standard `require` using the `moduleName`.
* @private
* @method _requireGlobal
* @param {string} globalName The global module name
* @param {string} moduleName The fallback CommonJS module name
* @return {} The loaded module
*/
Common._requireGlobal = function(globalName, moduleName) {
var obj = (typeof window !== 'undefined' ? window[globalName] : typeof global !== 'undefined' ? global[globalName] : null);
return obj || require(moduleName);
};
})(); })();

View file

@ -18,7 +18,6 @@ var Common = require('../core/Common');
var Body = require('../body/Body'); var Body = require('../body/Body');
var Bounds = require('../geometry/Bounds'); var Bounds = require('../geometry/Bounds');
var Vector = require('../geometry/Vector'); var Vector = require('../geometry/Vector');
var decomp;
(function() { (function() {
@ -197,11 +196,8 @@ var decomp;
* @return {body} * @return {body}
*/ */
Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) { Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) {
if (!decomp) { var decomp = typeof decomp !== 'undefined' ? decomp : require('poly-decomp'),
decomp = Common._requireGlobal('decomp', 'poly-decomp'); body,
}
var body,
parts, parts,
isConvex, isConvex,
vertices, vertices,