From 94e9614436a10907c208ebbf7e8a4a3c484eb7b1 Mon Sep 17 00:00:00 2001 From: liabru Date: Sat, 14 Sep 2019 18:59:01 +0100 Subject: [PATCH] fix decomp import in Bodies.fromVertices --- src/core/Common.js | 15 --------------- src/factory/Bodies.js | 8 ++------ 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/core/Common.js b/src/core/Common.js index 70d38d8..f03de7b 100644 --- a/src/core/Common.js +++ b/src/core/Common.js @@ -535,19 +535,4 @@ module.exports = Common; 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); - }; })(); diff --git a/src/factory/Bodies.js b/src/factory/Bodies.js index d1edd68..e27a93c 100644 --- a/src/factory/Bodies.js +++ b/src/factory/Bodies.js @@ -18,7 +18,6 @@ var Common = require('../core/Common'); var Body = require('../body/Body'); var Bounds = require('../geometry/Bounds'); var Vector = require('../geometry/Vector'); -var decomp; (function() { @@ -197,11 +196,8 @@ var decomp; * @return {body} */ Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) { - if (!decomp) { - decomp = Common._requireGlobal('decomp', 'poly-decomp'); - } - - var body, + var decomp = typeof decomp !== 'undefined' ? decomp : require('poly-decomp'), + body, parts, isConvex, vertices,