var t = arequire("../@babel/runtime/helpers/typeof");

window.p2 = function t(e, o, i) {
    function n(r, a) {
        if (!o[r]) {
            if (!e[r]) {
                var c = "function" == typeof arequire && arequire;
                if (!a && c) return c(r, !0);
                if (s) return s(r, !0);
                throw new Error("Cannot find module '" + r + "'");
            }
            var h = o[r] = {
                exports: {}
            };
            e[r][0].call(h.exports, function(t) {
                return n(e[r][1][t] || t);
            }, h, h.exports, t, e, o, i);
        }
        return o[r].exports;
    }
    for (var s = "function" == typeof arequire && arequire, r = 0; r < i.length; r++) n(i[r]);
    return n;
}({
    1: [ function(t, e, o) {
        var i = t("./Scalar");
        function n() {}
        e.exports = n, n.lineInt = function(t, e, o) {
            o = o || 0;
            var n, s, r, a, c, h, l, p = [ 0, 0 ];
            return n = t[1][1] - t[0][1], s = t[0][0] - t[1][0], r = n * t[0][0] + s * t[0][1], 
            a = e[1][1] - e[0][1], c = e[0][0] - e[1][0], h = a * e[0][0] + c * e[0][1], l = n * c - a * s, 
            i.eq(l, 0, o) || (p[0] = (c * r - s * h) / l, p[1] = (n * h - a * r) / l), p;
        }, n.segmentsIntersect = function(t, e, o, i) {
            var n = e[0] - t[0], s = e[1] - t[1], r = i[0] - o[0], a = i[1] - o[1];
            if (r * s - a * n == 0) return !1;
            var c = (n * (o[1] - t[1]) + s * (t[0] - o[0])) / (r * s - a * n), h = (r * (t[1] - o[1]) + a * (o[0] - t[0])) / (a * n - r * s);
            return c >= 0 && c <= 1 && h >= 0 && h <= 1;
        };
    }, {
        "./Scalar": 4
    } ],
    2: [ function(t, e, o) {
        function i() {}
        e.exports = i, i.area = function(t, e, o) {
            return (e[0] - t[0]) * (o[1] - t[1]) - (o[0] - t[0]) * (e[1] - t[1]);
        }, i.left = function(t, e, o) {
            return i.area(t, e, o) > 0;
        }, i.leftOn = function(t, e, o) {
            return i.area(t, e, o) >= 0;
        }, i.right = function(t, e, o) {
            return i.area(t, e, o) < 0;
        }, i.rightOn = function(t, e, o) {
            return i.area(t, e, o) <= 0;
        };
        var n = [], s = [];
        i.collinear = function(t, e, o, r) {
            if (r) {
                var a = n, c = s;
                a[0] = e[0] - t[0], a[1] = e[1] - t[1], c[0] = o[0] - e[0], c[1] = o[1] - e[1];
                var h = a[0] * c[0] + a[1] * c[1], l = Math.sqrt(a[0] * a[0] + a[1] * a[1]), p = Math.sqrt(c[0] * c[0] + c[1] * c[1]);
                return Math.acos(h / (l * p)) < r;
            }
            return 0 == i.area(t, e, o);
        }, i.sqdist = function(t, e) {
            var o = e[0] - t[0], i = e[1] - t[1];
            return o * o + i * i;
        };
    }, {} ],
    3: [ function(t, e, o) {
        var i = t("./Line"), n = t("./Point"), s = t("./Scalar");
        function r() {
            this.vertices = [];
        }
        e.exports = r, r.prototype.at = function(t) {
            var e = this.vertices, o = e.length;
            return e[t < 0 ? t % o + o : t % o];
        }, r.prototype.first = function() {
            return this.vertices[0];
        }, r.prototype.last = function() {
            return this.vertices[this.vertices.length - 1];
        }, r.prototype.clear = function() {
            this.vertices.length = 0;
        }, r.prototype.append = function(t, e, o) {
            if (void 0 === e) throw new Error("From is not given!");
            if (void 0 === o) throw new Error("To is not given!");
            if (o - 1 < e) throw new Error("lol1");
            if (o > t.vertices.length) throw new Error("lol2");
            if (e < 0) throw new Error("lol3");
            for (var i = e; i < o; i++) this.vertices.push(t.vertices[i]);
        }, r.prototype.makeCCW = function() {
            for (var t = 0, e = this.vertices, o = 1; o < this.vertices.length; ++o) (e[o][1] < e[t][1] || e[o][1] == e[t][1] && e[o][0] > e[t][0]) && (t = o);
            n.left(this.at(t - 1), this.at(t), this.at(t + 1)) || this.reverse();
        }, r.prototype.reverse = function() {
            for (var t = [], e = 0, o = this.vertices.length; e !== o; e++) t.push(this.vertices.pop());
            this.vertices = t;
        }, r.prototype.isReflex = function(t) {
            return n.right(this.at(t - 1), this.at(t), this.at(t + 1));
        };
        var a = [], c = [];
        function h(t, e, o, i, n) {
            n = n || 0;
            var r = e[1] - t[1], a = t[0] - e[0], c = r * t[0] + a * t[1], h = i[1] - o[1], l = o[0] - i[0], p = h * o[0] + l * o[1], u = r * l - h * a;
            return s.eq(u, 0, n) ? [ 0, 0 ] : [ (l * c - a * p) / u, (r * p - h * c) / u ];
        }
        r.prototype.canSee = function(t, e) {
            var o, s, r = a, h = c;
            if (n.leftOn(this.at(t + 1), this.at(t), this.at(e)) && n.rightOn(this.at(t - 1), this.at(t), this.at(e))) return !1;
            s = n.sqdist(this.at(t), this.at(e));
            for (var l = 0; l !== this.vertices.length; ++l) if ((l + 1) % this.vertices.length !== t && l !== t && n.leftOn(this.at(t), this.at(e), this.at(l + 1)) && n.rightOn(this.at(t), this.at(e), this.at(l)) && (r[0] = this.at(t), 
            r[1] = this.at(e), h[0] = this.at(l), h[1] = this.at(l + 1), o = i.lineInt(r, h), 
            n.sqdist(this.at(t), o) < s)) return !1;
            return !0;
        }, r.prototype.copy = function(t, e, o) {
            var i = o || new r();
            if (i.clear(), t < e) for (var n = t; n <= e; n++) i.vertices.push(this.vertices[n]); else {
                for (n = 0; n <= e; n++) i.vertices.push(this.vertices[n]);
                for (n = t; n < this.vertices.length; n++) i.vertices.push(this.vertices[n]);
            }
            return i;
        }, r.prototype.getCutEdges = function() {
            for (var t = [], e = [], o = [], i = new r(), n = Number.MAX_VALUE, s = 0; s < this.vertices.length; ++s) if (this.isReflex(s)) for (var a = 0; a < this.vertices.length; ++a) if (this.canSee(s, a)) {
                e = this.copy(s, a, i).getCutEdges(), o = this.copy(a, s, i).getCutEdges();
                for (var c = 0; c < o.length; c++) e.push(o[c]);
                e.length < n && (t = e, n = e.length, t.push([ this.at(s), this.at(a) ]));
            }
            return t;
        }, r.prototype.decomp = function() {
            var t = this.getCutEdges();
            return t.length > 0 ? this.slice(t) : [ this ];
        }, r.prototype.slice = function(t) {
            if (0 == t.length) return [ this ];
            if (t instanceof Array && t.length && t[0] instanceof Array && 2 == t[0].length && t[0][0] instanceof Array) {
                for (var e = [ this ], o = 0; o < t.length; o++) for (var i = t[o], n = 0; n < e.length; n++) {
                    var s = e[n].slice(i);
                    if (s) {
                        e.splice(n, 1), e.push(s[0], s[1]);
                        break;
                    }
                }
                return e;
            }
            i = t, o = this.vertices.indexOf(i[0]), n = this.vertices.indexOf(i[1]);
            return -1 != o && -1 != n && [ this.copy(o, n), this.copy(n, o) ];
        }, r.prototype.isSimple = function() {
            for (var t = this.vertices, e = 0; e < t.length - 1; e++) for (var o = 0; o < e - 1; o++) if (i.segmentsIntersect(t[e], t[e + 1], t[o], t[o + 1])) return !1;
            for (e = 1; e < t.length - 2; e++) if (i.segmentsIntersect(t[0], t[t.length - 1], t[e], t[e + 1])) return !1;
            return !0;
        }, r.prototype.quickDecomp = function(t, e, o, i, s, a) {
            s = s || 100, a = a || 0, i = i || 25, t = void 0 !== t ? t : [], e = e || [], o = o || [];
            var c = [ 0, 0 ], l = [ 0, 0 ], p = [ 0, 0 ], u = 0, d = 0, f = 0, v = 0, y = 0, m = 0, g = 0, A = new r(), b = new r(), E = this.vertices;
            if (E.length < 3) return t;
            if (++a > s) return console.warn("quickDecomp: max level (" + s + ") reached."), 
            t;
            for (var B = 0; B < this.vertices.length; ++B) if (this.isReflex(B)) {
                e.push(this.vertices[B]), u = d = Number.MAX_VALUE;
                for (var q = 0; q < this.vertices.length; ++q) n.left(this.at(B - 1), this.at(B), this.at(q)) && n.rightOn(this.at(B - 1), this.at(B), this.at(q - 1)) && (p = h(this.at(B - 1), this.at(B), this.at(q), this.at(q - 1)), 
                n.right(this.at(B + 1), this.at(B), p) && (f = n.sqdist(this.vertices[B], p)) < d && (d = f, 
                l = p, m = q)), n.left(this.at(B + 1), this.at(B), this.at(q + 1)) && n.rightOn(this.at(B + 1), this.at(B), this.at(q)) && (p = h(this.at(B + 1), this.at(B), this.at(q), this.at(q + 1)), 
                n.left(this.at(B - 1), this.at(B), p) && (f = n.sqdist(this.vertices[B], p)) < u && (u = f, 
                c = p, y = q));
                if (m == (y + 1) % this.vertices.length) p[0] = (l[0] + c[0]) / 2, p[1] = (l[1] + c[1]) / 2, 
                o.push(p), B < y ? (A.append(this, B, y + 1), A.vertices.push(p), b.vertices.push(p), 
                0 != m && b.append(this, m, this.vertices.length), b.append(this, 0, B + 1)) : (0 != B && A.append(this, B, this.vertices.length), 
                A.append(this, 0, y + 1), A.vertices.push(p), b.vertices.push(p), b.append(this, m, B + 1)); else {
                    if (m > y && (y += this.vertices.length), v = Number.MAX_VALUE, y < m) return t;
                    for (q = m; q <= y; ++q) n.leftOn(this.at(B - 1), this.at(B), this.at(q)) && n.rightOn(this.at(B + 1), this.at(B), this.at(q)) && (f = n.sqdist(this.at(B), this.at(q))) < v && (v = f, 
                    g = q % this.vertices.length);
                    B < g ? (A.append(this, B, g + 1), 0 != g && b.append(this, g, E.length), b.append(this, 0, B + 1)) : (0 != B && A.append(this, B, E.length), 
                    A.append(this, 0, g + 1), b.append(this, g, B + 1));
                }
                return A.vertices.length < b.vertices.length ? (A.quickDecomp(t, e, o, i, s, a), 
                b.quickDecomp(t, e, o, i, s, a)) : (b.quickDecomp(t, e, o, i, s, a), A.quickDecomp(t, e, o, i, s, a)), 
                t;
            }
            return t.push(this), t;
        }, r.prototype.removeCollinearPoints = function(t) {
            for (var e = 0, o = this.vertices.length - 1; this.vertices.length > 3 && o >= 0; --o) n.collinear(this.at(o - 1), this.at(o), this.at(o + 1), t) && (this.vertices.splice(o % this.vertices.length, 1), 
            o--, e++);
            return e;
        };
    }, {
        "./Line": 1,
        "./Point": 2,
        "./Scalar": 4
    } ],
    4: [ function(t, e, o) {
        function i() {}
        e.exports = i, i.eq = function(t, e, o) {
            return o = o || 0, Math.abs(t - e) < o;
        };
    }, {} ],
    5: [ function(t, e, o) {
        e.exports = {
            Polygon: t("./Polygon"),
            Point: t("./Point")
        };
    }, {
        "./Point": 2,
        "./Polygon": 3
    } ],
    6: [ function(t, e, o) {
        e.exports = {
            name: "p2",
            version: "0.7.1",
            description: "A JavaScript 2D physics engine.",
            author: "Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",
            keywords: [ "p2.js", "p2", "physics", "engine", "2d" ],
            main: "./src/p2.js",
            engines: {
                node: "*"
            },
            repository: {
                type: "git",
                url: "https://github.com/schteppe/p2.js.git"
            },
            bugs: {
                url: "https://github.com/schteppe/p2.js/issues"
            },
            licenses: [ {
                type: "MIT"
            } ],
            devDependencies: {
                grunt: "^0.4.5",
                "grunt-contrib-jshint": "^0.11.2",
                "grunt-contrib-nodeunit": "^0.4.1",
                "grunt-contrib-uglify": "~0.4.0",
                "grunt-contrib-watch": "~0.5.0",
                "grunt-browserify": "~2.0.1",
                "grunt-contrib-concat": "^0.4.0"
            },
            dependencies: {
                "poly-decomp": "0.1.1"
            }
        };
    }, {} ],
    7: [ function(t, e, o) {
        var i = t("../math/vec2");
        function n(t) {
            this.lowerBound = i.create(), t && t.lowerBound && i.copy(this.lowerBound, t.lowerBound), 
            this.upperBound = i.create(), t && t.upperBound && i.copy(this.upperBound, t.upperBound);
        }
        t("../utils/Utils"), e.exports = n;
        var s = i.create();
        n.prototype.setFromPoints = function(t, e, o, n) {
            var r = this.lowerBound, a = this.upperBound;
            "number" != typeof o && (o = 0), 0 !== o ? i.rotate(r, t[0], o) : i.copy(r, t[0]), 
            i.copy(a, r);
            for (var c = Math.cos(o), h = Math.sin(o), l = 1; l < t.length; l++) {
                var p = t[l];
                if (0 !== o) {
                    var u = p[0], d = p[1];
                    s[0] = c * u - h * d, s[1] = h * u + c * d, p = s;
                }
                for (var f = 0; f < 2; f++) p[f] > a[f] && (a[f] = p[f]), p[f] < r[f] && (r[f] = p[f]);
            }
            e && (i.add(this.lowerBound, this.lowerBound, e), i.add(this.upperBound, this.upperBound, e)), 
            n && (this.lowerBound[0] -= n, this.lowerBound[1] -= n, this.upperBound[0] += n, 
            this.upperBound[1] += n);
        }, n.prototype.copy = function(t) {
            i.copy(this.lowerBound, t.lowerBound), i.copy(this.upperBound, t.upperBound);
        }, n.prototype.extend = function(t) {
            for (var e = 2; e--; ) {
                var o = t.lowerBound[e];
                this.lowerBound[e] > o && (this.lowerBound[e] = o);
                var i = t.upperBound[e];
                this.upperBound[e] < i && (this.upperBound[e] = i);
            }
        }, n.prototype.overlaps = function(t) {
            var e = this.lowerBound, o = this.upperBound, i = t.lowerBound, n = t.upperBound;
            return (i[0] <= o[0] && o[0] <= n[0] || e[0] <= n[0] && n[0] <= o[0]) && (i[1] <= o[1] && o[1] <= n[1] || e[1] <= n[1] && n[1] <= o[1]);
        }, n.prototype.containsPoint = function(t) {
            var e = this.lowerBound, o = this.upperBound;
            return e[0] <= t[0] && t[0] <= o[0] && e[1] <= t[1] && t[1] <= o[1];
        }, n.prototype.overlapsRay = function(t) {
            var e = 1 / t.direction[0], o = 1 / t.direction[1], i = (this.lowerBound[0] - t.from[0]) * e, n = (this.upperBound[0] - t.from[0]) * e, s = (this.lowerBound[1] - t.from[1]) * o, r = (this.upperBound[1] - t.from[1]) * o, a = Math.max(Math.max(Math.min(i, n), Math.min(s, r))), c = Math.min(Math.min(Math.max(i, n), Math.max(s, r)));
            return c < 0 || a > c ? -1 : a;
        };
    }, {
        "../math/vec2": 30,
        "../utils/Utils": 57
    } ],
    8: [ function(t, e, o) {
        var i = t("../math/vec2"), n = t("../objects/Body");
        function s(t) {
            this.type = t, this.result = [], this.world = null, this.boundingVolumeType = s.AABB;
        }
        e.exports = s, s.AABB = 1, s.BOUNDING_CIRCLE = 2, s.prototype.setWorld = function(t) {
            this.world = t;
        }, s.prototype.getCollisionPairs = function(t) {};
        var r = i.create();
        s.boundingRadiusCheck = function(t, e) {
            i.sub(r, t.position, e.position);
            var o = i.squaredLength(r), n = t.boundingRadius + e.boundingRadius;
            return o <= n * n;
        }, s.aabbCheck = function(t, e) {
            return t.getAABB().overlaps(e.getAABB());
        }, s.prototype.boundingVolumeCheck = function(t, e) {
            var o;
            switch (this.boundingVolumeType) {
              case s.BOUNDING_CIRCLE:
                o = s.boundingRadiusCheck(t, e);
                break;

              case s.AABB:
                o = s.aabbCheck(t, e);
                break;

              default:
                throw new Error("Bounding volume type not recognized: " + this.boundingVolumeType);
            }
            return o;
        }, s.canCollide = function(t, e) {
            var o = n.KINEMATIC, i = n.STATIC;
            return !(t.type === i && e.type === i || t.type === o && e.type === i || t.type === i && e.type === o || t.type === o && e.type === o || t.sleepState === n.SLEEPING && e.sleepState === n.SLEEPING || t.sleepState === n.SLEEPING && e.type === i || e.sleepState === n.SLEEPING && t.type === i);
        }, s.NAIVE = 1, s.SAP = 2;
    }, {
        "../math/vec2": 30,
        "../objects/Body": 31
    } ],
    9: [ function(t, e, o) {
        t("../shapes/Circle"), t("../shapes/Plane"), t("../shapes/Shape"), t("../shapes/Particle");
        var i = t("../collision/Broadphase");
        function n() {
            i.call(this, i.NAIVE);
        }
        t("../math/vec2"), e.exports = n, n.prototype = new i(), n.prototype.constructor = n, 
        n.prototype.getCollisionPairs = function(t) {
            var e = t.bodies, o = this.result;
            o.length = 0;
            for (var n = 0, s = e.length; n !== s; n++) for (var r = e[n], a = 0; a < n; a++) {
                var c = e[a];
                i.canCollide(r, c) && this.boundingVolumeCheck(r, c) && o.push(r, c);
            }
            return o;
        }, n.prototype.aabbQuery = function(t, e, o) {
            o = o || [];
            for (var i = t.bodies, n = 0; n < i.length; n++) {
                var s = i[n];
                s.aabbNeedsUpdate && s.updateAABB(), s.aabb.overlaps(e) && o.push(s);
            }
            return o;
        };
    }, {
        "../collision/Broadphase": 8,
        "../math/vec2": 30,
        "../shapes/Circle": 39,
        "../shapes/Particle": 43,
        "../shapes/Plane": 44,
        "../shapes/Shape": 45
    } ],
    10: [ function(t, e, o) {
        var i = t("../math/vec2"), n = i.sub, s = i.add, r = i.dot, a = (t("../utils/Utils"), 
        t("../utils/ContactEquationPool")), c = t("../utils/FrictionEquationPool"), h = t("../utils/TupleDictionary"), l = t("../equations/Equation"), p = (t("../equations/ContactEquation"), 
        t("../equations/FrictionEquation"), t("../shapes/Circle")), u = t("../shapes/Convex"), d = t("../shapes/Shape"), f = (t("../objects/Body"), 
        t("../shapes/Box"));
        e.exports = T;
        var v = i.fromValues(0, 1), y = i.fromValues(0, 0), m = i.fromValues(0, 0), g = i.fromValues(0, 0), A = i.fromValues(0, 0), b = i.fromValues(0, 0), E = i.fromValues(0, 0), B = i.fromValues(0, 0), q = i.fromValues(0, 0), P = i.fromValues(0, 0), w = i.fromValues(0, 0), S = i.fromValues(0, 0), C = i.fromValues(0, 0), L = i.fromValues(0, 0), x = i.fromValues(0, 0), F = i.fromValues(0, 0), M = i.fromValues(0, 0), I = i.fromValues(0, 0), R = i.fromValues(0, 0), V = [];
        function T() {
            this.contactEquations = [], this.frictionEquations = [], this.enableFriction = !0, 
            this.enabledEquations = !0, this.slipForce = 10, this.frictionCoefficient = .3, 
            this.surfaceVelocity = 0, this.contactEquationPool = new a({
                size: 32
            }), this.frictionEquationPool = new c({
                size: 64
            }), this.restitution = 0, this.stiffness = l.DEFAULT_STIFFNESS, this.relaxation = l.DEFAULT_RELAXATION, 
            this.frictionStiffness = l.DEFAULT_STIFFNESS, this.frictionRelaxation = l.DEFAULT_RELAXATION, 
            this.enableFrictionReduction = !0, this.collidingBodiesLastStep = new h(), this.contactSkinSize = .01;
        }
        var N = i.create(), G = i.create();
        function O(t, e) {
            i.set(t.vertices[0], .5 * -e.length, -e.radius), i.set(t.vertices[1], .5 * e.length, -e.radius), 
            i.set(t.vertices[2], .5 * e.length, e.radius), i.set(t.vertices[3], .5 * -e.length, e.radius);
        }
        T.prototype.bodiesOverlap = function(t, e) {
            for (var o = N, i = G, n = 0, s = t.shapes.length; n !== s; n++) {
                var r = t.shapes[n];
                t.toWorldFrame(o, r.position);
                for (var a = 0, c = e.shapes.length; a !== c; a++) {
                    var h = e.shapes[a];
                    if (e.toWorldFrame(i, h.position), this[r.type | h.type](t, r, o, r.angle + t.angle, e, h, i, h.angle + e.angle, !0)) return !0;
                }
            }
            return !1;
        }, T.prototype.collidedLastStep = function(t, e) {
            var o = 0 | t.id, i = 0 | e.id;
            return !!this.collidingBodiesLastStep.get(o, i);
        }, T.prototype.reset = function() {
            this.collidingBodiesLastStep.reset();
            for (var t = this.contactEquations, e = t.length; e--; ) {
                var o = t[e], i = o.bodyA.id, n = o.bodyB.id;
                this.collidingBodiesLastStep.set(i, n, !0);
            }
            for (var s = this.contactEquations, r = this.frictionEquations, a = 0; a < s.length; a++) this.contactEquationPool.release(s[a]);
            for (a = 0; a < r.length; a++) this.frictionEquationPool.release(r[a]);
            this.contactEquations.length = this.frictionEquations.length = 0;
        }, T.prototype.createContactEquation = function(t, e, o, i) {
            var n = this.contactEquationPool.get();
            return n.bodyA = t, n.bodyB = e, n.shapeA = o, n.shapeB = i, n.restitution = this.restitution, 
            n.firstImpact = !this.collidedLastStep(t, e), n.stiffness = this.stiffness, n.relaxation = this.relaxation, 
            n.needsUpdate = !0, n.enabled = this.enabledEquations, n.offset = this.contactSkinSize, 
            n;
        }, T.prototype.createFrictionEquation = function(t, e, o, i) {
            var n = this.frictionEquationPool.get();
            return n.bodyA = t, n.bodyB = e, n.shapeA = o, n.shapeB = i, n.setSlipForce(this.slipForce), 
            n.frictionCoefficient = this.frictionCoefficient, n.relativeVelocity = this.surfaceVelocity, 
            n.enabled = this.enabledEquations, n.needsUpdate = !0, n.stiffness = this.frictionStiffness, 
            n.relaxation = this.frictionRelaxation, n.contactEquations.length = 0, n;
        }, T.prototype.createFrictionFromContact = function(t) {
            var e = this.createFrictionEquation(t.bodyA, t.bodyB, t.shapeA, t.shapeB);
            return i.copy(e.contactPointA, t.contactPointA), i.copy(e.contactPointB, t.contactPointB), 
            i.rotate90cw(e.t, t.normalA), e.contactEquations.push(t), e;
        }, T.prototype.createFrictionFromAverage = function(t) {
            var e = this.contactEquations[this.contactEquations.length - 1], o = this.createFrictionEquation(e.bodyA, e.bodyB, e.shapeA, e.shapeB), n = e.bodyA;
            e.bodyB, i.set(o.contactPointA, 0, 0), i.set(o.contactPointB, 0, 0), i.set(o.t, 0, 0);
            for (var s = 0; s !== t; s++) (e = this.contactEquations[this.contactEquations.length - 1 - s]).bodyA === n ? (i.add(o.t, o.t, e.normalA), 
            i.add(o.contactPointA, o.contactPointA, e.contactPointA), i.add(o.contactPointB, o.contactPointB, e.contactPointB)) : (i.sub(o.t, o.t, e.normalA), 
            i.add(o.contactPointA, o.contactPointA, e.contactPointB), i.add(o.contactPointB, o.contactPointB, e.contactPointA)), 
            o.contactEquations.push(e);
            var r = 1 / t;
            return i.scale(o.contactPointA, o.contactPointA, r), i.scale(o.contactPointB, o.contactPointB, r), 
            i.normalize(o.t, o.t), i.rotate90cw(o.t, o.t), o;
        }, T.prototype[d.LINE | d.CONVEX] = T.prototype.convexLine = function(t, e, o, i, n, s, r, a, c) {
            return !c && 0;
        }, T.prototype[d.LINE | d.BOX] = T.prototype.lineBox = function(t, e, o, i, n, s, r, a, c) {
            return !c && 0;
        };
        var U = new f({
            width: 1,
            height: 1
        }), k = i.create();
        T.prototype[d.CAPSULE | d.CONVEX] = T.prototype[d.CAPSULE | d.BOX] = T.prototype.convexCapsule = function(t, e, o, n, s, r, a, c, h) {
            var l = k;
            i.set(l, r.length / 2, 0), i.rotate(l, l, c), i.add(l, l, a);
            var p = this.circleConvex(s, r, l, c, t, e, o, n, h, r.radius);
            i.set(l, -r.length / 2, 0), i.rotate(l, l, c), i.add(l, l, a);
            var u = this.circleConvex(s, r, l, c, t, e, o, n, h, r.radius);
            if (h && (p || u)) return !0;
            var d = U;
            return O(d, r), this.convexConvex(t, e, o, n, s, d, a, c, h) + p + u;
        }, T.prototype[d.CAPSULE | d.LINE] = T.prototype.lineCapsule = function(t, e, o, i, n, s, r, a, c) {
            return !c && 0;
        };
        var _ = i.create(), D = i.create(), W = new f({
            width: 1,
            height: 1
        });
        T.prototype[d.CAPSULE | d.CAPSULE] = T.prototype.capsuleCapsule = function(t, e, o, n, s, r, a, c, h) {
            for (var l = _, p = D, u = 0, d = 0; d < 2; d++) {
                i.set(l, (0 === d ? -1 : 1) * e.length / 2, 0), i.rotate(l, l, n), i.add(l, l, o);
                for (var f = 0; f < 2; f++) {
                    i.set(p, (0 === f ? -1 : 1) * r.length / 2, 0), i.rotate(p, p, c), i.add(p, p, a), 
                    this.enableFrictionReduction && (g = this.enableFriction, this.enableFriction = !1);
                    var v = this.circleCircle(t, e, l, n, s, r, p, c, h, e.radius, r.radius);
                    if (this.enableFrictionReduction && (this.enableFriction = g), h && v) return !0;
                    u += v;
                }
            }
            this.enableFrictionReduction && (g = this.enableFriction, this.enableFriction = !1);
            var y = W;
            O(y, e);
            var m = this.convexCapsule(t, y, o, n, s, r, a, c, h);
            if (this.enableFrictionReduction && (this.enableFriction = g), h && m) return !0;
            if (u += m, this.enableFrictionReduction) {
                var g = this.enableFriction;
                this.enableFriction = !1;
            }
            O(y, r);
            var A = this.convexCapsule(s, y, a, c, t, e, o, n, h);
            return this.enableFrictionReduction && (this.enableFriction = g), !(!h || !A) || (u += A, 
            this.enableFrictionReduction && u && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(u)), 
            u);
        }, T.prototype[d.LINE | d.LINE] = T.prototype.lineLine = function(t, e, o, i, n, s, r, a, c) {
            return !c && 0;
        }, T.prototype[d.PLANE | d.LINE] = T.prototype.planeLine = function(t, e, o, a, c, h, l, p, u) {
            var d = y, f = m, w = g, S = A, C = b, L = E, x = B, F = q, M = P, I = V, R = 0;
            i.set(d, -h.length / 2, 0), i.set(f, h.length / 2, 0), i.rotate(w, d, p), i.rotate(S, f, p), 
            s(w, w, l), s(S, S, l), i.copy(d, w), i.copy(f, S), n(C, f, d), i.normalize(L, C), 
            i.rotate90cw(M, L), i.rotate(F, v, a), I[0] = d, I[1] = f;
            for (var T = 0; T < I.length; T++) {
                var N = I[T];
                n(x, N, o);
                var G = r(x, F);
                if (G < 0) {
                    if (u) return !0;
                    var O = this.createContactEquation(t, c, e, h);
                    R++, i.copy(O.normalA, F), i.normalize(O.normalA, O.normalA), i.scale(x, F, G), 
                    n(O.contactPointA, N, x), n(O.contactPointA, O.contactPointA, t.position), n(O.contactPointB, N, l), 
                    s(O.contactPointB, O.contactPointB, l), n(O.contactPointB, O.contactPointB, c.position), 
                    this.contactEquations.push(O), this.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(O));
                }
            }
            return !u && (this.enableFrictionReduction || R && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(R)), 
            R);
        }, T.prototype[d.PARTICLE | d.CAPSULE] = T.prototype.particleCapsule = function(t, e, o, i, n, s, r, a, c) {
            return this.circleLine(t, e, o, i, n, s, r, a, c, s.radius, 0);
        }, T.prototype[d.CIRCLE | d.LINE] = T.prototype.circleLine = function(t, e, o, a, c, h, l, p, u, d, f) {
            d = d || 0, f = void 0 !== f ? f : e.radius;
            var v = y, F = m, M = g, I = A, R = b, T = E, N = B, G = q, O = P, U = w, k = S, _ = C, D = L, W = x, X = V;
            i.set(G, -h.length / 2, 0), i.set(O, h.length / 2, 0), i.rotate(U, G, p), i.rotate(k, O, p), 
            s(U, U, l), s(k, k, l), i.copy(G, U), i.copy(O, k), n(T, O, G), i.normalize(N, T), 
            i.rotate90cw(R, N), n(_, o, G);
            var j = r(_, R);
            n(I, G, l), n(D, o, l);
            var z = f + d;
            if (Math.abs(j) < z) {
                i.scale(v, R, j), n(M, o, v), i.scale(F, R, r(R, D)), i.normalize(F, F), i.scale(F, F, d), 
                s(M, M, F);
                var Y = r(N, M), K = r(N, G), H = r(N, O);
                if (Y > K && Y < H) {
                    if (u) return !0;
                    var Z = this.createContactEquation(t, c, e, h);
                    return i.scale(Z.normalA, v, -1), i.normalize(Z.normalA, Z.normalA), i.scale(Z.contactPointA, Z.normalA, f), 
                    s(Z.contactPointA, Z.contactPointA, o), n(Z.contactPointA, Z.contactPointA, t.position), 
                    n(Z.contactPointB, M, l), s(Z.contactPointB, Z.contactPointB, l), n(Z.contactPointB, Z.contactPointB, c.position), 
                    this.contactEquations.push(Z), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(Z)), 
                    1;
                }
            }
            X[0] = G, X[1] = O;
            for (var J = 0; J < X.length; J++) {
                var Q = X[J];
                if (n(_, Q, o), i.squaredLength(_) < Math.pow(z, 2)) {
                    if (u) return !0;
                    Z = this.createContactEquation(t, c, e, h);
                    return i.copy(Z.normalA, _), i.normalize(Z.normalA, Z.normalA), i.scale(Z.contactPointA, Z.normalA, f), 
                    s(Z.contactPointA, Z.contactPointA, o), n(Z.contactPointA, Z.contactPointA, t.position), 
                    n(Z.contactPointB, Q, l), i.scale(W, Z.normalA, -d), s(Z.contactPointB, Z.contactPointB, W), 
                    s(Z.contactPointB, Z.contactPointB, l), n(Z.contactPointB, Z.contactPointB, c.position), 
                    this.contactEquations.push(Z), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(Z)), 
                    1;
                }
            }
            return 0;
        }, T.prototype[d.CIRCLE | d.CAPSULE] = T.prototype.circleCapsule = function(t, e, o, i, n, s, r, a, c) {
            return this.circleLine(t, e, o, i, n, s, r, a, c, s.radius);
        }, T.prototype[d.CIRCLE | d.CONVEX] = T.prototype[d.CIRCLE | d.BOX] = T.prototype.circleConvex = function(t, e, o, r, a, c, h, l, p, u) {
            u = "number" == typeof u ? u : e.radius;
            for (var d = y, f = m, v = g, E = A, B = b, q = w, P = S, C = L, I = x, R = F, V = M, T = !1, N = Number.MAX_VALUE, G = c.vertices, O = 0; O !== G.length + 1; O++) {
                var U = G[O % G.length], k = G[(O + 1) % G.length];
                if (i.rotate(d, U, l), i.rotate(f, k, l), s(d, d, h), s(f, f, h), n(v, f, d), i.normalize(E, v), 
                i.rotate90cw(B, E), i.scale(I, B, -e.radius), s(I, I, o), K(I, c, h, l)) {
                    i.sub(R, d, I);
                    var _ = Math.abs(i.dot(R, B));
                    _ < N && (i.copy(V, I), N = _, i.scale(C, B, _), i.add(C, C, I), T = !0);
                }
            }
            if (T) {
                if (p) return !0;
                var D = this.createContactEquation(t, a, e, c);
                return i.sub(D.normalA, V, o), i.normalize(D.normalA, D.normalA), i.scale(D.contactPointA, D.normalA, u), 
                s(D.contactPointA, D.contactPointA, o), n(D.contactPointA, D.contactPointA, t.position), 
                n(D.contactPointB, C, h), s(D.contactPointB, D.contactPointB, h), n(D.contactPointB, D.contactPointB, a.position), 
                this.contactEquations.push(D), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(D)), 
                1;
            }
            if (u > 0) for (O = 0; O < G.length; O++) {
                var W = G[O];
                if (i.rotate(P, W, l), s(P, P, h), n(q, P, o), i.squaredLength(q) < Math.pow(u, 2)) {
                    if (p) return !0;
                    D = this.createContactEquation(t, a, e, c);
                    return i.copy(D.normalA, q), i.normalize(D.normalA, D.normalA), i.scale(D.contactPointA, D.normalA, u), 
                    s(D.contactPointA, D.contactPointA, o), n(D.contactPointA, D.contactPointA, t.position), 
                    n(D.contactPointB, P, h), s(D.contactPointB, D.contactPointB, h), n(D.contactPointB, D.contactPointB, a.position), 
                    this.contactEquations.push(D), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(D)), 
                    1;
                }
            }
            return 0;
        };
        var X = i.create(), j = i.create(), z = i.create(), Y = i.create();
        function K(t, e, o, r) {
            for (var a = X, c = j, h = z, l = Y, p = t, u = e.vertices, d = null, f = 0; f !== u.length + 1; f++) {
                var v = u[f % u.length], y = u[(f + 1) % u.length];
                i.rotate(a, v, r), i.rotate(c, y, r), s(a, a, o), s(c, c, o), n(h, a, p), n(l, c, p);
                var m = i.crossLength(h, l);
                if (null === d && (d = m), m * d <= 0) return !1;
                d = m;
            }
            return !0;
        }
        T.prototype[d.PARTICLE | d.CONVEX] = T.prototype[d.PARTICLE | d.BOX] = T.prototype.particleConvex = function(t, e, o, a, c, h, l, p, u) {
            var d = y, f = m, v = g, q = A, P = b, S = E, C = B, x = w, F = L, M = I, V = R, T = Number.MAX_VALUE, N = !1, G = h.vertices;
            if (!K(o, h, l, p)) return 0;
            if (u) return !0;
            for (var O = 0; O !== G.length + 1; O++) {
                var U = G[O % G.length], k = G[(O + 1) % G.length];
                i.rotate(d, U, p), i.rotate(f, k, p), s(d, d, l), s(f, f, l), n(v, f, d), i.normalize(q, v), 
                i.rotate90cw(P, q), n(x, o, d), r(x, P), n(S, d, l), n(C, o, l), i.sub(M, d, o);
                var _ = Math.abs(i.dot(M, P));
                _ < T && (T = _, i.scale(F, P, _), i.add(F, F, o), i.copy(V, P), N = !0);
            }
            if (N) {
                var D = this.createContactEquation(t, c, e, h);
                return i.scale(D.normalA, V, -1), i.normalize(D.normalA, D.normalA), i.set(D.contactPointA, 0, 0), 
                s(D.contactPointA, D.contactPointA, o), n(D.contactPointA, D.contactPointA, t.position), 
                n(D.contactPointB, F, l), s(D.contactPointB, D.contactPointB, l), n(D.contactPointB, D.contactPointB, c.position), 
                this.contactEquations.push(D), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(D)), 
                1;
            }
            return 0;
        }, T.prototype[d.CIRCLE] = T.prototype.circleCircle = function(t, e, o, r, a, c, h, l, p, u, d) {
            var f = y;
            u = u || e.radius, d = d || c.radius;
            n(f, o, h);
            var v = u + d;
            if (i.squaredLength(f) > Math.pow(v, 2)) return 0;
            if (p) return !0;
            var m = this.createContactEquation(t, a, e, c);
            return n(m.normalA, h, o), i.normalize(m.normalA, m.normalA), i.scale(m.contactPointA, m.normalA, u), 
            i.scale(m.contactPointB, m.normalA, -d), s(m.contactPointA, m.contactPointA, o), 
            n(m.contactPointA, m.contactPointA, t.position), s(m.contactPointB, m.contactPointB, h), 
            n(m.contactPointB, m.contactPointB, a.position), this.contactEquations.push(m), 
            this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(m)), 
            1;
        }, T.prototype[d.PLANE | d.CONVEX] = T.prototype[d.PLANE | d.BOX] = T.prototype.planeConvex = function(t, e, o, a, c, h, l, p, u) {
            var d = y, f = m, A = g, b = 0;
            i.rotate(f, v, a);
            for (var E = 0; E !== h.vertices.length; E++) {
                var B = h.vertices[E];
                if (i.rotate(d, B, p), s(d, d, l), n(A, d, o), r(A, f) <= 0) {
                    if (u) return !0;
                    b++;
                    var q = this.createContactEquation(t, c, e, h);
                    n(A, d, o), i.copy(q.normalA, f);
                    var P = r(A, q.normalA);
                    i.scale(A, q.normalA, P), n(q.contactPointB, d, c.position), n(q.contactPointA, d, A), 
                    n(q.contactPointA, q.contactPointA, t.position), this.contactEquations.push(q), 
                    this.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(q));
                }
            }
            return this.enableFrictionReduction && this.enableFriction && b && this.frictionEquations.push(this.createFrictionFromAverage(b)), 
            b;
        }, T.prototype[d.PARTICLE | d.PLANE] = T.prototype.particlePlane = function(t, e, o, s, a, c, h, l, p) {
            var u = y, d = m;
            l = l || 0, n(u, o, h), i.rotate(d, v, l);
            var f = r(u, d);
            if (f > 0) return 0;
            if (p) return !0;
            var g = this.createContactEquation(a, t, c, e);
            return i.copy(g.normalA, d), i.scale(u, g.normalA, f), n(g.contactPointA, o, u), 
            n(g.contactPointA, g.contactPointA, a.position), n(g.contactPointB, o, t.position), 
            this.contactEquations.push(g), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(g)), 
            1;
        }, T.prototype[d.CIRCLE | d.PARTICLE] = T.prototype.circleParticle = function(t, e, o, r, a, c, h, l, p) {
            var u = y;
            if (n(u, h, o), i.squaredLength(u) > Math.pow(e.radius, 2)) return 0;
            if (p) return !0;
            var d = this.createContactEquation(t, a, e, c);
            return i.copy(d.normalA, u), i.normalize(d.normalA, d.normalA), i.scale(d.contactPointA, d.normalA, e.radius), 
            s(d.contactPointA, d.contactPointA, o), n(d.contactPointA, d.contactPointA, t.position), 
            n(d.contactPointB, h, a.position), this.contactEquations.push(d), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(d)), 
            1;
        };
        var H = new p({
            radius: 1
        }), Z = i.create(), J = i.create();
        i.create(), T.prototype[d.PLANE | d.CAPSULE] = T.prototype.planeCapsule = function(t, e, o, n, r, a, c, h, l) {
            var p, u = Z, d = J, f = H;
            i.set(u, -a.length / 2, 0), i.rotate(u, u, h), s(u, u, c), i.set(d, a.length / 2, 0), 
            i.rotate(d, d, h), s(d, d, c), f.radius = a.radius, this.enableFrictionReduction && (p = this.enableFriction, 
            this.enableFriction = !1);
            var v = this.circlePlane(r, f, u, 0, t, e, o, n, l), y = this.circlePlane(r, f, d, 0, t, e, o, n, l);
            if (this.enableFrictionReduction && (this.enableFriction = p), l) return v || y;
            var m = v + y;
            return this.enableFrictionReduction && m && this.frictionEquations.push(this.createFrictionFromAverage(m)), 
            m;
        }, T.prototype[d.CIRCLE | d.PLANE] = T.prototype.circlePlane = function(t, e, o, a, c, h, l, p, u) {
            var d = t, f = e, A = o, b = c, E = l, B = p;
            B = B || 0;
            var q = y, P = m, w = g;
            n(q, A, E), i.rotate(P, v, B);
            var S = r(P, q);
            if (S > f.radius) return 0;
            if (u) return !0;
            var C = this.createContactEquation(b, d, h, e);
            return i.copy(C.normalA, P), i.scale(C.contactPointB, C.normalA, -f.radius), s(C.contactPointB, C.contactPointB, A), 
            n(C.contactPointB, C.contactPointB, d.position), i.scale(w, C.normalA, S), n(C.contactPointA, q, w), 
            s(C.contactPointA, C.contactPointA, E), n(C.contactPointA, C.contactPointA, b.position), 
            this.contactEquations.push(C), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(C)), 
            1;
        }, T.prototype[d.CONVEX] = T.prototype[d.CONVEX | d.BOX] = T.prototype[d.BOX] = T.prototype.convexConvex = function(t, e, o, a, c, h, l, p, u, d) {
            var f = y, v = m, E = g, w = A, S = b, C = B, L = q, x = P, F = 0;
            d = "number" == typeof d ? d : 0;
            if (!T.findSeparatingAxis(e, o, a, h, l, p, f)) return 0;
            n(L, l, o), r(f, L) > 0 && i.scale(f, f, -1);
            var M = T.getClosestEdge(e, a, f, !0), I = T.getClosestEdge(h, p, f);
            if (-1 === M || -1 === I) return 0;
            for (var R = 0; R < 2; R++) {
                var V, N = M, G = I, O = e, U = h, k = o, _ = l, D = a, W = p, X = t, j = c;
                0 === R && (V = N, N = G, G = V, V = O, O = U, U = V, V = k, k = _, _ = V, V = D, 
                D = W, W = V, V = X, X = j, j = V);
                for (var z = G; z < G + 2; z++) {
                    var Y = U.vertices[(z + U.vertices.length) % U.vertices.length];
                    i.rotate(v, Y, W), s(v, v, _);
                    for (var K = 0, H = N - 1; H < N + 2; H++) {
                        var Z = O.vertices[(H + O.vertices.length) % O.vertices.length], J = O.vertices[(H + 1 + O.vertices.length) % O.vertices.length];
                        i.rotate(E, Z, D), i.rotate(w, J, D), s(E, E, k), s(w, w, k), n(S, w, E), i.rotate90cw(x, S), 
                        i.normalize(x, x), n(L, v, E);
                        var Q = r(x, L);
                        (H === N && Q <= d || H !== N && Q <= 0) && K++;
                    }
                    if (K >= 3) {
                        if (u) return !0;
                        var $ = this.createContactEquation(X, j, O, U);
                        F++;
                        Z = O.vertices[N % O.vertices.length], J = O.vertices[(N + 1) % O.vertices.length];
                        i.rotate(E, Z, D), i.rotate(w, J, D), s(E, E, k), s(w, w, k), n(S, w, E), i.rotate90cw($.normalA, S), 
                        i.normalize($.normalA, $.normalA), n(L, v, E);
                        Q = r($.normalA, L);
                        i.scale(C, $.normalA, Q), n($.contactPointA, v, k), n($.contactPointA, $.contactPointA, C), 
                        s($.contactPointA, $.contactPointA, k), n($.contactPointA, $.contactPointA, X.position), 
                        n($.contactPointB, v, _), s($.contactPointB, $.contactPointB, _), n($.contactPointB, $.contactPointB, j.position), 
                        this.contactEquations.push($), this.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact($));
                    }
                }
            }
            return this.enableFrictionReduction && this.enableFriction && F && this.frictionEquations.push(this.createFrictionFromAverage(F)), 
            F;
        };
        var Q = i.fromValues(0, 0);
        T.projectConvexOntoAxis = function(t, e, o, n, s) {
            var a, c, h = null, l = null, p = Q;
            i.rotate(p, n, -o);
            for (var u = 0; u < t.vertices.length; u++) a = t.vertices[u], c = r(a, p), (null === h || c > h) && (h = c), 
            (null === l || c < l) && (l = c);
            if (l > h) {
                var d = l;
                l = h, h = d;
            }
            var f = r(e, n);
            i.set(s, l + f, h + f);
        };
        var $ = i.fromValues(0, 0), tt = i.fromValues(0, 0), et = i.fromValues(0, 0), ot = i.fromValues(0, 0), it = i.fromValues(0, 0), nt = i.fromValues(0, 0);
        T.findSeparatingAxis = function(t, e, o, s, r, a, c) {
            var h = null, l = !1, p = !1, u = $, d = tt, v = et, y = ot, m = it, g = nt;
            if (t instanceof f && s instanceof f) for (var A = 0; 2 !== A; A++) {
                var b = t, E = o;
                1 === A && (b = s, E = a);
                for (var B = 0; 2 !== B; B++) {
                    0 === B ? i.set(y, 0, 1) : 1 === B && i.set(y, 1, 0), 0 !== E && i.rotate(y, y, E), 
                    T.projectConvexOntoAxis(t, e, o, y, m), T.projectConvexOntoAxis(s, r, a, y, g);
                    var q = m, P = g;
                    m[0] > g[0] && (P = m, q = g), l = (w = P[0] - q[1]) <= 0, (null === h || w > h) && (i.copy(c, y), 
                    h = w, p = l);
                }
            } else for (A = 0; 2 !== A; A++) {
                b = t, E = o;
                1 === A && (b = s, E = a);
                for (B = 0; B !== b.vertices.length; B++) {
                    i.rotate(d, b.vertices[B], E), i.rotate(v, b.vertices[(B + 1) % b.vertices.length], E), 
                    n(u, v, d), i.rotate90cw(y, u), i.normalize(y, y), T.projectConvexOntoAxis(t, e, o, y, m), 
                    T.projectConvexOntoAxis(s, r, a, y, g);
                    var w;
                    q = m, P = g;
                    m[0] > g[0] && (P = m, q = g), l = (w = P[0] - q[1]) <= 0, (null === h || w > h) && (i.copy(c, y), 
                    h = w, p = l);
                }
            }
            return p;
        };
        var st = i.fromValues(0, 0), rt = i.fromValues(0, 0), at = i.fromValues(0, 0);
        T.getClosestEdge = function(t, e, o, s) {
            var a = st, c = rt, h = at;
            i.rotate(a, o, -e), s && i.scale(a, a, -1);
            for (var l = -1, p = t.vertices.length, u = -1, d = 0; d !== p; d++) {
                n(c, t.vertices[(d + 1) % p], t.vertices[d % p]), i.rotate90cw(h, c), i.normalize(h, h);
                var f = r(h, a);
                (-1 === l || f > u) && (l = d % p, u = f);
            }
            return l;
        };
        var ct = i.create(), ht = i.create(), lt = i.create(), pt = i.create(), ut = i.create(), dt = i.create(), ft = i.create();
        T.prototype[d.CIRCLE | d.HEIGHTFIELD] = T.prototype.circleHeightfield = function(t, e, o, r, a, c, h, l, p, u) {
            var d = c.heights, f = (u = u || e.radius, c.elementWidth), v = ht, y = ct, m = ut, g = ft, A = dt, b = lt, E = pt, B = Math.floor((o[0] - u - h[0]) / f), q = Math.ceil((o[0] + u - h[0]) / f);
            B < 0 && (B = 0), q >= d.length && (q = d.length - 1);
            for (var P = d[B], w = d[q], S = B; S < q; S++) d[S] < w && (w = d[S]), d[S] > P && (P = d[S]);
            if (o[1] - u > P) return !p && 0;
            var C = !1;
            for (S = B; S < q; S++) {
                i.set(b, S * f, d[S]), i.set(E, (S + 1) * f, d[S + 1]), i.add(b, b, h), i.add(E, E, h), 
                i.sub(A, E, b), i.rotate(A, A, Math.PI / 2), i.normalize(A, A), i.scale(y, A, -u), 
                i.add(y, y, o), i.sub(v, y, b);
                var L = i.dot(v, A);
                if (y[0] >= b[0] && y[0] < E[0] && L <= 0) {
                    if (p) return !0;
                    C = !0, i.scale(v, A, -L), i.add(m, y, v), i.copy(g, A);
                    var x = this.createContactEquation(a, t, c, e);
                    i.copy(x.normalA, g), i.scale(x.contactPointB, x.normalA, -u), s(x.contactPointB, x.contactPointB, o), 
                    n(x.contactPointB, x.contactPointB, t.position), i.copy(x.contactPointA, m), i.sub(x.contactPointA, x.contactPointA, a.position), 
                    this.contactEquations.push(x), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(x));
                }
            }
            if (C = !1, u > 0) for (S = B; S <= q; S++) if (i.set(b, S * f, d[S]), i.add(b, b, h), 
            i.sub(v, o, b), i.squaredLength(v) < Math.pow(u, 2)) {
                if (p) return !0;
                C = !0;
                x = this.createContactEquation(a, t, c, e);
                i.copy(x.normalA, v), i.normalize(x.normalA, x.normalA), i.scale(x.contactPointB, x.normalA, -u), 
                s(x.contactPointB, x.contactPointB, o), n(x.contactPointB, x.contactPointB, t.position), 
                n(x.contactPointA, b, h), s(x.contactPointA, x.contactPointA, h), n(x.contactPointA, x.contactPointA, a.position), 
                this.contactEquations.push(x), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(x));
            }
            return C ? 1 : 0;
        };
        var vt = i.create(), yt = i.create(), mt = i.create(), gt = new u({
            vertices: [ i.create(), i.create(), i.create(), i.create() ]
        });
        T.prototype[d.BOX | d.HEIGHTFIELD] = T.prototype[d.CONVEX | d.HEIGHTFIELD] = T.prototype.convexHeightfield = function(t, e, o, n, s, r, a, c, h) {
            var l = r.heights, p = r.elementWidth, u = vt, d = yt, f = mt, v = gt, y = Math.floor((t.aabb.lowerBound[0] - a[0]) / p), m = Math.ceil((t.aabb.upperBound[0] - a[0]) / p);
            y < 0 && (y = 0), m >= l.length && (m = l.length - 1);
            for (var g = l[y], A = l[m], b = y; b < m; b++) l[b] < A && (A = l[b]), l[b] > g && (g = l[b]);
            if (t.aabb.lowerBound[1] > g) return !h && 0;
            var E = 0;
            for (b = y; b < m; b++) i.set(u, b * p, l[b]), i.set(d, (b + 1) * p, l[b + 1]), 
            i.add(u, u, a), i.add(d, d, a), i.set(f, .5 * (d[0] + u[0]), .5 * (d[1] + u[1] - 100)), 
            i.sub(v.vertices[0], d, f), i.sub(v.vertices[1], u, f), i.copy(v.vertices[2], v.vertices[1]), 
            i.copy(v.vertices[3], v.vertices[0]), v.vertices[2][1] -= 100, v.vertices[3][1] -= 100, 
            E += this.convexConvex(t, e, o, n, s, v, f, 0, h);
            return E;
        };
    }, {
        "../equations/ContactEquation": 21,
        "../equations/Equation": 22,
        "../equations/FrictionEquation": 23,
        "../math/vec2": 30,
        "../objects/Body": 31,
        "../shapes/Box": 37,
        "../shapes/Circle": 39,
        "../shapes/Convex": 40,
        "../shapes/Shape": 45,
        "../utils/ContactEquationPool": 48,
        "../utils/FrictionEquationPool": 49,
        "../utils/TupleDictionary": 56,
        "../utils/Utils": 57
    } ],
    11: [ function(t, e, o) {
        e.exports = n;
        var i = t("../math/vec2");
        function n(t) {
            t = t || {}, this.from = t.from ? i.fromValues(t.from[0], t.from[1]) : i.create(), 
            this.to = t.to ? i.fromValues(t.to[0], t.to[1]) : i.create(), this.checkCollisionResponse = void 0 === t.checkCollisionResponse || t.checkCollisionResponse, 
            this.skipBackfaces = !!t.skipBackfaces, this.collisionMask = void 0 !== t.collisionMask ? t.collisionMask : -1, 
            this.collisionGroup = void 0 !== t.collisionGroup ? t.collisionGroup : -1, this.mode = void 0 !== t.mode ? t.mode : n.ANY, 
            this.callback = t.callback || function(t) {}, this.direction = i.create(), this.length = 1, 
            this.update();
        }
        t("../collision/RaycastResult"), t("../shapes/Shape"), t("../collision/AABB"), n.prototype.constructor = n, 
        n.CLOSEST = 1, n.ANY = 2, n.ALL = 4, n.prototype.update = function() {
            var t = this.direction;
            i.sub(t, this.to, this.from), this.length = i.length(t), i.normalize(t, t);
        }, n.prototype.intersectBodies = function(t, e) {
            for (var o = 0, i = e.length; !t.shouldStop(this) && o < i; o++) {
                var n = e[o], s = n.getAABB();
                (s.overlapsRay(this) >= 0 || s.containsPoint(this.from)) && this.intersectBody(t, n);
            }
        };
        var s = i.create();
        n.prototype.intersectBody = function(t, e) {
            var o = this.checkCollisionResponse;
            if (!o || e.collisionResponse) for (var n = s, r = 0, a = e.shapes.length; r < a; r++) {
                var c = e.shapes[r];
                if ((!o || c.collisionResponse) && 0 != (this.collisionGroup & c.collisionMask) && 0 != (c.collisionGroup & this.collisionMask)) {
                    i.rotate(n, c.position, e.angle), i.add(n, n, e.position);
                    var h = c.angle + e.angle;
                    if (this.intersectShape(t, c, h, n, e), t.shouldStop(this)) break;
                }
            }
        }, n.prototype.intersectShape = function(t, e, o, n, s) {
            (function(t, e, o) {
                i.sub(r, o, t);
                var n = i.dot(r, e);
                return i.scale(a, e, n), i.add(a, a, t), i.squaredDistance(o, a);
            })(this.from, this.direction, n) > e.boundingRadius * e.boundingRadius || (this._currentBody = s, 
            this._currentShape = e, e.raycast(t, this, n, o), this._currentBody = this._currentShape = null);
        }, n.prototype.getAABB = function(t) {
            var e = this.to, o = this.from;
            i.set(t.lowerBound, Math.min(e[0], o[0]), Math.min(e[1], o[1])), i.set(t.upperBound, Math.max(e[0], o[0]), Math.max(e[1], o[1]));
        }, i.create(), n.prototype.reportIntersection = function(t, e, o, s) {
            this.from, this.to;
            var r = this._currentShape, a = this._currentBody;
            if (!(this.skipBackfaces && i.dot(o, this.direction) > 0)) switch (this.mode) {
              case n.ALL:
                t.set(o, r, a, e, s), this.callback(t);
                break;

              case n.CLOSEST:
                (e < t.fraction || !t.hasHit()) && t.set(o, r, a, e, s);
                break;

              case n.ANY:
                t.set(o, r, a, e, s);
            }
        };
        var r = i.create(), a = i.create();
    }, {
        "../collision/AABB": 7,
        "../collision/RaycastResult": 12,
        "../math/vec2": 30,
        "../shapes/Shape": 45
    } ],
    12: [ function(t, e, o) {
        var i = t("../math/vec2"), n = t("../collision/Ray");
        function s() {
            this.normal = i.create(), this.shape = null, this.body = null, this.faceIndex = -1, 
            this.fraction = -1, this.isStopped = !1;
        }
        e.exports = s, s.prototype.reset = function() {
            i.set(this.normal, 0, 0), this.shape = null, this.body = null, this.faceIndex = -1, 
            this.fraction = -1, this.isStopped = !1;
        }, s.prototype.getHitDistance = function(t) {
            return i.distance(t.from, t.to) * this.fraction;
        }, s.prototype.hasHit = function() {
            return -1 !== this.fraction;
        }, s.prototype.getHitPoint = function(t, e) {
            i.lerp(t, e.from, e.to, this.fraction);
        }, s.prototype.stop = function() {
            this.isStopped = !0;
        }, s.prototype.shouldStop = function(t) {
            return this.isStopped || -1 !== this.fraction && t.mode === n.ANY;
        }, s.prototype.set = function(t, e, o, n, s) {
            i.copy(this.normal, t), this.shape = e, this.body = o, this.fraction = n, this.faceIndex = s;
        };
    }, {
        "../collision/Ray": 11,
        "../math/vec2": 30
    } ],
    13: [ function(t, e, o) {
        var i = t("../utils/Utils"), n = t("../collision/Broadphase");
        function s() {
            n.call(this, n.SAP), this.axisList = [], this.axisIndex = 0;
            var t = this;
            this._addBodyHandler = function(e) {
                t.axisList.push(e.body);
            }, this._removeBodyHandler = function(e) {
                var o = t.axisList.indexOf(e.body);
                -1 !== o && t.axisList.splice(o, 1);
            };
        }
        e.exports = s, s.prototype = new n(), s.prototype.constructor = s, s.prototype.setWorld = function(t) {
            this.axisList.length = 0, i.appendArray(this.axisList, t.bodies), t.off("addBody", this._addBodyHandler).off("removeBody", this._removeBodyHandler), 
            t.on("addBody", this._addBodyHandler).on("removeBody", this._removeBodyHandler), 
            this.world = t;
        }, s.sortAxisList = function(t, e) {
            e |= 0;
            for (var o = 1, i = t.length; o < i; o++) {
                for (var n = t[o], s = o - 1; s >= 0 && !(t[s].aabb.lowerBound[e] <= n.aabb.lowerBound[e]); s--) t[s + 1] = t[s];
                t[s + 1] = n;
            }
            return t;
        }, s.prototype.sortList = function() {
            var t = this.axisList, e = this.axisIndex;
            s.sortAxisList(t, e);
        }, s.prototype.getCollisionPairs = function(t) {
            var e = this.axisList, o = this.result, i = this.axisIndex;
            o.length = 0;
            for (var s = e.length; s--; ) {
                var r = e[s];
                r.aabbNeedsUpdate && r.updateAABB();
            }
            this.sortList();
            for (var a = 0, c = 0 | e.length; a !== c; a++) for (var h = e[a], l = a + 1; l < c; l++) {
                var p = e[l];
                if (!(p.aabb.lowerBound[i] <= h.aabb.upperBound[i])) break;
                n.canCollide(h, p) && this.boundingVolumeCheck(h, p) && o.push(h, p);
            }
            return o;
        }, s.prototype.aabbQuery = function(t, e, o) {
            o = o || [], this.sortList();
            var i = this.axisIndex, n = "x";
            1 === i && (n = "y"), 2 === i && (n = "z");
            for (var s = this.axisList, r = (e.lowerBound[n], e.upperBound[n], 0); r < s.length; r++) {
                var a = s[r];
                a.aabbNeedsUpdate && a.updateAABB(), a.aabb.overlaps(e) && o.push(a);
            }
            return o;
        };
    }, {
        "../collision/Broadphase": 8,
        "../utils/Utils": 57
    } ],
    14: [ function(t, e, o) {
        e.exports = n;
        var i = t("../utils/Utils");
        function n(t, e, o, n) {
            this.type = o, n = i.defaults(n, {
                collideConnected: !0,
                wakeUpBodies: !0
            }), this.equations = [], this.bodyA = t, this.bodyB = e, this.collideConnected = n.collideConnected, 
            n.wakeUpBodies && (t && t.wakeUp(), e && e.wakeUp());
        }
        n.prototype.update = function() {
            throw new Error("method update() not implmemented in this Constraint subclass!");
        }, n.DISTANCE = 1, n.GEAR = 2, n.LOCK = 3, n.PRISMATIC = 4, n.REVOLUTE = 5, n.prototype.setStiffness = function(t) {
            for (var e = this.equations, o = 0; o !== e.length; o++) {
                var i = e[o];
                i.stiffness = t, i.needsUpdate = !0;
            }
        }, n.prototype.setRelaxation = function(t) {
            for (var e = this.equations, o = 0; o !== e.length; o++) {
                var i = e[o];
                i.relaxation = t, i.needsUpdate = !0;
            }
        };
    }, {
        "../utils/Utils": 57
    } ],
    15: [ function(t, e, o) {
        var i = t("./Constraint"), n = t("../equations/Equation"), s = t("../math/vec2"), r = t("../utils/Utils");
        function a(t, e, o) {
            o = r.defaults(o, {
                localAnchorA: [ 0, 0 ],
                localAnchorB: [ 0, 0 ]
            }), i.call(this, t, e, i.DISTANCE, o), this.localAnchorA = s.fromValues(o.localAnchorA[0], o.localAnchorA[1]), 
            this.localAnchorB = s.fromValues(o.localAnchorB[0], o.localAnchorB[1]);
            var a, c = this.localAnchorA, h = this.localAnchorB;
            if (this.distance = 0, "number" == typeof o.distance) this.distance = o.distance; else {
                var l = s.create(), p = s.create(), u = s.create();
                s.rotate(l, c, t.angle), s.rotate(p, h, e.angle), s.add(u, e.position, p), s.sub(u, u, l), 
                s.sub(u, u, t.position), this.distance = s.length(u);
            }
            a = void 0 === o.maxForce ? Number.MAX_VALUE : o.maxForce;
            var d = new n(t, e, -a, a);
            this.equations = [ d ], this.maxForce = a;
            u = s.create();
            var f = s.create(), v = s.create(), y = this;
            d.computeGq = function() {
                var t = this.bodyA, e = this.bodyB, o = t.position, i = e.position;
                return s.rotate(f, c, t.angle), s.rotate(v, h, e.angle), s.add(u, i, v), s.sub(u, u, f), 
                s.sub(u, u, o), s.length(u) - y.distance;
            }, this.setMaxForce(a), this.upperLimitEnabled = !1, this.upperLimit = 1, this.lowerLimitEnabled = !1, 
            this.lowerLimit = 0, this.position = 0;
        }
        e.exports = a, a.prototype = new i(), a.prototype.constructor = a;
        var c = s.create(), h = s.create(), l = s.create();
        a.prototype.update = function() {
            var t = this.equations[0], e = this.bodyA, o = this.bodyB, i = (this.distance, e.position), n = o.position, r = this.equations[0], a = t.G;
            s.rotate(h, this.localAnchorA, e.angle), s.rotate(l, this.localAnchorB, o.angle), 
            s.add(c, n, l), s.sub(c, c, h), s.sub(c, c, i), this.position = s.length(c);
            var p = !1;
            if (this.upperLimitEnabled && this.position > this.upperLimit && (r.maxForce = 0, 
            r.minForce = -this.maxForce, this.distance = this.upperLimit, p = !0), this.lowerLimitEnabled && this.position < this.lowerLimit && (r.maxForce = this.maxForce, 
            r.minForce = 0, this.distance = this.lowerLimit, p = !0), !this.lowerLimitEnabled && !this.upperLimitEnabled || p) {
                r.enabled = !0, s.normalize(c, c);
                var u = s.crossLength(h, c), d = s.crossLength(l, c);
                a[0] = -c[0], a[1] = -c[1], a[2] = -u, a[3] = c[0], a[4] = c[1], a[5] = d;
            } else r.enabled = !1;
        }, a.prototype.setMaxForce = function(t) {
            var e = this.equations[0];
            e.minForce = -t, e.maxForce = t;
        }, a.prototype.getMaxForce = function() {
            return this.equations[0].maxForce;
        };
    }, {
        "../equations/Equation": 22,
        "../math/vec2": 30,
        "../utils/Utils": 57,
        "./Constraint": 14
    } ],
    16: [ function(t, e, o) {
        var i = t("./Constraint"), n = (t("../equations/Equation"), t("../equations/AngleLockEquation"));
        function s(t, e, o) {
            o = o || {}, i.call(this, t, e, i.GEAR, o), this.ratio = void 0 !== o.ratio ? o.ratio : 1, 
            this.angle = void 0 !== o.angle ? o.angle : e.angle - this.ratio * t.angle, o.angle = this.angle, 
            o.ratio = this.ratio, this.equations = [ new n(t, e, o) ], void 0 !== o.maxTorque && this.setMaxTorque(o.maxTorque);
        }
        t("../math/vec2"), e.exports = s, s.prototype = new i(), s.prototype.constructor = s, 
        s.prototype.update = function() {
            var t = this.equations[0];
            t.ratio !== this.ratio && t.setRatio(this.ratio), t.angle = this.angle;
        }, s.prototype.setMaxTorque = function(t) {
            this.equations[0].setMaxTorque(t);
        }, s.prototype.getMaxTorque = function(t) {
            return this.equations[0].maxForce;
        };
    }, {
        "../equations/AngleLockEquation": 20,
        "../equations/Equation": 22,
        "../math/vec2": 30,
        "./Constraint": 14
    } ],
    17: [ function(t, e, o) {
        var i = t("./Constraint"), n = t("../math/vec2"), s = t("../equations/Equation");
        function r(t, e, o) {
            o = o || {}, i.call(this, t, e, i.LOCK, o);
            var r = void 0 === o.maxForce ? Number.MAX_VALUE : o.maxForce, a = (o.localAngleB, 
            new s(t, e, -r, r)), c = new s(t, e, -r, r), h = new s(t, e, -r, r), l = n.create(), p = n.create(), u = this;
            a.computeGq = function() {
                return n.rotate(l, u.localOffsetB, t.angle), n.sub(p, e.position, t.position), n.sub(p, p, l), 
                p[0];
            }, c.computeGq = function() {
                return n.rotate(l, u.localOffsetB, t.angle), n.sub(p, e.position, t.position), n.sub(p, p, l), 
                p[1];
            };
            var d = n.create(), f = n.create();
            h.computeGq = function() {
                return n.rotate(d, u.localOffsetB, e.angle - u.localAngleB), n.scale(d, d, -1), 
                n.sub(p, t.position, e.position), n.add(p, p, d), n.rotate(f, d, -Math.PI / 2), 
                n.normalize(f, f), n.dot(p, f);
            }, this.localOffsetB = n.create(), o.localOffsetB ? n.copy(this.localOffsetB, o.localOffsetB) : (n.sub(this.localOffsetB, e.position, t.position), 
            n.rotate(this.localOffsetB, this.localOffsetB, -t.angle)), this.localAngleB = 0, 
            "number" == typeof o.localAngleB ? this.localAngleB = o.localAngleB : this.localAngleB = e.angle - t.angle, 
            this.equations.push(a, c, h), this.setMaxForce(r);
        }
        e.exports = r, r.prototype = new i(), r.prototype.constructor = r, r.prototype.setMaxForce = function(t) {
            for (var e = this.equations, o = 0; o < this.equations.length; o++) e[o].maxForce = t, 
            e[o].minForce = -t;
        }, r.prototype.getMaxForce = function() {
            return this.equations[0].maxForce;
        };
        var a = n.create(), c = n.create(), h = n.create(), l = n.fromValues(1, 0), p = n.fromValues(0, 1);
        r.prototype.update = function() {
            var t = this.equations[0], e = this.equations[1], o = this.equations[2], i = this.bodyA, s = this.bodyB;
            n.rotate(a, this.localOffsetB, i.angle), n.rotate(c, this.localOffsetB, s.angle - this.localAngleB), 
            n.scale(c, c, -1), n.rotate(h, c, Math.PI / 2), n.normalize(h, h), t.G[0] = -1, 
            t.G[1] = 0, t.G[2] = -n.crossLength(a, l), t.G[3] = 1, e.G[0] = 0, e.G[1] = -1, 
            e.G[2] = -n.crossLength(a, p), e.G[4] = 1, o.G[0] = -h[0], o.G[1] = -h[1], o.G[3] = h[0], 
            o.G[4] = h[1], o.G[5] = n.crossLength(c, h);
        };
    }, {
        "../equations/Equation": 22,
        "../math/vec2": 30,
        "./Constraint": 14
    } ],
    18: [ function(t, e, o) {
        var i = t("./Constraint"), n = t("../equations/ContactEquation"), s = t("../equations/Equation"), r = t("../math/vec2"), a = t("../equations/RotationalLockEquation");
        function c(t, e, o) {
            o = o || {}, i.call(this, t, e, i.PRISMATIC, o);
            var c = r.fromValues(0, 0), h = r.fromValues(1, 0), l = r.fromValues(0, 0);
            o.localAnchorA && r.copy(c, o.localAnchorA), o.localAxisA && r.copy(h, o.localAxisA), 
            o.localAnchorB && r.copy(l, o.localAnchorB), this.localAnchorA = c, this.localAnchorB = l, 
            this.localAxisA = h;
            var p = this.maxForce = void 0 !== o.maxForce ? o.maxForce : Number.MAX_VALUE, u = new s(t, e, -p, p), d = new r.create(), f = new r.create(), v = new r.create(), y = new r.create();
            if (u.computeGq = function() {
                return r.dot(v, y);
            }, u.updateJacobian = function() {
                var o = this.G, i = t.position, n = e.position;
                r.rotate(d, c, t.angle), r.rotate(f, l, e.angle), r.add(v, n, f), r.sub(v, v, i), 
                r.sub(v, v, d), r.rotate(y, h, t.angle + Math.PI / 2), o[0] = -y[0], o[1] = -y[1], 
                o[2] = -r.crossLength(d, y) + r.crossLength(y, v), o[3] = y[0], o[4] = y[1], o[5] = r.crossLength(f, y);
            }, this.equations.push(u), !o.disableRotationalLock) {
                var m = new a(t, e, -p, p);
                this.equations.push(m);
            }
            this.position = 0, this.velocity = 0, this.lowerLimitEnabled = void 0 !== o.lowerLimit, 
            this.upperLimitEnabled = void 0 !== o.upperLimit, this.lowerLimit = void 0 !== o.lowerLimit ? o.lowerLimit : 0, 
            this.upperLimit = void 0 !== o.upperLimit ? o.upperLimit : 1, this.upperLimitEquation = new n(t, e), 
            this.lowerLimitEquation = new n(t, e), this.upperLimitEquation.minForce = this.lowerLimitEquation.minForce = 0, 
            this.upperLimitEquation.maxForce = this.lowerLimitEquation.maxForce = p, this.motorEquation = new s(t, e), 
            this.motorEnabled = !1, this.motorSpeed = 0;
            var g = this, A = this.motorEquation;
            A.computeGW, A.computeGq = function() {
                return 0;
            }, A.computeGW = function() {
                var t = this.G, e = this.bodyA, o = this.bodyB, i = e.velocity, n = o.velocity, s = e.angularVelocity, r = o.angularVelocity;
                return this.gmult(t, i, s, n, r) + g.motorSpeed;
            };
        }
        e.exports = c, c.prototype = new i(), c.prototype.constructor = c;
        var h = r.create(), l = r.create(), p = r.create(), u = r.create(), d = r.create(), f = r.create();
        c.prototype.update = function() {
            var t = this.equations, e = t[0], o = this.upperLimit, i = this.lowerLimit, n = this.upperLimitEquation, s = this.lowerLimitEquation, a = this.bodyA, c = this.bodyB, v = this.localAxisA, y = this.localAnchorA, m = this.localAnchorB;
            e.updateJacobian(), r.rotate(h, v, a.angle), r.rotate(u, y, a.angle), r.add(l, u, a.position), 
            r.rotate(d, m, c.angle), r.add(p, d, c.position);
            var g, A = this.position = r.dot(p, h) - r.dot(l, h);
            if (this.motorEnabled) {
                var b = this.motorEquation.G;
                b[0] = h[0], b[1] = h[1], b[2] = r.crossLength(h, d), b[3] = -h[0], b[4] = -h[1], 
                b[5] = -r.crossLength(h, u);
            }
            this.upperLimitEnabled && A > o ? (r.scale(n.normalA, h, -1), r.sub(n.contactPointA, l, a.position), 
            r.sub(n.contactPointB, p, c.position), r.scale(f, h, o), r.add(n.contactPointA, n.contactPointA, f), 
            -1 === t.indexOf(n) && t.push(n)) : -1 !== (g = t.indexOf(n)) && t.splice(g, 1);
            this.lowerLimitEnabled && A < i ? (r.scale(s.normalA, h, 1), r.sub(s.contactPointA, l, a.position), 
            r.sub(s.contactPointB, p, c.position), r.scale(f, h, i), r.sub(s.contactPointB, s.contactPointB, f), 
            -1 === t.indexOf(s) && t.push(s)) : -1 !== (g = t.indexOf(s)) && t.splice(g, 1);
        }, c.prototype.enableMotor = function() {
            this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0);
        }, c.prototype.disableMotor = function() {
            if (this.motorEnabled) {
                var t = this.equations.indexOf(this.motorEquation);
                this.equations.splice(t, 1), this.motorEnabled = !1;
            }
        }, c.prototype.setLimits = function(t, e) {
            "number" == typeof t ? (this.lowerLimit = t, this.lowerLimitEnabled = !0) : (this.lowerLimit = t, 
            this.lowerLimitEnabled = !1), "number" == typeof e ? (this.upperLimit = e, this.upperLimitEnabled = !0) : (this.upperLimit = e, 
            this.upperLimitEnabled = !1);
        };
    }, {
        "../equations/ContactEquation": 21,
        "../equations/Equation": 22,
        "../equations/RotationalLockEquation": 24,
        "../math/vec2": 30,
        "./Constraint": 14
    } ],
    19: [ function(t, e, o) {
        var i = t("./Constraint"), n = t("../equations/Equation"), s = t("../equations/RotationalVelocityEquation"), r = t("../equations/RotationalLockEquation"), a = t("../math/vec2");
        e.exports = d;
        var c = a.create(), h = a.create(), l = a.fromValues(1, 0), p = a.fromValues(0, 1), u = a.create();
        function d(t, e, o) {
            o = o || {}, i.call(this, t, e, i.REVOLUTE, o);
            var d = this.maxForce = void 0 !== o.maxForce ? o.maxForce : Number.MAX_VALUE;
            this.pivotA = a.create(), this.pivotB = a.create(), o.worldPivot ? (a.sub(this.pivotA, o.worldPivot, t.position), 
            a.sub(this.pivotB, o.worldPivot, e.position), a.rotate(this.pivotA, this.pivotA, -t.angle), 
            a.rotate(this.pivotB, this.pivotB, -e.angle)) : (a.copy(this.pivotA, o.localPivotA), 
            a.copy(this.pivotB, o.localPivotB));
            var f = this.equations = [ new n(t, e, -d, d), new n(t, e, -d, d) ], v = f[0], y = f[1], m = this;
            v.computeGq = function() {
                return a.rotate(c, m.pivotA, t.angle), a.rotate(h, m.pivotB, e.angle), a.add(u, e.position, h), 
                a.sub(u, u, t.position), a.sub(u, u, c), a.dot(u, l);
            }, y.computeGq = function() {
                return a.rotate(c, m.pivotA, t.angle), a.rotate(h, m.pivotB, e.angle), a.add(u, e.position, h), 
                a.sub(u, u, t.position), a.sub(u, u, c), a.dot(u, p);
            }, y.minForce = v.minForce = -d, y.maxForce = v.maxForce = d, this.motorEquation = new s(t, e), 
            this.motorEnabled = !1, this.angle = 0, this.lowerLimitEnabled = !1, this.upperLimitEnabled = !1, 
            this.lowerLimit = 0, this.upperLimit = 0, this.upperLimitEquation = new r(t, e), 
            this.lowerLimitEquation = new r(t, e), this.upperLimitEquation.minForce = 0, this.lowerLimitEquation.maxForce = 0;
        }
        d.prototype = new i(), d.prototype.constructor = d, d.prototype.setLimits = function(t, e) {
            "number" == typeof t ? (this.lowerLimit = t, this.lowerLimitEnabled = !0) : (this.lowerLimit = t, 
            this.lowerLimitEnabled = !1), "number" == typeof e ? (this.upperLimit = e, this.upperLimitEnabled = !0) : (this.upperLimit = e, 
            this.upperLimitEnabled = !1);
        }, d.prototype.update = function() {
            var t, e = this.bodyA, o = this.bodyB, i = this.pivotA, n = this.pivotB, s = this.equations, r = (s[0], 
            s[1], s[0]), u = s[1], d = this.upperLimit, f = this.lowerLimit, v = this.upperLimitEquation, y = this.lowerLimitEquation, m = this.angle = o.angle - e.angle;
            this.upperLimitEnabled && m > d ? (v.angle = d, -1 === s.indexOf(v) && s.push(v)) : -1 !== (t = s.indexOf(v)) && s.splice(t, 1);
            this.lowerLimitEnabled && m < f ? (y.angle = f, -1 === s.indexOf(y) && s.push(y)) : -1 !== (t = s.indexOf(y)) && s.splice(t, 1);
            a.rotate(c, i, e.angle), a.rotate(h, n, o.angle), r.G[0] = -1, r.G[1] = 0, r.G[2] = -a.crossLength(c, l), 
            r.G[3] = 1, r.G[4] = 0, r.G[5] = a.crossLength(h, l), u.G[0] = 0, u.G[1] = -1, u.G[2] = -a.crossLength(c, p), 
            u.G[3] = 0, u.G[4] = 1, u.G[5] = a.crossLength(h, p);
        }, d.prototype.enableMotor = function() {
            this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0);
        }, d.prototype.disableMotor = function() {
            if (this.motorEnabled) {
                var t = this.equations.indexOf(this.motorEquation);
                this.equations.splice(t, 1), this.motorEnabled = !1;
            }
        }, d.prototype.motorIsEnabled = function() {
            return !!this.motorEnabled;
        }, d.prototype.setMotorSpeed = function(t) {
            if (this.motorEnabled) {
                var e = this.equations.indexOf(this.motorEquation);
                this.equations[e].relativeVelocity = t;
            }
        }, d.prototype.getMotorSpeed = function() {
            return !!this.motorEnabled && this.motorEquation.relativeVelocity;
        };
    }, {
        "../equations/Equation": 22,
        "../equations/RotationalLockEquation": 24,
        "../equations/RotationalVelocityEquation": 25,
        "../math/vec2": 30,
        "./Constraint": 14
    } ],
    20: [ function(t, e, o) {
        var i = t("./Equation");
        function n(t, e, o) {
            o = o || {}, i.call(this, t, e, -Number.MAX_VALUE, Number.MAX_VALUE), this.angle = o.angle || 0, 
            this.ratio = "number" == typeof o.ratio ? o.ratio : 1, this.setRatio(this.ratio);
        }
        t("../math/vec2"), e.exports = n, n.prototype = new i(), n.prototype.constructor = n, 
        n.prototype.computeGq = function() {
            return this.ratio * this.bodyA.angle - this.bodyB.angle + this.angle;
        }, n.prototype.setRatio = function(t) {
            var e = this.G;
            e[2] = t, e[5] = -1, this.ratio = t;
        }, n.prototype.setMaxTorque = function(t) {
            this.maxForce = t, this.minForce = -t;
        };
    }, {
        "../math/vec2": 30,
        "./Equation": 22
    } ],
    21: [ function(t, e, o) {
        var i = t("./Equation"), n = t("../math/vec2");
        function s(t, e) {
            i.call(this, t, e, 0, Number.MAX_VALUE), this.contactPointA = n.create(), this.penetrationVec = n.create(), 
            this.contactPointB = n.create(), this.normalA = n.create(), this.restitution = 0, 
            this.firstImpact = !1, this.shapeA = null, this.shapeB = null;
        }
        e.exports = s, s.prototype = new i(), s.prototype.constructor = s, s.prototype.computeB = function(t, e, o) {
            var i, s, r = this.bodyA, a = this.bodyB, c = this.contactPointA, h = this.contactPointB, l = r.position, p = a.position, u = this.penetrationVec, d = this.normalA, f = this.G, v = n.crossLength(c, d), y = n.crossLength(h, d);
            return f[0] = -d[0], f[1] = -d[1], f[2] = -v, f[3] = d[0], f[4] = d[1], f[5] = y, 
            n.add(u, p, h), n.sub(u, u, l), n.sub(u, u, c), this.firstImpact && 0 !== this.restitution ? (s = 0, 
            i = 1 / e * (1 + this.restitution) * this.computeGW()) : (s = n.dot(d, u) + this.offset, 
            i = this.computeGW()), -s * t - i * e - o * this.computeGiMf();
        };
        var r = n.create(), a = n.create(), c = n.create();
        s.prototype.getVelocityAlongNormal = function() {
            return this.bodyA.getVelocityAtPoint(r, this.contactPointA), this.bodyB.getVelocityAtPoint(a, this.contactPointB), 
            n.subtract(c, r, a), n.dot(this.normalA, c);
        };
    }, {
        "../math/vec2": 30,
        "./Equation": 22
    } ],
    22: [ function(t, e, o) {
        e.exports = s;
        var i = t("../math/vec2"), n = t("../utils/Utils");
        function s(t, e, o, i) {
            this.minForce = void 0 === o ? -Number.MAX_VALUE : o, this.maxForce = void 0 === i ? Number.MAX_VALUE : i, 
            this.bodyA = t, this.bodyB = e, this.stiffness = s.DEFAULT_STIFFNESS, this.relaxation = s.DEFAULT_RELAXATION, 
            this.G = new n.ARRAY_TYPE(6);
            for (var r = 0; r < 6; r++) this.G[r] = 0;
            this.offset = 0, this.a = 0, this.b = 0, this.epsilon = 0, this.timeStep = 1 / 60, 
            this.needsUpdate = !0, this.multiplier = 0, this.relativeVelocity = 0, this.enabled = !0;
        }
        t("../objects/Body"), s.prototype.constructor = s, s.DEFAULT_STIFFNESS = 1e6, s.DEFAULT_RELAXATION = 4, 
        s.prototype.update = function() {
            var t = this.stiffness, e = this.relaxation, o = this.timeStep;
            this.a = 4 / (o * (1 + 4 * e)), this.b = 4 * e / (1 + 4 * e), this.epsilon = 4 / (o * o * t * (1 + 4 * e)), 
            this.needsUpdate = !1;
        }, s.prototype.gmult = function(t, e, o, i, n) {
            return t[0] * e[0] + t[1] * e[1] + t[2] * o + t[3] * i[0] + t[4] * i[1] + t[5] * n;
        }, s.prototype.computeB = function(t, e, o) {
            var i = this.computeGW();
            return -this.computeGq() * t - i * e - this.computeGiMf() * o;
        };
        var r = i.create(), a = i.create();
        s.prototype.computeGq = function() {
            var t = this.G, e = this.bodyA, o = this.bodyB, i = (e.position, o.position, e.angle), n = o.angle;
            return this.gmult(t, r, i, a, n) + this.offset;
        }, s.prototype.computeGW = function() {
            var t = this.G, e = this.bodyA, o = this.bodyB, i = e.velocity, n = o.velocity, s = e.angularVelocity, r = o.angularVelocity;
            return this.gmult(t, i, s, n, r) + this.relativeVelocity;
        }, s.prototype.computeGWlambda = function() {
            var t = this.G, e = this.bodyA, o = this.bodyB, i = e.vlambda, n = o.vlambda, s = e.wlambda, r = o.wlambda;
            return this.gmult(t, i, s, n, r);
        };
        var c = i.create(), h = i.create();
        s.prototype.computeGiMf = function() {
            var t = this.bodyA, e = this.bodyB, o = t.force, n = t.angularForce, s = e.force, r = e.angularForce, a = t.invMassSolve, l = e.invMassSolve, p = t.invInertiaSolve, u = e.invInertiaSolve, d = this.G;
            return i.scale(c, o, a), i.multiply(c, t.massMultiplier, c), i.scale(h, s, l), i.multiply(h, e.massMultiplier, h), 
            this.gmult(d, c, n * p, h, r * u);
        }, s.prototype.computeGiMGt = function() {
            var t = this.bodyA, e = this.bodyB, o = t.invMassSolve, i = e.invMassSolve, n = t.invInertiaSolve, s = e.invInertiaSolve, r = this.G;
            return r[0] * r[0] * o * t.massMultiplier[0] + r[1] * r[1] * o * t.massMultiplier[1] + r[2] * r[2] * n + r[3] * r[3] * i * e.massMultiplier[0] + r[4] * r[4] * i * e.massMultiplier[1] + r[5] * r[5] * s;
        };
        var l = i.create(), p = i.create(), u = i.create();
        i.create(), i.create(), i.create(), s.prototype.addToWlambda = function(t) {
            var e = this.bodyA, o = this.bodyB, n = l, s = p, r = u, a = e.invMassSolve, c = o.invMassSolve, h = e.invInertiaSolve, d = o.invInertiaSolve, f = this.G;
            s[0] = f[0], s[1] = f[1], r[0] = f[3], r[1] = f[4], i.scale(n, s, a * t), i.multiply(n, n, e.massMultiplier), 
            i.add(e.vlambda, e.vlambda, n), e.wlambda += h * f[2] * t, i.scale(n, r, c * t), 
            i.multiply(n, n, o.massMultiplier), i.add(o.vlambda, o.vlambda, n), o.wlambda += d * f[5] * t;
        }, s.prototype.computeInvC = function(t) {
            return 1 / (this.computeGiMGt() + t);
        };
    }, {
        "../math/vec2": 30,
        "../objects/Body": 31,
        "../utils/Utils": 57
    } ],
    23: [ function(t, e, o) {
        var i = t("../math/vec2"), n = t("./Equation");
        function s(t, e, o) {
            n.call(this, t, e, -o, o), this.contactPointA = i.create(), this.contactPointB = i.create(), 
            this.t = i.create(), this.contactEquations = [], this.shapeA = null, this.shapeB = null, 
            this.frictionCoefficient = .3;
        }
        t("../utils/Utils"), e.exports = s, s.prototype = new n(), s.prototype.constructor = s, 
        s.prototype.setSlipForce = function(t) {
            this.maxForce = t, this.minForce = -t;
        }, s.prototype.getSlipForce = function() {
            return this.maxForce;
        }, s.prototype.computeB = function(t, e, o) {
            this.bodyA, this.bodyB;
            var n = this.contactPointA, s = this.contactPointB, r = this.t, a = this.G;
            return a[0] = -r[0], a[1] = -r[1], a[2] = -i.crossLength(n, r), a[3] = r[0], a[4] = r[1], 
            a[5] = i.crossLength(s, r), -this.computeGW() * e - o * this.computeGiMf();
        };
    }, {
        "../math/vec2": 30,
        "../utils/Utils": 57,
        "./Equation": 22
    } ],
    24: [ function(t, e, o) {
        var i = t("./Equation"), n = t("../math/vec2");
        function s(t, e, o) {
            o = o || {}, i.call(this, t, e, -Number.MAX_VALUE, Number.MAX_VALUE), this.angle = o.angle || 0;
            var n = this.G;
            n[2] = 1, n[5] = -1;
        }
        e.exports = s, s.prototype = new i(), s.prototype.constructor = s;
        var r = n.create(), a = n.create(), c = n.fromValues(1, 0), h = n.fromValues(0, 1);
        s.prototype.computeGq = function() {
            return n.rotate(r, c, this.bodyA.angle + this.angle), n.rotate(a, h, this.bodyB.angle), 
            n.dot(r, a);
        };
    }, {
        "../math/vec2": 30,
        "./Equation": 22
    } ],
    25: [ function(t, e, o) {
        var i = t("./Equation");
        function n(t, e) {
            i.call(this, t, e, -Number.MAX_VALUE, Number.MAX_VALUE), this.relativeVelocity = 1, 
            this.ratio = 1;
        }
        t("../math/vec2"), e.exports = n, n.prototype = new i(), n.prototype.constructor = n, 
        n.prototype.computeB = function(t, e, o) {
            var i = this.G;
            i[2] = -1, i[5] = this.ratio;
            var n = this.computeGiMf();
            return -this.computeGW() * e - o * n;
        };
    }, {
        "../math/vec2": 30,
        "./Equation": 22
    } ],
    26: [ function(t, e, o) {
        var i = function() {};
        e.exports = i, i.prototype = {
            constructor: i,
            on: function(t, e, o) {
                e.context = o || this, void 0 === this._listeners && (this._listeners = {});
                var i = this._listeners;
                return void 0 === i[t] && (i[t] = []), -1 === i[t].indexOf(e) && i[t].push(e), this;
            },
            has: function(t, e) {
                if (void 0 === this._listeners) return !1;
                var o = this._listeners;
                if (e) {
                    if (void 0 !== o[t] && -1 !== o[t].indexOf(e)) return !0;
                } else if (void 0 !== o[t]) return !0;
                return !1;
            },
            off: function(t, e) {
                if (void 0 === this._listeners) return this;
                var o = this._listeners, i = o[t].indexOf(e);
                return -1 !== i && o[t].splice(i, 1), this;
            },
            emit: function(t) {
                if (void 0 === this._listeners) return this;
                var e = this._listeners[t.type];
                if (void 0 !== e) {
                    t.target = this;
                    for (var o = 0, i = e.length; o < i; o++) {
                        var n = e[o];
                        n.call(n.context, t);
                    }
                }
                return this;
            }
        };
    }, {} ],
    27: [ function(t, e, o) {
        var i = t("./Material"), n = t("../equations/Equation");
        function s(t, e, o) {
            if (o = o || {}, !(t instanceof i && e instanceof i)) throw new Error("First two arguments must be Material instances.");
            this.id = s.idCounter++, this.materialA = t, this.materialB = e, this.friction = void 0 !== o.friction ? Number(o.friction) : .3, 
            this.restitution = void 0 !== o.restitution ? Number(o.restitution) : 0, this.stiffness = void 0 !== o.stiffness ? Number(o.stiffness) : n.DEFAULT_STIFFNESS, 
            this.relaxation = void 0 !== o.relaxation ? Number(o.relaxation) : n.DEFAULT_RELAXATION, 
            this.frictionStiffness = void 0 !== o.frictionStiffness ? Number(o.frictionStiffness) : n.DEFAULT_STIFFNESS, 
            this.frictionRelaxation = void 0 !== o.frictionRelaxation ? Number(o.frictionRelaxation) : n.DEFAULT_RELAXATION, 
            this.surfaceVelocity = void 0 !== o.surfaceVelocity ? Number(o.surfaceVelocity) : 0, 
            this.contactSkinSize = .005;
        }
        e.exports = s, s.idCounter = 0;
    }, {
        "../equations/Equation": 22,
        "./Material": 28
    } ],
    28: [ function(t, e, o) {
        function i(t) {
            this.id = t || i.idCounter++;
        }
        e.exports = i, i.idCounter = 0;
    }, {} ],
    29: [ function(t, e, o) {
        var i = {
            GetArea: function(t) {
                if (t.length < 6) return 0;
                for (var e = t.length - 2, o = 0, i = 0; i < e; i += 2) o += (t[i + 2] - t[i]) * (t[i + 1] + t[i + 3]);
                return .5 * -(o += (t[0] - t[e]) * (t[e + 1] + t[1]));
            },
            Triangulate: function(t) {
                var e = t.length >> 1;
                if (e < 3) return [];
                for (var o = [], n = [], s = 0; s < e; s++) n.push(s);
                s = 0;
                for (var r = e; r > 3; ) {
                    var a = n[(s + 0) % r], c = n[(s + 1) % r], h = n[(s + 2) % r], l = t[2 * a], p = t[2 * a + 1], u = t[2 * c], d = t[2 * c + 1], f = t[2 * h], v = t[2 * h + 1], y = !1;
                    if (i._convex(l, p, u, d, f, v)) {
                        y = !0;
                        for (var m = 0; m < r; m++) {
                            var g = n[m];
                            if (g != a && g != c && g != h && i._PointInTriangle(t[2 * g], t[2 * g + 1], l, p, u, d, f, v)) {
                                y = !1;
                                break;
                            }
                        }
                    }
                    if (y) o.push(a, c, h), n.splice((s + 1) % r, 1), r--, s = 0; else if (s++ > 3 * r) break;
                }
                return o.push(n[0], n[1], n[2]), o;
            },
            _PointInTriangle: function(t, e, o, i, n, s, r, a) {
                var c = r - o, h = a - i, l = n - o, p = s - i, u = t - o, d = e - i, f = c * c + h * h, v = c * l + h * p, y = c * u + h * d, m = l * l + p * p, g = l * u + p * d, A = 1 / (f * m - v * v), b = (m * y - v * g) * A, E = (f * g - v * y) * A;
                return b >= 0 && E >= 0 && b + E < 1;
            },
            _convex: function(t, e, o, i, n, s) {
                return (e - i) * (n - o) + (o - t) * (s - i) >= 0;
            }
        };
        e.exports = i;
    }, {} ],
    30: [ function(t, e, o) {
        var i = e.exports = {}, n = t("../utils/Utils");
        i.crossLength = function(t, e) {
            return t[0] * e[1] - t[1] * e[0];
        }, i.crossVZ = function(t, e, o) {
            return i.rotate(t, e, -Math.PI / 2), i.scale(t, t, o), t;
        }, i.crossZV = function(t, e, o) {
            return i.rotate(t, o, Math.PI / 2), i.scale(t, t, e), t;
        }, i.rotate = function(t, e, o) {
            if (0 !== o) {
                var i = Math.cos(o), n = Math.sin(o), s = e[0], r = e[1];
                t[0] = i * s - n * r, t[1] = n * s + i * r;
            } else t[0] = e[0], t[1] = e[1];
        }, i.rotate90cw = function(t, e) {
            var o = e[0], i = e[1];
            t[0] = i, t[1] = -o;
        }, i.toLocalFrame = function(t, e, o, n) {
            i.copy(t, e), i.sub(t, t, o), i.rotate(t, t, -n);
        }, i.toGlobalFrame = function(t, e, o, n) {
            i.copy(t, e), i.rotate(t, t, n), i.add(t, t, o);
        }, i.vectorToLocalFrame = function(t, e, o) {
            i.rotate(t, e, -o);
        }, i.vectorToGlobalFrame = function(t, e, o) {
            i.rotate(t, e, o);
        }, i.centroid = function(t, e, o, n) {
            return i.add(t, e, o), i.add(t, t, n), i.scale(t, t, 1 / 3), t;
        }, i.create = function() {
            var t = new n.ARRAY_TYPE(2);
            return t[0] = 0, t[1] = 0, t;
        }, i.clone = function(t) {
            var e = new n.ARRAY_TYPE(2);
            return e[0] = t[0], e[1] = t[1], e;
        }, i.fromValues = function(t, e) {
            var o = new n.ARRAY_TYPE(2);
            return o[0] = t, o[1] = e, o;
        }, i.copy = function(t, e) {
            return t[0] = e[0], t[1] = e[1], t;
        }, i.set = function(t, e, o) {
            return t[0] = e, t[1] = o, t;
        }, i.add = function(t, e, o) {
            return t[0] = e[0] + o[0], t[1] = e[1] + o[1], t;
        }, i.subtract = function(t, e, o) {
            return t[0] = e[0] - o[0], t[1] = e[1] - o[1], t;
        }, i.sub = i.subtract, i.multiply = function(t, e, o) {
            return t[0] = e[0] * o[0], t[1] = e[1] * o[1], t;
        }, i.mul = i.multiply, i.divide = function(t, e, o) {
            return t[0] = e[0] / o[0], t[1] = e[1] / o[1], t;
        }, i.div = i.divide, i.scale = function(t, e, o) {
            return t[0] = e[0] * o, t[1] = e[1] * o, t;
        }, i.distance = function(t, e) {
            var o = e[0] - t[0], i = e[1] - t[1];
            return Math.sqrt(o * o + i * i);
        }, i.dist = i.distance, i.squaredDistance = function(t, e) {
            var o = e[0] - t[0], i = e[1] - t[1];
            return o * o + i * i;
        }, i.sqrDist = i.squaredDistance, i.length = function(t) {
            var e = t[0], o = t[1];
            return Math.sqrt(e * e + o * o);
        }, i.len = i.length, i.squaredLength = function(t) {
            var e = t[0], o = t[1];
            return e * e + o * o;
        }, i.sqrLen = i.squaredLength, i.negate = function(t, e) {
            return t[0] = -e[0], t[1] = -e[1], t;
        }, i.normalize = function(t, e) {
            var o = e[0], i = e[1], n = o * o + i * i;
            return n > 0 && (n = 1 / Math.sqrt(n), t[0] = e[0] * n, t[1] = e[1] * n), t;
        }, i.dot = function(t, e) {
            return t[0] * e[0] + t[1] * e[1];
        }, i.str = function(t) {
            return "vec2(" + t[0] + ", " + t[1] + ")";
        }, i.lerp = function(t, e, o, i) {
            var n = e[0], s = e[1];
            return t[0] = n + i * (o[0] - n), t[1] = s + i * (o[1] - s), t;
        }, i.reflect = function(t, e, o) {
            var i = e[0] * o[0] + e[1] * o[1];
            t[0] = e[0] - 2 * o[0] * i, t[1] = e[1] - 2 * o[1] * i;
        }, i.getLineSegmentsIntersection = function(t, e, o, n, s) {
            var r = i.getLineSegmentsIntersectionFraction(e, o, n, s);
            return !(r < 0 || (t[0] = e[0] + r * (o[0] - e[0]), t[1] = e[1] + r * (o[1] - e[1]), 
            0));
        }, i.getLineSegmentsIntersectionFraction = function(t, e, o, i) {
            var n, s, r = e[0] - t[0], a = e[1] - t[1], c = i[0] - o[0], h = i[1] - o[1];
            return n = (-a * (t[0] - o[0]) + r * (t[1] - o[1])) / (-c * a + r * h), s = (c * (t[1] - o[1]) - h * (t[0] - o[0])) / (-c * a + r * h), 
            n >= 0 && n <= 1 && s >= 0 && s <= 1 ? s : -1;
        };
    }, {
        "../utils/Utils": 57
    } ],
    31: [ function(t, e, o) {
        var i = t("../math/vec2"), n = t("poly-decomp"), s = t("../shapes/Convex"), r = t("../collision/RaycastResult"), a = t("../collision/Ray"), c = t("../collision/AABB"), h = t("../events/EventEmitter");
        function l(t) {
            t = t || {}, h.call(this), this.id = t.id || ++l._idCounter, this.world = null, 
            this.shapes = [], this.mass = t.mass || 0, this.invMass = 0, this.inertia = 0, this.invInertia = 0, 
            this.invMassSolve = 0, this.invInertiaSolve = 0, this.fixedRotation = !!t.fixedRotation, 
            this.fixedX = !!t.fixedX, this.fixedY = !!t.fixedY, this.massMultiplier = i.create(), 
            this.position = i.fromValues(0, 0), t.position && i.copy(this.position, t.position), 
            this.interpolatedPosition = i.fromValues(0, 0), this.interpolatedAngle = 0, this.previousPosition = i.fromValues(0, 0), 
            this.previousAngle = 0, this.velocity = i.fromValues(0, 0), t.velocity && i.copy(this.velocity, t.velocity), 
            this.vlambda = i.fromValues(0, 0), this.wlambda = 0, this.angle = t.angle || 0, 
            this.angularVelocity = t.angularVelocity || 0, this.force = i.create(), t.force && i.copy(this.force, t.force), 
            this.angularForce = t.angularForce || 0, this.damping = "number" == typeof t.damping ? t.damping : .1, 
            this.angularDamping = "number" == typeof t.angularDamping ? t.angularDamping : .1, 
            this.type = l.STATIC, void 0 !== t.type ? this.type = t.type : t.mass ? this.type = l.DYNAMIC : this.type = l.STATIC, 
            this.boundingRadius = 0, this.aabb = new c(), this.aabbNeedsUpdate = !0, this.allowSleep = void 0 === t.allowSleep || t.allowSleep, 
            this.wantsToSleep = !1, this.sleepState = l.AWAKE, this.sleepSpeedLimit = void 0 !== t.sleepSpeedLimit ? t.sleepSpeedLimit : .2, 
            this.sleepTimeLimit = void 0 !== t.sleepTimeLimit ? t.sleepTimeLimit : 1, this.gravityScale = void 0 !== t.gravityScale ? t.gravityScale : 1, 
            this.collisionResponse = void 0 === t.collisionResponse || t.collisionResponse, 
            this.idleTime = 0, this.timeLastSleepy = 0, this.ccdSpeedThreshold = void 0 !== t.ccdSpeedThreshold ? t.ccdSpeedThreshold : -1, 
            this.ccdIterations = void 0 !== t.ccdIterations ? t.ccdIterations : 10, this.concavePath = null, 
            this._wakeUpAfterNarrowphase = !1, this.updateMassProperties();
        }
        e.exports = l, l.prototype = new h(), l.prototype.constructor = l, l._idCounter = 0, 
        l.prototype.updateSolveMassProperties = function() {
            this.sleepState === l.SLEEPING || this.type === l.KINEMATIC ? (this.invMassSolve = 0, 
            this.invInertiaSolve = 0) : (this.invMassSolve = this.invMass, this.invInertiaSolve = this.invInertia);
        }, l.prototype.setDensity = function(t) {
            var e = this.getArea();
            this.mass = e * t, this.updateMassProperties();
        }, l.prototype.getArea = function() {
            for (var t = 0, e = 0; e < this.shapes.length; e++) t += this.shapes[e].area;
            return t;
        }, l.prototype.getAABB = function() {
            return this.aabbNeedsUpdate && this.updateAABB(), this.aabb;
        };
        var p = new c(), u = i.create();
        l.prototype.updateAABB = function() {
            for (var t = this.shapes, e = t.length, o = u, n = this.angle, s = 0; s !== e; s++) {
                var r = t[s], a = r.angle + n;
                i.rotate(o, r.position, n), i.add(o, o, this.position), r.computeAABB(p, o, a), 
                0 === s ? this.aabb.copy(p) : this.aabb.extend(p);
            }
            this.aabbNeedsUpdate = !1;
        }, l.prototype.updateBoundingRadius = function() {
            for (var t = this.shapes, e = t.length, o = 0, n = 0; n !== e; n++) {
                var s = t[n], r = i.length(s.position), a = s.boundingRadius;
                r + a > o && (o = r + a);
            }
            this.boundingRadius = o;
        }, l.prototype.addShape = function(t, e, o) {
            if (t.body) throw new Error("A shape can only be added to one body.");
            t.body = this, e ? i.copy(t.position, e) : i.set(t.position, 0, 0), t.angle = o || 0, 
            this.shapes.push(t), this.updateMassProperties(), this.updateBoundingRadius(), this.aabbNeedsUpdate = !0;
        }, l.prototype.removeShape = function(t) {
            var e = this.shapes.indexOf(t);
            return -1 !== e && (this.shapes.splice(e, 1), this.aabbNeedsUpdate = !0, t.body = null, 
            !0);
        }, l.prototype.updateMassProperties = function() {
            if (this.type === l.STATIC || this.type === l.KINEMATIC) this.mass = Number.MAX_VALUE, 
            this.invMass = 0, this.inertia = Number.MAX_VALUE, this.invInertia = 0; else {
                var t = this.shapes, e = t.length, o = this.mass / e, n = 0;
                if (this.fixedRotation) this.inertia = Number.MAX_VALUE, this.invInertia = 0; else {
                    for (var s = 0; s < e; s++) {
                        var r = t[s], a = i.squaredLength(r.position);
                        n += r.computeMomentOfInertia(o) + o * a;
                    }
                    this.inertia = n, this.invInertia = n > 0 ? 1 / n : 0;
                }
                this.invMass = 1 / this.mass, i.set(this.massMultiplier, this.fixedX ? 0 : 1, this.fixedY ? 0 : 1);
            }
        }, i.create(), l.prototype.applyForce = function(t, e) {
            if (i.add(this.force, this.force, t), e) {
                var o = i.crossLength(e, t);
                this.angularForce += o;
            }
        };
        var d = i.create(), f = i.create(), v = i.create();
        l.prototype.applyForceLocal = function(t, e) {
            e = e || v;
            var o = d, i = f;
            this.vectorToWorldFrame(o, t), this.vectorToWorldFrame(i, e), this.applyForce(o, i);
        };
        var y = i.create();
        l.prototype.applyImpulse = function(t, e) {
            if (this.type === l.DYNAMIC) {
                var o = y;
                if (i.scale(o, t, this.invMass), i.multiply(o, this.massMultiplier, o), i.add(this.velocity, o, this.velocity), 
                e) {
                    var n = i.crossLength(e, t);
                    n *= this.invInertia, this.angularVelocity += n;
                }
            }
        };
        var m = i.create(), g = i.create(), A = i.create();
        l.prototype.applyImpulseLocal = function(t, e) {
            e = e || A;
            var o = m, i = g;
            this.vectorToWorldFrame(o, t), this.vectorToWorldFrame(i, e), this.applyImpulse(o, i);
        }, l.prototype.toLocalFrame = function(t, e) {
            i.toLocalFrame(t, e, this.position, this.angle);
        }, l.prototype.toWorldFrame = function(t, e) {
            i.toGlobalFrame(t, e, this.position, this.angle);
        }, l.prototype.vectorToLocalFrame = function(t, e) {
            i.vectorToLocalFrame(t, e, this.angle);
        }, l.prototype.vectorToWorldFrame = function(t, e) {
            i.vectorToGlobalFrame(t, e, this.angle);
        }, l.prototype.fromPolygon = function(t, e) {
            e = e || {};
            for (var o = this.shapes.length; o >= 0; --o) this.removeShape(this.shapes[o]);
            var r, a = new n.Polygon();
            if (a.vertices = t, a.makeCCW(), "number" == typeof e.removeCollinearPoints && a.removeCollinearPoints(e.removeCollinearPoints), 
            void 0 === e.skipSimpleCheck && !a.isSimple()) return !1;
            this.concavePath = a.vertices.slice(0);
            for (o = 0; o < this.concavePath.length; o++) {
                var c = [ 0, 0 ];
                i.copy(c, this.concavePath[o]), this.concavePath[o] = c;
            }
            r = e.optimalDecomp ? a.decomp() : a.quickDecomp();
            var h = i.create();
            for (o = 0; o !== r.length; o++) {
                for (var l = new s({
                    vertices: r[o].vertices
                }), p = 0; p !== l.vertices.length; p++) {
                    c = l.vertices[p];
                    i.sub(c, c, l.centerOfMass);
                }
                i.scale(h, l.centerOfMass, 1), l.updateTriangles(), l.updateCenterOfMass(), l.updateBoundingRadius(), 
                this.addShape(l, h);
            }
            return this.adjustCenterOfMass(), this.aabbNeedsUpdate = !0, !0;
        }, i.fromValues(0, 0);
        var b = i.fromValues(0, 0), E = i.fromValues(0, 0), B = i.fromValues(0, 0);
        l.prototype.adjustCenterOfMass = function() {
            var t = b, e = E, o = B, n = 0;
            i.set(e, 0, 0);
            for (var s = 0; s !== this.shapes.length; s++) {
                var r = this.shapes[s];
                i.scale(t, r.position, r.area), i.add(e, e, t), n += r.area;
            }
            i.scale(o, e, 1 / n);
            for (s = 0; s !== this.shapes.length; s++) {
                r = this.shapes[s];
                i.sub(r.position, r.position, o);
            }
            i.add(this.position, this.position, o);
            for (s = 0; this.concavePath && s < this.concavePath.length; s++) i.sub(this.concavePath[s], this.concavePath[s], o);
            this.updateMassProperties(), this.updateBoundingRadius();
        }, l.prototype.setZeroForce = function() {
            i.set(this.force, 0, 0), this.angularForce = 0;
        }, l.prototype.resetConstraintVelocity = function() {
            var t = this.vlambda;
            i.set(t, 0, 0), this.wlambda = 0;
        }, l.prototype.addConstraintVelocity = function() {
            var t = this, e = t.velocity;
            i.add(e, e, t.vlambda), t.angularVelocity += t.wlambda;
        }, l.prototype.applyDamping = function(t) {
            if (this.type === l.DYNAMIC) {
                var e = this.velocity;
                i.scale(e, e, Math.pow(1 - this.damping, t)), this.angularVelocity *= Math.pow(1 - this.angularDamping, t);
            }
        }, l.prototype.wakeUp = function() {
            var t = this.sleepState;
            this.sleepState = l.AWAKE, this.idleTime = 0, t !== l.AWAKE && this.emit(l.wakeUpEvent);
        }, l.prototype.sleep = function() {
            this.sleepState = l.SLEEPING, this.angularVelocity = 0, this.angularForce = 0, i.set(this.velocity, 0, 0), 
            i.set(this.force, 0, 0), this.emit(l.sleepEvent);
        }, l.prototype.sleepTick = function(t, e, o) {
            this.allowSleep && this.type !== l.SLEEPING && (this.wantsToSleep = !1, this.sleepState, 
            i.squaredLength(this.velocity) + Math.pow(this.angularVelocity, 2) >= Math.pow(this.sleepSpeedLimit, 2) ? (this.idleTime = 0, 
            this.sleepState = l.AWAKE) : (this.idleTime += o, this.sleepState = l.SLEEPY), this.idleTime > this.sleepTimeLimit && (e ? this.wantsToSleep = !0 : this.sleep()));
        }, l.prototype.overlaps = function(t) {
            return this.world.overlapKeeper.bodiesAreOverlapping(this, t);
        };
        var q = i.create(), P = i.create();
        l.prototype.integrate = function(t) {
            var e = this.invMass, o = this.force, n = this.position, s = this.velocity;
            i.copy(this.previousPosition, this.position), this.previousAngle = this.angle, this.fixedRotation || (this.angularVelocity += this.angularForce * this.invInertia * t), 
            i.scale(q, o, t * e), i.multiply(q, this.massMultiplier, q), i.add(s, q, s), this.integrateToTimeOfImpact(t) || (i.scale(P, s, t), 
            i.add(n, n, P), this.fixedRotation || (this.angle += this.angularVelocity * t)), 
            this.aabbNeedsUpdate = !0;
        };
        var w = new r(), S = new a({
            mode: a.ALL
        }), C = i.create(), L = i.create(), x = i.create(), F = i.create();
        l.prototype.integrateToTimeOfImpact = function(t) {
            if (this.ccdSpeedThreshold < 0 || i.squaredLength(this.velocity) < Math.pow(this.ccdSpeedThreshold, 2)) return !1;
            i.normalize(C, this.velocity), i.scale(L, this.velocity, t), i.add(L, L, this.position), 
            i.sub(x, L, this.position);
            var e, o = this.angularVelocity * t, n = i.length(x), s = 1, r = this;
            if (w.reset(), S.callback = function(t) {
                t.body !== r && (e = t.body, t.getHitPoint(L, S), i.sub(x, L, r.position), s = i.length(x) / n, 
                t.stop());
            }, i.copy(S.from, this.position), i.copy(S.to, L), S.update(), this.world.raycast(w, S), 
            !e) return !1;
            var a = this.angle;
            i.copy(F, this.position);
            for (var c = 0, h = 0, l = 0, p = s; p >= h && c < this.ccdIterations; ) {
                c++, l = (p - h) / 2, i.scale(P, x, s), i.add(this.position, F, P), this.angle = a + o * s, 
                this.updateAABB(), this.aabb.overlaps(e.aabb) && this.world.narrowphase.bodiesOverlap(this, e) ? h = l : p = l;
            }
            return s = l, i.copy(this.position, F), this.angle = a, i.scale(P, x, s), i.add(this.position, this.position, P), 
            this.fixedRotation || (this.angle += o * s), !0;
        }, l.prototype.getVelocityAtPoint = function(t, e) {
            return i.crossVZ(t, e, this.angularVelocity), i.subtract(t, this.velocity, t), t;
        }, l.sleepyEvent = {
            type: "sleepy"
        }, l.sleepEvent = {
            type: "sleep"
        }, l.wakeUpEvent = {
            type: "wakeup"
        }, l.DYNAMIC = 1, l.STATIC = 2, l.KINEMATIC = 4, l.AWAKE = 0, l.SLEEPY = 1, l.SLEEPING = 2;
    }, {
        "../collision/AABB": 7,
        "../collision/Ray": 11,
        "../collision/RaycastResult": 12,
        "../events/EventEmitter": 26,
        "../math/vec2": 30,
        "../shapes/Convex": 40,
        "poly-decomp": 5
    } ],
    32: [ function(t, e, o) {
        var i = t("../math/vec2"), n = t("./Spring");
        function s(t, e, o) {
            o = o || {}, n.call(this, t, e, o), this.localAnchorA = i.fromValues(0, 0), this.localAnchorB = i.fromValues(0, 0), 
            o.localAnchorA && i.copy(this.localAnchorA, o.localAnchorA), o.localAnchorB && i.copy(this.localAnchorB, o.localAnchorB), 
            o.worldAnchorA && this.setWorldAnchorA(o.worldAnchorA), o.worldAnchorB && this.setWorldAnchorB(o.worldAnchorB);
            var s = i.create(), r = i.create();
            this.getWorldAnchorA(s), this.getWorldAnchorB(r);
            var a = i.distance(s, r);
            this.restLength = "number" == typeof o.restLength ? o.restLength : a;
        }
        t("../utils/Utils"), e.exports = s, s.prototype = new n(), s.prototype.constructor = s, 
        s.prototype.setWorldAnchorA = function(t) {
            this.bodyA.toLocalFrame(this.localAnchorA, t);
        }, s.prototype.setWorldAnchorB = function(t) {
            this.bodyB.toLocalFrame(this.localAnchorB, t);
        }, s.prototype.getWorldAnchorA = function(t) {
            this.bodyA.toWorldFrame(t, this.localAnchorA);
        }, s.prototype.getWorldAnchorB = function(t) {
            this.bodyB.toWorldFrame(t, this.localAnchorB);
        };
        var r = i.create(), a = i.create(), c = i.create(), h = i.create(), l = i.create(), p = i.create(), u = i.create(), d = i.create(), f = i.create();
        s.prototype.applyForce = function() {
            var t = this.stiffness, e = this.damping, o = this.restLength, n = this.bodyA, s = this.bodyB, v = r, y = a, m = c, g = h, A = f, b = l, E = p, B = u, q = d;
            this.getWorldAnchorA(b), this.getWorldAnchorB(E), i.sub(B, b, n.position), i.sub(q, E, s.position), 
            i.sub(v, E, b);
            var P = i.len(v);
            i.normalize(y, v), i.sub(m, s.velocity, n.velocity), i.crossZV(A, s.angularVelocity, q), 
            i.add(m, m, A), i.crossZV(A, n.angularVelocity, B), i.sub(m, m, A), i.scale(g, y, -t * (P - o) - e * i.dot(m, y)), 
            i.sub(n.force, n.force, g), i.add(s.force, s.force, g);
            var w = i.crossLength(B, g), S = i.crossLength(q, g);
            n.angularForce -= w, s.angularForce += S;
        };
    }, {
        "../math/vec2": 30,
        "../utils/Utils": 57,
        "./Spring": 34
    } ],
    33: [ function(t, e, o) {
        t("../math/vec2");
        var i = t("./Spring");
        function n(t, e, o) {
            o = o || {}, i.call(this, t, e, o), this.restAngle = "number" == typeof o.restAngle ? o.restAngle : e.angle - t.angle;
        }
        e.exports = n, n.prototype = new i(), n.prototype.constructor = n, n.prototype.applyForce = function() {
            var t = this.stiffness, e = this.damping, o = this.restAngle, i = this.bodyA, n = this.bodyB, s = -t * (n.angle - i.angle - o) - e * (n.angularVelocity - i.angularVelocity) * 0;
            i.angularForce -= s, n.angularForce += s;
        };
    }, {
        "../math/vec2": 30,
        "./Spring": 34
    } ],
    34: [ function(t, e, o) {
        t("../math/vec2");
        var i = t("../utils/Utils");
        function n(t, e, o) {
            o = i.defaults(o, {
                stiffness: 100,
                damping: 1
            }), this.stiffness = o.stiffness, this.damping = o.damping, this.bodyA = t, this.bodyB = e;
        }
        e.exports = n, n.prototype.applyForce = function() {};
    }, {
        "../math/vec2": 30,
        "../utils/Utils": 57
    } ],
    35: [ function(t, e, o) {
        var i = t("../math/vec2"), n = (t("../utils/Utils"), t("../constraints/Constraint")), s = t("../equations/FrictionEquation"), r = t("../objects/Body");
        function a(t, e) {
            e = e || {}, this.chassisBody = t, this.wheels = [], this.groundBody = new r({
                mass: 0
            }), this.world = null;
            var o = this;
            this.preStepCallback = function() {
                o.update();
            };
        }
        function c(t, e) {
            e = e || {}, this.vehicle = t, this.forwardEquation = new s(t.chassisBody, t.groundBody), 
            this.sideEquation = new s(t.chassisBody, t.groundBody), this.steerValue = 0, this.engineForce = 0, 
            this.setSideFriction(void 0 !== e.sideFriction ? e.sideFriction : 5), this.localForwardVector = i.fromValues(0, 1), 
            e.localForwardVector && i.copy(this.localForwardVector, e.localForwardVector), this.localPosition = i.fromValues(0, 0), 
            e.localPosition && i.copy(this.localPosition, e.localPosition), n.apply(this, t.chassisBody, t.groundBody), 
            this.equations.push(this.forwardEquation, this.sideEquation), this.setBrakeForce(0);
        }
        e.exports = a, a.prototype.addToWorld = function(t) {
            this.world = t, t.addBody(this.groundBody), t.on("preStep", this.preStepCallback);
            for (var e = 0; e < this.wheels.length; e++) {
                var o = this.wheels[e];
                t.addConstraint(o);
            }
        }, a.prototype.removeFromWorld = function() {
            var t = this.world;
            t.removeBody(this.groundBody), t.off("preStep", this.preStepCallback);
            for (var e = 0; e < this.wheels.length; e++) {
                var o = this.wheels[e];
                t.removeConstraint(o);
            }
            this.world = null;
        }, a.prototype.addWheel = function(t) {
            var e = new c(this, t);
            return this.wheels.push(e), e;
        }, a.prototype.update = function() {
            for (var t = 0; t < this.wheels.length; t++) this.wheels[t].update();
        }, c.prototype = new n(), c.prototype.setBrakeForce = function(t) {
            this.forwardEquation.setSlipForce(t);
        }, c.prototype.setSideFriction = function(t) {
            this.sideEquation.setSlipForce(t);
        };
        var h = i.create(), l = i.create();
        c.prototype.getSpeed = function() {
            return this.vehicle.chassisBody.vectorToWorldFrame(l, this.localForwardVector), 
            this.vehicle.chassisBody.getVelocityAtPoint(h, l), i.dot(h, l);
        };
        var p = i.create();
        c.prototype.update = function() {
            this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.t, this.localForwardVector), 
            i.rotate(this.sideEquation.t, this.localForwardVector, Math.PI / 2), this.vehicle.chassisBody.vectorToWorldFrame(this.sideEquation.t, this.sideEquation.t), 
            i.rotate(this.forwardEquation.t, this.forwardEquation.t, this.steerValue), i.rotate(this.sideEquation.t, this.sideEquation.t, this.steerValue), 
            this.vehicle.chassisBody.toWorldFrame(this.forwardEquation.contactPointB, this.localPosition), 
            i.copy(this.sideEquation.contactPointB, this.forwardEquation.contactPointB), this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.contactPointA, this.localPosition), 
            i.copy(this.sideEquation.contactPointA, this.forwardEquation.contactPointA), i.normalize(p, this.forwardEquation.t), 
            i.scale(p, p, this.engineForce), this.vehicle.chassisBody.applyForce(p, this.forwardEquation.contactPointA);
        };
    }, {
        "../constraints/Constraint": 14,
        "../equations/FrictionEquation": 23,
        "../math/vec2": 30,
        "../objects/Body": 31,
        "../utils/Utils": 57
    } ],
    36: [ function(t, e, o) {
        var i = e.exports = {
            AABB: t("./collision/AABB"),
            AngleLockEquation: t("./equations/AngleLockEquation"),
            Body: t("./objects/Body"),
            Broadphase: t("./collision/Broadphase"),
            Capsule: t("./shapes/Capsule"),
            Circle: t("./shapes/Circle"),
            Constraint: t("./constraints/Constraint"),
            ContactEquation: t("./equations/ContactEquation"),
            ContactEquationPool: t("./utils/ContactEquationPool"),
            ContactMaterial: t("./material/ContactMaterial"),
            Convex: t("./shapes/Convex"),
            DistanceConstraint: t("./constraints/DistanceConstraint"),
            Equation: t("./equations/Equation"),
            EventEmitter: t("./events/EventEmitter"),
            FrictionEquation: t("./equations/FrictionEquation"),
            FrictionEquationPool: t("./utils/FrictionEquationPool"),
            GearConstraint: t("./constraints/GearConstraint"),
            GSSolver: t("./solver/GSSolver"),
            Heightfield: t("./shapes/Heightfield"),
            Line: t("./shapes/Line"),
            LockConstraint: t("./constraints/LockConstraint"),
            Material: t("./material/Material"),
            Narrowphase: t("./collision/Narrowphase"),
            NaiveBroadphase: t("./collision/NaiveBroadphase"),
            Particle: t("./shapes/Particle"),
            Plane: t("./shapes/Plane"),
            Pool: t("./utils/Pool"),
            RevoluteConstraint: t("./constraints/RevoluteConstraint"),
            PrismaticConstraint: t("./constraints/PrismaticConstraint"),
            Ray: t("./collision/Ray"),
            RaycastResult: t("./collision/RaycastResult"),
            Box: t("./shapes/Box"),
            RotationalVelocityEquation: t("./equations/RotationalVelocityEquation"),
            SAPBroadphase: t("./collision/SAPBroadphase"),
            Shape: t("./shapes/Shape"),
            Solver: t("./solver/Solver"),
            Spring: t("./objects/Spring"),
            TopDownVehicle: t("./objects/TopDownVehicle"),
            LinearSpring: t("./objects/LinearSpring"),
            RotationalSpring: t("./objects/RotationalSpring"),
            Utils: t("./utils/Utils"),
            World: t("./world/World"),
            vec2: t("./math/vec2"),
            version: t("../package.json").version
        };
        Object.defineProperty(i, "Rectangle", {
            get: function() {
                return console.warn("The Rectangle class has been renamed to Box."), this.Box;
            }
        });
    }, {
        "../package.json": 6,
        "./collision/AABB": 7,
        "./collision/Broadphase": 8,
        "./collision/NaiveBroadphase": 9,
        "./collision/Narrowphase": 10,
        "./collision/Ray": 11,
        "./collision/RaycastResult": 12,
        "./collision/SAPBroadphase": 13,
        "./constraints/Constraint": 14,
        "./constraints/DistanceConstraint": 15,
        "./constraints/GearConstraint": 16,
        "./constraints/LockConstraint": 17,
        "./constraints/PrismaticConstraint": 18,
        "./constraints/RevoluteConstraint": 19,
        "./equations/AngleLockEquation": 20,
        "./equations/ContactEquation": 21,
        "./equations/Equation": 22,
        "./equations/FrictionEquation": 23,
        "./equations/RotationalVelocityEquation": 25,
        "./events/EventEmitter": 26,
        "./material/ContactMaterial": 27,
        "./material/Material": 28,
        "./math/vec2": 30,
        "./objects/Body": 31,
        "./objects/LinearSpring": 32,
        "./objects/RotationalSpring": 33,
        "./objects/Spring": 34,
        "./objects/TopDownVehicle": 35,
        "./shapes/Box": 37,
        "./shapes/Capsule": 38,
        "./shapes/Circle": 39,
        "./shapes/Convex": 40,
        "./shapes/Heightfield": 41,
        "./shapes/Line": 42,
        "./shapes/Particle": 43,
        "./shapes/Plane": 44,
        "./shapes/Shape": 45,
        "./solver/GSSolver": 46,
        "./solver/Solver": 47,
        "./utils/ContactEquationPool": 48,
        "./utils/FrictionEquationPool": 49,
        "./utils/Pool": 55,
        "./utils/Utils": 57,
        "./world/World": 61
    } ],
    37: [ function(t, e, o) {
        var i = t("../math/vec2"), n = t("./Shape"), s = t("./Convex");
        function r(t) {
            "number" == typeof arguments[0] && "number" == typeof arguments[1] && (t = {
                width: arguments[0],
                height: arguments[1]
            }, console.warn("The Rectangle has been renamed to Box and its constructor signature has changed. Please use the following format: new Box({ width: 1, height: 1, ... })")), 
            t = t || {};
            var e = this.width = t.width || 1, o = this.height = t.height || 1, r = [ i.fromValues(-e / 2, -o / 2), i.fromValues(e / 2, -o / 2), i.fromValues(e / 2, o / 2), i.fromValues(-e / 2, o / 2) ], a = [ i.fromValues(1, 0), i.fromValues(0, 1) ];
            t.vertices = r, t.axes = a, t.type = n.BOX, s.call(this, t);
        }
        e.exports = r, r.prototype = new s(), r.prototype.constructor = r, r.prototype.computeMomentOfInertia = function(t) {
            var e = this.width, o = this.height;
            return t * (o * o + e * e) / 12;
        }, r.prototype.updateBoundingRadius = function() {
            var t = this.width, e = this.height;
            this.boundingRadius = Math.sqrt(t * t + e * e) / 2;
        }, i.create(), i.create(), i.create(), i.create(), r.prototype.computeAABB = function(t, e, o) {
            t.setFromPoints(this.vertices, e, o, 0);
        }, r.prototype.updateArea = function() {
            this.area = this.width * this.height;
        };
    }, {
        "../math/vec2": 30,
        "./Convex": 40,
        "./Shape": 45
    } ],
    38: [ function(t, e, o) {
        var i = t("./Shape"), n = t("../math/vec2");
        function s(t) {
            "number" == typeof arguments[0] && "number" == typeof arguments[1] && (t = {
                length: arguments[0],
                radius: arguments[1]
            }, console.warn("The Capsule constructor signature has changed. Please use the following format: new Capsule({ radius: 1, length: 1 })")), 
            t = t || {}, this.length = t.length || 1, this.radius = t.radius || 1, t.type = i.CAPSULE, 
            i.call(this, t);
        }
        e.exports = s, s.prototype = new i(), s.prototype.constructor = s, s.prototype.computeMomentOfInertia = function(t) {
            var e = this.radius, o = this.length + e, i = 2 * e;
            return t * (i * i + o * o) / 12;
        }, s.prototype.updateBoundingRadius = function() {
            this.boundingRadius = this.radius + this.length / 2;
        }, s.prototype.updateArea = function() {
            this.area = Math.PI * this.radius * this.radius + 2 * this.radius * this.length;
        };
        var r = n.create();
        s.prototype.computeAABB = function(t, e, o) {
            var i = this.radius;
            n.set(r, this.length / 2, 0), 0 !== o && n.rotate(r, r, o), n.set(t.upperBound, Math.max(r[0] + i, -r[0] + i), Math.max(r[1] + i, -r[1] + i)), 
            n.set(t.lowerBound, Math.min(r[0] - i, -r[0] - i), Math.min(r[1] - i, -r[1] - i)), 
            n.add(t.lowerBound, t.lowerBound, e), n.add(t.upperBound, t.upperBound, e);
        };
        var a = n.create(), c = n.create(), h = n.create(), l = n.create(), p = n.fromValues(0, 1);
        s.prototype.raycast = function(t, e, o, i) {
            for (var s = e.from, r = e.to, u = (e.direction, a), d = c, f = h, v = l, y = this.length / 2, m = 0; m < 2; m++) {
                var g = this.radius * (2 * m - 1);
                if (n.set(f, -y, g), n.set(v, y, g), n.toGlobalFrame(f, f, o, i), n.toGlobalFrame(v, v, o, i), 
                (b = n.getLineSegmentsIntersectionFraction(s, r, f, v)) >= 0 && (n.rotate(d, p, i), 
                n.scale(d, d, 2 * m - 1), e.reportIntersection(t, b, d, -1), t.shouldStop(e))) return;
            }
            var A = Math.pow(this.radius, 2) + Math.pow(y, 2);
            for (m = 0; m < 2; m++) {
                n.set(f, y * (2 * m - 1), 0), n.toGlobalFrame(f, f, o, i);
                var b, E = Math.pow(r[0] - s[0], 2) + Math.pow(r[1] - s[1], 2), B = 2 * ((r[0] - s[0]) * (s[0] - f[0]) + (r[1] - s[1]) * (s[1] - f[1])), q = Math.pow(s[0] - f[0], 2) + Math.pow(s[1] - f[1], 2) - Math.pow(this.radius, 2);
                if (!((b = Math.pow(B, 2) - 4 * E * q) < 0)) if (0 === b) {
                    if (n.lerp(u, s, r, b), n.squaredDistance(u, o) > A && (n.sub(d, u, f), n.normalize(d, d), 
                    e.reportIntersection(t, b, d, -1), t.shouldStop(e))) return;
                } else {
                    var P = Math.sqrt(b), w = 1 / (2 * E), S = (-B - P) * w, C = (-B + P) * w;
                    if (S >= 0 && S <= 1 && (n.lerp(u, s, r, S), n.squaredDistance(u, o) > A && (n.sub(d, u, f), 
                    n.normalize(d, d), e.reportIntersection(t, S, d, -1), t.shouldStop(e)))) return;
                    if (C >= 0 && C <= 1 && (n.lerp(u, s, r, C), n.squaredDistance(u, o) > A && (n.sub(d, u, f), 
                    n.normalize(d, d), e.reportIntersection(t, C, d, -1), t.shouldStop(e)))) return;
                }
            }
        };
    }, {
        "../math/vec2": 30,
        "./Shape": 45
    } ],
    39: [ function(t, e, o) {
        var i = t("./Shape"), n = t("../math/vec2");
        function s(t) {
            "number" == typeof arguments[0] && (t = {
                radius: arguments[0]
            }, console.warn("The Circle constructor signature has changed. Please use the following format: new Circle({ radius: 1 })")), 
            t = t || {}, this.radius = t.radius || 1, t.type = i.CIRCLE, i.call(this, t);
        }
        e.exports = s, s.prototype = new i(), s.prototype.constructor = s, s.prototype.computeMomentOfInertia = function(t) {
            var e = this.radius;
            return t * e * e / 2;
        }, s.prototype.updateBoundingRadius = function() {
            this.boundingRadius = this.radius;
        }, s.prototype.updateArea = function() {
            this.area = Math.PI * this.radius * this.radius;
        }, s.prototype.computeAABB = function(t, e, o) {
            var i = this.radius;
            n.set(t.upperBound, i, i), n.set(t.lowerBound, -i, -i), e && (n.add(t.lowerBound, t.lowerBound, e), 
            n.add(t.upperBound, t.upperBound, e));
        };
        var r = n.create(), a = n.create();
        s.prototype.raycast = function(t, e, o, i) {
            var s = e.from, c = e.to, h = this.radius, l = Math.pow(c[0] - s[0], 2) + Math.pow(c[1] - s[1], 2), p = 2 * ((c[0] - s[0]) * (s[0] - o[0]) + (c[1] - s[1]) * (s[1] - o[1])), u = Math.pow(s[0] - o[0], 2) + Math.pow(s[1] - o[1], 2) - Math.pow(h, 2), d = Math.pow(p, 2) - 4 * l * u, f = r, v = a;
            if (!(d < 0)) if (0 === d) n.lerp(f, s, c, d), n.sub(v, f, o), n.normalize(v, v), 
            e.reportIntersection(t, d, v, -1); else {
                var y = Math.sqrt(d), m = 1 / (2 * l), g = (-p - y) * m, A = (-p + y) * m;
                if (g >= 0 && g <= 1 && (n.lerp(f, s, c, g), n.sub(v, f, o), n.normalize(v, v), 
                e.reportIntersection(t, g, v, -1), t.shouldStop(e))) return;
                A >= 0 && A <= 1 && (n.lerp(f, s, c, A), n.sub(v, f, o), n.normalize(v, v), e.reportIntersection(t, A, v, -1));
            }
        };
    }, {
        "../math/vec2": 30,
        "./Shape": 45
    } ],
    40: [ function(t, e, o) {
        var i = t("./Shape"), n = t("../math/vec2"), s = t("../math/polyk");
        function r(t) {
            Array.isArray(arguments[0]) && (t = {
                vertices: arguments[0],
                axes: arguments[1]
            }, console.warn("The Convex constructor signature has changed. Please use the following format: new Convex({ vertices: [...], ... })")), 
            t = t || {}, this.vertices = [];
            for (var e = void 0 !== t.vertices ? t.vertices : [], o = 0; o < e.length; o++) {
                var s = n.create();
                n.copy(s, e[o]), this.vertices.push(s);
            }
            if (this.axes = [], t.axes) for (o = 0; o < t.axes.length; o++) {
                var r = n.create();
                n.copy(r, t.axes[o]), this.axes.push(r);
            } else for (o = 0; o < this.vertices.length; o++) {
                var a = this.vertices[o], c = this.vertices[(o + 1) % this.vertices.length], h = n.create();
                n.sub(h, c, a), n.rotate90cw(h, h), n.normalize(h, h), this.axes.push(h);
            }
            if (this.centerOfMass = n.fromValues(0, 0), this.triangles = [], this.vertices.length && (this.updateTriangles(), 
            this.updateCenterOfMass()), this.boundingRadius = 0, t.type = i.CONVEX, i.call(this, t), 
            this.updateBoundingRadius(), this.updateArea(), this.area < 0) throw new Error("Convex vertices must be given in conter-clockwise winding.");
        }
        t("poly-decomp"), e.exports = r, r.prototype = new i(), r.prototype.constructor = r;
        var a = n.create(), c = n.create();
        r.prototype.projectOntoLocalAxis = function(t, e) {
            for (var o, i, s = null, r = null, c = (t = a, 0); c < this.vertices.length; c++) o = this.vertices[c], 
            i = n.dot(o, t), (null === s || i > s) && (s = i), (null === r || i < r) && (r = i);
            if (r > s) {
                var h = r;
                r = s, s = h;
            }
            n.set(e, r, s);
        }, r.prototype.projectOntoWorldAxis = function(t, e, o, i) {
            var s = c;
            this.projectOntoLocalAxis(t, i), 0 !== o ? n.rotate(s, t, o) : s = t;
            var r = n.dot(e, s);
            n.set(i, i[0] + r, i[1] + r);
        }, r.prototype.updateTriangles = function() {
            this.triangles.length = 0;
            for (var t = [], e = 0; e < this.vertices.length; e++) {
                var o = this.vertices[e];
                t.push(o[0], o[1]);
            }
            var i = s.Triangulate(t);
            for (e = 0; e < i.length; e += 3) {
                var n = i[e], r = i[e + 1], a = i[e + 2];
                this.triangles.push([ n, r, a ]);
            }
        };
        var h = n.create(), l = n.create(), p = n.create(), u = n.create(), d = n.create();
        n.create(), n.create(), n.create(), n.create(), r.prototype.updateCenterOfMass = function() {
            var t = this.triangles, e = this.vertices, o = this.centerOfMass, i = h, s = p, a = u, c = d, f = l;
            n.set(o, 0, 0);
            for (var v = 0, y = 0; y !== t.length; y++) {
                var m = t[y];
                s = e[m[0]], a = e[m[1]], c = e[m[2]];
                n.centroid(i, s, a, c);
                var g = r.triangleArea(s, a, c);
                v += g, n.scale(f, i, g), n.add(o, o, f);
            }
            n.scale(o, o, 1 / v);
        }, r.prototype.computeMomentOfInertia = function(t) {
            for (var e = 0, o = 0, i = this.vertices.length, s = i - 1, r = 0; r < i; s = r, 
            r++) {
                var a = this.vertices[s], c = this.vertices[r], h = Math.abs(n.crossLength(a, c));
                e += h * (n.dot(c, c) + n.dot(c, a) + n.dot(a, a)), o += h;
            }
            return t / 6 * (e / o);
        }, r.prototype.updateBoundingRadius = function() {
            for (var t = this.vertices, e = 0, o = 0; o !== t.length; o++) {
                var i = n.squaredLength(t[o]);
                i > e && (e = i);
            }
            this.boundingRadius = Math.sqrt(e);
        }, r.triangleArea = function(t, e, o) {
            return .5 * ((e[0] - t[0]) * (o[1] - t[1]) - (o[0] - t[0]) * (e[1] - t[1]));
        }, r.prototype.updateArea = function() {
            this.updateTriangles(), this.area = 0;
            for (var t = this.triangles, e = this.vertices, o = 0; o !== t.length; o++) {
                var i = t[o], n = e[i[0]], s = e[i[1]], a = e[i[2]], c = r.triangleArea(n, s, a);
                this.area += c;
            }
        }, r.prototype.computeAABB = function(t, e, o) {
            t.setFromPoints(this.vertices, e, o, 0);
        };
        var f = n.create(), v = n.create(), y = n.create();
        r.prototype.raycast = function(t, e, o, i) {
            var s = f, r = v, a = y, c = this.vertices;
            n.toLocalFrame(s, e.from, o, i), n.toLocalFrame(r, e.to, o, i);
            for (var h = c.length, l = 0; l < h && !t.shouldStop(e); l++) {
                var p = c[l], u = c[(l + 1) % h], d = n.getLineSegmentsIntersectionFraction(s, r, p, u);
                d >= 0 && (n.sub(a, u, p), n.rotate(a, a, -Math.PI / 2 + i), n.normalize(a, a), 
                e.reportIntersection(t, d, a, l));
            }
        };
    }, {
        "../math/polyk": 29,
        "../math/vec2": 30,
        "./Shape": 45,
        "poly-decomp": 5
    } ],
    41: [ function(e, o, i) {
        var n = e("./Shape"), s = e("../math/vec2");
        function r(e) {
            if (Array.isArray(arguments[0])) {
                if (e = {
                    heights: arguments[0]
                }, "object" == t(arguments[1])) for (var o in arguments[1]) e[o] = arguments[1][o];
                console.warn("The Heightfield constructor signature has changed. Please use the following format: new Heightfield({ heights: [...], ... })");
            }
            e = e || {}, this.heights = e.heights ? e.heights.slice(0) : [], this.maxValue = e.maxValue || null, 
            this.minValue = e.minValue || null, this.elementWidth = e.elementWidth || .1, void 0 !== e.maxValue && void 0 !== e.minValue || this.updateMaxMinValues(), 
            e.type = n.HEIGHTFIELD, n.call(this, e);
        }
        e("../utils/Utils"), o.exports = r, r.prototype = new n(), r.prototype.constructor = r, 
        r.prototype.updateMaxMinValues = function() {
            for (var t = this.heights, e = t[0], o = t[0], i = 0; i !== t.length; i++) {
                var n = t[i];
                n > e && (e = n), n < o && (o = n);
            }
            this.maxValue = e, this.minValue = o;
        }, r.prototype.computeMomentOfInertia = function(t) {
            return Number.MAX_VALUE;
        }, r.prototype.updateBoundingRadius = function() {
            this.boundingRadius = Number.MAX_VALUE;
        }, r.prototype.updateArea = function() {
            for (var t = this.heights, e = 0, o = 0; o < t.length - 1; o++) e += (t[o] + t[o + 1]) / 2 * this.elementWidth;
            this.area = e;
        };
        var a = [ s.create(), s.create(), s.create(), s.create() ];
        r.prototype.computeAABB = function(t, e, o) {
            s.set(a[0], 0, this.maxValue), s.set(a[1], this.elementWidth * this.heights.length, this.maxValue), 
            s.set(a[2], this.elementWidth * this.heights.length, this.minValue), s.set(a[3], 0, this.minValue), 
            t.setFromPoints(a, e, o);
        }, r.prototype.getLineSegment = function(t, e, o) {
            var i = this.heights, n = this.elementWidth;
            s.set(t, o * n, i[o]), s.set(e, (o + 1) * n, i[o + 1]);
        }, r.prototype.getSegmentIndex = function(t) {
            return Math.floor(t[0] / this.elementWidth);
        }, r.prototype.getClampedSegmentIndex = function(t) {
            var e = this.getSegmentIndex(t);
            return Math.min(this.heights.length, Math.max(e, 0));
        }, s.create();
        var c = s.create(), h = s.create(), l = s.create(), p = s.create(), u = s.create();
        s.fromValues(0, 1), r.prototype.raycast = function(t, e, o, i) {
            var n = e.from, r = e.to, a = (e.direction, c), d = h, f = l, v = p, y = u;
            s.toLocalFrame(v, n, o, i), s.toLocalFrame(y, r, o, i);
            var m = this.getClampedSegmentIndex(v), g = this.getClampedSegmentIndex(y);
            if (m > g) {
                var A = m;
                m = g, g = A;
            }
            for (var b = 0; b < this.heights.length - 1; b++) {
                this.getLineSegment(d, f, b);
                var E = s.getLineSegmentsIntersectionFraction(v, y, d, f);
                if (E >= 0 && (s.sub(a, f, d), s.rotate(a, a, i + Math.PI / 2), s.normalize(a, a), 
                e.reportIntersection(t, E, a, -1), t.shouldStop(e))) return;
            }
        };
    }, {
        "../math/vec2": 30,
        "../utils/Utils": 57,
        "./Shape": 45
    } ],
    42: [ function(t, e, o) {
        var i = t("./Shape"), n = t("../math/vec2");
        function s(t) {
            "number" == typeof arguments[0] && (t = {
                length: arguments[0]
            }, console.warn("The Line constructor signature has changed. Please use the following format: new Line({ length: 1, ... })")), 
            t = t || {}, this.length = t.length || 1, t.type = i.LINE, i.call(this, t);
        }
        e.exports = s, s.prototype = new i(), s.prototype.constructor = s, s.prototype.computeMomentOfInertia = function(t) {
            return t * Math.pow(this.length, 2) / 12;
        }, s.prototype.updateBoundingRadius = function() {
            this.boundingRadius = this.length / 2;
        };
        var r = [ n.create(), n.create() ];
        s.prototype.computeAABB = function(t, e, o) {
            var i = this.length / 2;
            n.set(r[0], -i, 0), n.set(r[1], i, 0), t.setFromPoints(r, e, o, 0);
        }, n.create();
        var a = n.create(), c = n.create(), h = n.create(), l = n.fromValues(0, 1);
        s.prototype.raycast = function(t, e, o, i) {
            var s = e.from, r = e.to, p = c, u = h, d = this.length / 2;
            n.set(p, -d, 0), n.set(u, d, 0), n.toGlobalFrame(p, p, o, i), n.toGlobalFrame(u, u, o, i);
            var f = n.getLineSegmentsIntersectionFraction(p, u, s, r);
            if (f >= 0) {
                var v = a;
                n.rotate(v, l, i), e.reportIntersection(t, f, v, -1);
            }
        };
    }, {
        "../math/vec2": 30,
        "./Shape": 45
    } ],
    43: [ function(t, e, o) {
        var i = t("./Shape"), n = t("../math/vec2");
        function s(t) {
            (t = t || {}).type = i.PARTICLE, i.call(this, t);
        }
        e.exports = s, s.prototype = new i(), s.prototype.constructor = s, s.prototype.computeMomentOfInertia = function(t) {
            return 0;
        }, s.prototype.updateBoundingRadius = function() {
            this.boundingRadius = 0;
        }, s.prototype.computeAABB = function(t, e, o) {
            n.copy(t.lowerBound, e), n.copy(t.upperBound, e);
        };
    }, {
        "../math/vec2": 30,
        "./Shape": 45
    } ],
    44: [ function(t, e, o) {
        var i = t("./Shape"), n = t("../math/vec2");
        function s(t) {
            (t = t || {}).type = i.PLANE, i.call(this, t);
        }
        t("../utils/Utils"), e.exports = s, s.prototype = new i(), s.prototype.constructor = s, 
        s.prototype.computeMomentOfInertia = function(t) {
            return 0;
        }, s.prototype.updateBoundingRadius = function() {
            this.boundingRadius = Number.MAX_VALUE;
        }, s.prototype.computeAABB = function(t, e, o) {
            var i = o % (2 * Math.PI), s = n.set, r = t.lowerBound, a = t.upperBound;
            s(r, -1e7, -1e7), s(a, 1e7, 1e7), 0 === i ? a[1] = 0 : i === Math.PI / 2 ? r[0] = 0 : i === Math.PI ? r[1] = 0 : i === 3 * Math.PI / 2 && (a[0] = 0);
        }, s.prototype.updateArea = function() {
            this.area = Number.MAX_VALUE;
        };
        var r = n.create(), a = (n.create(), n.create(), n.create()), c = n.create();
        s.prototype.raycast = function(t, e, o, i) {
            var s = e.from, h = e.to, l = e.direction, p = r, u = a, d = c;
            n.set(u, 0, 1), n.rotate(u, u, i), n.sub(d, s, o);
            var f = n.dot(d, u);
            if (n.sub(d, h, o), !(f * n.dot(d, u) > 0 || n.squaredDistance(s, h) < f * f)) {
                var v = n.dot(u, l);
                n.sub(p, s, o);
                var y = -n.dot(u, p) / v / e.length;
                e.reportIntersection(t, y, u, -1);
            }
        };
    }, {
        "../math/vec2": 30,
        "../utils/Utils": 57,
        "./Shape": 45
    } ],
    45: [ function(t, e, o) {
        e.exports = n;
        var i = t("../math/vec2");
        function n(t) {
            t = t || {}, this.body = null, this.position = i.fromValues(0, 0), t.position && i.copy(this.position, t.position), 
            this.angle = t.angle || 0, this.type = t.type || 0, this.id = n.idCounter++, this.boundingRadius = 0, 
            this.collisionGroup = void 0 !== t.collisionGroup ? t.collisionGroup : 1, this.collisionResponse = void 0 === t.collisionResponse || t.collisionResponse, 
            this.collisionMask = void 0 !== t.collisionMask ? t.collisionMask : 1, this.material = t.material || null, 
            this.area = 0, this.sensor = void 0 !== t.sensor && t.sensor, this.type && this.updateBoundingRadius(), 
            this.updateArea();
        }
        n.idCounter = 0, n.CIRCLE = 1, n.PARTICLE = 2, n.PLANE = 4, n.CONVEX = 8, n.LINE = 16, 
        n.BOX = 32, Object.defineProperty(n, "RECTANGLE", {
            get: function() {
                return console.warn("Shape.RECTANGLE is deprecated, use Shape.BOX instead."), n.BOX;
            }
        }), n.CAPSULE = 64, n.HEIGHTFIELD = 128, n.prototype.computeMomentOfInertia = function(t) {}, 
        n.prototype.updateBoundingRadius = function() {}, n.prototype.updateArea = function() {}, 
        n.prototype.computeAABB = function(t, e, o) {}, n.prototype.raycast = function(t, e, o, i) {};
    }, {
        "../math/vec2": 30
    } ],
    46: [ function(t, e, o) {
        var i = t("../math/vec2"), n = t("./Solver"), s = t("../utils/Utils"), r = t("../equations/FrictionEquation");
        function a(t) {
            n.call(this, t, n.GS), t = t || {}, this.iterations = t.iterations || 10, this.tolerance = t.tolerance || 1e-7, 
            this.arrayStep = 30, this.lambda = new s.ARRAY_TYPE(this.arrayStep), this.Bs = new s.ARRAY_TYPE(this.arrayStep), 
            this.invCs = new s.ARRAY_TYPE(this.arrayStep), this.useZeroRHS = !1, this.frictionIterations = void 0 !== t.frictionIterations ? 0 : t.frictionIterations, 
            this.usedIterations = 0;
        }
        e.exports = a, a.prototype = new n(), a.prototype.constructor = a, a.prototype.solve = function(t, e) {
            this.sortEquations();
            var o = 0, n = this.iterations, c = this.frictionIterations, h = this.equations, l = h.length, p = Math.pow(this.tolerance * l, 2), u = e.bodies, d = e.bodies.length, f = (i.add, 
            i.set, this.useZeroRHS), v = this.lambda;
            if (this.usedIterations = 0, l) for (var y = 0; y !== d; y++) {
                u[y].updateSolveMassProperties();
            }
            v.length < l && (v = this.lambda = new s.ARRAY_TYPE(l + this.arrayStep), this.Bs = new s.ARRAY_TYPE(l + this.arrayStep), 
            this.invCs = new s.ARRAY_TYPE(l + this.arrayStep)), function(t) {
                for (var e = t.length; e--; ) t[e] = 0;
            }(v);
            var m, g, A = this.invCs, b = this.Bs;
            for (v = this.lambda, y = 0; y !== h.length; y++) {
                var E = h[y];
                (E.timeStep !== t || E.needsUpdate) && (E.timeStep = t, E.update()), b[y] = E.computeB(E.a, E.b, t), 
                A[y] = E.computeInvC(E.epsilon);
            }
            if (0 !== l) {
                for (y = 0; y !== d; y++) {
                    u[y].resetConstraintVelocity();
                }
                if (c) {
                    for (o = 0; o !== c; o++) {
                        for (m = 0, g = 0; g !== l; g++) {
                            E = h[g];
                            var B = a.iterateEquation(g, E, E.epsilon, b, A, v, f, t, o);
                            m += Math.abs(B);
                        }
                        if (this.usedIterations++, m * m <= p) break;
                    }
                    for (a.updateMultipliers(h, v, 1 / t), g = 0; g !== l; g++) {
                        var q = h[g];
                        if (q instanceof r) {
                            for (var P = 0, w = 0; w !== q.contactEquations.length; w++) P += q.contactEquations[w].multiplier;
                            P *= q.frictionCoefficient / q.contactEquations.length, q.maxForce = P, q.minForce = -P;
                        }
                    }
                }
                for (o = 0; o !== n; o++) {
                    for (m = 0, g = 0; g !== l; g++) {
                        E = h[g];
                        B = a.iterateEquation(g, E, E.epsilon, b, A, v, f, t, o);
                        m += Math.abs(B);
                    }
                    if (this.usedIterations++, m * m <= p) break;
                }
                for (y = 0; y !== d; y++) u[y].addConstraintVelocity();
                a.updateMultipliers(h, v, 1 / t);
            }
        }, a.updateMultipliers = function(t, e, o) {
            for (var i = t.length; i--; ) t[i].multiplier = e[i] * o;
        }, a.iterateEquation = function(t, e, o, i, n, s, r, a, c) {
            var h = i[t], l = n[t], p = s[t], u = e.computeGWlambda(), d = e.maxForce, f = e.minForce;
            r && (h = 0);
            var v = l * (h - u - o * p), y = p + v;
            return y < f * a ? v = f * a - p : y > d * a && (v = d * a - p), s[t] += v, e.addToWlambda(v), 
            v;
        };
    }, {
        "../equations/FrictionEquation": 23,
        "../math/vec2": 30,
        "../utils/Utils": 57,
        "./Solver": 47
    } ],
    47: [ function(t, e, o) {
        t("../utils/Utils");
        var i = t("../events/EventEmitter");
        function n(t, e) {
            t = t || {}, i.call(this), this.type = e, this.equations = [], this.equationSortFunction = t.equationSortFunction || !1;
        }
        e.exports = n, n.prototype = new i(), n.prototype.constructor = n, n.prototype.solve = function(t, e) {
            throw new Error("Solver.solve should be implemented by subclasses!");
        };
        var s = {
            bodies: []
        };
        n.prototype.solveIsland = function(t, e) {
            this.removeAllEquations(), e.equations.length && (this.addEquations(e.equations), 
            s.bodies.length = 0, e.getBodies(s.bodies), s.bodies.length && this.solve(t, s));
        }, n.prototype.sortEquations = function() {
            this.equationSortFunction && this.equations.sort(this.equationSortFunction);
        }, n.prototype.addEquation = function(t) {
            t.enabled && this.equations.push(t);
        }, n.prototype.addEquations = function(t) {
            for (var e = 0, o = t.length; e !== o; e++) {
                var i = t[e];
                i.enabled && this.equations.push(i);
            }
        }, n.prototype.removeEquation = function(t) {
            var e = this.equations.indexOf(t);
            -1 !== e && this.equations.splice(e, 1);
        }, n.prototype.removeAllEquations = function() {
            this.equations.length = 0;
        }, n.GS = 1, n.ISLAND = 2;
    }, {
        "../events/EventEmitter": 26,
        "../utils/Utils": 57
    } ],
    48: [ function(t, e, o) {
        var i = t("../equations/ContactEquation"), n = t("./Pool");
        function s() {
            n.apply(this, arguments);
        }
        e.exports = s, s.prototype = new n(), s.prototype.constructor = s, s.prototype.create = function() {
            return new i();
        }, s.prototype.destroy = function(t) {
            return t.bodyA = t.bodyB = null, this;
        };
    }, {
        "../equations/ContactEquation": 21,
        "./Pool": 55
    } ],
    49: [ function(t, e, o) {
        var i = t("../equations/FrictionEquation"), n = t("./Pool");
        function s() {
            n.apply(this, arguments);
        }
        e.exports = s, s.prototype = new n(), s.prototype.constructor = s, s.prototype.create = function() {
            return new i();
        }, s.prototype.destroy = function(t) {
            return t.bodyA = t.bodyB = null, this;
        };
    }, {
        "../equations/FrictionEquation": 23,
        "./Pool": 55
    } ],
    50: [ function(t, e, o) {
        var i = t("../world/IslandNode"), n = t("./Pool");
        function s() {
            n.apply(this, arguments);
        }
        e.exports = s, s.prototype = new n(), s.prototype.constructor = s, s.prototype.create = function() {
            return new i();
        }, s.prototype.destroy = function(t) {
            return t.reset(), this;
        };
    }, {
        "../world/IslandNode": 60,
        "./Pool": 55
    } ],
    51: [ function(t, e, o) {
        var i = t("../world/Island"), n = t("./Pool");
        function s() {
            n.apply(this, arguments);
        }
        e.exports = s, s.prototype = new n(), s.prototype.constructor = s, s.prototype.create = function() {
            return new i();
        }, s.prototype.destroy = function(t) {
            return t.reset(), this;
        };
    }, {
        "../world/Island": 58,
        "./Pool": 55
    } ],
    52: [ function(t, e, o) {
        var i = t("./TupleDictionary"), n = (t("./OverlapKeeperRecord"), t("./OverlapKeeperRecordPool"));
        function s() {
            this.overlappingShapesLastState = new i(), this.overlappingShapesCurrentState = new i(), 
            this.recordPool = new n({
                size: 16
            }), this.tmpDict = new i(), this.tmpArray1 = [];
        }
        t("./Utils"), e.exports = s, s.prototype.tick = function() {
            for (var t = this.overlappingShapesLastState, e = this.overlappingShapesCurrentState, o = t.keys.length; o--; ) {
                var i = t.keys[o], n = t.getByKey(i);
                e.getByKey(i), n && this.recordPool.release(n);
            }
            t.reset(), t.copy(e), e.reset();
        }, s.prototype.setOverlapping = function(t, e, o, i) {
            this.overlappingShapesLastState;
            var n = this.overlappingShapesCurrentState;
            if (!n.get(e.id, i.id)) {
                var s = this.recordPool.get();
                s.set(t, e, o, i), n.set(e.id, i.id, s);
            }
        }, s.prototype.getNewOverlaps = function(t) {
            return this.getDiff(this.overlappingShapesLastState, this.overlappingShapesCurrentState, t);
        }, s.prototype.getEndOverlaps = function(t) {
            return this.getDiff(this.overlappingShapesCurrentState, this.overlappingShapesLastState, t);
        }, s.prototype.bodiesAreOverlapping = function(t, e) {
            for (var o = this.overlappingShapesCurrentState, i = o.keys.length; i--; ) {
                var n = o.keys[i], s = o.data[n];
                if (s.bodyA === t && s.bodyB === e || s.bodyA === e && s.bodyB === t) return !0;
            }
            return !1;
        }, s.prototype.getDiff = function(t, e, o) {
            var i = t, n = e;
            (o = o || []).length = 0;
            for (var s = n.keys.length; s--; ) {
                var r = n.keys[s], a = n.data[r];
                if (!a) throw new Error("Key " + r + " had no data!");
                i.data[r] || o.push(a);
            }
            return o;
        }, s.prototype.isNewOverlap = function(t, e) {
            var o = 0 | t.id, i = 0 | e.id, n = this.overlappingShapesLastState, s = this.overlappingShapesCurrentState;
            return !n.get(o, i) && !!s.get(o, i);
        }, s.prototype.getNewBodyOverlaps = function(t) {
            this.tmpArray1.length = 0;
            var e = this.getNewOverlaps(this.tmpArray1);
            return this.getBodyDiff(e, t);
        }, s.prototype.getEndBodyOverlaps = function(t) {
            this.tmpArray1.length = 0;
            var e = this.getEndOverlaps(this.tmpArray1);
            return this.getBodyDiff(e, t);
        }, s.prototype.getBodyDiff = function(t, e) {
            e = e || [];
            for (var o = this.tmpDict, i = t.length; i--; ) {
                var n = t[i];
                o.set(0 | n.bodyA.id, 0 | n.bodyB.id, n);
            }
            for (i = o.keys.length; i--; ) {
                (n = o.getByKey(o.keys[i])) && e.push(n.bodyA, n.bodyB);
            }
            return o.reset(), e;
        };
    }, {
        "./OverlapKeeperRecord": 53,
        "./OverlapKeeperRecordPool": 54,
        "./TupleDictionary": 56,
        "./Utils": 57
    } ],
    53: [ function(t, e, o) {
        function i(t, e, o, i) {
            this.shapeA = e, this.shapeB = i, this.bodyA = t, this.bodyB = o;
        }
        e.exports = i, i.prototype.set = function(t, e, o, n) {
            i.call(this, t, e, o, n);
        };
    }, {} ],
    54: [ function(t, e, o) {
        var i = t("./OverlapKeeperRecord"), n = t("./Pool");
        function s() {
            n.apply(this, arguments);
        }
        e.exports = s, s.prototype = new n(), s.prototype.constructor = s, s.prototype.create = function() {
            return new i();
        }, s.prototype.destroy = function(t) {
            return t.bodyA = t.bodyB = t.shapeA = t.shapeB = null, this;
        };
    }, {
        "./OverlapKeeperRecord": 53,
        "./Pool": 55
    } ],
    55: [ function(t, e, o) {
        function i(t) {
            t = t || {}, this.objects = [], void 0 !== t.size && this.resize(t.size);
        }
        e.exports = i, i.prototype.resize = function(t) {
            for (var e = this.objects; e.length > t; ) e.pop();
            for (;e.length < t; ) e.push(this.create());
            return this;
        }, i.prototype.get = function() {
            var t = this.objects;
            return t.length ? t.pop() : this.create();
        }, i.prototype.release = function(t) {
            return this.destroy(t), this.objects.push(t), this;
        };
    }, {} ],
    56: [ function(t, e, o) {
        var i = t("./Utils");
        function n() {
            this.data = {}, this.keys = [];
        }
        e.exports = n, n.prototype.getKey = function(t, e) {
            return (0 | (t |= 0)) == (0 | (e |= 0)) ? -1 : 0 | ((0 | t) > (0 | e) ? t << 16 | 65535 & e : e << 16 | 65535 & t);
        }, n.prototype.getByKey = function(t) {
            return t |= 0, this.data[t];
        }, n.prototype.get = function(t, e) {
            return this.data[this.getKey(t, e)];
        }, n.prototype.set = function(t, e, o) {
            if (!o) throw new Error("No data!");
            var i = this.getKey(t, e);
            return this.data[i] || this.keys.push(i), this.data[i] = o, i;
        }, n.prototype.reset = function() {
            for (var t = this.data, e = this.keys, o = e.length; o--; ) delete t[e[o]];
            e.length = 0;
        }, n.prototype.copy = function(t) {
            this.reset(), i.appendArray(this.keys, t.keys);
            for (var e = t.keys.length; e--; ) {
                var o = t.keys[e];
                this.data[o] = t.data[o];
            }
        };
    }, {
        "./Utils": 57
    } ],
    57: [ function(t, e, o) {
        function i() {}
        e.exports = i, i.appendArray = function(t, e) {
            if (e.length < 15e4) t.push.apply(t, e); else for (var o = 0, i = e.length; o !== i; ++o) t.push(e[o]);
        }, i.splice = function(t, e, o) {
            o = o || 1;
            for (var i = e, n = t.length - o; i < n; i++) t[i] = t[i + o];
            t.length = n;
        }, "undefined" != typeof P2_ARRAY_TYPE ? i.ARRAY_TYPE = P2_ARRAY_TYPE : "undefined" != typeof Float32Array ? i.ARRAY_TYPE = Float32Array : i.ARRAY_TYPE = Array, 
        i.extend = function(t, e) {
            for (var o in e) t[o] = e[o];
        }, i.defaults = function(t, e) {
            for (var o in t = t || {}, e) o in t || (t[o] = e[o]);
            return t;
        };
    }, {} ],
    58: [ function(t, e, o) {
        var i = t("../objects/Body");
        function n() {
            this.equations = [], this.bodies = [];
        }
        e.exports = n, n.prototype.reset = function() {
            this.equations.length = this.bodies.length = 0;
        };
        var s = [];
        n.prototype.getBodies = function(t) {
            var e = t || [], o = this.equations;
            s.length = 0;
            for (var i = 0; i !== o.length; i++) {
                var n = o[i];
                -1 === s.indexOf(n.bodyA.id) && (e.push(n.bodyA), s.push(n.bodyA.id)), -1 === s.indexOf(n.bodyB.id) && (e.push(n.bodyB), 
                s.push(n.bodyB.id));
            }
            return e;
        }, n.prototype.wantsToSleep = function() {
            for (var t = 0; t < this.bodies.length; t++) {
                var e = this.bodies[t];
                if (e.type === i.DYNAMIC && !e.wantsToSleep) return !1;
            }
            return !0;
        }, n.prototype.sleep = function() {
            for (var t = 0; t < this.bodies.length; t++) {
                this.bodies[t].sleep();
            }
            return !0;
        };
    }, {
        "../objects/Body": 31
    } ],
    59: [ function(t, e, o) {
        t("../math/vec2"), t("./Island"), t("./IslandNode");
        var i = t("./../utils/IslandNodePool"), n = t("./../utils/IslandPool"), s = t("../objects/Body");
        function r(t) {
            this.nodePool = new i({
                size: 16
            }), this.islandPool = new n({
                size: 8
            }), this.equations = [], this.islands = [], this.nodes = [], this.queue = [];
        }
        e.exports = r, r.getUnvisitedNode = function(t) {
            for (var e = t.length, o = 0; o !== e; o++) {
                var i = t[o];
                if (!i.visited && i.body.type === s.DYNAMIC) return i;
            }
            return !1;
        }, r.prototype.visit = function(t, e, o) {
            e.push(t.body);
            for (var i = t.equations.length, n = 0; n !== i; n++) {
                var s = t.equations[n];
                -1 === o.indexOf(s) && o.push(s);
            }
        }, r.prototype.bfs = function(t, e, o) {
            var i = this.queue;
            for (i.length = 0, i.push(t), t.visited = !0, this.visit(t, e, o); i.length; ) for (var n, a = i.pop(); n = r.getUnvisitedNode(a.neighbors); ) n.visited = !0, 
            this.visit(n, e, o), n.body.type === s.DYNAMIC && i.push(n);
        }, r.prototype.split = function(t) {
            for (var e = t.bodies, o = this.nodes, i = this.equations; o.length; ) this.nodePool.release(o.pop());
            for (var n = 0; n !== e.length; n++) {
                var s = this.nodePool.get();
                s.body = e[n], o.push(s);
            }
            for (var a = 0; a !== i.length; a++) {
                var c = i[a], h = (n = e.indexOf(c.bodyA), e.indexOf(c.bodyB)), l = o[n], p = o[h];
                l.neighbors.push(p), p.neighbors.push(l), l.equations.push(c), p.equations.push(c);
            }
            var u, d = this.islands;
            for (n = 0; n < d.length; n++) this.islandPool.release(d[n]);
            for (d.length = 0; u = r.getUnvisitedNode(o); ) {
                var f = this.islandPool.get();
                this.bfs(u, f.bodies, f.equations), d.push(f);
            }
            return d;
        };
    }, {
        "../math/vec2": 30,
        "../objects/Body": 31,
        "./../utils/IslandNodePool": 50,
        "./../utils/IslandPool": 51,
        "./Island": 58,
        "./IslandNode": 60
    } ],
    60: [ function(t, e, o) {
        function i(t) {
            this.body = t, this.neighbors = [], this.equations = [], this.visited = !1;
        }
        e.exports = i, i.prototype.reset = function() {
            this.equations.length = 0, this.neighbors.length = 0, this.visited = !1, this.body = null;
        };
    }, {} ],
    61: [ function(t, e, o) {
        var i = t("../solver/GSSolver"), n = (t("../solver/Solver"), t("../collision/Ray"), 
        t("../math/vec2")), s = t("../shapes/Circle"), r = t("../shapes/Convex"), a = (t("../shapes/Line"), 
        t("../shapes/Plane")), c = t("../shapes/Capsule"), h = t("../shapes/Particle"), l = t("../events/EventEmitter"), p = t("../objects/Body"), u = (t("../shapes/Shape"), 
        t("../objects/LinearSpring"), t("../material/Material")), d = t("../material/ContactMaterial"), f = (t("../constraints/DistanceConstraint"), 
        t("../constraints/Constraint"), t("../constraints/LockConstraint"), t("../constraints/RevoluteConstraint"), 
        t("../constraints/PrismaticConstraint"), t("../constraints/GearConstraint"), t("../../package.json"), 
        t("../collision/Broadphase"), t("../collision/AABB")), v = t("../collision/SAPBroadphase"), y = t("../collision/Narrowphase"), m = t("../utils/Utils"), g = t("../utils/OverlapKeeper"), A = t("./IslandManager");
        function b(t) {
            l.apply(this), t = t || {}, this.springs = [], this.bodies = [], this.disabledBodyCollisionPairs = [], 
            this.solver = t.solver || new i(), this.narrowphase = new y(this), this.islandManager = new A(), 
            this.gravity = n.fromValues(0, -9.78), t.gravity && n.copy(this.gravity, t.gravity), 
            this.frictionGravity = n.length(this.gravity) || 10, this.useWorldGravityAsFrictionGravity = !0, 
            this.useFrictionGravityOnZeroGravity = !0, this.broadphase = t.broadphase || new v(), 
            this.broadphase.setWorld(this), this.constraints = [], this.defaultMaterial = new u(), 
            this.defaultContactMaterial = new d(this.defaultMaterial, this.defaultMaterial), 
            this.lastTimeStep = 1 / 60, this.applySpringForces = !0, this.applyDamping = !0, 
            this.applyGravity = !0, this.solveConstraints = !0, this.contactMaterials = [], 
            this.time = 0, this.accumulator = 0, this.stepping = !1, this.bodiesToBeRemoved = [], 
            this.islandSplit = void 0 === t.islandSplit || !!t.islandSplit, this.emitImpactEvent = !0, 
            this._constraintIdCounter = 0, this._bodyIdCounter = 0, this.postStepEvent = {
                type: "postStep"
            }, this.addBodyEvent = {
                type: "addBody",
                body: null
            }, this.removeBodyEvent = {
                type: "removeBody",
                body: null
            }, this.addSpringEvent = {
                type: "addSpring",
                spring: null
            }, this.impactEvent = {
                type: "impact",
                bodyA: null,
                bodyB: null,
                shapeA: null,
                shapeB: null,
                contactEquation: null
            }, this.postBroadphaseEvent = {
                type: "postBroadphase",
                pairs: null
            }, this.sleepMode = b.NO_SLEEPING, this.beginContactEvent = {
                type: "beginContact",
                shapeA: null,
                shapeB: null,
                bodyA: null,
                bodyB: null,
                contactEquations: []
            }, this.endContactEvent = {
                type: "endContact",
                shapeA: null,
                shapeB: null,
                bodyA: null,
                bodyB: null
            }, this.preSolveEvent = {
                type: "preSolve",
                contactEquations: null,
                frictionEquations: null
            }, this.overlappingShapesLastState = {
                keys: []
            }, this.overlappingShapesCurrentState = {
                keys: []
            }, this.overlapKeeper = new g();
        }
        t("../objects/RotationalSpring"), e.exports = b, b.prototype = new Object(l.prototype), 
        b.prototype.constructor = b, b.NO_SLEEPING = 1, b.BODY_SLEEPING = 2, b.ISLAND_SLEEPING = 4, 
        b.prototype.addConstraint = function(t) {
            this.constraints.push(t);
        }, b.prototype.addContactMaterial = function(t) {
            this.contactMaterials.push(t);
        }, b.prototype.removeContactMaterial = function(t) {
            var e = this.contactMaterials.indexOf(t);
            -1 !== e && m.splice(this.contactMaterials, e, 1);
        }, b.prototype.getContactMaterial = function(t, e) {
            for (var o = this.contactMaterials, i = 0, n = o.length; i !== n; i++) {
                var s = o[i];
                if (s.materialA.id === t.id && s.materialB.id === e.id || s.materialA.id === e.id && s.materialB.id === t.id) return s;
            }
            return !1;
        }, b.prototype.removeConstraint = function(t) {
            var e = this.constraints.indexOf(t);
            -1 !== e && m.splice(this.constraints, e, 1);
        }, n.create(), n.create(), n.create(), n.create(), n.create(), n.create();
        var E = n.create(), B = n.fromValues(0, 0), q = n.fromValues(0, 0);
        n.fromValues(0, 0), n.fromValues(0, 0), b.prototype.step = function(t, e, o) {
            if (o = o || 10, 0 === (e = e || 0)) this.internalStep(t), this.time += t; else {
                this.accumulator += e;
                for (var i = 0; this.accumulator >= t && i < o; ) this.internalStep(t), this.time += t, 
                this.accumulator -= t, i++;
                for (var s = this.accumulator % t / t, r = 0; r !== this.bodies.length; r++) {
                    var a = this.bodies[r];
                    n.lerp(a.interpolatedPosition, a.previousPosition, a.position, s), a.interpolatedAngle = a.previousAngle + s * (a.angle - a.previousAngle);
                }
            }
        };
        var P = [];
        b.prototype.internalStep = function(t) {
            this.stepping = !0;
            var e = this.springs.length, o = this.springs, i = this.bodies, s = this.gravity, r = this.solver, a = this.bodies.length, c = this.broadphase, h = this.narrowphase, l = this.constraints, u = E, d = (n.scale, 
            n.add), f = (n.rotate, this.islandManager);
            if (this.overlapKeeper.tick(), this.lastTimeStep = t, this.useWorldGravityAsFrictionGravity) {
                var v = n.length(this.gravity);
                0 === v && this.useFrictionGravityOnZeroGravity || (this.frictionGravity = v);
            }
            if (this.applyGravity) for (var y = 0; y !== a; y++) {
                var g = (A = i[y]).force;
                A.type === p.DYNAMIC && A.sleepState !== p.SLEEPING && (n.scale(u, s, A.mass * A.gravityScale), 
                d(g, g, u));
            }
            if (this.applySpringForces) for (y = 0; y !== e; y++) {
                o[y].applyForce();
            }
            if (this.applyDamping) for (y = 0; y !== a; y++) {
                var A;
                (A = i[y]).type === p.DYNAMIC && A.applyDamping(t);
            }
            var B = c.getCollisionPairs(this), q = this.disabledBodyCollisionPairs;
            for (y = q.length - 2; y >= 0; y -= 2) for (var w = B.length - 2; w >= 0; w -= 2) (q[y] === B[w] && q[y + 1] === B[w + 1] || q[y + 1] === B[w] && q[y] === B[w + 1]) && B.splice(w, 2);
            var S = l.length;
            for (y = 0; y !== S; y++) {
                var C = l[y];
                if (!C.collideConnected) for (w = B.length - 2; w >= 0; w -= 2) (C.bodyA === B[w] && C.bodyB === B[w + 1] || C.bodyB === B[w] && C.bodyA === B[w + 1]) && B.splice(w, 2);
            }
            this.postBroadphaseEvent.pairs = B, this.emit(this.postBroadphaseEvent), this.postBroadphaseEvent.pairs = null, 
            h.reset(this);
            y = 0;
            for (var L = B.length; y !== L; y += 2) for (var x = B[y], F = B[y + 1], M = 0, I = x.shapes.length; M !== I; M++) for (var R = x.shapes[M], V = R.position, T = R.angle, N = 0, G = F.shapes.length; N !== G; N++) {
                var O = F.shapes[N], U = O.position, k = O.angle, _ = this.defaultContactMaterial;
                if (R.material && O.material) {
                    var D = this.getContactMaterial(R.material, O.material);
                    D && (_ = D);
                }
                this.runNarrowphase(h, x, R, V, T, F, O, U, k, _, this.frictionGravity);
            }
            for (y = 0; y !== a; y++) {
                (z = i[y])._wakeUpAfterNarrowphase && (z.wakeUp(), z._wakeUpAfterNarrowphase = !1);
            }
            if (this.has("endContact")) {
                this.overlapKeeper.getEndOverlaps(P);
                var W = this.endContactEvent;
                for (N = P.length; N--; ) {
                    var X = P[N];
                    W.shapeA = X.shapeA, W.shapeB = X.shapeB, W.bodyA = X.bodyA, W.bodyB = X.bodyB, 
                    this.emit(W);
                }
                P.length = 0;
            }
            var j = this.preSolveEvent;
            j.contactEquations = h.contactEquations, j.frictionEquations = h.frictionEquations, 
            this.emit(j), j.contactEquations = j.frictionEquations = null;
            S = l.length;
            for (y = 0; y !== S; y++) l[y].update();
            if (h.contactEquations.length || h.frictionEquations.length || S) if (this.islandSplit) {
                for (f.equations.length = 0, m.appendArray(f.equations, h.contactEquations), m.appendArray(f.equations, h.frictionEquations), 
                y = 0; y !== S; y++) m.appendArray(f.equations, l[y].equations);
                f.split(this);
                for (y = 0; y !== f.islands.length; y++) {
                    (H = f.islands[y]).equations.length && r.solveIsland(t, H);
                }
            } else {
                for (r.addEquations(h.contactEquations), r.addEquations(h.frictionEquations), y = 0; y !== S; y++) r.addEquations(l[y].equations);
                this.solveConstraints && r.solve(t, this), r.removeAllEquations();
            }
            for (y = 0; y !== a; y++) {
                var z;
                (z = i[y]).integrate(t);
            }
            for (y = 0; y !== a; y++) i[y].setZeroForce();
            if (this.emitImpactEvent && this.has("impact")) {
                var Y = this.impactEvent;
                for (y = 0; y !== h.contactEquations.length; y++) {
                    var K = h.contactEquations[y];
                    K.firstImpact && (Y.bodyA = K.bodyA, Y.bodyB = K.bodyB, Y.shapeA = K.shapeA, Y.shapeB = K.shapeB, 
                    Y.contactEquation = K, this.emit(Y));
                }
            }
            if (this.sleepMode === b.BODY_SLEEPING) for (y = 0; y !== a; y++) i[y].sleepTick(this.time, !1, t); else if (this.sleepMode === b.ISLAND_SLEEPING && this.islandSplit) {
                for (y = 0; y !== a; y++) i[y].sleepTick(this.time, !0, t);
                for (y = 0; y < this.islandManager.islands.length; y++) {
                    var H;
                    (H = this.islandManager.islands[y]).wantsToSleep() && H.sleep();
                }
            }
            this.stepping = !1;
            var Z = this.bodiesToBeRemoved;
            for (y = 0; y !== Z.length; y++) this.removeBody(Z[y]);
            Z.length = 0, this.emit(this.postStepEvent);
        }, b.prototype.runNarrowphase = function(t, e, o, i, s, r, a, c, h, l, u) {
            if (0 != (o.collisionGroup & a.collisionMask) && 0 != (a.collisionGroup & o.collisionMask)) {
                n.rotate(B, i, e.angle), n.rotate(q, c, r.angle), n.add(B, B, e.position), n.add(q, q, r.position);
                var d, f = s + e.angle, v = h + r.angle;
                t.enableFriction = l.friction > 0, t.frictionCoefficient = l.friction, d = e.type === p.STATIC || e.type === p.KINEMATIC ? r.mass : r.type === p.STATIC || r.type === p.KINEMATIC ? e.mass : e.mass * r.mass / (e.mass + r.mass), 
                t.slipForce = l.friction * u * d, t.restitution = l.restitution, t.surfaceVelocity = l.surfaceVelocity, 
                t.frictionStiffness = l.frictionStiffness, t.frictionRelaxation = l.frictionRelaxation, 
                t.stiffness = l.stiffness, t.relaxation = l.relaxation, t.contactSkinSize = l.contactSkinSize, 
                t.enabledEquations = e.collisionResponse && r.collisionResponse && o.collisionResponse && a.collisionResponse;
                var y = t[o.type | a.type], m = 0;
                if (y) {
                    var g = o.sensor || a.sensor, A = t.frictionEquations.length;
                    m = o.type < a.type ? y.call(t, e, o, B, f, r, a, q, v, g) : y.call(t, r, a, q, v, e, o, B, f, g);
                    var b = t.frictionEquations.length - A;
                    if (m) {
                        if (e.allowSleep && e.type === p.DYNAMIC && e.sleepState === p.SLEEPING && r.sleepState === p.AWAKE && r.type !== p.STATIC) n.squaredLength(r.velocity) + Math.pow(r.angularVelocity, 2) >= 2 * Math.pow(r.sleepSpeedLimit, 2) && (e._wakeUpAfterNarrowphase = !0);
                        if (r.allowSleep && r.type === p.DYNAMIC && r.sleepState === p.SLEEPING && e.sleepState === p.AWAKE && e.type !== p.STATIC) n.squaredLength(e.velocity) + Math.pow(e.angularVelocity, 2) >= 2 * Math.pow(e.sleepSpeedLimit, 2) && (r._wakeUpAfterNarrowphase = !0);
                        if (this.overlapKeeper.setOverlapping(e, o, r, a), this.has("beginContact") && this.overlapKeeper.isNewOverlap(o, a)) {
                            var E = this.beginContactEvent;
                            if (E.shapeA = o, E.shapeB = a, E.bodyA = e, E.bodyB = r, E.contactEquations.length = 0, 
                            "number" == typeof m) for (var P = t.contactEquations.length - m; P < t.contactEquations.length; P++) E.contactEquations.push(t.contactEquations[P]);
                            this.emit(E);
                        }
                        if ("number" == typeof m && b > 1) for (P = t.frictionEquations.length - b; P < t.frictionEquations.length; P++) {
                            var w = t.frictionEquations[P];
                            w.setSlipForce(w.getSlipForce() / b);
                        }
                    }
                }
            }
        }, b.prototype.addSpring = function(t) {
            this.springs.push(t);
            var e = this.addSpringEvent;
            e.spring = t, this.emit(e), e.spring = null;
        }, b.prototype.removeSpring = function(t) {
            var e = this.springs.indexOf(t);
            -1 !== e && m.splice(this.springs, e, 1);
        }, b.prototype.addBody = function(t) {
            if (-1 === this.bodies.indexOf(t)) {
                this.bodies.push(t), t.world = this;
                var e = this.addBodyEvent;
                e.body = t, this.emit(e), e.body = null;
            }
        }, b.prototype.removeBody = function(t) {
            if (this.stepping) this.bodiesToBeRemoved.push(t); else {
                t.world = null;
                var e = this.bodies.indexOf(t);
                -1 !== e && (m.splice(this.bodies, e, 1), this.removeBodyEvent.body = t, t.resetConstraintVelocity(), 
                this.emit(this.removeBodyEvent), this.removeBodyEvent.body = null);
            }
        }, b.prototype.getBodyById = function(t) {
            for (var e = this.bodies, o = 0; o < e.length; o++) {
                var i = e[o];
                if (i.id === t) return i;
            }
            return !1;
        }, b.prototype.disableBodyCollision = function(t, e) {
            this.disabledBodyCollisionPairs.push(t, e);
        }, b.prototype.enableBodyCollision = function(t, e) {
            for (var o = this.disabledBodyCollisionPairs, i = 0; i < o.length; i += 2) if (o[i] === t && o[i + 1] === e || o[i + 1] === t && o[i] === e) return void o.splice(i, 2);
        }, b.prototype.clear = function() {
            this.time = 0, this.solver && this.solver.equations.length && this.solver.removeAllEquations();
            for (var t = this.constraints, e = t.length - 1; e >= 0; e--) this.removeConstraint(t[e]);
            var o = this.bodies;
            for (e = o.length - 1; e >= 0; e--) this.removeBody(o[e]);
            var i = this.springs;
            for (e = i.length - 1; e >= 0; e--) this.removeSpring(i[e]);
            var n = this.contactMaterials;
            for (e = n.length - 1; e >= 0; e--) this.removeContactMaterial(n[e]);
            b.apply(this);
        };
        var w = n.create(), S = (n.fromValues(0, 0), n.fromValues(0, 0));
        b.prototype.hitTest = function(t, e, o) {
            o = o || 0;
            var i = new p({
                position: t
            }), l = new h(), u = t, d = w, f = S;
            i.addShape(l);
            for (var v = this.narrowphase, y = [], m = 0, g = e.length; m !== g; m++) for (var A = e[m], b = 0, E = A.shapes.length; b !== E; b++) {
                var B = A.shapes[b];
                n.rotate(d, B.position, A.angle), n.add(d, d, A.position);
                var q = B.angle + A.angle;
                (B instanceof s && v.circleParticle(A, B, d, q, i, l, u, 0, !0) || B instanceof r && v.particleConvex(i, l, u, 0, A, B, d, q, !0) || B instanceof a && v.particlePlane(i, l, u, 0, A, B, d, q, !0) || B instanceof c && v.particleCapsule(i, l, u, 0, A, B, d, q, !0) || B instanceof h && n.squaredLength(n.sub(f, d, t)) < o * o) && y.push(A);
            }
            return y;
        }, b.prototype.setGlobalStiffness = function(t) {
            for (var e = this.constraints, o = 0; o !== e.length; o++) for (var i = e[o], n = 0; n !== i.equations.length; n++) {
                var s = i.equations[n];
                s.stiffness = t, s.needsUpdate = !0;
            }
            var r = this.contactMaterials;
            for (o = 0; o !== r.length; o++) {
                (i = r[o]).stiffness = i.frictionStiffness = t;
            }
            (i = this.defaultContactMaterial).stiffness = i.frictionStiffness = t;
        }, b.prototype.setGlobalRelaxation = function(t) {
            for (var e = 0; e !== this.constraints.length; e++) for (var o = this.constraints[e], i = 0; i !== o.equations.length; i++) {
                var n = o.equations[i];
                n.relaxation = t, n.needsUpdate = !0;
            }
            for (e = 0; e !== this.contactMaterials.length; e++) {
                (o = this.contactMaterials[e]).relaxation = o.frictionRelaxation = t;
            }
            (o = this.defaultContactMaterial).relaxation = o.frictionRelaxation = t;
        };
        var C = new f(), L = [];
        b.prototype.raycast = function(t, e) {
            return e.getAABB(C), this.broadphase.aabbQuery(this, C, L), e.intersectBodies(t, L), 
            L.length = 0, t.hasHit();
        };
    }, {
        "../../package.json": 6,
        "../collision/AABB": 7,
        "../collision/Broadphase": 8,
        "../collision/Narrowphase": 10,
        "../collision/Ray": 11,
        "../collision/SAPBroadphase": 13,
        "../constraints/Constraint": 14,
        "../constraints/DistanceConstraint": 15,
        "../constraints/GearConstraint": 16,
        "../constraints/LockConstraint": 17,
        "../constraints/PrismaticConstraint": 18,
        "../constraints/RevoluteConstraint": 19,
        "../events/EventEmitter": 26,
        "../material/ContactMaterial": 27,
        "../material/Material": 28,
        "../math/vec2": 30,
        "../objects/Body": 31,
        "../objects/LinearSpring": 32,
        "../objects/RotationalSpring": 33,
        "../shapes/Capsule": 38,
        "../shapes/Circle": 39,
        "../shapes/Convex": 40,
        "../shapes/Line": 42,
        "../shapes/Particle": 43,
        "../shapes/Plane": 44,
        "../shapes/Shape": 45,
        "../solver/GSSolver": 46,
        "../solver/Solver": 47,
        "../utils/OverlapKeeper": 52,
        "../utils/Utils": 57,
        "./IslandManager": 59
    } ]
}, {}, [ 36 ])(36);