diff --git a/src/factory/Bodies.js b/src/factory/Bodies.js index 1a703fa..9103d5d 100644 --- a/src/factory/Bodies.js +++ b/src/factory/Bodies.js @@ -196,7 +196,8 @@ var Vector = require('../geometry/Vector'); * @return {body} */ Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) { - var decomp = global.decomp || require('poly-decomp'), + var globals = typeof global !== 'undefined' ? global : window, + decomp, body, parts, isConvex, @@ -207,6 +208,12 @@ var Vector = require('../geometry/Vector'); v, z; + try { + decomp = globals.decomp || require('poly-decomp'); + } catch (e) { + // decomp is undefined + } + options = options || {}; parts = [];