var t, e = arequire("../@babel/runtime/helpers/assertThisInitialized"), i = arequire("../@babel/runtime/helpers/get"), o = arequire("../@babel/runtime/helpers/getPrototypeOf"), n = arequire("../@babel/runtime/helpers/inherits"), s = arequire("../@babel/runtime/helpers/createSuper"), r = arequire("../@babel/runtime/helpers/classCallCheck"), a = arequire("../@babel/runtime/helpers/createClass"), l = arequire("../@babel/runtime/helpers/typeof");

"undefined" != typeof window ? t = window : "undefined" != typeof global ? t = global : "undefined" != typeof self && (t = self), 
t.CANNON = function t(e, i, o) {
    function n(r, a) {
        if (!i[r]) {
            if (!e[r]) {
                var l = "function" == typeof arequire && arequire;
                if (!a && l) return l(r, !0);
                if (s) return s(r, !0);
                throw new Error("Cannot find module '" + r + "'");
            }
            var h = i[r] = {
                exports: {}
            };
            e[r][0].call(h.exports, function(t) {
                return n(e[r][1][t] || t);
            }, h, h.exports, t, e, i, o);
        }
        return i[r].exports;
    }
    for (var s = "function" == typeof arequire && arequire, r = 0; r < o.length; r++) n(o[r]);
    return n;
}({
    1: [ function(t, e, i) {
        e.exports = {
            name: "cannon",
            version: "0.6.2",
            description: "A lightweight 3D physics engine written in JavaScript.",
            homepage: "https://github.com/schteppe/cannon.js",
            author: "Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",
            keywords: [ "cannon.js", "cannon", "physics", "engine", "3d" ],
            main: "./build/cannon.js",
            engines: {
                node: "*"
            },
            repository: {
                type: "git",
                url: "https://github.com/schteppe/cannon.js.git"
            },
            bugs: {
                url: "https://github.com/schteppe/cannon.js/issues"
            },
            licenses: [ {
                type: "MIT"
            } ],
            devDependencies: {
                jshint: "latest",
                "uglify-js": "latest",
                nodeunit: "^0.9.0",
                grunt: "~0.4.0",
                "grunt-contrib-jshint": "~0.1.1",
                "grunt-contrib-nodeunit": "^0.4.1",
                "grunt-contrib-concat": "~0.1.3",
                "grunt-contrib-uglify": "^0.5.1",
                "grunt-browserify": "^2.1.4",
                "grunt-contrib-yuidoc": "^0.5.2",
                browserify: "*"
            },
            dependencies: {}
        };
    }, {} ],
    2: [ function(t, e, i) {
        e.exports = {
            version: t("../package.json").version,
            AABB: t("./collision/AABB"),
            ArrayCollisionMatrix: t("./collision/ArrayCollisionMatrix"),
            Body: t("./objects/Body"),
            Box: t("./shapes/Box"),
            Broadphase: t("./collision/Broadphase"),
            Constraint: t("./constraints/Constraint"),
            ContactEquation: t("./equations/ContactEquation"),
            Narrowphase: t("./world/Narrowphase"),
            ConeTwistConstraint: t("./constraints/ConeTwistConstraint"),
            ContactMaterial: t("./material/ContactMaterial"),
            ConvexPolyhedron: t("./shapes/ConvexPolyhedron"),
            Cylinder: t("./shapes/Cylinder"),
            DistanceConstraint: t("./constraints/DistanceConstraint"),
            Equation: t("./equations/Equation"),
            EventTarget: t("./utils/EventTarget"),
            FrictionEquation: t("./equations/FrictionEquation"),
            GSSolver: t("./solver/GSSolver"),
            GridBroadphase: t("./collision/GridBroadphase"),
            Heightfield: t("./shapes/Heightfield"),
            HingeConstraint: t("./constraints/HingeConstraint"),
            LockConstraint: t("./constraints/LockConstraint"),
            Mat3: t("./math/Mat3"),
            Material: t("./material/Material"),
            NaiveBroadphase: t("./collision/NaiveBroadphase"),
            ObjectCollisionMatrix: t("./collision/ObjectCollisionMatrix"),
            Pool: t("./utils/Pool"),
            Particle: t("./shapes/Particle"),
            Plane: t("./shapes/Plane"),
            PointToPointConstraint: t("./constraints/PointToPointConstraint"),
            Quaternion: t("./math/Quaternion"),
            Ray: t("./collision/Ray"),
            RaycastVehicle: t("./objects/RaycastVehicle"),
            RaycastResult: t("./collision/RaycastResult"),
            RigidVehicle: t("./objects/RigidVehicle"),
            RotationalEquation: t("./equations/RotationalEquation"),
            RotationalMotorEquation: t("./equations/RotationalMotorEquation"),
            SAPBroadphase: t("./collision/SAPBroadphase"),
            SPHSystem: t("./objects/SPHSystem"),
            Shape: t("./shapes/Shape"),
            Solver: t("./solver/Solver"),
            Sphere: t("./shapes/Sphere"),
            SplitSolver: t("./solver/SplitSolver"),
            Spring: t("./objects/Spring"),
            Trimesh: t("./shapes/Trimesh"),
            Vec3: t("./math/Vec3"),
            Vec3Pool: t("./utils/Vec3Pool"),
            World: t("./world/World")
        };
    }, {
        "../package.json": 1,
        "./collision/AABB": 3,
        "./collision/ArrayCollisionMatrix": 4,
        "./collision/Broadphase": 5,
        "./collision/GridBroadphase": 6,
        "./collision/NaiveBroadphase": 7,
        "./collision/ObjectCollisionMatrix": 8,
        "./collision/Ray": 9,
        "./collision/RaycastResult": 10,
        "./collision/SAPBroadphase": 11,
        "./constraints/ConeTwistConstraint": 12,
        "./constraints/Constraint": 13,
        "./constraints/DistanceConstraint": 14,
        "./constraints/HingeConstraint": 15,
        "./constraints/LockConstraint": 16,
        "./constraints/PointToPointConstraint": 17,
        "./equations/ContactEquation": 19,
        "./equations/Equation": 20,
        "./equations/FrictionEquation": 21,
        "./equations/RotationalEquation": 22,
        "./equations/RotationalMotorEquation": 23,
        "./material/ContactMaterial": 24,
        "./material/Material": 25,
        "./math/Mat3": 27,
        "./math/Quaternion": 28,
        "./math/Vec3": 30,
        "./objects/Body": 31,
        "./objects/RaycastVehicle": 32,
        "./objects/RigidVehicle": 33,
        "./objects/SPHSystem": 34,
        "./objects/Spring": 35,
        "./shapes/Box": 37,
        "./shapes/ConvexPolyhedron": 38,
        "./shapes/Cylinder": 39,
        "./shapes/Heightfield": 40,
        "./shapes/Particle": 41,
        "./shapes/Plane": 42,
        "./shapes/Shape": 43,
        "./shapes/Sphere": 44,
        "./shapes/Trimesh": 45,
        "./solver/GSSolver": 46,
        "./solver/Solver": 47,
        "./solver/SplitSolver": 48,
        "./utils/EventTarget": 49,
        "./utils/Pool": 51,
        "./utils/Vec3Pool": 54,
        "./world/Narrowphase": 55,
        "./world/World": 56
    } ],
    3: [ function(t, e, i) {
        var o = t("../math/Vec3");
        function n(t) {
            t = t || {}, this.lowerBound = new o(), t.lowerBound && this.lowerBound.copy(t.lowerBound), 
            this.upperBound = new o(), t.upperBound && this.upperBound.copy(t.upperBound);
        }
        t("../utils/Utils"), e.exports = n;
        var s = new o();
        n.prototype.setFromPoints = function(t, e, i, o) {
            var n = this.lowerBound, r = this.upperBound, a = i;
            n.copy(t[0]), a && a.vmult(n, n), r.copy(n);
            for (var l = 1; l < t.length; l++) {
                var h = t[l];
                a && (a.vmult(h, s), h = s), h.x > r.x && (r.x = h.x), h.x < n.x && (n.x = h.x), 
                h.y > r.y && (r.y = h.y), h.y < n.y && (n.y = h.y), h.z > r.z && (r.z = h.z), h.z < n.z && (n.z = h.z);
            }
            return e && (e.vadd(n, n), e.vadd(r, r)), o && (n.x -= o, n.y -= o, n.z -= o, r.x += o, 
            r.y += o, r.z += o), this;
        }, n.prototype.copy = function(t) {
            return this.lowerBound.copy(t.lowerBound), this.upperBound.copy(t.upperBound), this;
        }, n.prototype.clone = function() {
            return new n().copy(this);
        }, n.prototype.extend = function(t) {
            var e = t.lowerBound.x;
            this.lowerBound.x > e && (this.lowerBound.x = e);
            var i = t.upperBound.x;
            this.upperBound.x < i && (this.upperBound.x = i), e = t.lowerBound.y, this.lowerBound.y > e && (this.lowerBound.y = e), 
            i = t.upperBound.y, this.upperBound.y < i && (this.upperBound.y = i), e = t.lowerBound.z, 
            this.lowerBound.z > e && (this.lowerBound.z = e), i = t.upperBound.z, this.upperBound.z < i && (this.upperBound.z = i);
        }, n.prototype.overlaps = function(t) {
            var e = this.lowerBound, i = this.upperBound, o = t.lowerBound, n = t.upperBound;
            return (o.x <= i.x && i.x <= n.x || e.x <= n.x && n.x <= i.x) && (o.y <= i.y && i.y <= n.y || e.y <= n.y && n.y <= i.y) && (o.z <= i.z && i.z <= n.z || e.z <= n.z && n.z <= i.z);
        }, n.prototype.contains = function(t) {
            var e = this.lowerBound, i = this.upperBound, o = t.lowerBound, n = t.upperBound;
            return e.x <= o.x && i.x >= n.x && e.y <= o.y && i.y >= n.y && e.z <= o.z && i.z >= n.z;
        }, n.prototype.getCorners = function(t, e, i, o, n, s, r, a) {
            var l = this.lowerBound, h = this.upperBound;
            t.copy(l), e.set(h.x, l.y, l.z), i.set(h.x, h.y, l.z), o.set(l.x, h.y, h.z), n.set(h.x, l.y, l.z), 
            s.set(l.x, h.y, l.z), r.set(l.x, l.y, h.z), a.copy(h);
        };
        var r = [ new o(), new o(), new o(), new o(), new o(), new o(), new o(), new o() ];
        n.prototype.toLocalFrame = function(t, e) {
            var i = r, o = i[0], n = i[1], s = i[2], a = i[3], l = i[4], h = i[5], c = i[6], u = i[7];
            this.getCorners(o, n, s, a, l, h, c, u);
            for (var p = 0; 8 !== p; p++) {
                var d = i[p];
                t.pointToLocal(d, d);
            }
            return e.setFromPoints(i);
        }, n.prototype.toWorldFrame = function(t, e) {
            var i = r, o = i[0], n = i[1], s = i[2], a = i[3], l = i[4], h = i[5], c = i[6], u = i[7];
            this.getCorners(o, n, s, a, l, h, c, u);
            for (var p = 0; 8 !== p; p++) {
                var d = i[p];
                t.pointToWorld(d, d);
            }
            return e.setFromPoints(i);
        };
    }, {
        "../math/Vec3": 30,
        "../utils/Utils": 53
    } ],
    4: [ function(t, e, i) {
        function o() {
            this.matrix = [];
        }
        e.exports = o, o.prototype.get = function(t, e) {
            if (t = t.index, (e = e.index) > t) {
                var i = e;
                e = t, t = i;
            }
            return this.matrix[(t * (t + 1) >> 1) + e - 1];
        }, o.prototype.set = function(t, e, i) {
            if (t = t.index, (e = e.index) > t) {
                var o = e;
                e = t, t = o;
            }
            this.matrix[(t * (t + 1) >> 1) + e - 1] = i ? 1 : 0;
        }, o.prototype.reset = function() {
            for (var t = 0, e = this.matrix.length; t !== e; t++) this.matrix[t] = 0;
        }, o.prototype.setNumObjects = function(t) {
            this.matrix.length = t * (t - 1) >> 1;
        };
    }, {} ],
    5: [ function(t, e, i) {
        var o = t("../objects/Body"), n = t("../math/Vec3"), s = t("../math/Quaternion");
        function r() {
            this.world = null, this.useBoundingBoxes = !1, this.dirty = !0;
        }
        t("../shapes/Shape"), t("../shapes/Plane"), e.exports = r, r.prototype.collisionPairs = function(t, e, i) {
            throw new Error("collisionPairs not implemented for this BroadPhase class!");
        }, o.STATIC, o.KINEMATIC, r.prototype.needBroadphaseCollision = function(t, e) {
            return 0 != (t.collisionFilterGroup & e.collisionFilterMask) && 0 != (e.collisionFilterGroup & t.collisionFilterMask) && (0 == (t.type & o.STATIC) && t.sleepState !== o.SLEEPING || 0 == (e.type & o.STATIC) && e.sleepState !== o.SLEEPING);
        }, r.prototype.intersectionTest = function(t, e, i, o) {
            this.useBoundingBoxes ? this.doBoundingBoxBroadphase(t, e, i, o) : this.doBoundingSphereBroadphase(t, e, i, o);
        };
        var a = new n();
        new n(), new s(), new n(), r.prototype.doBoundingSphereBroadphase = function(t, e, i, o) {
            var n = a;
            e.position.vsub(t.position, n);
            var s = Math.pow(t.boundingRadius + e.boundingRadius, 2);
            n.norm2() < s && (i.push(t), o.push(e));
        }, r.prototype.doBoundingBoxBroadphase = function(t, e, i, o) {
            t.aabbNeedsUpdate && t.computeAABB(), e.aabbNeedsUpdate && e.computeAABB(), t.aabb.overlaps(e.aabb) && (i.push(t), 
            o.push(e));
        };
        var l = {
            keys: []
        }, h = [], c = [];
        r.prototype.makePairsUnique = function(t, e) {
            for (var i = l, o = h, n = c, s = t.length, r = 0; r !== s; r++) o[r] = t[r], n[r] = e[r];
            for (t.length = 0, e.length = 0, r = 0; r !== s; r++) {
                var a = o[r].id, u = n[r].id;
                i[p = a < u ? a + "," + u : u + "," + a] = r, i.keys.push(p);
            }
            for (r = 0; r !== i.keys.length; r++) {
                var p = i.keys.pop(), d = i[p];
                t.push(o[d]), e.push(n[d]), delete i[p];
            }
        }, r.prototype.setWorld = function(t) {};
        var u = new n();
        r.boundingSphereCheck = function(t, e) {
            var i = u;
            return t.position.vsub(e.position, i), Math.pow(t.shape.boundingSphereRadius + e.shape.boundingSphereRadius, 2) > i.norm2();
        }, r.prototype.aabbQuery = function(t, e, i) {
            return console.warn(".aabbQuery is not implemented in this Broadphase subclass."), 
            [];
        };
    }, {
        "../math/Quaternion": 28,
        "../math/Vec3": 30,
        "../objects/Body": 31,
        "../shapes/Plane": 42,
        "../shapes/Shape": 43
    } ],
    6: [ function(t, e, i) {
        e.exports = r;
        var o = t("./Broadphase"), n = t("../math/Vec3"), s = t("../shapes/Shape");
        function r(t, e, i, s, r) {
            o.apply(this), this.nx = i || 10, this.ny = s || 10, this.nz = r || 10, this.aabbMin = t || new n(100, 100, 100), 
            this.aabbMax = e || new n(-100, -100, -100);
            var a = this.nx * this.ny * this.nz;
            if (a <= 0) throw "GridBroadphase: Each dimension's n must be >0";
            this.bins = [], this.binLengths = [], this.bins.length = a, this.binLengths.length = a;
            for (var l = 0; l < a; l++) this.bins[l] = [], this.binLengths[l] = 0;
        }
        r.prototype = new o(), r.prototype.constructor = r;
        var a = new n();
        new n(), r.prototype.collisionPairs = function(t, e, i) {
            for (var o = t.numObjects(), n = t.bodies, r = this.aabbMax, l = this.aabbMin, h = this.nx, c = this.ny, u = this.nz, p = c * u, d = u, v = r.x, y = r.y, f = r.z, m = l.x, g = l.y, w = l.z, b = h / (v - m), x = c / (y - g), _ = u / (f - w), C = (v - m) / h, S = (y - g) / c, A = (f - w) / u, E = .5 * Math.sqrt(C * C + S * S + A * A), T = s.types, B = T.SPHERE, R = T.PLANE, P = (T.BOX, 
            T.COMPOUND, T.CONVEXPOLYHEDRON, this.bins), N = this.binLengths, O = this.bins.length, I = 0; I !== O; I++) N[I] = 0;
            var F = Math.ceil;
            function z(t, e, i, o, n, s, r) {
                var a = (t - m) * b | 0, l = (e - g) * x | 0, v = (i - w) * _ | 0, y = F((o - m) * b), f = F((n - g) * x), C = F((s - w) * _);
                a < 0 ? a = 0 : a >= h && (a = h - 1), l < 0 ? l = 0 : l >= c && (l = c - 1), v < 0 ? v = 0 : v >= u && (v = u - 1), 
                y < 0 ? y = 0 : y >= h && (y = h - 1), f < 0 ? f = 0 : f >= c && (f = c - 1), C < 0 ? C = 0 : C >= u && (C = u - 1), 
                l *= d, v *= 1, y *= p, f *= d, C *= 1;
                for (var S = a *= p; S <= y; S += p) for (var A = l; A <= f; A += d) for (var E = v; E <= C; E += 1) {
                    var T = S + A + E;
                    P[T][N[T]++] = r;
                }
            }
            for (l = Math.min, r = Math.max, I = 0; I !== o; I++) {
                var M = (et = n[I]).shape;
                switch (M.type) {
                  case B:
                    var V = et.position.x, L = et.position.y, q = et.position.z, j = M.radius;
                    z(V - j, L - j, q - j, V + j, L + j, q + j, et);
                    break;

                  case R:
                    M.worldNormalNeedsUpdate && M.computeWorldNormal(et.quaternion);
                    var W = M.worldNormal, k = m + .5 * C - et.position.x, D = g + .5 * S - et.position.y, U = w + .5 * A - et.position.z, H = a;
                    H.set(k, D, U);
                    for (var G = 0, Y = 0; G !== h; G++, Y += p, H.y = D, H.x += C) for (var Q = 0, X = 0; Q !== c; Q++, 
                    X += d, H.z = U, H.y += S) for (var Z = 0, K = 0; Z !== u; Z++, K += 1, H.z += A) if (H.dot(W) < E) {
                        var J = Y + X + K;
                        P[J][N[J]++] = et;
                    }
                    break;

                  default:
                    et.aabbNeedsUpdate && et.computeAABB(), z(et.aabb.lowerBound.x, et.aabb.lowerBound.y, et.aabb.lowerBound.z, et.aabb.upperBound.x, et.aabb.upperBound.y, et.aabb.upperBound.z, et);
                }
            }
            for (I = 0; I !== O; I++) {
                var $ = N[I];
                if ($ > 1) {
                    var tt = P[I];
                    for (G = 0; G !== $; G++) {
                        var et = tt[G];
                        for (Q = 0; Q !== G; Q++) {
                            var it = tt[Q];
                            this.needBroadphaseCollision(et, it) && this.intersectionTest(et, it, e, i);
                        }
                    }
                }
            }
            this.makePairsUnique(e, i);
        };
    }, {
        "../math/Vec3": 30,
        "../shapes/Shape": 43,
        "./Broadphase": 5
    } ],
    7: [ function(t, e, i) {
        e.exports = s;
        var o = t("./Broadphase"), n = t("./AABB");
        function s() {
            o.apply(this);
        }
        s.prototype = new o(), s.prototype.constructor = s, s.prototype.collisionPairs = function(t, e, i) {
            var o, n, s, r, a = t.bodies, l = a.length;
            for (o = 0; o !== l; o++) for (n = 0; n !== o; n++) s = a[o], r = a[n], this.needBroadphaseCollision(s, r) && this.intersectionTest(s, r, e, i);
        }, new n(), s.prototype.aabbQuery = function(t, e, i) {
            i = i || [];
            for (var o = 0; o < t.bodies.length; o++) {
                var n = t.bodies[o];
                n.aabbNeedsUpdate && n.computeAABB(), n.aabb.overlaps(e) && i.push(n);
            }
            return i;
        };
    }, {
        "./AABB": 3,
        "./Broadphase": 5
    } ],
    8: [ function(t, e, i) {
        function o() {
            this.matrix = {};
        }
        e.exports = o, o.prototype.get = function(t, e) {
            if (t = t.id, (e = e.id) > t) {
                var i = e;
                e = t, t = i;
            }
            return t + "-" + e in this.matrix;
        }, o.prototype.set = function(t, e, i) {
            if (t = t.id, (e = e.id) > t) {
                var o = e;
                e = t, t = o;
            }
            i ? this.matrix[t + "-" + e] = !0 : delete this.matrix[t + "-" + e];
        }, o.prototype.reset = function() {
            this.matrix = {};
        }, o.prototype.setNumObjects = function(t) {};
    }, {} ],
    9: [ function(t, e, i) {
        e.exports = h;
        var o = t("../math/Vec3"), n = t("../math/Quaternion"), s = t("../math/Transform"), r = (t("../shapes/ConvexPolyhedron"), 
        t("../shapes/Box"), t("../collision/RaycastResult")), a = t("../shapes/Shape"), l = t("../collision/AABB");
        function h(t, e) {
            this.from = t ? t.clone() : new o(), this.to = e ? e.clone() : new o(), this._direction = new o(), 
            this.precision = 1e-4, this.checkCollisionResponse = !0, this.skipBackfaces = !1, 
            this.collisionFilterMask = -1, this.collisionFilterGroup = -1, this.mode = h.ANY, 
            this.result = new r(), this.hasHit = !1, this.callback = function(t) {};
        }
        h.prototype.constructor = h, h.CLOSEST = 1, h.ANY = 2, h.ALL = 4;
        var c = new l(), u = [];
        h.prototype.intersectWorld = function(t, e) {
            return this.mode = e.mode || h.ANY, this.result = e.result || new r(), this.skipBackfaces = !!e.skipBackfaces, 
            this.collisionFilterMask = void 0 !== e.collisionFilterMask ? e.collisionFilterMask : -1, 
            this.collisionFilterGroup = void 0 !== e.collisionFilterGroup ? e.collisionFilterGroup : -1, 
            e.from && this.from.copy(e.from), e.to && this.to.copy(e.to), this.callback = e.callback || function() {}, 
            this.hasHit = !1, this.result.reset(), this._updateDirection(), this.getAABB(c), 
            u.length = 0, t.broadphase.aabbQuery(t, c, u), this.intersectBodies(u), this.hasHit;
        };
        var p = new o(), d = new o();
        function v(t, e, i, o) {
            o.vsub(e, F), i.vsub(e, p), t.vsub(e, d);
            var n, s, r = F.dot(F), a = F.dot(p), l = F.dot(d), h = p.dot(p), c = p.dot(d);
            return (n = h * l - a * c) >= 0 && (s = r * c - a * l) >= 0 && n + s < r * h - a * a;
        }
        h.pointInTriangle = v;
        var y = new o(), f = new n();
        h.prototype.intersectBody = function(t, e) {
            e && (this.result = e, this._updateDirection());
            var i = this.checkCollisionResponse;
            if ((!i || t.collisionResponse) && 0 != (this.collisionFilterGroup & t.collisionFilterMask) && 0 != (t.collisionFilterGroup & this.collisionFilterMask)) for (var o = y, n = f, s = 0, r = t.shapes.length; s < r; s++) {
                var a = t.shapes[s];
                if ((!i || a.collisionResponse) && (t.quaternion.mult(t.shapeOrientations[s], n), 
                t.quaternion.vmult(t.shapeOffsets[s], o), o.vadd(t.position, o), this.intersectShape(a, n, o, t), 
                this.result._shouldStop)) break;
            }
        }, h.prototype.intersectBodies = function(t, e) {
            e && (this.result = e, this._updateDirection());
            for (var i = 0, o = t.length; !this.result._shouldStop && i < o; i++) this.intersectBody(t[i]);
        }, h.prototype._updateDirection = function() {
            this.to.vsub(this.from, this._direction), this._direction.normalize();
        }, h.prototype.intersectShape = function(t, e, i, o) {
            if (!(function(t, e, i) {
                i.vsub(t, F);
                var o = F.dot(e);
                return e.mult(o, z), z.vadd(t, z), i.distanceTo(z);
            }(this.from, this._direction, i) > t.boundingSphereRadius)) {
                var n = this[t.type];
                n && n.call(this, t, e, i, o);
            }
        }, new o(), new o();
        var m = new o(), g = new o(), w = new o(), b = new o();
        new o(), new r(), h.prototype.intersectBox = function(t, e, i, o) {
            return this.intersectConvex(t.convexPolyhedronRepresentation, e, i, o);
        }, h.prototype[a.types.BOX] = h.prototype.intersectBox, h.prototype.intersectPlane = function(t, e, i, n) {
            var s = this.from, r = this.to, a = this._direction, l = new o(0, 0, 1);
            e.vmult(l, l);
            var h = new o();
            s.vsub(i, h);
            var c = h.dot(l);
            if (r.vsub(i, h), !(c * h.dot(l) > 0 || s.distanceTo(r) < c)) {
                var u = l.dot(a);
                if (!(Math.abs(u) < this.precision)) {
                    var p = new o(), d = new o(), v = new o();
                    s.vsub(i, p);
                    var y = -l.dot(p) / u;
                    a.scale(y, d), s.vadd(d, v), this.reportIntersection(l, v, t, n, -1);
                }
            }
        }, h.prototype[a.types.PLANE] = h.prototype.intersectPlane, h.prototype.getAABB = function(t) {
            var e = this.to, i = this.from;
            t.lowerBound.x = Math.min(e.x, i.x), t.lowerBound.y = Math.min(e.y, i.y), t.lowerBound.z = Math.min(e.z, i.z), 
            t.upperBound.x = Math.max(e.x, i.x), t.upperBound.y = Math.max(e.y, i.y), t.upperBound.z = Math.max(e.z, i.z);
        };
        var x = {
            faceList: [ 0 ]
        };
        h.prototype.intersectHeightfield = function(t, e, i, n) {
            t.data, t.elementSize;
            var r = new o(), a = new h(this.from, this.to);
            s.pointToLocalFrame(i, e, a.from, a.from), s.pointToLocalFrame(i, e, a.to, a.to);
            var l = [], c = null, u = null, p = null, d = null, v = t.getIndexOfPosition(a.from.x, a.from.y, l, !1);
            if (v && (c = l[0], u = l[1], p = l[0], d = l[1]), (v = t.getIndexOfPosition(a.to.x, a.to.y, l, !1)) && ((null === c || l[0] < c) && (c = l[0]), 
            (null === p || l[0] > p) && (p = l[0]), (null === u || l[1] < u) && (u = l[1]), 
            (null === d || l[1] > d) && (d = l[1])), null !== c) {
                t.getRectMinMax(c, u, p, d, []);
                for (var y = c; y <= p; y++) for (var f = u; f <= d; f++) {
                    if (this.result._shouldStop) return;
                    if (t.getConvexTrianglePillar(y, f, !1), s.pointToWorldFrame(i, e, t.pillarOffset, r), 
                    this.intersectConvex(t.pillarConvex, e, r, n, x), this.result._shouldStop) return;
                    t.getConvexTrianglePillar(y, f, !0), s.pointToWorldFrame(i, e, t.pillarOffset, r), 
                    this.intersectConvex(t.pillarConvex, e, r, n, x);
                }
            }
        }, h.prototype[a.types.HEIGHTFIELD] = h.prototype.intersectHeightfield;
        var _ = new o(), C = new o();
        h.prototype.intersectSphere = function(t, e, i, o) {
            var n = this.from, s = this.to, r = t.radius, a = Math.pow(s.x - n.x, 2) + Math.pow(s.y - n.y, 2) + Math.pow(s.z - n.z, 2), l = 2 * ((s.x - n.x) * (n.x - i.x) + (s.y - n.y) * (n.y - i.y) + (s.z - n.z) * (n.z - i.z)), h = Math.pow(n.x - i.x, 2) + Math.pow(n.y - i.y, 2) + Math.pow(n.z - i.z, 2) - Math.pow(r, 2), c = Math.pow(l, 2) - 4 * a * h, u = _, p = C;
            if (!(c < 0)) if (0 === c) n.lerp(s, c, u), u.vsub(i, p), p.normalize(), this.reportIntersection(p, u, t, o, -1); else {
                var d = (-l - Math.sqrt(c)) / (2 * a), v = (-l + Math.sqrt(c)) / (2 * a);
                if (d >= 0 && d <= 1 && (n.lerp(s, d, u), u.vsub(i, p), p.normalize(), this.reportIntersection(p, u, t, o, -1)), 
                this.result._shouldStop) return;
                v >= 0 && v <= 1 && (n.lerp(s, v, u), u.vsub(i, p), p.normalize(), this.reportIntersection(p, u, t, o, -1));
            }
        }, h.prototype[a.types.SPHERE] = h.prototype.intersectSphere;
        var S = new o(), A = (new o(), new o(), new o());
        h.prototype.intersectConvex = function(t, e, i, o, n) {
            for (var s = S, r = A, a = n && n.faceList || null, l = t.faces, h = t.vertices, c = t.faceNormals, u = this._direction, p = this.from, d = this.to, y = p.distanceTo(d), f = a ? a.length : l.length, x = this.result, _ = 0; !x._shouldStop && _ < f; _++) {
                var C = a ? a[_] : _, E = l[C], T = c[C], B = e, R = i;
                r.copy(h[E[0]]), B.vmult(r, r), r.vadd(R, r), r.vsub(p, r), B.vmult(T, s);
                var P = u.dot(s);
                if (!(Math.abs(P) < this.precision)) {
                    var N = s.dot(r) / P;
                    if (!(N < 0)) {
                        u.mult(N, m), m.vadd(p, m), g.copy(h[E[0]]), B.vmult(g, g), R.vadd(g, g);
                        for (var O = 1; !x._shouldStop && O < E.length - 1; O++) {
                            w.copy(h[E[O]]), b.copy(h[E[O + 1]]), B.vmult(w, w), B.vmult(b, b), R.vadd(w, w), 
                            R.vadd(b, b);
                            var I = m.distanceTo(p);
                            !v(m, g, w, b) && !v(m, w, g, b) || I > y || this.reportIntersection(s, m, t, o, C);
                        }
                    }
                }
            }
        }, h.prototype[a.types.CONVEXPOLYHEDRON] = h.prototype.intersectConvex;
        var E = new o(), T = new o(), B = new o(), R = new o(), P = new o(), N = new o(), O = (new l(), 
        []), I = new s();
        h.prototype.intersectTrimesh = function(t, e, i, o, n) {
            var r = E, a = O, l = I, h = A, c = T, u = B, p = R, d = N, y = P, f = (n && n.faceList, 
            t.indices), x = (t.vertices, t.faceNormals, this.from), _ = this.to, C = this._direction;
            l.position.copy(i), l.quaternion.copy(e), s.vectorToLocalFrame(i, e, C, c), s.pointToLocalFrame(i, e, x, u), 
            s.pointToLocalFrame(i, e, _, p);
            var S = u.distanceSquared(p);
            t.tree.rayQuery(this, l, a);
            for (var F = 0, z = a.length; !this.result._shouldStop && F !== z; F++) {
                var M = a[F];
                t.getNormal(M, r), t.getVertex(f[3 * M], g), g.vsub(u, h);
                var V = c.dot(r), L = r.dot(h) / V;
                if (!(L < 0)) {
                    c.scale(L, m), m.vadd(u, m), t.getVertex(f[3 * M + 1], w), t.getVertex(f[3 * M + 2], b);
                    var q = m.distanceSquared(u);
                    !v(m, w, g, b) && !v(m, g, w, b) || q > S || (s.vectorToWorldFrame(e, r, y), s.pointToWorldFrame(i, e, m, d), 
                    this.reportIntersection(y, d, t, o, M));
                }
            }
            a.length = 0;
        }, h.prototype[a.types.TRIMESH] = h.prototype.intersectTrimesh, h.prototype.reportIntersection = function(t, e, i, o, n) {
            var s = this.from, r = this.to, a = s.distanceTo(e), l = this.result;
            if (!(this.skipBackfaces && t.dot(this._direction) > 0)) switch (l.hitFaceIndex = void 0 !== n ? n : -1, 
            this.mode) {
              case h.ALL:
                this.hasHit = !0, l.set(s, r, t, e, i, o, a), l.hasHit = !0, this.callback(l);
                break;

              case h.CLOSEST:
                (a < l.distance || !l.hasHit) && (this.hasHit = !0, l.hasHit = !0, l.set(s, r, t, e, i, o, a));
                break;

              case h.ANY:
                this.hasHit = !0, l.hasHit = !0, l.set(s, r, t, e, i, o, a), l._shouldStop = !0;
            }
        };
        var F = new o(), z = new o();
    }, {
        "../collision/AABB": 3,
        "../collision/RaycastResult": 10,
        "../math/Quaternion": 28,
        "../math/Transform": 29,
        "../math/Vec3": 30,
        "../shapes/Box": 37,
        "../shapes/ConvexPolyhedron": 38,
        "../shapes/Shape": 43
    } ],
    10: [ function(t, e, i) {
        var o = t("../math/Vec3");
        function n() {
            this.rayFromWorld = new o(), this.rayToWorld = new o(), this.hitNormalWorld = new o(), 
            this.hitPointWorld = new o(), this.hasHit = !1, this.shape = null, this.body = null, 
            this.hitFaceIndex = -1, this.distance = -1, this._shouldStop = !1;
        }
        e.exports = n, n.prototype.reset = function() {
            this.rayFromWorld.setZero(), this.rayToWorld.setZero(), this.hitNormalWorld.setZero(), 
            this.hitPointWorld.setZero(), this.hasHit = !1, this.shape = null, this.body = null, 
            this.hitFaceIndex = -1, this.distance = -1, this._shouldStop = !1;
        }, n.prototype.abort = function() {
            this._shouldStop = !0;
        }, n.prototype.set = function(t, e, i, o, n, s, r) {
            this.rayFromWorld.copy(t), this.rayToWorld.copy(e), this.hitNormalWorld.copy(i), 
            this.hitPointWorld.copy(o), this.shape = n, this.body = s, this.distance = r;
        };
    }, {
        "../math/Vec3": 30
    } ],
    11: [ function(t, e, i) {
        t("../shapes/Shape");
        var o = t("../collision/Broadphase");
        function n(t) {
            o.apply(this), this.axisList = [], this.world = null, this.axisIndex = 0;
            var e = this.axisList;
            this._addBodyHandler = function(t) {
                e.push(t.body);
            }, this._removeBodyHandler = function(t) {
                var i = e.indexOf(t.body);
                -1 !== i && e.splice(i, 1);
            }, t && this.setWorld(t);
        }
        e.exports = n, n.prototype = new o(), n.prototype.setWorld = function(t) {
            this.axisList.length = 0;
            for (var e = 0; e < t.bodies.length; e++) this.axisList.push(t.bodies[e]);
            t.removeEventListener("addBody", this._addBodyHandler), t.removeEventListener("removeBody", this._removeBodyHandler), 
            t.addEventListener("addBody", this._addBodyHandler), t.addEventListener("removeBody", this._removeBodyHandler), 
            this.world = t, this.dirty = !0;
        }, n.insertionSortX = function(t) {
            for (var e = 1, i = t.length; e < i; e++) {
                for (var o = t[e], n = e - 1; n >= 0 && !(t[n].aabb.lowerBound.x <= o.aabb.lowerBound.x); n--) t[n + 1] = t[n];
                t[n + 1] = o;
            }
            return t;
        }, n.insertionSortY = function(t) {
            for (var e = 1, i = t.length; e < i; e++) {
                for (var o = t[e], n = e - 1; n >= 0 && !(t[n].aabb.lowerBound.y <= o.aabb.lowerBound.y); n--) t[n + 1] = t[n];
                t[n + 1] = o;
            }
            return t;
        }, n.insertionSortZ = function(t) {
            for (var e = 1, i = t.length; e < i; e++) {
                for (var o = t[e], n = e - 1; n >= 0 && !(t[n].aabb.lowerBound.z <= o.aabb.lowerBound.z); n--) t[n + 1] = t[n];
                t[n + 1] = o;
            }
            return t;
        }, n.prototype.collisionPairs = function(t, e, i) {
            var o, s, r = this.axisList, a = r.length, l = this.axisIndex;
            for (this.dirty && (this.sortList(), this.dirty = !1), o = 0; o !== a; o++) {
                var h = r[o];
                for (s = o + 1; s < a; s++) {
                    var c = r[s];
                    if (this.needBroadphaseCollision(h, c)) {
                        if (!n.checkBounds(h, c, l)) break;
                        this.intersectionTest(h, c, e, i);
                    }
                }
            }
        }, n.prototype.sortList = function() {
            for (var t = this.axisList, e = this.axisIndex, i = t.length, o = 0; o !== i; o++) {
                var s = t[o];
                s.aabbNeedsUpdate && s.computeAABB();
            }
            0 === e ? n.insertionSortX(t) : 1 === e ? n.insertionSortY(t) : 2 === e && n.insertionSortZ(t);
        }, n.checkBounds = function(t, e, i) {
            var o, n;
            0 === i ? (o = t.position.x, n = e.position.x) : 1 === i ? (o = t.position.y, n = e.position.y) : 2 === i && (o = t.position.z, 
            n = e.position.z);
            var s = t.boundingRadius;
            return n - e.boundingRadius < o + s;
        }, n.prototype.autoDetectAxis = function() {
            for (var t = 0, e = 0, i = 0, o = 0, n = 0, s = 0, r = this.axisList, a = r.length, l = 1 / a, h = 0; h !== a; h++) {
                var c = r[h], u = c.position.x;
                t += u, e += u * u;
                var p = c.position.y;
                i += p, o += p * p;
                var d = c.position.z;
                n += d, s += d * d;
            }
            var v = e - t * t * l, y = o - i * i * l, f = s - n * n * l;
            this.axisIndex = v > y ? v > f ? 0 : 2 : y > f ? 1 : 2;
        }, n.prototype.aabbQuery = function(t, e, i) {
            i = i || [], this.dirty && (this.sortList(), this.dirty = !1);
            var o = this.axisIndex, n = "x";
            1 === o && (n = "y"), 2 === o && (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.computeAABB(), a.aabb.overlaps(e) && i.push(a);
            }
            return i;
        };
    }, {
        "../collision/Broadphase": 5,
        "../shapes/Shape": 43
    } ],
    12: [ function(t, e, i) {
        e.exports = a, t("./Constraint");
        var o = t("./PointToPointConstraint"), n = t("../equations/ConeEquation"), s = t("../equations/RotationalEquation"), r = (t("../equations/ContactEquation"), 
        t("../math/Vec3"));
        function a(t, e, i) {
            var a = void 0 !== (i = i || {}).maxForce ? i.maxForce : 1e6, l = i.pivotA ? i.pivotA.clone() : new r(), h = i.pivotB ? i.pivotB.clone() : new r();
            this.axisA = i.axisA ? i.axisA.clone() : new r(), this.axisB = i.axisB ? i.axisB.clone() : new r(), 
            o.call(this, t, l, e, h, a), this.collideConnected = !!i.collideConnected, this.angle = void 0 !== i.angle ? i.angle : 0;
            var c = this.coneEquation = new n(t, e, i), u = this.twistEquation = new s(t, e, i);
            this.twistAngle = void 0 !== i.twistAngle ? i.twistAngle : 0, c.maxForce = 0, c.minForce = -a, 
            u.maxForce = 0, u.minForce = -a, this.equations.push(c, u);
        }
        a.prototype = new o(), a.constructor = a, new r(), new r(), a.prototype.update = function() {
            var t = this.bodyA, e = this.bodyB, i = this.coneEquation, n = this.twistEquation;
            o.prototype.update.call(this), t.vectorToWorldFrame(this.axisA, i.axisA), e.vectorToWorldFrame(this.axisB, i.axisB), 
            this.axisA.tangents(n.axisA, n.axisA), t.vectorToWorldFrame(n.axisA, n.axisA), this.axisB.tangents(n.axisB, n.axisB), 
            e.vectorToWorldFrame(n.axisB, n.axisB), i.angle = this.angle, n.maxAngle = this.twistAngle;
        };
    }, {
        "../equations/ConeEquation": 18,
        "../equations/ContactEquation": 19,
        "../equations/RotationalEquation": 22,
        "../math/Vec3": 30,
        "./Constraint": 13,
        "./PointToPointConstraint": 17
    } ],
    13: [ function(t, e, i) {
        e.exports = n;
        var o = t("../utils/Utils");
        function n(t, e, i) {
            i = o.defaults(i, {
                collideConnected: !0,
                wakeUpBodies: !0
            }), this.equations = [], this.bodyA = t, this.bodyB = e, this.id = n.idCounter++, 
            this.collideConnected = i.collideConnected, i.wakeUpBodies && (t && t.wakeUp(), 
            e && e.wakeUp());
        }
        n.prototype.update = function() {
            throw new Error("method update() not implmemented in this Constraint subclass!");
        }, n.prototype.enable = function() {
            for (var t = this.equations, e = 0; e < t.length; e++) t[e].enabled = !0;
        }, n.prototype.disable = function() {
            for (var t = this.equations, e = 0; e < t.length; e++) t[e].enabled = !1;
        }, n.idCounter = 0;
    }, {
        "../utils/Utils": 53
    } ],
    14: [ function(t, e, i) {
        e.exports = s;
        var o = t("./Constraint"), n = t("../equations/ContactEquation");
        function s(t, e, i, s) {
            o.call(this, t, e), void 0 === i && (i = t.position.distanceTo(e.position)), void 0 === s && (s = 1e6), 
            this.distance = i;
            var r = this.distanceEquation = new n(t, e);
            this.equations.push(r), r.minForce = -s, r.maxForce = s;
        }
        s.prototype = new o(), s.prototype.update = function() {
            var t = this.bodyA, e = this.bodyB, i = this.distanceEquation, o = .5 * this.distance, n = i.ni;
            e.position.vsub(t.position, n), n.normalize(), n.mult(o, i.ri), n.mult(-o, i.rj);
        };
    }, {
        "../equations/ContactEquation": 19,
        "./Constraint": 13
    } ],
    15: [ function(t, e, i) {
        e.exports = a, t("./Constraint");
        var o = t("./PointToPointConstraint"), n = t("../equations/RotationalEquation"), s = t("../equations/RotationalMotorEquation"), r = (t("../equations/ContactEquation"), 
        t("../math/Vec3"));
        function a(t, e, i) {
            var a = void 0 !== (i = i || {}).maxForce ? i.maxForce : 1e6, l = i.pivotA ? i.pivotA.clone() : new r(), h = i.pivotB ? i.pivotB.clone() : new r();
            o.call(this, t, l, e, h, a), (this.axisA = i.axisA ? i.axisA.clone() : new r(1, 0, 0)).normalize(), 
            (this.axisB = i.axisB ? i.axisB.clone() : new r(1, 0, 0)).normalize();
            var c = this.rotationalEquation1 = new n(t, e, i), u = this.rotationalEquation2 = new n(t, e, i), p = this.motorEquation = new s(t, e, a);
            p.enabled = !1, this.equations.push(c, u, p);
        }
        a.prototype = new o(), a.constructor = a, a.prototype.enableMotor = function() {
            this.motorEquation.enabled = !0;
        }, a.prototype.disableMotor = function() {
            this.motorEquation.enabled = !1;
        }, a.prototype.setMotorSpeed = function(t) {
            this.motorEquation.targetVelocity = t;
        }, a.prototype.setMotorMaxForce = function(t) {
            this.motorEquation.maxForce = t, this.motorEquation.minForce = -t;
        };
        var l = new r(), h = new r();
        a.prototype.update = function() {
            var t = this.bodyA, e = this.bodyB, i = this.motorEquation, n = this.rotationalEquation1, s = this.rotationalEquation2, r = l, a = h, c = this.axisA, u = this.axisB;
            o.prototype.update.call(this), t.quaternion.vmult(c, r), e.quaternion.vmult(u, a), 
            r.tangents(n.axisA, s.axisA), n.axisB.copy(a), s.axisB.copy(a), this.motorEquation.enabled && (t.quaternion.vmult(this.axisA, i.axisA), 
            e.quaternion.vmult(this.axisB, i.axisB));
        };
    }, {
        "../equations/ContactEquation": 19,
        "../equations/RotationalEquation": 22,
        "../equations/RotationalMotorEquation": 23,
        "../math/Vec3": 30,
        "./Constraint": 13,
        "./PointToPointConstraint": 17
    } ],
    16: [ function(t, e, i) {
        e.exports = r, t("./Constraint");
        var o = t("./PointToPointConstraint"), n = t("../equations/RotationalEquation"), s = (t("../equations/RotationalMotorEquation"), 
        t("../equations/ContactEquation"), t("../math/Vec3"));
        function r(t, e, i) {
            var r = void 0 !== (i = i || {}).maxForce ? i.maxForce : 1e6, a = new s(), l = new s(), h = new s();
            t.position.vadd(e.position, h), h.scale(.5, h), e.pointToLocalFrame(h, l), t.pointToLocalFrame(h, a), 
            o.call(this, t, a, e, l, r);
            var c = this.rotationalEquation1 = new n(t, e, i), u = this.rotationalEquation2 = new n(t, e, i), p = this.rotationalEquation3 = new n(t, e, i);
            this.equations.push(c, u, p);
        }
        r.prototype = new o(), r.constructor = r, new s(), new s(), r.prototype.update = function() {
            var t = this.bodyA, e = this.bodyB, i = (this.motorEquation, this.rotationalEquation1), n = this.rotationalEquation2, r = this.rotationalEquation3;
            o.prototype.update.call(this), t.vectorToWorldFrame(s.UNIT_X, i.axisA), e.vectorToWorldFrame(s.UNIT_Y, i.axisB), 
            t.vectorToWorldFrame(s.UNIT_Y, n.axisA), e.vectorToWorldFrame(s.UNIT_Z, n.axisB), 
            t.vectorToWorldFrame(s.UNIT_Z, r.axisA), e.vectorToWorldFrame(s.UNIT_X, r.axisB);
        };
    }, {
        "../equations/ContactEquation": 19,
        "../equations/RotationalEquation": 22,
        "../equations/RotationalMotorEquation": 23,
        "../math/Vec3": 30,
        "./Constraint": 13,
        "./PointToPointConstraint": 17
    } ],
    17: [ function(t, e, i) {
        e.exports = r;
        var o = t("./Constraint"), n = t("../equations/ContactEquation"), s = t("../math/Vec3");
        function r(t, e, i, r, a) {
            o.call(this, t, i), a = void 0 !== a ? a : 1e6, this.pivotA = e ? e.clone() : new s(), 
            this.pivotB = r ? r.clone() : new s();
            var l = this.equationX = new n(t, i), h = this.equationY = new n(t, i), c = this.equationZ = new n(t, i);
            this.equations.push(l, h, c), l.minForce = h.minForce = c.minForce = -a, l.maxForce = h.maxForce = c.maxForce = a, 
            l.ni.set(1, 0, 0), h.ni.set(0, 1, 0), c.ni.set(0, 0, 1);
        }
        r.prototype = new o(), r.prototype.update = function() {
            var t = this.bodyA, e = this.bodyB, i = this.equationX, o = this.equationY, n = this.equationZ;
            t.quaternion.vmult(this.pivotA, i.ri), e.quaternion.vmult(this.pivotB, i.rj), o.ri.copy(i.ri), 
            o.rj.copy(i.rj), n.ri.copy(i.ri), n.rj.copy(i.rj);
        };
    }, {
        "../equations/ContactEquation": 19,
        "../math/Vec3": 30,
        "./Constraint": 13
    } ],
    18: [ function(t, e, i) {
        e.exports = s;
        var o = t("../math/Vec3"), n = (t("../math/Mat3"), t("./Equation"));
        function s(t, e, i) {
            var s = void 0 !== (i = i || {}).maxForce ? i.maxForce : 1e6;
            n.call(this, t, e, -s, s), this.axisA = i.axisA ? i.axisA.clone() : new o(1, 0, 0), 
            this.axisB = i.axisB ? i.axisB.clone() : new o(0, 1, 0), this.angle = void 0 !== i.angle ? i.angle : 0;
        }
        s.prototype = new n(), s.prototype.constructor = s;
        var r = new o(), a = new o();
        s.prototype.computeB = function(t) {
            var e = this.a, i = this.b, o = this.axisA, n = this.axisB, s = r, l = a, h = this.jacobianElementA, c = this.jacobianElementB;
            return o.cross(n, s), n.cross(o, l), h.rotational.copy(l), c.rotational.copy(s), 
            -(Math.cos(this.angle) - o.dot(n)) * e - this.computeGW() * i - t * this.computeGiMf();
        };
    }, {
        "../math/Mat3": 27,
        "../math/Vec3": 30,
        "./Equation": 20
    } ],
    19: [ function(t, e, i) {
        e.exports = s;
        var o = t("./Equation"), n = t("../math/Vec3");
        function s(t, e, i) {
            i = void 0 !== i ? i : 1e6, o.call(this, t, e, 0, i), this.restitution = 0, this.ri = new n(), 
            this.rj = new n(), this.ni = new n();
        }
        t("../math/Mat3"), s.prototype = new o(), s.prototype.constructor = s;
        var r = new n(), a = new n(), l = new n();
        s.prototype.computeB = function(t) {
            var e = this.a, i = this.b, o = this.bi, n = this.bj, s = this.ri, h = this.rj, c = r, u = a, p = o.velocity, d = o.angularVelocity, v = (o.force, 
            o.torque, n.velocity), y = n.angularVelocity, f = (n.force, n.torque, l), m = this.jacobianElementA, g = this.jacobianElementB, w = this.ni;
            s.cross(w, c), h.cross(w, u), w.negate(m.spatial), c.negate(m.rotational), g.spatial.copy(w), 
            g.rotational.copy(u), f.copy(n.position), f.vadd(h, f), f.vsub(o.position, f), f.vsub(s, f);
            var b = w.dot(f), x = this.restitution + 1;
            return -b * e - (x * v.dot(w) - x * p.dot(w) + y.dot(u) - d.dot(c)) * i - t * this.computeGiMf();
        };
        var h = new n(), c = new n(), u = new n(), p = new n(), d = new n();
        s.prototype.getImpactVelocityAlongNormal = function() {
            var t = h, e = c, i = u, o = p, n = d;
            return this.bi.position.vadd(this.ri, i), this.bj.position.vadd(this.rj, o), this.bi.getVelocityAtWorldPoint(i, t), 
            this.bj.getVelocityAtWorldPoint(o, e), t.vsub(e, n), this.ni.dot(n);
        };
    }, {
        "../math/Mat3": 27,
        "../math/Vec3": 30,
        "./Equation": 20
    } ],
    20: [ function(t, e, i) {
        e.exports = s;
        var o = t("../math/JacobianElement"), n = t("../math/Vec3");
        function s(t, e, i, n) {
            this.id = s.id++, this.minForce = void 0 === i ? -1e6 : i, this.maxForce = void 0 === n ? 1e6 : n, 
            this.bi = t, this.bj = e, this.a = 0, this.b = 0, this.eps = 0, this.jacobianElementA = new o(), 
            this.jacobianElementB = new o(), this.enabled = !0, this.setSpookParams(1e7, 4, 1 / 60);
        }
        s.prototype.constructor = s, s.id = 0, s.prototype.setSpookParams = function(t, e, i) {
            var o = e, n = t, s = i;
            this.a = 4 / (s * (1 + 4 * o)), this.b = 4 * o / (1 + 4 * o), this.eps = 4 / (s * s * n * (1 + 4 * o));
        }, s.prototype.computeB = function(t, e, i) {
            var o = this.computeGW();
            return -this.computeGq() * t - o * e - this.computeGiMf() * i;
        }, s.prototype.computeGq = function() {
            var t = this.jacobianElementA, e = this.jacobianElementB, i = this.bi, o = this.bj, n = i.position, s = o.position;
            return t.spatial.dot(n) + e.spatial.dot(s);
        };
        var r = new n();
        s.prototype.computeGW = function() {
            var t = this.jacobianElementA, e = this.jacobianElementB, i = this.bi, o = this.bj, n = i.velocity, s = o.velocity, a = i.angularVelocity || r, l = o.angularVelocity || r;
            return t.multiplyVectors(n, a) + e.multiplyVectors(s, l);
        }, s.prototype.computeGWlambda = function() {
            var t = this.jacobianElementA, e = this.jacobianElementB, i = this.bi, o = this.bj, n = i.vlambda, s = o.vlambda, a = i.wlambda || r, l = o.wlambda || r;
            return t.multiplyVectors(n, a) + e.multiplyVectors(s, l);
        };
        var a = new n(), l = new n(), h = new n(), c = new n();
        s.prototype.computeGiMf = function() {
            var t = this.jacobianElementA, e = this.jacobianElementB, i = this.bi, o = this.bj, n = i.force, s = i.torque, r = o.force, u = o.torque, p = i.invMassSolve, d = o.invMassSolve;
            return i.invInertiaWorldSolve ? i.invInertiaWorldSolve.vmult(s, h) : h.set(0, 0, 0), 
            o.invInertiaWorldSolve ? o.invInertiaWorldSolve.vmult(u, c) : c.set(0, 0, 0), n.mult(p, a), 
            r.mult(d, l), t.multiplyVectors(a, h) + e.multiplyVectors(l, c);
        };
        var u = new n();
        s.prototype.computeGiMGt = function() {
            var t = this.jacobianElementA, e = this.jacobianElementB, i = this.bi, o = this.bj, n = i.invMassSolve, s = o.invMassSolve, r = i.invInertiaWorldSolve, a = o.invInertiaWorldSolve, l = n + s;
            return r && (r.vmult(t.rotational, u), l += u.dot(t.rotational)), a && (a.vmult(e.rotational, u), 
            l += u.dot(e.rotational)), l;
        };
        var p = new n();
        new n(), new n(), new n(), new n(), new n(), s.prototype.addToWlambda = function(t) {
            var e = this.jacobianElementA, i = this.jacobianElementB, o = this.bi, n = this.bj, s = p;
            e.spatial.mult(o.invMassSolve * t, s), o.vlambda.vadd(s, o.vlambda), i.spatial.mult(n.invMassSolve * t, s), 
            n.vlambda.vadd(s, n.vlambda), o.invInertiaWorldSolve && (o.invInertiaWorldSolve.vmult(e.rotational, s), 
            s.mult(t, s), o.wlambda.vadd(s, o.wlambda)), n.invInertiaWorldSolve && (n.invInertiaWorldSolve.vmult(i.rotational, s), 
            s.mult(t, s), n.wlambda.vadd(s, n.wlambda));
        }, s.prototype.computeC = function() {
            return this.computeGiMGt() + this.eps;
        };
    }, {
        "../math/JacobianElement": 26,
        "../math/Vec3": 30
    } ],
    21: [ function(t, e, i) {
        e.exports = s;
        var o = t("./Equation"), n = t("../math/Vec3");
        function s(t, e, i) {
            o.call(this, t, e, -i, i), this.ri = new n(), this.rj = new n(), this.t = new n();
        }
        t("../math/Mat3"), s.prototype = new o(), s.prototype.constructor = s;
        var r = new n(), a = new n();
        s.prototype.computeB = function(t) {
            this.a;
            var e = this.b, i = (this.bi, this.bj, this.ri), o = this.rj, n = r, s = a, l = this.t;
            i.cross(l, n), o.cross(l, s);
            var h = this.jacobianElementA, c = this.jacobianElementB;
            return l.negate(h.spatial), n.negate(h.rotational), c.spatial.copy(l), c.rotational.copy(s), 
            -this.computeGW() * e - t * this.computeGiMf();
        };
    }, {
        "../math/Mat3": 27,
        "../math/Vec3": 30,
        "./Equation": 20
    } ],
    22: [ function(t, e, i) {
        e.exports = s;
        var o = t("../math/Vec3"), n = (t("../math/Mat3"), t("./Equation"));
        function s(t, e, i) {
            var s = void 0 !== (i = i || {}).maxForce ? i.maxForce : 1e6;
            n.call(this, t, e, -s, s), this.axisA = i.axisA ? i.axisA.clone() : new o(1, 0, 0), 
            this.axisB = i.axisB ? i.axisB.clone() : new o(0, 1, 0), this.maxAngle = Math.PI / 2;
        }
        s.prototype = new n(), s.prototype.constructor = s;
        var r = new o(), a = new o();
        s.prototype.computeB = function(t) {
            var e = this.a, i = this.b, o = this.axisA, n = this.axisB, s = r, l = a, h = this.jacobianElementA, c = this.jacobianElementB;
            return o.cross(n, s), n.cross(o, l), h.rotational.copy(l), c.rotational.copy(s), 
            -(Math.cos(this.maxAngle) - o.dot(n)) * e - this.computeGW() * i - t * this.computeGiMf();
        };
    }, {
        "../math/Mat3": 27,
        "../math/Vec3": 30,
        "./Equation": 20
    } ],
    23: [ function(t, e, i) {
        e.exports = s;
        var o = t("../math/Vec3"), n = (t("../math/Mat3"), t("./Equation"));
        function s(t, e, i) {
            i = void 0 !== i ? i : 1e6, n.call(this, t, e, -i, i), this.axisA = new o(), this.axisB = new o(), 
            this.targetVelocity = 0;
        }
        s.prototype = new n(), s.prototype.constructor = s, s.prototype.computeB = function(t) {
            this.a;
            var e = this.b, i = (this.bi, this.bj, this.axisA), o = this.axisB, n = this.jacobianElementA, s = this.jacobianElementB;
            return n.rotational.copy(i), o.negate(s.rotational), -(this.computeGW() - this.targetVelocity) * e - t * this.computeGiMf();
        };
    }, {
        "../math/Mat3": 27,
        "../math/Vec3": 30,
        "./Equation": 20
    } ],
    24: [ function(t, e, i) {
        var o = t("../utils/Utils");
        function n(t, e, i) {
            i = o.defaults(i, {
                friction: .3,
                restitution: .3,
                contactEquationStiffness: 1e7,
                contactEquationRelaxation: 3,
                frictionEquationStiffness: 1e7,
                frictionEquationRelaxation: 3
            }), this.id = n.idCounter++, this.materials = [ t, e ], this.friction = i.friction, 
            this.restitution = i.restitution, this.contactEquationStiffness = i.contactEquationStiffness, 
            this.contactEquationRelaxation = i.contactEquationRelaxation, this.frictionEquationStiffness = i.frictionEquationStiffness, 
            this.frictionEquationRelaxation = i.frictionEquationRelaxation;
        }
        e.exports = n, n.idCounter = 0;
    }, {
        "../utils/Utils": 53
    } ],
    25: [ function(t, e, i) {
        function o(t) {
            var e = "";
            "string" == typeof (t = t || {}) ? (e = t, t = {}) : "object" == l(t) && (e = ""), 
            this.name = e, this.id = o.idCounter++, this.friction = void 0 !== t.friction ? t.friction : -1, 
            this.restitution = void 0 !== t.restitution ? t.restitution : -1;
        }
        e.exports = o, o.idCounter = 0;
    }, {} ],
    26: [ function(t, e, i) {
        e.exports = n;
        var o = t("./Vec3");
        function n() {
            this.spatial = new o(), this.rotational = new o();
        }
        n.prototype.multiplyElement = function(t) {
            return t.spatial.dot(this.spatial) + t.rotational.dot(this.rotational);
        }, n.prototype.multiplyVectors = function(t, e) {
            return t.dot(this.spatial) + e.dot(this.rotational);
        };
    }, {
        "./Vec3": 30
    } ],
    27: [ function(t, e, i) {
        e.exports = n;
        var o = t("./Vec3");
        function n(t) {
            this.elements = t || [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
        }
        n.prototype.identity = function() {
            var t = this.elements;
            t[0] = 1, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 1, t[5] = 0, t[6] = 0, t[7] = 0, 
            t[8] = 1;
        }, n.prototype.setZero = function() {
            var t = this.elements;
            t[0] = 0, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = 0, t[6] = 0, t[7] = 0, 
            t[8] = 0;
        }, n.prototype.setTrace = function(t) {
            var e = this.elements;
            e[0] = t.x, e[4] = t.y, e[8] = t.z;
        }, n.prototype.getTrace = function(t) {
            t = t || new o();
            var e = this.elements;
            t.x = e[0], t.y = e[4], t.z = e[8];
        }, n.prototype.vmult = function(t, e) {
            e = e || new o();
            var i = this.elements, n = t.x, s = t.y, r = t.z;
            return e.x = i[0] * n + i[1] * s + i[2] * r, e.y = i[3] * n + i[4] * s + i[5] * r, 
            e.z = i[6] * n + i[7] * s + i[8] * r, e;
        }, n.prototype.smult = function(t) {
            for (var e = 0; e < this.elements.length; e++) this.elements[e] *= t;
        }, n.prototype.mmult = function(t, e) {
            for (var i = e || new n(), o = 0; o < 3; o++) for (var s = 0; s < 3; s++) {
                for (var r = 0, a = 0; a < 3; a++) r += t.elements[o + 3 * a] * this.elements[a + 3 * s];
                i.elements[o + 3 * s] = r;
            }
            return i;
        }, n.prototype.scale = function(t, e) {
            e = e || new n();
            for (var i = this.elements, o = e.elements, s = 0; 3 !== s; s++) o[3 * s + 0] = t.x * i[3 * s + 0], 
            o[3 * s + 1] = t.y * i[3 * s + 1], o[3 * s + 2] = t.z * i[3 * s + 2];
            return e;
        }, n.prototype.solve = function(t, e) {
            e = e || new o();
            for (var i, n = [], s = 0; s < 12; s++) n.push(0);
            for (s = 0; s < 3; s++) for (i = 0; i < 3; i++) n[s + 4 * i] = this.elements[s + 3 * i];
            n[3] = t.x, n[7] = t.y, n[11] = t.z;
            var r, a, l = 3, h = l;
            do {
                if (0 === n[(s = h - l) + 4 * s]) for (i = s + 1; i < h; i++) if (0 !== n[s + 4 * i]) {
                    r = 4;
                    do {
                        n[(a = 4 - r) + 4 * s] += n[a + 4 * i];
                    } while (--r);
                    break;
                }
                if (0 !== n[s + 4 * s]) for (i = s + 1; i < h; i++) {
                    var c = n[s + 4 * i] / n[s + 4 * s];
                    r = 4;
                    do {
                        n[(a = 4 - r) + 4 * i] = a <= s ? 0 : n[a + 4 * i] - n[a + 4 * s] * c;
                    } while (--r);
                }
            } while (--l);
            if (e.z = n[11] / n[10], e.y = (n[7] - n[6] * e.z) / n[5], e.x = (n[3] - n[2] * e.z - n[1] * e.y) / n[0], 
            isNaN(e.x) || isNaN(e.y) || isNaN(e.z) || e.x === 1 / 0 || e.y === 1 / 0 || e.z === 1 / 0) throw "Could not solve equation! Got x=[" + e.toString() + "], b=[" + t.toString() + "], A=[" + this.toString() + "]";
            return e;
        }, n.prototype.e = function(t, e, i) {
            if (void 0 === i) return this.elements[e + 3 * t];
            this.elements[e + 3 * t] = i;
        }, n.prototype.copy = function(t) {
            for (var e = 0; e < t.elements.length; e++) this.elements[e] = t.elements[e];
            return this;
        }, n.prototype.toString = function() {
            for (var t = "", e = 0; e < 9; e++) t += this.elements[e] + ",";
            return t;
        }, n.prototype.reverse = function(t) {
            t = t || new n();
            for (var e, i = [], o = 0; o < 18; o++) i.push(0);
            for (o = 0; o < 3; o++) for (e = 0; e < 3; e++) i[o + 6 * e] = this.elements[o + 3 * e];
            i[3] = 1, i[9] = 0, i[15] = 0, i[4] = 0, i[10] = 1, i[16] = 0, i[5] = 0, i[11] = 0, 
            i[17] = 1;
            var s, r, a = 3, l = a;
            do {
                if (0 === i[(o = l - a) + 6 * o]) for (e = o + 1; e < l; e++) if (0 !== i[o + 6 * e]) {
                    s = 6;
                    do {
                        i[(r = 6 - s) + 6 * o] += i[r + 6 * e];
                    } while (--s);
                    break;
                }
                if (0 !== i[o + 6 * o]) for (e = o + 1; e < l; e++) {
                    var h = i[o + 6 * e] / i[o + 6 * o];
                    s = 6;
                    do {
                        i[(r = 6 - s) + 6 * e] = r <= o ? 0 : i[r + 6 * e] - i[r + 6 * o] * h;
                    } while (--s);
                }
            } while (--a);
            o = 2;
            do {
                e = o - 1;
                do {
                    h = i[o + 6 * e] / i[o + 6 * o], s = 6;
                    do {
                        i[(r = 6 - s) + 6 * e] = i[r + 6 * e] - i[r + 6 * o] * h;
                    } while (--s);
                } while (e--);
            } while (--o);
            o = 2;
            do {
                h = 1 / i[o + 6 * o], s = 6;
                do {
                    i[(r = 6 - s) + 6 * o] = i[r + 6 * o] * h;
                } while (--s);
            } while (o--);
            o = 2;
            do {
                e = 2;
                do {
                    if (r = i[3 + e + 6 * o], isNaN(r) || r === 1 / 0) throw "Could not reverse! A=[" + this.toString() + "]";
                    t.e(o, e, r);
                } while (e--);
            } while (o--);
            return t;
        }, n.prototype.setRotationFromQuaternion = function(t) {
            var e = t.x, i = t.y, o = t.z, n = t.w, s = e + e, r = i + i, a = o + o, l = e * s, h = e * r, c = e * a, u = i * r, p = i * a, d = o * a, v = n * s, y = n * r, f = n * a, m = this.elements;
            return m[0] = 1 - (u + d), m[1] = h - f, m[2] = c + y, m[3] = h + f, m[4] = 1 - (l + d), 
            m[5] = p - v, m[6] = c - y, m[7] = p + v, m[8] = 1 - (l + u), this;
        }, n.prototype.transpose = function(t) {
            for (var e = (t = t || new n()).elements, i = this.elements, o = 0; 3 !== o; o++) for (var s = 0; 3 !== s; s++) e[3 * o + s] = i[3 * s + o];
            return t;
        };
    }, {
        "./Vec3": 30
    } ],
    28: [ function(t, e, i) {
        e.exports = n;
        var o = t("./Vec3");
        function n(t, e, i, o) {
            this.x = void 0 !== t ? t : 0, this.y = void 0 !== e ? e : 0, this.z = void 0 !== i ? i : 0, 
            this.w = void 0 !== o ? o : 1;
        }
        n.prototype.set = function(t, e, i, o) {
            this.x = t, this.y = e, this.z = i, this.w = o;
        }, n.prototype.toString = function() {
            return this.x + "," + this.y + "," + this.z + "," + this.w;
        }, n.prototype.toArray = function() {
            return [ this.x, this.y, this.z, this.w ];
        }, n.prototype.setFromAxisAngle = function(t, e) {
            var i = Math.sin(.5 * e);
            this.x = t.x * i, this.y = t.y * i, this.z = t.z * i, this.w = Math.cos(.5 * e);
        }, n.prototype.toAxisAngle = function(t) {
            t = t || new o(), this.normalize();
            var e = 2 * Math.acos(this.w), i = Math.sqrt(1 - this.w * this.w);
            return i < .001 ? (t.x = this.x, t.y = this.y, t.z = this.z) : (t.x = this.x / i, 
            t.y = this.y / i, t.z = this.z / i), [ t, e ];
        };
        var s = new o(), r = new o();
        n.prototype.setFromVectors = function(t, e) {
            if (t.isAntiparallelTo(e)) {
                var i = s, o = r;
                t.tangents(i, o), this.setFromAxisAngle(i, Math.PI);
            } else {
                var n = t.cross(e);
                this.x = n.x, this.y = n.y, this.z = n.z, this.w = Math.sqrt(Math.pow(t.norm(), 2) * Math.pow(e.norm(), 2)) + t.dot(e), 
                this.normalize();
            }
        };
        var a = new o(), l = new o(), h = new o();
        n.prototype.mult = function(t, e) {
            e = e || new n();
            var i = this.w, o = a, s = l, r = h;
            return o.set(this.x, this.y, this.z), s.set(t.x, t.y, t.z), e.w = i * t.w - o.dot(s), 
            o.cross(s, r), e.x = i * s.x + t.w * o.x + r.x, e.y = i * s.y + t.w * o.y + r.y, 
            e.z = i * s.z + t.w * o.z + r.z, e;
        }, n.prototype.inverse = function(t) {
            var e = this.x, i = this.y, o = this.z, s = this.w;
            t = t || new n(), this.conjugate(t);
            var r = 1 / (e * e + i * i + o * o + s * s);
            return t.x *= r, t.y *= r, t.z *= r, t.w *= r, t;
        }, n.prototype.conjugate = function(t) {
            return (t = t || new n()).x = -this.x, t.y = -this.y, t.z = -this.z, t.w = this.w, 
            t;
        }, n.prototype.normalize = function() {
            var t = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
            0 === t ? (this.x = 0, this.y = 0, this.z = 0, this.w = 0) : (t = 1 / t, this.x *= t, 
            this.y *= t, this.z *= t, this.w *= t);
        }, n.prototype.normalizeFast = function() {
            var t = (3 - (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)) / 2;
            0 === t ? (this.x = 0, this.y = 0, this.z = 0, this.w = 0) : (this.x *= t, this.y *= t, 
            this.z *= t, this.w *= t);
        }, n.prototype.vmult = function(t, e) {
            e = e || new o();
            var i = t.x, n = t.y, s = t.z, r = this.x, a = this.y, l = this.z, h = this.w, c = h * i + a * s - l * n, u = h * n + l * i - r * s, p = h * s + r * n - a * i, d = -r * i - a * n - l * s;
            return e.x = c * h + d * -r + u * -l - p * -a, e.y = u * h + d * -a + p * -r - c * -l, 
            e.z = p * h + d * -l + c * -a - u * -r, e;
        }, n.prototype.copy = function(t) {
            return this.x = t.x, this.y = t.y, this.z = t.z, this.w = t.w, this;
        }, n.prototype.toEuler = function(t, e) {
            var i, o, n;
            e = e || "YZX";
            var s = this.x, r = this.y, a = this.z, l = this.w;
            switch (e) {
              case "YZX":
                var h = s * r + a * l;
                if (h > .499 && (i = 2 * Math.atan2(s, l), o = Math.PI / 2, n = 0), h < -.499 && (i = -2 * Math.atan2(s, l), 
                o = -Math.PI / 2, n = 0), isNaN(i)) {
                    var c = s * s, u = r * r, p = a * a;
                    i = Math.atan2(2 * r * l - 2 * s * a, 1 - 2 * u - 2 * p), o = Math.asin(2 * h), 
                    n = Math.atan2(2 * s * l - 2 * r * a, 1 - 2 * c - 2 * p);
                }
                break;

              default:
                throw new Error("Euler order " + e + " not supported yet.");
            }
            t.y = i, t.z = o, t.x = n;
        }, n.prototype.setFromEuler = function(t, e, i, o) {
            o = o || "XYZ";
            var n = Math.cos(t / 2), s = Math.cos(e / 2), r = Math.cos(i / 2), a = Math.sin(t / 2), l = Math.sin(e / 2), h = Math.sin(i / 2);
            return "XYZ" === o ? (this.x = a * s * r + n * l * h, this.y = n * l * r - a * s * h, 
            this.z = n * s * h + a * l * r, this.w = n * s * r - a * l * h) : "YXZ" === o ? (this.x = a * s * r + n * l * h, 
            this.y = n * l * r - a * s * h, this.z = n * s * h - a * l * r, this.w = n * s * r + a * l * h) : "ZXY" === o ? (this.x = a * s * r - n * l * h, 
            this.y = n * l * r + a * s * h, this.z = n * s * h + a * l * r, this.w = n * s * r - a * l * h) : "ZYX" === o ? (this.x = a * s * r - n * l * h, 
            this.y = n * l * r + a * s * h, this.z = n * s * h - a * l * r, this.w = n * s * r + a * l * h) : "YZX" === o ? (this.x = a * s * r + n * l * h, 
            this.y = n * l * r + a * s * h, this.z = n * s * h - a * l * r, this.w = n * s * r - a * l * h) : "XZY" === o && (this.x = a * s * r - n * l * h, 
            this.y = n * l * r - a * s * h, this.z = n * s * h + a * l * r, this.w = n * s * r + a * l * h), 
            this;
        }, n.prototype.clone = function() {
            return new n(this.x, this.y, this.z, this.w);
        };
    }, {
        "./Vec3": 30
    } ],
    29: [ function(t, e, i) {
        var o = t("./Vec3"), n = t("./Quaternion");
        function s(t) {
            t = t || {}, this.position = new o(), t.position && this.position.copy(t.position), 
            this.quaternion = new n(), t.quaternion && this.quaternion.copy(t.quaternion);
        }
        e.exports = s;
        var r = new n();
        s.pointToLocalFrame = function(t, e, i, n) {
            return n = n || new o(), i.vsub(t, n), e.conjugate(r), r.vmult(n, n), n;
        }, s.prototype.pointToLocal = function(t, e) {
            return s.pointToLocalFrame(this.position, this.quaternion, t, e);
        }, s.pointToWorldFrame = function(t, e, i, n) {
            return n = n || new o(), e.vmult(i, n), n.vadd(t, n), n;
        }, s.prototype.pointToWorld = function(t, e) {
            return s.pointToWorldFrame(this.position, this.quaternion, t, e);
        }, s.prototype.vectorToWorldFrame = function(t, e) {
            return e = e || new o(), this.quaternion.vmult(t, e), e;
        }, s.vectorToWorldFrame = function(t, e, i) {
            return t.vmult(e, i), i;
        }, s.vectorToLocalFrame = function(t, e, i, n) {
            return n = n || new o(), e.w *= -1, e.vmult(i, n), e.w *= -1, n;
        };
    }, {
        "./Quaternion": 28,
        "./Vec3": 30
    } ],
    30: [ function(t, e, i) {
        e.exports = n;
        var o = t("./Mat3");
        function n(t, e, i) {
            this.x = t || 0, this.y = e || 0, this.z = i || 0;
        }
        n.ZERO = new n(0, 0, 0), n.UNIT_X = new n(1, 0, 0), n.UNIT_Y = new n(0, 1, 0), n.UNIT_Z = new n(0, 0, 1), 
        n.prototype.cross = function(t, e) {
            var i = t.x, o = t.y, s = t.z, r = this.x, a = this.y, l = this.z;
            return (e = e || new n()).x = a * s - l * o, e.y = l * i - r * s, e.z = r * o - a * i, 
            e;
        }, n.prototype.set = function(t, e, i) {
            return this.x = t, this.y = e, this.z = i, this;
        }, n.prototype.setZero = function() {
            this.x = this.y = this.z = 0;
        }, n.prototype.vadd = function(t, e) {
            if (!e) return new n(this.x + t.x, this.y + t.y, this.z + t.z);
            e.x = t.x + this.x, e.y = t.y + this.y, e.z = t.z + this.z;
        }, n.prototype.vsub = function(t, e) {
            if (!e) return new n(this.x - t.x, this.y - t.y, this.z - t.z);
            e.x = this.x - t.x, e.y = this.y - t.y, e.z = this.z - t.z;
        }, n.prototype.crossmat = function() {
            return new o([ 0, -this.z, this.y, this.z, 0, -this.x, -this.y, this.x, 0 ]);
        }, n.prototype.normalize = function() {
            var t = this.x, e = this.y, i = this.z, o = Math.sqrt(t * t + e * e + i * i);
            if (o > 0) {
                var n = 1 / o;
                this.x *= n, this.y *= n, this.z *= n;
            } else this.x = 0, this.y = 0, this.z = 0;
            return o;
        }, n.prototype.unit = function(t) {
            t = t || new n();
            var e = this.x, i = this.y, o = this.z, s = Math.sqrt(e * e + i * i + o * o);
            return s > 0 ? (s = 1 / s, t.x = e * s, t.y = i * s, t.z = o * s) : (t.x = 1, t.y = 0, 
            t.z = 0), t;
        }, n.prototype.norm = function() {
            var t = this.x, e = this.y, i = this.z;
            return Math.sqrt(t * t + e * e + i * i);
        }, n.prototype.length = n.prototype.norm, n.prototype.norm2 = function() {
            return this.dot(this);
        }, n.prototype.lengthSquared = n.prototype.norm2, n.prototype.distanceTo = function(t) {
            var e = this.x, i = this.y, o = this.z, n = t.x, s = t.y, r = t.z;
            return Math.sqrt((n - e) * (n - e) + (s - i) * (s - i) + (r - o) * (r - o));
        }, n.prototype.distanceSquared = function(t) {
            var e = this.x, i = this.y, o = this.z, n = t.x, s = t.y, r = t.z;
            return (n - e) * (n - e) + (s - i) * (s - i) + (r - o) * (r - o);
        }, n.prototype.mult = function(t, e) {
            e = e || new n();
            var i = this.x, o = this.y, s = this.z;
            return e.x = t * i, e.y = t * o, e.z = t * s, e;
        }, n.prototype.scale = n.prototype.mult, n.prototype.dot = function(t) {
            return this.x * t.x + this.y * t.y + this.z * t.z;
        }, n.prototype.isZero = function() {
            return 0 === this.x && 0 === this.y && 0 === this.z;
        }, n.prototype.negate = function(t) {
            return (t = t || new n()).x = -this.x, t.y = -this.y, t.z = -this.z, t;
        };
        var s = new n(), r = new n();
        n.prototype.tangents = function(t, e) {
            var i = this.norm();
            if (i > 0) {
                var o = s, n = 1 / i;
                o.set(this.x * n, this.y * n, this.z * n);
                var a = r;
                Math.abs(o.x) < .9 ? (a.set(1, 0, 0), o.cross(a, t)) : (a.set(0, 1, 0), o.cross(a, t)), 
                o.cross(t, e);
            } else t.set(1, 0, 0), e.set(0, 1, 0);
        }, n.prototype.toString = function() {
            return this.x + "," + this.y + "," + this.z;
        }, n.prototype.toArray = function() {
            return [ this.x, this.y, this.z ];
        }, n.prototype.copy = function(t) {
            return this.x = t.x, this.y = t.y, this.z = t.z, this;
        }, n.prototype.lerp = function(t, e, i) {
            var o = this.x, n = this.y, s = this.z;
            i.x = o + (t.x - o) * e, i.y = n + (t.y - n) * e, i.z = s + (t.z - s) * e;
        }, n.prototype.almostEquals = function(t, e) {
            return void 0 === e && (e = 1e-6), !(Math.abs(this.x - t.x) > e || Math.abs(this.y - t.y) > e || Math.abs(this.z - t.z) > e);
        }, n.prototype.almostZero = function(t) {
            return void 0 === t && (t = 1e-6), !(Math.abs(this.x) > t || Math.abs(this.y) > t || Math.abs(this.z) > t);
        };
        var a = new n();
        n.prototype.isAntiparallelTo = function(t, e) {
            return this.negate(a), a.almostEquals(t, e);
        }, n.prototype.clone = function() {
            return new n(this.x, this.y, this.z);
        };
    }, {
        "./Mat3": 27
    } ],
    31: [ function(t, e, i) {
        e.exports = c;
        var o = t("../utils/EventTarget"), n = (t("../shapes/Shape"), t("../math/Vec3")), s = t("../math/Mat3"), r = t("../math/Quaternion"), a = (t("../material/Material"), 
        t("../collision/AABB")), h = t("../shapes/Box");
        function c(t) {
            t = t || {}, o.apply(this), this.id = c.idCounter++, this.layaID, this.isTrigger = !1, 
            this.world = null, this.preStep = null, this.postStep = null, this.vlambda = new n(), 
            this.collisionFilterGroup = "number" == typeof t.collisionFilterGroup ? t.collisionFilterGroup : 1, 
            this.collisionFilterMask = "number" == typeof t.collisionFilterMask ? t.collisionFilterMask : 1, 
            this.collisionResponse = !0, this.position = new n(), t.position && this.position.copy(t.position), 
            this.previousPosition = new n(), this.initPosition = new n(), this.velocity = new n(), 
            t.velocity && this.velocity.copy(t.velocity), this.initVelocity = new n(), this.force = new n();
            var e = "number" == typeof t.mass ? t.mass : 0;
            this.mass = e, this.invMass = e > 0 ? 1 / e : 0, this.material = t.material || null, 
            this.linearDamping = "number" == typeof t.linearDamping ? t.linearDamping : .01, 
            this.type = e <= 0 ? c.STATIC : c.DYNAMIC, l(t.type) == l(c.STATIC) && (this.type = t.type), 
            this.allowSleep = void 0 === t.allowSleep || t.allowSleep, this.sleepState = 0, 
            this.sleepSpeedLimit = void 0 !== t.sleepSpeedLimit ? t.sleepSpeedLimit : .1, this.sleepTimeLimit = void 0 !== t.sleepTimeLimit ? t.sleepTimeLimit : 1, 
            this.timeLastSleepy = 0, this._wakeUpAfterNarrowphase = !1, this.torque = new n(), 
            this.quaternion = new r(), t.quaternion && this.quaternion.copy(t.quaternion), this.initQuaternion = new r(), 
            this.angularVelocity = new n(), t.angularVelocity && this.angularVelocity.copy(t.angularVelocity), 
            this.initAngularVelocity = new n(), this.interpolatedPosition = new n(), this.interpolatedQuaternion = new r(), 
            this.shapes = [], this.shapeOffsets = [], this.shapeOrientations = [], this.inertia = new n(), 
            this.invInertia = new n(), this.invInertiaWorld = new s(), this.invMassSolve = 0, 
            this.invInertiaSolve = new n(), this.invInertiaWorldSolve = new s(), this.fixedRotation = void 0 !== t.fixedRotation && t.fixedRotation, 
            this.angularDamping = void 0 !== t.angularDamping ? t.angularDamping : .01, this.aabb = new a(), 
            this.aabbNeedsUpdate = !0, this.wlambda = new n(), t.shape && this.addShape(t.shape), 
            this.updateMassProperties();
        }
        c.prototype = new o(), c.prototype.constructor = c, c.DYNAMIC = 1, c.STATIC = 2, 
        c.KINEMATIC = 4, c.AWAKE = 0, c.SLEEPY = 1, c.SLEEPING = 2, c.idCounter = 0, c.prototype.wakeUp = function() {
            var t = this.sleepState;
            this.sleepState = 0, t === c.SLEEPING && this.dispatchEvent({
                type: "wakeup"
            });
        }, c.prototype.sleep = function() {
            this.sleepState = c.SLEEPING, this.velocity.set(0, 0, 0), this.angularVelocity.set(0, 0, 0);
        }, c.sleepyEvent = {
            type: "sleepy"
        }, c.sleepEvent = {
            type: "sleep"
        }, c.prototype.sleepTick = function(t) {
            if (this.allowSleep) {
                var e = this.sleepState, i = this.velocity.norm2() + this.angularVelocity.norm2(), o = Math.pow(this.sleepSpeedLimit, 2);
                e === c.AWAKE && i < o ? (this.sleepState = c.SLEEPY, this.timeLastSleepy = t, this.dispatchEvent(c.sleepyEvent)) : e === c.SLEEPY && i > o ? this.wakeUp() : e === c.SLEEPY && t - this.timeLastSleepy > this.sleepTimeLimit && (this.sleep(), 
                this.dispatchEvent(c.sleepEvent));
            }
        }, c.prototype.updateSolveMassProperties = function() {
            this.sleepState === c.SLEEPING || this.type === c.KINEMATIC ? (this.invMassSolve = 0, 
            this.invInertiaSolve.setZero(), this.invInertiaWorldSolve.setZero()) : (this.invMassSolve = this.invMass, 
            this.invInertiaSolve.copy(this.invInertia), this.invInertiaWorldSolve.copy(this.invInertiaWorld));
        }, c.prototype.pointToLocalFrame = function(t, e) {
            return e = e || new n(), t.vsub(this.position, e), this.quaternion.conjugate().vmult(e, e), 
            e;
        }, c.prototype.vectorToLocalFrame = function(t, e) {
            return e = e || new n(), this.quaternion.conjugate().vmult(t, e), e;
        }, c.prototype.pointToWorldFrame = function(t, e) {
            return e = e || new n(), this.quaternion.vmult(t, e), e.vadd(this.position, e), 
            e;
        }, c.prototype.vectorToWorldFrame = function(t, e) {
            return e = e || new n(), this.quaternion.vmult(t, e), e;
        };
        var u = new n(), p = new r();
        c.prototype.addShape = function(t, e, i) {
            var o = new n(), s = new r();
            return e && o.copy(e), i && s.copy(i), this.shapes.push(t), this.shapeOffsets.push(o), 
            this.shapeOrientations.push(s), this.updateMassProperties(), this.updateBoundingRadius(), 
            this.aabbNeedsUpdate = !0, this;
        }, c.prototype.updateBoundingRadius = function() {
            for (var t = this.shapes, e = this.shapeOffsets, i = t.length, o = 0, n = 0; n !== i; n++) {
                var s = t[n];
                s.updateBoundingSphereRadius();
                var r = e[n].norm(), a = s.boundingSphereRadius;
                r + a > o && (o = r + a);
            }
            this.boundingRadius = o;
        };
        var d = new a();
        c.prototype.computeAABB = function() {
            for (var t = this.shapes, e = this.shapeOffsets, i = this.shapeOrientations, o = t.length, n = u, s = p, r = this.quaternion, a = this.aabb, l = d, h = 0; h !== o; h++) {
                var c = t[h];
                i[h].mult(r, s), s.vmult(e[h], n), n.vadd(this.position, n), c.calculateWorldAABB(n, s, l.lowerBound, l.upperBound), 
                0 === h ? a.copy(l) : a.extend(l);
            }
            this.aabbNeedsUpdate = !1;
        };
        var v = new s(), y = new s();
        new s(), c.prototype.updateInertiaWorld = function(t) {
            var e = this.invInertia;
            if (e.x !== e.y || e.y !== e.z || t) {
                var i = v, o = y;
                i.setRotationFromQuaternion(this.quaternion), i.transpose(o), i.scale(e, i), i.mmult(o, this.invInertiaWorld);
            }
        };
        var f = new n(), m = new n();
        c.prototype.applyForce = function(t, e) {
            if (this.type === c.DYNAMIC) {
                var i = f;
                e.vsub(this.position, i);
                var o = m;
                i.cross(t, o), this.force.vadd(t, this.force), this.torque.vadd(o, this.torque);
            }
        };
        var g = new n(), w = new n();
        c.prototype.applyLocalForce = function(t, e) {
            if (this.type === c.DYNAMIC) {
                var i = g, o = w;
                this.vectorToWorldFrame(t, i), this.pointToWorldFrame(e, o), this.applyForce(i, o);
            }
        };
        var b = new n(), x = new n(), _ = new n();
        c.prototype.applyImpulse = function(t, e) {
            if (this.type === c.DYNAMIC) {
                var i = b;
                e.vsub(this.position, i);
                var o = x;
                o.copy(t), o.mult(this.invMass, o), this.velocity.vadd(o, this.velocity);
                var n = _;
                i.cross(t, n), this.invInertiaWorld.vmult(n, n), this.angularVelocity.vadd(n, this.angularVelocity);
            }
        };
        var C = new n(), S = new n();
        c.prototype.applyLocalImpulse = function(t, e) {
            if (this.type === c.DYNAMIC) {
                var i = C, o = S;
                this.vectorToWorldFrame(t, i), this.pointToWorldFrame(e, o), this.applyImpulse(i, o);
            }
        };
        var A = new n();
        c.prototype.updateMassProperties = function() {
            var t = A;
            this.invMass = this.mass > 0 ? 1 / this.mass : 0;
            var e = this.inertia, i = this.fixedRotation;
            this.computeAABB(), t.set((this.aabb.upperBound.x - this.aabb.lowerBound.x) / 2, (this.aabb.upperBound.y - this.aabb.lowerBound.y) / 2, (this.aabb.upperBound.z - this.aabb.lowerBound.z) / 2), 
            h.calculateInertia(t, this.mass, e), this.invInertia.set(e.x > 0 && !i ? 1 / e.x : 0, e.y > 0 && !i ? 1 / e.y : 0, e.z > 0 && !i ? 1 / e.z : 0), 
            this.updateInertiaWorld(!0);
        }, c.prototype.getVelocityAtWorldPoint = function(t, e) {
            var i = new n();
            return t.vsub(this.position, i), this.angularVelocity.cross(i, e), this.velocity.vadd(e, e), 
            e;
        };
    }, {
        "../collision/AABB": 3,
        "../material/Material": 25,
        "../math/Mat3": 27,
        "../math/Quaternion": 28,
        "../math/Vec3": 30,
        "../shapes/Box": 37,
        "../shapes/Shape": 43,
        "../utils/EventTarget": 49
    } ],
    32: [ function(t, e, i) {
        t("./Body");
        var o = t("../math/Vec3"), n = t("../math/Quaternion"), s = (t("../collision/RaycastResult"), 
        t("../collision/Ray")), r = t("../objects/WheelInfo");
        function a(t) {
            this.chassisBody = t.chassisBody, this.wheelInfos = [], this.sliding = !1, this.world = null, 
            this.indexRightAxis = void 0 !== t.indexRightAxis ? t.indexRightAxis : 1, this.indexForwardAxis = void 0 !== t.indexForwardAxis ? t.indexForwardAxis : 0, 
            this.indexUpAxis = void 0 !== t.indexUpAxis ? t.indexUpAxis : 2;
        }
        e.exports = a, new o(), new o(), new o();
        var l = new o(), h = new o(), c = new o();
        new s(), a.prototype.addWheel = function(t) {
            var e = new r(t = t || {}), i = this.wheelInfos.length;
            return this.wheelInfos.push(e), i;
        }, a.prototype.setSteeringValue = function(t, e) {
            this.wheelInfos[e].steering = t;
        }, new o(), a.prototype.applyEngineForce = function(t, e) {
            this.wheelInfos[e].engineForce = t;
        }, a.prototype.setBrake = function(t, e) {
            this.wheelInfos[e].brake = t;
        }, a.prototype.addToWorld = function(t) {
            this.constraints, t.add(this.chassisBody);
            var e = this;
            this.preStepCallback = function() {
                e.updateVehicle(t.dt);
            }, t.addEventListener("preStep", this.preStepCallback), this.world = t;
        }, a.prototype.getVehicleAxisWorld = function(t, e) {
            e.set(0 === t ? 1 : 0, 1 === t ? 1 : 0, 2 === t ? 1 : 0), this.chassisBody.vectorToWorldFrame(e, e);
        }, a.prototype.updateVehicle = function(t) {
            for (var e = this.wheelInfos, i = e.length, n = this.chassisBody, s = 0; s < i; s++) this.updateWheelTransform(s);
            this.currentVehicleSpeedKmHour = 3.6 * n.velocity.norm();
            var r = new o();
            for (this.getVehicleAxisWorld(this.indexForwardAxis, r), r.dot(n.velocity) < 0 && (this.currentVehicleSpeedKmHour *= -1), 
            s = 0; s < i; s++) this.castRay(e[s]);
            this.updateSuspension(t);
            var a = new o(), l = new o();
            for (s = 0; s < i; s++) {
                var h = (d = e[s]).suspensionForce;
                h > d.maxSuspensionForce && (h = d.maxSuspensionForce), d.raycastResult.hitNormalWorld.scale(h * t, a), 
                d.raycastResult.hitPointWorld.vsub(n.position, l), n.applyImpulse(a, d.raycastResult.hitPointWorld);
            }
            this.updateFriction(t);
            var c = new o(), u = new o(), p = new o();
            for (s = 0; s < i; s++) {
                var d = e[s];
                n.getVelocityAtWorldPoint(d.chassisConnectionPointWorld, p);
                var v = 1;
                switch (this.indexUpAxis) {
                  case 1:
                    v = -1;
                }
                if (d.isInContact) {
                    this.getVehicleAxisWorld(this.indexForwardAxis, u);
                    var y = u.dot(d.raycastResult.hitNormalWorld);
                    d.raycastResult.hitNormalWorld.scale(y, c), u.vsub(c, u);
                    var f = u.dot(p);
                    d.deltaRotation = v * f * t / d.radius;
                }
                !d.sliding && d.isInContact || 0 === d.engineForce || !d.useCustomSlidingRotationalSpeed || (d.deltaRotation = (d.engineForce > 0 ? 1 : -1) * d.customSlidingRotationalSpeed * t), 
                Math.abs(d.brake) > Math.abs(d.engineForce) && (d.deltaRotation = 0), d.rotation += d.deltaRotation, 
                d.deltaRotation *= .99;
            }
        }, a.prototype.updateSuspension = function(t) {
            for (var e = this.chassisBody.mass, i = this.wheelInfos, o = i.length, n = 0; n < o; n++) {
                var s = i[n];
                if (s.isInContact) {
                    var r, a = s.suspensionRestLength - s.suspensionLength;
                    r = s.suspensionStiffness * a * s.clippedInvContactDotSuspension;
                    var l = s.suspensionRelativeVelocity;
                    r -= (l < 0 ? s.dampingCompression : s.dampingRelaxation) * l, s.suspensionForce = r * e, 
                    s.suspensionForce < 0 && (s.suspensionForce = 0);
                } else s.suspensionForce = 0;
            }
        }, a.prototype.removeFromWorld = function(t) {
            this.constraints, t.remove(this.chassisBody), t.removeEventListener("preStep", this.preStepCallback), 
            this.world = null;
        };
        var u = new o(), p = new o();
        a.prototype.castRay = function(t) {
            var e = u, i = p;
            this.updateWheelTransformWorld(t);
            var n = this.chassisBody, s = -1, r = t.suspensionRestLength + t.radius;
            t.directionWorld.scale(r, e);
            var a = t.chassisConnectionPointWorld;
            a.vadd(e, i);
            var l = t.raycastResult;
            l.reset();
            var h = n.collisionResponse;
            n.collisionResponse = !1, this.world.rayTest(a, i, l), n.collisionResponse = h;
            var c = l.body;
            if (t.raycastResult.groundObject = 0, c) {
                s = l.distance, t.raycastResult.hitNormalWorld = l.hitNormalWorld, t.isInContact = !0;
                var d = l.distance;
                t.suspensionLength = d - t.radius;
                var v = t.suspensionRestLength - t.maxSuspensionTravel, y = t.suspensionRestLength + t.maxSuspensionTravel;
                t.suspensionLength < v && (t.suspensionLength = v), t.suspensionLength > y && (t.suspensionLength = y, 
                t.raycastResult.reset());
                var f = t.raycastResult.hitNormalWorld.dot(t.directionWorld), m = new o();
                n.getVelocityAtWorldPoint(t.raycastResult.hitPointWorld, m);
                var g = t.raycastResult.hitNormalWorld.dot(m);
                if (f >= -.1) t.suspensionRelativeVelocity = 0, t.clippedInvContactDotSuspension = 10; else {
                    var w = -1 / f;
                    t.suspensionRelativeVelocity = g * w, t.clippedInvContactDotSuspension = w;
                }
            } else t.suspensionLength = t.suspensionRestLength + 0 * t.maxSuspensionTravel, 
            t.suspensionRelativeVelocity = 0, t.directionWorld.scale(-1, t.raycastResult.hitNormalWorld), 
            t.clippedInvContactDotSuspension = 1;
            return s;
        }, a.prototype.updateWheelTransformWorld = function(t) {
            t.isInContact = !1;
            var e = this.chassisBody;
            e.pointToWorldFrame(t.chassisConnectionPointLocal, t.chassisConnectionPointWorld), 
            e.vectorToWorldFrame(t.directionLocal, t.directionWorld), e.vectorToWorldFrame(t.axleLocal, t.axleWorld);
        }, a.prototype.updateWheelTransform = function(t) {
            var e = l, i = h, o = c, s = this.wheelInfos[t];
            this.updateWheelTransformWorld(s), s.directionLocal.scale(-1, e), i.copy(s.axleLocal), 
            e.cross(i, o), o.normalize(), i.normalize();
            var r = s.steering, a = new n();
            a.setFromAxisAngle(e, r);
            var u = new n();
            u.setFromAxisAngle(i, s.rotation);
            var p = s.worldTransform.quaternion;
            this.chassisBody.quaternion.mult(a, p), p.mult(u, p), p.normalize();
            var d = s.worldTransform.position;
            d.copy(s.directionWorld), d.scale(s.suspensionLength, d), d.vadd(s.chassisConnectionPointWorld, d);
        };
        var d = [ new o(1, 0, 0), new o(0, 1, 0), new o(0, 0, 1) ];
        a.prototype.getWheelTransformWorld = function(t) {
            return this.wheelInfos[t].worldTransform;
        };
        var v = new o(), y = [], f = [];
        a.prototype.updateFriction = function(t) {
            for (var e = v, i = this.wheelInfos, n = i.length, s = this.chassisBody, r = f, a = y, l = 0; l < n; l++) p = (E = i[l]).raycastResult.body, 
            E.sideImpulse = 0, E.forwardImpulse = 0, r[l] || (r[l] = new o()), a[l] || (a[l] = new o());
            for (l = 0; l < n; l++) if (p = (E = i[l]).raycastResult.body) {
                var h = a[l];
                this.getWheelTransformWorld(l).vectorToWorldFrame(d[this.indexRightAxis], h);
                var c = E.raycastResult.hitNormalWorld, u = h.dot(c);
                c.scale(u, e), h.vsub(e, h), h.normalize(), c.cross(h, r[l]), r[l].normalize(), 
                E.sideImpulse = R(s, E.raycastResult.hitPointWorld, p, E.raycastResult.hitPointWorld, h), 
                E.sideImpulse *= 1;
            }
            for (this.sliding = !1, l = 0; l < n; l++) {
                var p = (E = i[l]).raycastResult.body, m = 0;
                if (E.slipInfo = 1, p) {
                    var g = E.brake ? E.brake : 0;
                    m = b(s, p, E.raycastResult.hitPointWorld, r[l], g);
                    var w = g / (m += E.engineForce * t);
                    E.slipInfo *= w;
                }
                if (E.forwardImpulse = 0, E.skidInfo = 1, p) {
                    E.skidInfo = 1;
                    var x = E.suspensionForce * t * E.frictionSlip, _ = x * x;
                    E.forwardImpulse = m;
                    var C = .5 * E.forwardImpulse, S = 1 * E.sideImpulse, A = C * C + S * S;
                    E.sliding = !1, A > _ && (this.sliding = !0, E.sliding = !0, w = x / Math.sqrt(A), 
                    E.skidInfo *= w);
                }
            }
            if (this.sliding) for (l = 0; l < n; l++) 0 !== (E = i[l]).sideImpulse && E.skidInfo < 1 && (E.forwardImpulse *= E.skidInfo, 
            E.sideImpulse *= E.skidInfo);
            for (l = 0; l < n; l++) {
                var E = i[l], T = new o();
                if (T.copy(E.raycastResult.hitPointWorld), 0 !== E.forwardImpulse) {
                    var B = new o();
                    r[l].scale(E.forwardImpulse, B), s.applyImpulse(B, T);
                }
                if (0 !== E.sideImpulse) {
                    p = E.raycastResult.body;
                    var P = new o();
                    P.copy(E.raycastResult.hitPointWorld);
                    var N = new o();
                    a[l].scale(E.sideImpulse, N), s.pointToLocalFrame(T, T), T["xyz"[this.indexUpAxis]] *= E.rollInfluence, 
                    s.pointToWorldFrame(T, T), s.applyImpulse(N, T), N.scale(-1, N), p.applyImpulse(N, P);
                }
            }
        };
        var m = new o(), g = new o(), w = new o();
        function b(t, e, i, o, n) {
            var s = 0, r = i, a = m, l = g, h = w;
            return t.getVelocityAtWorldPoint(r, a), e.getVelocityAtWorldPoint(r, l), a.vsub(l, h), 
            n < (s = -o.dot(h) * (1 / (A(t, i, o) + A(e, i, o)))) && (s = n), s < -n && (s = -n), 
            s;
        }
        var x = new o(), _ = new o(), C = new o(), S = new o();
        function A(t, e, i) {
            var o = x, n = _, s = C, r = S;
            return e.vsub(t.position, o), o.cross(i, n), t.invInertiaWorld.vmult(n, r), r.cross(o, s), 
            t.invMass + i.dot(s);
        }
        var E = new o(), T = new o(), B = new o();
        function R(t, e, i, o, n, s) {
            if (n.norm2() > 1.1) return 0;
            var r = E, a = T, l = B;
            return t.getVelocityAtWorldPoint(e, r), i.getVelocityAtWorldPoint(o, a), r.vsub(a, l), 
            -.2 * n.dot(l) * (1 / (t.invMass + i.invMass));
        }
    }, {
        "../collision/Ray": 9,
        "../collision/RaycastResult": 10,
        "../math/Quaternion": 28,
        "../math/Vec3": 30,
        "../objects/WheelInfo": 36,
        "./Body": 31
    } ],
    33: [ function(t, e, i) {
        var o = t("./Body"), n = t("../shapes/Sphere"), s = t("../shapes/Box"), r = t("../math/Vec3"), a = t("../constraints/HingeConstraint");
        function l(t) {
            if (this.wheelBodies = [], this.coordinateSystem = void 0 === t.coordinateSystem ? new r(1, 2, 3) : t.coordinateSystem.clone(), 
            this.chassisBody = t.chassisBody, !this.chassisBody) {
                var e = new s(new r(5, 2, .5));
                this.chassisBody = new o(1, e);
            }
            this.constraints = [], this.wheelAxes = [], this.wheelForces = [];
        }
        e.exports = l, l.prototype.addWheel = function(t) {
            var e = (t = t || {}).body;
            e || (e = new o(1, new n(1.2))), this.wheelBodies.push(e), this.wheelForces.push(0), 
            new r();
            var i = void 0 !== t.position ? t.position.clone() : new r(), s = new r();
            this.chassisBody.pointToWorldFrame(i, s), e.position.set(s.x, s.y, s.z);
            var l = void 0 !== t.axis ? t.axis.clone() : new r(0, 1, 0);
            this.wheelAxes.push(l);
            var h = new a(this.chassisBody, e, {
                pivotA: i,
                axisA: l,
                pivotB: r.ZERO,
                axisB: l,
                collideConnected: !1
            });
            return this.constraints.push(h), this.wheelBodies.length - 1;
        }, l.prototype.setSteeringValue = function(t, e) {
            var i = this.wheelAxes[e], o = Math.cos(t), n = Math.sin(t), s = i.x, r = i.y;
            this.constraints[e].axisA.set(o * s - n * r, n * s + o * r, 0);
        }, l.prototype.setMotorSpeed = function(t, e) {
            var i = this.constraints[e];
            i.enableMotor(), i.motorTargetVelocity = t;
        }, l.prototype.disableMotor = function(t) {
            this.constraints[t].disableMotor();
        };
        var h = new r();
        l.prototype.setWheelForce = function(t, e) {
            this.wheelForces[e] = t;
        }, l.prototype.applyWheelForce = function(t, e) {
            var i = this.wheelAxes[e], o = this.wheelBodies[e], n = o.torque;
            i.scale(t, h), o.vectorToWorldFrame(h, h), n.vadd(h, n);
        }, l.prototype.addToWorld = function(t) {
            for (var e = this.constraints, i = this.wheelBodies.concat([ this.chassisBody ]), o = 0; o < i.length; o++) t.add(i[o]);
            for (o = 0; o < e.length; o++) t.addConstraint(e[o]);
            t.addEventListener("preStep", this._update.bind(this));
        }, l.prototype._update = function() {
            for (var t = this.wheelForces, e = 0; e < t.length; e++) this.applyWheelForce(t[e], e);
        }, l.prototype.removeFromWorld = function(t) {
            for (var e = this.constraints, i = this.wheelBodies.concat([ this.chassisBody ]), o = 0; o < i.length; o++) t.remove(i[o]);
            for (o = 0; o < e.length; o++) t.removeConstraint(e[o]);
        };
        var c = new r();
        l.prototype.getWheelSpeed = function(t) {
            var e = this.wheelAxes[t], i = this.wheelBodies[t].angularVelocity;
            return this.chassisBody.vectorToWorldFrame(e, c), i.dot(c);
        };
    }, {
        "../constraints/HingeConstraint": 15,
        "../math/Vec3": 30,
        "../shapes/Box": 37,
        "../shapes/Sphere": 44,
        "./Body": 31
    } ],
    34: [ function(t, e, i) {
        e.exports = n, t("../shapes/Shape");
        var o = t("../math/Vec3");
        function n() {
            this.particles = [], this.density = 1, this.smoothingRadius = 1, this.speedOfSound = 1, 
            this.viscosity = .01, this.eps = 1e-6, this.pressures = [], this.densities = [], 
            this.neighbors = [];
        }
        t("../math/Quaternion"), t("../shapes/Particle"), t("../objects/Body"), t("../material/Material"), 
        n.prototype.add = function(t) {
            this.particles.push(t), this.neighbors.length < this.particles.length && this.neighbors.push([]);
        }, n.prototype.remove = function(t) {
            var e = this.particles.indexOf(t);
            -1 !== e && (this.particles.splice(e, 1), this.neighbors.length > this.particles.length && this.neighbors.pop());
        };
        var s = new o();
        n.prototype.getNeighbors = function(t, e) {
            for (var i = this.particles.length, o = t.id, n = this.smoothingRadius * this.smoothingRadius, r = s, a = 0; a !== i; a++) {
                var l = this.particles[a];
                l.position.vsub(t.position, r), o !== l.id && r.norm2() < n && e.push(l);
            }
        };
        var r = new o(), a = new o(), l = new o(), h = new o(), c = new o(), u = new o();
        n.prototype.update = function() {
            for (var t = this.particles.length, e = r, i = this.speedOfSound, o = this.eps, n = 0; n !== t; n++) {
                var s = this.particles[n];
                (S = this.neighbors[n]).length = 0, this.getNeighbors(s, S), S.push(this.particles[n]);
                for (var p = S.length, d = 0, v = 0; v !== p; v++) {
                    s.position.vsub(S[v].position, e);
                    var y = e.norm(), f = this.w(y);
                    d += S[v].mass * f;
                }
                this.densities[n] = d, this.pressures[n] = i * i * (this.densities[n] - this.density);
            }
            var m = a, g = l, w = h, b = c, x = u;
            for (n = 0; n !== t; n++) {
                var _, C, S, A = this.particles[n];
                for (m.set(0, 0, 0), g.set(0, 0, 0), p = (S = this.neighbors[n]).length, v = 0; v !== p; v++) {
                    var E = S[v];
                    A.position.vsub(E.position, b);
                    var T = b.norm();
                    _ = -E.mass * (this.pressures[n] / (this.densities[n] * this.densities[n] + o) + this.pressures[v] / (this.densities[v] * this.densities[v] + o)), 
                    this.gradw(b, w), w.mult(_, w), m.vadd(w, m), E.velocity.vsub(A.velocity, x), x.mult(1 / (1e-4 + this.densities[n] * this.densities[v]) * this.viscosity * E.mass, x), 
                    C = this.nablaw(T), x.mult(C, x), g.vadd(x, g);
                }
                g.mult(A.mass, g), m.mult(A.mass, m), A.force.vadd(g, A.force), A.force.vadd(m, A.force);
            }
        }, n.prototype.w = function(t) {
            var e = this.smoothingRadius;
            return 315 / (64 * Math.PI * Math.pow(e, 9)) * Math.pow(e * e - t * t, 3);
        }, n.prototype.gradw = function(t, e) {
            var i = t.norm(), o = this.smoothingRadius;
            t.mult(945 / (32 * Math.PI * Math.pow(o, 9)) * Math.pow(o * o - i * i, 2), e);
        }, n.prototype.nablaw = function(t) {
            var e = this.smoothingRadius;
            return 945 / (32 * Math.PI * Math.pow(e, 9)) * (e * e - t * t) * (7 * t * t - 3 * e * e);
        };
    }, {
        "../material/Material": 25,
        "../math/Quaternion": 28,
        "../math/Vec3": 30,
        "../objects/Body": 31,
        "../shapes/Particle": 41,
        "../shapes/Shape": 43
    } ],
    35: [ function(t, e, i) {
        var o = t("../math/Vec3");
        function n(t, e, i) {
            i = i || {}, this.restLength = "number" == typeof i.restLength ? i.restLength : 1, 
            this.stiffness = i.stiffness || 100, this.damping = i.damping || 1, this.bodyA = t, 
            this.bodyB = e, this.localAnchorA = new o(), this.localAnchorB = new o(), i.localAnchorA && this.localAnchorA.copy(i.localAnchorA), 
            i.localAnchorB && this.localAnchorB.copy(i.localAnchorB), i.worldAnchorA && this.setWorldAnchorA(i.worldAnchorA), 
            i.worldAnchorB && this.setWorldAnchorB(i.worldAnchorB);
        }
        e.exports = n, n.prototype.setWorldAnchorA = function(t) {
            this.bodyA.pointToLocalFrame(t, this.localAnchorA);
        }, n.prototype.setWorldAnchorB = function(t) {
            this.bodyB.pointToLocalFrame(t, this.localAnchorB);
        }, n.prototype.getWorldAnchorA = function(t) {
            this.bodyA.pointToWorldFrame(this.localAnchorA, t);
        }, n.prototype.getWorldAnchorB = function(t) {
            this.bodyB.pointToWorldFrame(this.localAnchorB, t);
        };
        var s = new o(), r = new o(), a = new o(), l = new o(), h = new o(), c = new o(), u = new o(), p = new o(), d = new o(), v = new o(), y = new o();
        n.prototype.applyForce = function() {
            var t = this.stiffness, e = this.damping, i = this.restLength, o = this.bodyA, n = this.bodyB, f = s, m = r, g = a, w = l, b = y, x = h, _ = c, C = u, S = p, A = d, E = v;
            this.getWorldAnchorA(x), this.getWorldAnchorB(_), x.vsub(o.position, C), _.vsub(n.position, S), 
            _.vsub(x, f);
            var T = f.norm();
            m.copy(f), m.normalize(), n.velocity.vsub(o.velocity, g), n.angularVelocity.cross(S, b), 
            g.vadd(b, g), o.angularVelocity.cross(C, b), g.vsub(b, g), m.mult(-t * (T - i) - e * g.dot(m), w), 
            o.force.vsub(w, o.force), n.force.vadd(w, n.force), C.cross(w, A), S.cross(w, E), 
            o.torque.vsub(A, o.torque), n.torque.vadd(E, n.torque);
        };
    }, {
        "../math/Vec3": 30
    } ],
    36: [ function(t, e, i) {
        var o = t("../math/Vec3"), n = t("../math/Transform"), s = t("../collision/RaycastResult"), r = t("../utils/Utils");
        function a(t) {
            t = r.defaults(t, {
                chassisConnectionPointLocal: new o(),
                chassisConnectionPointWorld: new o(),
                directionLocal: new o(),
                directionWorld: new o(),
                axleLocal: new o(),
                axleWorld: new o(),
                suspensionRestLength: 1,
                suspensionMaxLength: 2,
                radius: 1,
                suspensionStiffness: 100,
                dampingCompression: 10,
                dampingRelaxation: 10,
                frictionSlip: 1e4,
                steering: 0,
                rotation: 0,
                deltaRotation: 0,
                rollInfluence: .01,
                maxSuspensionForce: Number.MAX_VALUE,
                isFrontWheel: !0,
                clippedInvContactDotSuspension: 1,
                suspensionRelativeVelocity: 0,
                suspensionForce: 0,
                skidInfo: 0,
                suspensionLength: 0,
                maxSuspensionTravel: 1,
                useCustomSlidingRotationalSpeed: !1,
                customSlidingRotationalSpeed: -.1
            }), this.maxSuspensionTravel = t.maxSuspensionTravel, this.customSlidingRotationalSpeed = t.customSlidingRotationalSpeed, 
            this.useCustomSlidingRotationalSpeed = t.useCustomSlidingRotationalSpeed, this.sliding = !1, 
            this.chassisConnectionPointLocal = t.chassisConnectionPointLocal.clone(), this.chassisConnectionPointWorld = t.chassisConnectionPointWorld.clone(), 
            this.directionLocal = t.directionLocal.clone(), this.directionWorld = t.directionWorld.clone(), 
            this.axleLocal = t.axleLocal.clone(), this.axleWorld = t.axleWorld.clone(), this.suspensionRestLength = t.suspensionRestLength, 
            this.suspensionMaxLength = t.suspensionMaxLength, this.radius = t.radius, this.suspensionStiffness = t.suspensionStiffness, 
            this.dampingCompression = t.dampingCompression, this.dampingRelaxation = t.dampingRelaxation, 
            this.frictionSlip = t.frictionSlip, this.steering = 0, this.rotation = 0, this.deltaRotation = 0, 
            this.rollInfluence = t.rollInfluence, this.maxSuspensionForce = t.maxSuspensionForce, 
            this.engineForce = 0, this.brake = 0, this.isFrontWheel = t.isFrontWheel, this.clippedInvContactDotSuspension = 1, 
            this.suspensionRelativeVelocity = 0, this.suspensionForce = 0, this.skidInfo = 0, 
            this.suspensionLength = 0, this.sideImpulse = 0, this.forwardImpulse = 0, this.raycastResult = new s(), 
            this.worldTransform = new n(), this.isInContact = !1;
        }
        e.exports = a;
        var l = new o(), h = new o();
        l = new o(), a.prototype.updateWheel = function(t) {
            var e = this.raycastResult;
            if (this.isInContact) {
                var i = e.hitNormalWorld.dot(e.directionWorld);
                e.hitPointWorld.vsub(t.position, h), t.getVelocityAtWorldPoint(h, l);
                var o = e.hitNormalWorld.dot(l);
                if (i >= -.1) this.suspensionRelativeVelocity = 0, this.clippedInvContactDotSuspension = 10; else {
                    var n = -1 / i;
                    this.suspensionRelativeVelocity = o * n, this.clippedInvContactDotSuspension = n;
                }
            } else e.suspensionLength = this.suspensionRestLength, this.suspensionRelativeVelocity = 0, 
            e.directionWorld.scale(-1, e.hitNormalWorld), this.clippedInvContactDotSuspension = 1;
        };
    }, {
        "../collision/RaycastResult": 10,
        "../math/Transform": 29,
        "../math/Vec3": 30,
        "../utils/Utils": 53
    } ],
    37: [ function(t, e, i) {
        e.exports = r;
        var o = t("./Shape"), n = t("../math/Vec3"), s = t("./ConvexPolyhedron");
        function r(t) {
            o.call(this), this.type = o.types.BOX, this.halfExtents = t, this.convexPolyhedronRepresentation = null, 
            this.updateConvexPolyhedronRepresentation(), this.updateBoundingSphereRadius();
        }
        r.prototype = new o(), r.prototype.constructor = r, r.prototype.updateConvexPolyhedronRepresentation = function() {
            var t = this.halfExtents.x, e = this.halfExtents.y, i = this.halfExtents.z, o = n, r = [ new o(-t, -e, -i), new o(t, -e, -i), new o(t, e, -i), new o(-t, e, -i), new o(-t, -e, i), new o(t, -e, i), new o(t, e, i), new o(-t, e, i) ], a = (new o(0, 0, 1), 
            new o(0, 1, 0), new o(1, 0, 0), new s(r, [ [ 3, 2, 1, 0 ], [ 4, 5, 6, 7 ], [ 5, 4, 0, 1 ], [ 2, 3, 7, 6 ], [ 0, 4, 7, 3 ], [ 1, 2, 6, 5 ] ]));
            this.convexPolyhedronRepresentation = a, a.material = this.material;
        }, r.prototype.calculateLocalInertia = function(t, e) {
            return e = e || new n(), r.calculateInertia(this.halfExtents, t, e), e;
        }, r.calculateInertia = function(t, e, i) {
            var o = t;
            i.x = 1 / 12 * e * (2 * o.y * 2 * o.y + 2 * o.z * 2 * o.z), i.y = 1 / 12 * e * (2 * o.x * 2 * o.x + 2 * o.z * 2 * o.z), 
            i.z = 1 / 12 * e * (2 * o.y * 2 * o.y + 2 * o.x * 2 * o.x);
        }, r.prototype.getSideNormals = function(t, e) {
            var i = t, o = this.halfExtents;
            if (i[0].set(o.x, 0, 0), i[1].set(0, o.y, 0), i[2].set(0, 0, o.z), i[3].set(-o.x, 0, 0), 
            i[4].set(0, -o.y, 0), i[5].set(0, 0, -o.z), void 0 !== e) for (var n = 0; n !== i.length; n++) e.vmult(i[n], i[n]);
            return i;
        }, r.prototype.volume = function() {
            return 8 * this.halfExtents.x * this.halfExtents.y * this.halfExtents.z;
        }, r.prototype.updateBoundingSphereRadius = function() {
            this.boundingSphereRadius = this.halfExtents.norm();
        };
        var a = new n();
        new n(), r.prototype.forEachWorldCorner = function(t, e, i) {
            for (var o = this.halfExtents, n = [ [ o.x, o.y, o.z ], [ -o.x, o.y, o.z ], [ -o.x, -o.y, o.z ], [ -o.x, -o.y, -o.z ], [ o.x, -o.y, -o.z ], [ o.x, o.y, -o.z ], [ -o.x, o.y, -o.z ], [ o.x, -o.y, o.z ] ], s = 0; s < n.length; s++) a.set(n[s][0], n[s][1], n[s][2]), 
            e.vmult(a, a), t.vadd(a, a), i(a.x, a.y, a.z);
        };
        var l = [ new n(), new n(), new n(), new n(), new n(), new n(), new n(), new n() ];
        r.prototype.calculateWorldAABB = function(t, e, i, o) {
            var n = this.halfExtents;
            l[0].set(n.x, n.y, n.z), l[1].set(-n.x, n.y, n.z), l[2].set(-n.x, -n.y, n.z), l[3].set(-n.x, -n.y, -n.z), 
            l[4].set(n.x, -n.y, -n.z), l[5].set(n.x, n.y, -n.z), l[6].set(-n.x, n.y, -n.z), 
            l[7].set(n.x, -n.y, n.z);
            var s = l[0];
            e.vmult(s, s), t.vadd(s, s), o.copy(s), i.copy(s);
            for (var r = 1; r < 8; r++) {
                s = l[r], e.vmult(s, s), t.vadd(s, s);
                var a = s.x, h = s.y, c = s.z;
                a > o.x && (o.x = a), h > o.y && (o.y = h), c > o.z && (o.z = c), a < i.x && (i.x = a), 
                h < i.y && (i.y = h), c < i.z && (i.z = c);
            }
        };
    }, {
        "../math/Vec3": 30,
        "./ConvexPolyhedron": 38,
        "./Shape": 43
    } ],
    38: [ function(t, e, i) {
        e.exports = r;
        var o = t("./Shape"), n = t("../math/Vec3"), s = (t("../math/Quaternion"), t("../math/Transform"));
        function r(t, e, i) {
            o.call(this), this.type = o.types.CONVEXPOLYHEDRON, this.vertices = t || [], this.worldVertices = [], 
            this.worldVerticesNeedsUpdate = !0, this.faces = e || [], this.faceNormals = [], 
            this.computeNormals(), this.worldFaceNormalsNeedsUpdate = !0, this.worldFaceNormals = [], 
            this.uniqueEdges = [], this.uniqueAxes = i ? i.slice() : null, this.computeEdges(), 
            this.updateBoundingSphereRadius();
        }
        r.prototype = new o(), r.prototype.constructor = r;
        var a = new n();
        r.prototype.computeEdges = function() {
            var t = this.faces, e = this.vertices, i = (e.length, this.uniqueEdges);
            i.length = 0;
            for (var o = a, n = 0; n !== t.length; n++) for (var s = t[n], r = s.length, l = 0; l !== r; l++) {
                var h = (l + 1) % r;
                e[s[l]].vsub(e[s[h]], o), o.normalize();
                for (var c = !1, u = 0; u !== i.length; u++) if (i[u].almostEquals(o) || i[u].almostEquals(o)) {
                    c = !0;
                    break;
                }
                c || i.push(o.clone());
            }
        }, r.prototype.computeNormals = function() {
            this.faceNormals.length = this.faces.length;
            for (var t = 0; t < this.faces.length; t++) {
                for (var e = 0; e < this.faces[t].length; e++) if (!this.vertices[this.faces[t][e]]) throw new Error("Vertex " + this.faces[t][e] + " not found!");
                var i = this.faceNormals[t] || new n();
                this.getFaceNormal(t, i), i.negate(i), this.faceNormals[t] = i;
                var o = this.vertices[this.faces[t][0]];
                if (i.dot(o) < 0) for (console.error(".faceNormals[" + t + "] = Vec3(" + i.toString() + ") looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule."), 
                e = 0; e < this.faces[t].length; e++) console.warn(".vertices[" + this.faces[t][e] + "] = Vec3(" + this.vertices[this.faces[t][e]].toString() + ")");
            }
        };
        var l = new n(), h = new n();
        r.computeNormal = function(t, e, i, o) {
            e.vsub(t, h), i.vsub(e, l), l.cross(h, o), o.isZero() || o.normalize();
        }, r.prototype.getFaceNormal = function(t, e) {
            var i = this.faces[t], o = this.vertices[i[0]], n = this.vertices[i[1]], s = this.vertices[i[2]];
            return r.computeNormal(o, n, s, e);
        };
        var c = new n();
        r.prototype.clipAgainstHull = function(t, e, i, o, s, r, a, l, h) {
            for (var u = c, p = -1, d = -Number.MAX_VALUE, v = 0; v < i.faces.length; v++) {
                u.copy(i.faceNormals[v]), s.vmult(u, u);
                var y = u.dot(r);
                y > d && (d = y, p = v);
            }
            for (var f = [], m = i.faces[p], g = m.length, w = 0; w < g; w++) {
                var b = i.vertices[m[w]], x = new n();
                x.copy(b), s.vmult(x, x), o.vadd(x, x), f.push(x);
            }
            p >= 0 && this.clipFaceAgainstHull(r, t, e, f, a, l, h);
        };
        var u = new n(), p = new n(), d = new n(), v = new n(), y = new n(), f = new n();
        r.prototype.findSeparatingAxis = function(t, e, i, o, n, s, r, a) {
            var l = u, h = p, c = d, m = v, g = y, w = f, b = Number.MAX_VALUE;
            if (this.uniqueAxes) for (_ = 0; _ !== this.uniqueAxes.length; _++) {
                if (i.vmult(this.uniqueAxes[_], l), !1 === (A = this.testSepAxis(l, t, e, i, o, n))) return !1;
                A < b && (b = A, s.copy(l));
            } else for (var x = r ? r.length : this.faces.length, _ = 0; _ < x; _++) {
                var C = r ? r[_] : _;
                if (l.copy(this.faceNormals[C]), i.vmult(l, l), !1 === (A = this.testSepAxis(l, t, e, i, o, n))) return !1;
                A < b && (b = A, s.copy(l));
            }
            if (t.uniqueAxes) for (_ = 0; _ !== t.uniqueAxes.length; _++) {
                if (n.vmult(t.uniqueAxes[_], h), !1 === (A = this.testSepAxis(h, t, e, i, o, n))) return !1;
                A < b && (b = A, s.copy(h));
            } else {
                var S = a ? a.length : t.faces.length;
                for (_ = 0; _ < S; _++) {
                    var A;
                    if (C = a ? a[_] : _, h.copy(t.faceNormals[C]), n.vmult(h, h), !1 === (A = this.testSepAxis(h, t, e, i, o, n))) return !1;
                    A < b && (b = A, s.copy(h));
                }
            }
            for (var E = 0; E !== this.uniqueEdges.length; E++) {
                i.vmult(this.uniqueEdges[E], m);
                for (var T = 0; T !== t.uniqueEdges.length; T++) if (n.vmult(t.uniqueEdges[T], g), 
                m.cross(g, w), !w.almostZero()) {
                    w.normalize();
                    var B = this.testSepAxis(w, t, e, i, o, n);
                    if (!1 === B) return !1;
                    B < b && (b = B, s.copy(w));
                }
            }
            return o.vsub(e, c), c.dot(s) > 0 && s.negate(s), !0;
        };
        var m = [], g = [];
        r.prototype.testSepAxis = function(t, e, i, o, n, s) {
            r.project(this, t, i, o, m), r.project(e, t, n, s, g);
            var a = m[0], l = m[1], h = g[0], c = g[1];
            if (a < c || h < l) return !1;
            var u = a - c, p = h - l;
            return u < p ? u : p;
        };
        var w = new n(), b = new n();
        r.prototype.calculateLocalInertia = function(t, e) {
            this.computeLocalAABB(w, b);
            var i = b.x - w.x, o = b.y - w.y, n = b.z - w.z;
            e.x = 1 / 12 * t * (2 * o * 2 * o + 2 * n * 2 * n), e.y = 1 / 12 * t * (2 * i * 2 * i + 2 * n * 2 * n), 
            e.z = 1 / 12 * t * (2 * o * 2 * o + 2 * i * 2 * i);
        }, r.prototype.getPlaneConstantOfFace = function(t) {
            var e = this.faces[t], i = this.faceNormals[t], o = this.vertices[e[0]];
            return -i.dot(o);
        };
        var x = new n(), _ = new n(), C = new n(), S = new n(), A = new n(), E = new n(), T = new n(), B = new n();
        r.prototype.clipFaceAgainstHull = function(t, e, i, o, n, s, r) {
            for (var a = x, l = _, h = C, c = S, u = A, p = E, d = T, v = B, y = o, f = [], m = -1, g = Number.MAX_VALUE, w = 0; w < this.faces.length; w++) {
                a.copy(this.faceNormals[w]), i.vmult(a, a);
                var b = a.dot(t);
                b < g && (g = b, m = w);
            }
            if (!(m < 0)) {
                var R = this.faces[m];
                R.connectedFaces = [];
                for (var P = 0; P < this.faces.length; P++) for (var N = 0; N < this.faces[P].length; N++) -1 !== R.indexOf(this.faces[P][N]) && P !== m && -1 === R.connectedFaces.indexOf(P) && R.connectedFaces.push(P);
                y.length;
                for (var O = R.length, I = 0; I < O; I++) {
                    var F = this.vertices[R[I]], z = this.vertices[R[(I + 1) % O]];
                    F.vsub(z, l), h.copy(l), i.vmult(h, h), e.vadd(h, h), c.copy(this.faceNormals[m]), 
                    i.vmult(c, c), e.vadd(c, c), h.cross(c, u), u.negate(u), p.copy(F), i.vmult(p, p), 
                    e.vadd(p, p), p.dot(u);
                    var M = R.connectedFaces[I];
                    d.copy(this.faceNormals[M]);
                    var V = this.getPlaneConstantOfFace(M);
                    v.copy(d), i.vmult(v, v);
                    var L = V - v.dot(e);
                    for (this.clipFaceAgainstPlane(y, f, v, L); y.length; ) y.shift();
                    for (;f.length; ) y.push(f.shift());
                }
                for (d.copy(this.faceNormals[m]), V = this.getPlaneConstantOfFace(m), v.copy(d), 
                i.vmult(v, v), L = V - v.dot(e), P = 0; P < y.length; P++) {
                    var q = v.dot(y[P]) + L;
                    if (q <= n && (console.log("clamped: depth=" + q + " to minDist=" + n), q = n), 
                    q <= s) {
                        var j = y[P];
                        if (q <= 0) {
                            var W = {
                                point: j,
                                normal: v,
                                depth: q
                            };
                            r.push(W);
                        }
                    }
                }
            }
        }, r.prototype.clipFaceAgainstPlane = function(t, e, i, o) {
            var s, r, a = t.length;
            if (a < 2) return e;
            var l = t[t.length - 1], h = t[0];
            s = i.dot(l) + o;
            for (var c = 0; c < a; c++) {
                if (h = t[c], r = i.dot(h) + o, s < 0) if (r < 0) (u = new n()).copy(h), e.push(u); else {
                    var u = new n();
                    l.lerp(h, s / (s - r), u), e.push(u);
                } else r < 0 && (u = new n(), l.lerp(h, s / (s - r), u), e.push(u), e.push(h));
                l = h, s = r;
            }
            return e;
        }, r.prototype.computeWorldVertices = function(t, e) {
            for (var i = this.vertices.length; this.worldVertices.length < i; ) this.worldVertices.push(new n());
            for (var o = this.vertices, s = this.worldVertices, r = 0; r !== i; r++) e.vmult(o[r], s[r]), 
            t.vadd(s[r], s[r]);
            this.worldVerticesNeedsUpdate = !1;
        }, new n(), r.prototype.computeLocalAABB = function(t, e) {
            var i = this.vertices.length, o = this.vertices;
            t.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), e.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
            for (var n = 0; n < i; n++) {
                var s = o[n];
                s.x < t.x ? t.x = s.x : s.x > e.x && (e.x = s.x), s.y < t.y ? t.y = s.y : s.y > e.y && (e.y = s.y), 
                s.z < t.z ? t.z = s.z : s.z > e.z && (e.z = s.z);
            }
        }, r.prototype.computeWorldFaceNormals = function(t) {
            for (var e = this.faceNormals.length; this.worldFaceNormals.length < e; ) this.worldFaceNormals.push(new n());
            for (var i = this.faceNormals, o = this.worldFaceNormals, s = 0; s !== e; s++) t.vmult(i[s], o[s]);
            this.worldFaceNormalsNeedsUpdate = !1;
        }, r.prototype.updateBoundingSphereRadius = function() {
            for (var t = 0, e = this.vertices, i = 0, o = e.length; i !== o; i++) {
                var n = e[i].norm2();
                n > t && (t = n);
            }
            this.boundingSphereRadius = Math.sqrt(t);
        };
        var R = new n();
        r.prototype.calculateWorldAABB = function(t, e, i, o) {
            for (var n, s, r, a, l, h, c = this.vertices.length, u = this.vertices, p = 0; p < c; p++) {
                R.copy(u[p]), e.vmult(R, R), t.vadd(R, R);
                var d = R;
                d.x < n || void 0 === n ? n = d.x : (d.x > a || void 0 === a) && (a = d.x), d.y < s || void 0 === s ? s = d.y : (d.y > l || void 0 === l) && (l = d.y), 
                d.z < r || void 0 === r ? r = d.z : (d.z > h || void 0 === h) && (h = d.z);
            }
            i.set(n, s, r), o.set(a, l, h);
        }, r.prototype.volume = function() {
            return 4 * Math.PI * this.boundingSphereRadius / 3;
        }, r.prototype.getAveragePointLocal = function(t) {
            t = t || new n();
            for (var e = this.vertices.length, i = this.vertices, o = 0; o < e; o++) t.vadd(i[o], t);
            return t.mult(1 / e, t), t;
        }, r.prototype.transformAllPoints = function(t, e) {
            var i = this.vertices.length, o = this.vertices;
            if (e) {
                for (var n = 0; n < i; n++) {
                    var s = o[n];
                    e.vmult(s, s);
                }
                for (n = 0; n < this.faceNormals.length; n++) s = this.faceNormals[n], e.vmult(s, s);
            }
            if (t) for (n = 0; n < i; n++) (s = o[n]).vadd(t, s);
        };
        var P = new n(), N = new n(), O = new n();
        r.prototype.pointIsInside = function(t) {
            var e = this.vertices.length, i = this.vertices, o = this.faces, n = this.faceNormals, s = this.faces.length, r = P;
            this.getAveragePointLocal(r);
            for (var a = 0; a < s; a++) {
                this.faces[a].length, e = n[a];
                var l = i[o[a][0]], h = N;
                t.vsub(l, h);
                var c = e.dot(h), u = O;
                r.vsub(l, u);
                var p = e.dot(u);
                if (c < 0 && p > 0 || c > 0 && p < 0) return !1;
            }
            return -1;
        }, new n();
        var I = new n(), F = new n();
        r.project = function(t, e, i, o, n) {
            var r = t.vertices.length, a = I, l = 0, h = 0, c = F, u = t.vertices;
            c.setZero(), s.vectorToLocalFrame(i, o, e, a), s.pointToLocalFrame(i, o, c, c);
            var p = c.dot(a);
            h = l = u[0].dot(a);
            for (var d = 1; d < r; d++) {
                var v = u[d].dot(a);
                v > l && (l = v), v < h && (h = v);
            }
            if ((h -= p) > (l -= p)) {
                var y = h;
                h = l, l = y;
            }
            n[0] = l, n[1] = h;
        };
    }, {
        "../math/Quaternion": 28,
        "../math/Transform": 29,
        "../math/Vec3": 30,
        "./Shape": 43
    } ],
    39: [ function(t, e, i) {
        e.exports = r;
        var o = t("./Shape"), n = t("../math/Vec3"), s = (t("../math/Quaternion"), t("./ConvexPolyhedron"));
        function r(t, e, i, r) {
            var a = r, l = [], h = [], c = [], u = [], p = [], d = Math.cos, v = Math.sin;
            l.push(new n(e * d(0), e * v(0), .5 * -i)), u.push(0), l.push(new n(t * d(0), t * v(0), .5 * i)), 
            p.push(1);
            for (var y = 0; y < a; y++) {
                var f = 2 * Math.PI / a * (y + 1), m = 2 * Math.PI / a * (y + .5);
                y < a - 1 ? (l.push(new n(e * d(f), e * v(f), .5 * -i)), u.push(2 * y + 2), l.push(new n(t * d(f), t * v(f), .5 * i)), 
                p.push(2 * y + 3), c.push([ 2 * y + 2, 2 * y + 3, 2 * y + 1, 2 * y ])) : c.push([ 0, 1, 2 * y + 1, 2 * y ]), 
                (a % 2 == 1 || y < a / 2) && h.push(new n(d(m), v(m), 0));
            }
            c.push(p), h.push(new n(0, 0, 1));
            var g = [];
            for (y = 0; y < u.length; y++) g.push(u[u.length - y - 1]);
            c.push(g), this.type = o.types.CONVEXPOLYHEDRON, s.call(this, l, c, h);
        }
        r.prototype = new s();
    }, {
        "../math/Quaternion": 28,
        "../math/Vec3": 30,
        "./ConvexPolyhedron": 38,
        "./Shape": 43
    } ],
    40: [ function(t, e, i) {
        var o = t("./Shape"), n = t("./ConvexPolyhedron"), s = t("../math/Vec3"), r = t("../utils/Utils");
        function a(t, e) {
            e = r.defaults(e, {
                maxValue: null,
                minValue: null,
                elementSize: 1
            }), this.data = t, this.maxValue = e.maxValue, this.minValue = e.minValue, this.elementSize = e.elementSize, 
            null === e.minValue && this.updateMinValue(), null === e.maxValue && this.updateMaxValue(), 
            this.cacheEnabled = !0, o.call(this), this.pillarConvex = new n(), this.pillarOffset = new s(), 
            this.type = o.types.HEIGHTFIELD, this.updateBoundingSphereRadius(), this._cachedPillars = {};
        }
        e.exports = a, a.prototype = new o(), a.prototype.update = function() {
            this._cachedPillars = {};
        }, a.prototype.updateMinValue = function() {
            for (var t = this.data, e = t[0][0], i = 0; i !== t.length; i++) for (var o = 0; o !== t[i].length; o++) {
                var n = t[i][o];
                n < e && (e = n);
            }
            this.minValue = e;
        }, a.prototype.updateMaxValue = function() {
            for (var t = this.data, e = t[0][0], i = 0; i !== t.length; i++) for (var o = 0; o !== t[i].length; o++) {
                var n = t[i][o];
                n > e && (e = n);
            }
            this.maxValue = e;
        }, a.prototype.setHeightValueAtIndex = function(t, e, i) {
            this.data[t][e] = i, this.clearCachedConvexTrianglePillar(t, e, !1), t > 0 && (this.clearCachedConvexTrianglePillar(t - 1, e, !0), 
            this.clearCachedConvexTrianglePillar(t - 1, e, !1)), e > 0 && (this.clearCachedConvexTrianglePillar(t, e - 1, !0), 
            this.clearCachedConvexTrianglePillar(t, e - 1, !1)), e > 0 && t > 0 && this.clearCachedConvexTrianglePillar(t - 1, e - 1, !0);
        }, a.prototype.getRectMinMax = function(t, e, i, o, n) {
            n = n || [];
            for (var s = this.data, r = this.minValue, a = t; a <= i; a++) for (var l = e; l <= o; l++) {
                var h = s[a][l];
                h > r && (r = h);
            }
            n[0] = this.minValue, n[1] = r;
        }, a.prototype.getIndexOfPosition = function(t, e, i, o) {
            var n = this.elementSize, s = this.data, r = Math.floor(t / n), a = Math.floor(e / n);
            return i[0] = r, i[1] = a, o && (r < 0 && (r = 0), a < 0 && (a = 0), r >= s.length - 1 && (r = s.length - 1), 
            a >= s[0].length - 1 && (a = s[0].length - 1)), !(r < 0 || a < 0 || r >= s.length - 1 || a >= s[0].length - 1);
        }, a.prototype.getHeightAt = function(t, e, i) {
            var o = [];
            this.getIndexOfPosition(t, e, o, i);
            var n = [];
            return this.getRectMinMax(o[0], o[1] + 1, o[0], o[1] + 1, n), (n[0] + n[1]) / 2;
        }, a.prototype.getCacheConvexTrianglePillarKey = function(t, e, i) {
            return t + "_" + e + "_" + (i ? 1 : 0);
        }, a.prototype.getCachedConvexTrianglePillar = function(t, e, i) {
            return this._cachedPillars[this.getCacheConvexTrianglePillarKey(t, e, i)];
        }, a.prototype.setCachedConvexTrianglePillar = function(t, e, i, o, n) {
            this._cachedPillars[this.getCacheConvexTrianglePillarKey(t, e, i)] = {
                convex: o,
                offset: n
            };
        }, a.prototype.clearCachedConvexTrianglePillar = function(t, e, i) {
            delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(t, e, i)];
        }, a.prototype.getConvexTrianglePillar = function(t, e, i) {
            var o = this.pillarConvex, r = this.pillarOffset;
            if (this.cacheEnabled) {
                if (a = this.getCachedConvexTrianglePillar(t, e, i)) return this.pillarConvex = a.convex, 
                void (this.pillarOffset = a.offset);
                o = new n(), r = new s(), this.pillarConvex = o, this.pillarOffset = r;
            }
            var a = this.data, l = this.elementSize, h = o.faces;
            o.vertices.length = 6;
            for (var c = 0; c < 6; c++) o.vertices[c] || (o.vertices[c] = new s());
            for (h.length = 5, c = 0; c < 5; c++) h[c] || (h[c] = []);
            var u = o.vertices, p = (Math.min(a[t][e], a[t + 1][e], a[t][e + 1], a[t + 1][e + 1]) - this.minValue) / 2 + this.minValue;
            i ? (r.set((t + .75) * l, (e + .75) * l, p), u[0].set(.25 * l, .25 * l, a[t + 1][e + 1] - p), 
            u[1].set(-.75 * l, .25 * l, a[t][e + 1] - p), u[2].set(.25 * l, -.75 * l, a[t + 1][e] - p), 
            u[3].set(.25 * l, .25 * l, -p - 1), u[4].set(-.75 * l, .25 * l, -p - 1), u[5].set(.25 * l, -.75 * l, -p - 1), 
            h[0][0] = 0, h[0][1] = 1, h[0][2] = 2, h[1][0] = 5, h[1][1] = 4, h[1][2] = 3, h[2][0] = 2, 
            h[2][1] = 5, h[2][2] = 3, h[2][3] = 0, h[3][0] = 3, h[3][1] = 4, h[3][2] = 1, h[3][3] = 0, 
            h[4][0] = 1, h[4][1] = 4, h[4][2] = 5, h[4][3] = 2) : (r.set((t + .25) * l, (e + .25) * l, p), 
            u[0].set(-.25 * l, -.25 * l, a[t][e] - p), u[1].set(.75 * l, -.25 * l, a[t + 1][e] - p), 
            u[2].set(-.25 * l, .75 * l, a[t][e + 1] - p), u[3].set(-.25 * l, -.25 * l, -p - 1), 
            u[4].set(.75 * l, -.25 * l, -p - 1), u[5].set(-.25 * l, .75 * l, -p - 1), h[0][0] = 0, 
            h[0][1] = 1, h[0][2] = 2, h[1][0] = 5, h[1][1] = 4, h[1][2] = 3, h[2][0] = 0, h[2][1] = 2, 
            h[2][2] = 5, h[2][3] = 3, h[3][0] = 1, h[3][1] = 0, h[3][2] = 3, h[3][3] = 4, h[4][0] = 4, 
            h[4][1] = 5, h[4][2] = 2, h[4][3] = 1), o.computeNormals(), o.computeEdges(), o.updateBoundingSphereRadius(), 
            this.setCachedConvexTrianglePillar(t, e, i, o, r);
        }, a.prototype.calculateLocalInertia = function(t, e) {
            return (e = e || new s()).set(0, 0, 0), e;
        }, a.prototype.volume = function() {
            return Number.MAX_VALUE;
        }, a.prototype.calculateWorldAABB = function(t, e, i, o) {
            i.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), o.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
        }, a.prototype.updateBoundingSphereRadius = function() {
            var t = this.data, e = this.elementSize;
            this.boundingSphereRadius = new s(t.length * e, t[0].length * e, Math.max(Math.abs(this.maxValue), Math.abs(this.minValue))).norm();
        };
    }, {
        "../math/Vec3": 30,
        "../utils/Utils": 53,
        "./ConvexPolyhedron": 38,
        "./Shape": 43
    } ],
    41: [ function(t, e, i) {
        e.exports = s;
        var o = t("./Shape"), n = t("../math/Vec3");
        function s() {
            o.call(this), this.type = o.types.PARTICLE;
        }
        s.prototype = new o(), s.prototype.constructor = s, s.prototype.calculateLocalInertia = function(t, e) {
            return (e = e || new n()).set(0, 0, 0), e;
        }, s.prototype.volume = function() {
            return 0;
        }, s.prototype.updateBoundingSphereRadius = function() {
            this.boundingSphereRadius = 0;
        }, s.prototype.calculateWorldAABB = function(t, e, i, o) {
            i.copy(t), o.copy(t);
        };
    }, {
        "../math/Vec3": 30,
        "./Shape": 43
    } ],
    42: [ function(t, e, i) {
        e.exports = s;
        var o = t("./Shape"), n = t("../math/Vec3");
        function s() {
            o.call(this), this.type = o.types.PLANE, this.worldNormal = new n(), this.worldNormalNeedsUpdate = !0, 
            this.boundingSphereRadius = Number.MAX_VALUE;
        }
        s.prototype = new o(), s.prototype.constructor = s, s.prototype.computeWorldNormal = function(t) {
            var e = this.worldNormal;
            e.set(0, 0, 1), t.vmult(e, e), this.worldNormalNeedsUpdate = !1;
        }, s.prototype.calculateLocalInertia = function(t, e) {
            return e || new n();
        }, s.prototype.volume = function() {
            return Number.MAX_VALUE;
        };
        var r = new n();
        s.prototype.calculateWorldAABB = function(t, e, i, o) {
            r.set(0, 0, 1), e.vmult(r, r);
            var n = Number.MAX_VALUE;
            i.set(-n, -n, -n), o.set(n, n, n), 1 === r.x && (o.x = t.x), 1 === r.y && (o.y = t.y), 
            1 === r.z && (o.z = t.z), -1 === r.x && (i.x = t.x), -1 === r.y && (i.y = t.y), 
            -1 === r.z && (i.z = t.z);
        }, s.prototype.updateBoundingSphereRadius = function() {
            this.boundingSphereRadius = Number.MAX_VALUE;
        };
    }, {
        "../math/Vec3": 30,
        "./Shape": 43
    } ],
    43: [ function(t, e, i) {
        e.exports = o;
        var o = t("./Shape");
        function o() {
            this.id = o.idCounter++, this.type = 0, this.boundingSphereRadius = 0, this.collisionResponse = !0, 
            this.material = null;
        }
        t("../math/Vec3"), t("../math/Quaternion"), t("../material/Material"), o.prototype.constructor = o, 
        o.prototype.updateBoundingSphereRadius = function() {
            throw "computeBoundingSphereRadius() not implemented for shape type " + this.type;
        }, o.prototype.volume = function() {
            throw "volume() not implemented for shape type " + this.type;
        }, o.prototype.calculateLocalInertia = function(t, e) {
            throw "calculateLocalInertia() not implemented for shape type " + this.type;
        }, o.idCounter = 0, o.types = {
            SPHERE: 1,
            PLANE: 2,
            BOX: 4,
            COMPOUND: 8,
            CONVEXPOLYHEDRON: 16,
            HEIGHTFIELD: 32,
            PARTICLE: 64,
            CYLINDER: 128,
            TRIMESH: 256
        };
    }, {
        "../material/Material": 25,
        "../math/Quaternion": 28,
        "../math/Vec3": 30,
        "./Shape": 43
    } ],
    44: [ function(t, e, i) {
        e.exports = s;
        var o = t("./Shape"), n = t("../math/Vec3");
        function s(t) {
            if (o.call(this), this.radius = void 0 !== t ? Number(t) : 1, this.type = o.types.SPHERE, 
            this.radius < 0) throw new Error("The sphere radius cannot be negative.");
            this.updateBoundingSphereRadius();
        }
        s.prototype = new o(), s.prototype.constructor = s, s.prototype.calculateLocalInertia = function(t, e) {
            e = e || new n();
            var i = 2 * t * this.radius * this.radius / 5;
            return e.x = i, e.y = i, e.z = i, e;
        }, s.prototype.volume = function() {
            return 4 * Math.PI * this.radius / 3;
        }, s.prototype.updateBoundingSphereRadius = function() {
            this.boundingSphereRadius = this.radius;
        }, s.prototype.calculateWorldAABB = function(t, e, i, o) {
            for (var n = this.radius, s = [ "x", "y", "z" ], r = 0; r < s.length; r++) {
                var a = s[r];
                i[a] = t[a] - n, o[a] = t[a] + n;
            }
        };
    }, {
        "../math/Vec3": 30,
        "./Shape": 43
    } ],
    45: [ function(t, e, i) {
        e.exports = l;
        var o = t("./Shape"), n = t("../math/Vec3"), s = (t("../math/Quaternion"), t("../math/Transform")), r = t("../collision/AABB"), a = t("../utils/Octree");
        function l(t, e) {
            o.call(this), this.type = o.types.TRIMESH, this.vertices = new Float32Array(t), 
            this.indices = new Int16Array(e), this.normals = new Float32Array(e.length), this.aabb = new r(), 
            this.edges = null, this.scale = new n(1, 1, 1), this.tree = new a(), this.updateEdges(), 
            this.updateNormals(), this.updateAABB(), this.updateBoundingSphereRadius(), this.updateTree();
        }
        l.prototype = new o(), l.prototype.constructor = l;
        var h = new n();
        l.prototype.updateTree = function() {
            var t = this.tree;
            t.reset(), t.aabb.copy(this.aabb);
            var e = this.scale;
            t.aabb.lowerBound.x *= 1 / e.x, t.aabb.lowerBound.y *= 1 / e.y, t.aabb.lowerBound.z *= 1 / e.z, 
            t.aabb.upperBound.x *= 1 / e.x, t.aabb.upperBound.y *= 1 / e.y, t.aabb.upperBound.z *= 1 / e.z;
            for (var i = new r(), o = new n(), s = new n(), a = new n(), l = [ o, s, a ], h = 0; h < this.indices.length / 3; h++) {
                var c = 3 * h;
                this._getUnscaledVertex(this.indices[c], o), this._getUnscaledVertex(this.indices[c + 1], s), 
                this._getUnscaledVertex(this.indices[c + 2], a), i.setFromPoints(l), t.insert(i, h);
            }
            t.removeEmptyNodes();
        };
        var c = new r();
        l.prototype.getTrianglesInAABB = function(t, e) {
            c.copy(t);
            var i = this.scale, o = i.x, n = i.y, s = i.z, r = c.lowerBound, a = c.upperBound;
            return r.x /= o, r.y /= n, r.z /= s, a.x /= o, a.y /= n, a.z /= s, this.tree.aabbQuery(c, e);
        }, l.prototype.setScale = function(t) {
            var e = this.scale.x === this.scale.y === this.scale.z, i = t.x === t.y === t.z;
            e && i || this.updateNormals(), this.scale.copy(t), this.updateAABB(), this.updateBoundingSphereRadius();
        }, l.prototype.updateNormals = function() {
            for (var t = h, e = this.normals, i = 0; i < this.indices.length / 3; i++) {
                var o = 3 * i, n = this.indices[o], s = this.indices[o + 1], r = this.indices[o + 2];
                this.getVertex(n, y), this.getVertex(s, f), this.getVertex(r, m), l.computeNormal(f, y, m, t), 
                e[o] = t.x, e[o + 1] = t.y, e[o + 2] = t.z;
            }
        }, l.prototype.updateEdges = function() {
            for (var t = {}, e = function(e, i) {
                t[n < s ? n + "_" + s : s + "_" + n] = !0;
            }, i = 0; i < this.indices.length / 3; i++) {
                var o = 3 * i, n = this.indices[o], s = this.indices[o + 1];
                this.indices[o + 2], e(), e(), e();
            }
            var r = Object.keys(t);
            for (this.edges = new Int16Array(2 * r.length), i = 0; i < r.length; i++) {
                var a = r[i].split("_");
                this.edges[2 * i] = parseInt(a[0], 10), this.edges[2 * i + 1] = parseInt(a[1], 10);
            }
        }, l.prototype.getEdgeVertex = function(t, e, i) {
            var o = this.edges[2 * t + (e ? 1 : 0)];
            this.getVertex(o, i);
        };
        var u = new n(), p = new n();
        l.prototype.getEdgeVector = function(t, e) {
            var i = u, o = p;
            this.getEdgeVertex(t, 0, i), this.getEdgeVertex(t, 1, o), o.vsub(i, e);
        };
        var d = new n(), v = new n();
        l.computeNormal = function(t, e, i, o) {
            e.vsub(t, v), i.vsub(e, d), d.cross(v, o), o.isZero() || o.normalize();
        };
        var y = new n(), f = new n(), m = new n();
        l.prototype.getVertex = function(t, e) {
            var i = this.scale;
            return this._getUnscaledVertex(t, e), e.x *= i.x, e.y *= i.y, e.z *= i.z, e;
        }, l.prototype._getUnscaledVertex = function(t, e) {
            var i = 3 * t, o = this.vertices;
            return e.set(o[i], o[i + 1], o[i + 2]);
        }, l.prototype.getWorldVertex = function(t, e, i, o) {
            return this.getVertex(t, o), s.pointToWorldFrame(e, i, o, o), o;
        }, l.prototype.getTriangleVertices = function(t, e, i, o) {
            var n = 3 * t;
            this.getVertex(this.indices[n], e), this.getVertex(this.indices[n + 1], i), this.getVertex(this.indices[n + 2], o);
        }, l.prototype.getNormal = function(t, e) {
            var i = 3 * t;
            return e.set(this.normals[i], this.normals[i + 1], this.normals[i + 2]);
        };
        var g = new r();
        l.prototype.calculateLocalInertia = function(t, e) {
            this.computeLocalAABB(g);
            var i = g.upperBound.x - g.lowerBound.x, o = g.upperBound.y - g.lowerBound.y, n = g.upperBound.z - g.lowerBound.z;
            return e.set(1 / 12 * t * (2 * o * 2 * o + 2 * n * 2 * n), 1 / 12 * t * (2 * i * 2 * i + 2 * n * 2 * n), 1 / 12 * t * (2 * o * 2 * o + 2 * i * 2 * i));
        };
        var w = new n();
        l.prototype.computeLocalAABB = function(t) {
            var e = t.lowerBound, i = t.upperBound, o = this.vertices.length, n = (this.vertices, 
            w);
            this.getVertex(0, n), e.copy(n), i.copy(n);
            for (var s = 0; s !== o; s++) this.getVertex(s, n), n.x < e.x ? e.x = n.x : n.x > i.x && (i.x = n.x), 
            n.y < e.y ? e.y = n.y : n.y > i.y && (i.y = n.y), n.z < e.z ? e.z = n.z : n.z > i.z && (i.z = n.z);
        }, l.prototype.updateAABB = function() {
            this.computeLocalAABB(this.aabb);
        }, l.prototype.updateBoundingSphereRadius = function() {
            for (var t = 0, e = this.vertices, i = new n(), o = 0, s = e.length / 3; o !== s; o++) {
                this.getVertex(o, i);
                var r = i.norm2();
                r > t && (t = r);
            }
            this.boundingSphereRadius = Math.sqrt(t);
        }, new n();
        var b = new s(), x = new r();
        l.prototype.calculateWorldAABB = function(t, e, i, o) {
            var n = b, s = x;
            n.position = t, n.quaternion = e, this.aabb.toWorldFrame(n, s), i.copy(s.lowerBound), 
            o.copy(s.upperBound);
        }, l.prototype.volume = function() {
            return 4 * Math.PI * this.boundingSphereRadius / 3;
        }, l.createTorus = function(t, e, i, o, n) {
            t = t || 1, e = e || .5, i = i || 8, o = o || 6, n = n || 2 * Math.PI;
            for (var s = [], r = [], a = 0; a <= i; a++) for (var h = 0; h <= o; h++) {
                var c = h / o * n, u = a / i * Math.PI * 2, p = (t + e * Math.cos(u)) * Math.cos(c), d = (t + e * Math.cos(u)) * Math.sin(c), v = e * Math.sin(u);
                s.push(p, d, v);
            }
            for (a = 1; a <= i; a++) for (h = 1; h <= o; h++) {
                var y = (o + 1) * a + h - 1, f = (o + 1) * (a - 1) + h - 1, m = (o + 1) * (a - 1) + h, g = (o + 1) * a + h;
                r.push(y, f, g), r.push(f, m, g);
            }
            return new l(s, r);
        };
    }, {
        "../collision/AABB": 3,
        "../math/Quaternion": 28,
        "../math/Transform": 29,
        "../math/Vec3": 30,
        "../utils/Octree": 50,
        "./Shape": 43
    } ],
    46: [ function(t, e, i) {
        e.exports = n, t("../math/Vec3"), t("../math/Quaternion");
        var o = t("./Solver");
        function n() {
            o.call(this), this.iterations = 10, this.tolerance = 1e-7;
        }
        n.prototype = new o();
        var s = [], r = [], a = [];
        n.prototype.solve = function(t, e) {
            var i, o, n, l, h, c = 0, u = this.iterations, p = this.tolerance * this.tolerance, d = this.equations, v = d.length, y = e.bodies, f = y.length, m = t;
            if (0 !== v) for (var g = 0; g !== f; g++) y[g].updateSolveMassProperties();
            var w = r, b = a, x = s;
            for (w.length = v, b.length = v, x.length = v, g = 0; g !== v; g++) {
                var _ = d[g];
                x[g] = 0, b[g] = _.computeB(m), w[g] = 1 / _.computeC();
            }
            if (0 !== v) {
                for (g = 0; g !== f; g++) {
                    var C = (E = y[g]).vlambda, S = E.wlambda;
                    C.set(0, 0, 0), S && S.set(0, 0, 0);
                }
                for (c = 0; c !== u; c++) {
                    l = 0;
                    for (var A = 0; A !== v; A++) _ = d[A], i = b[A], o = w[A], (h = x[A]) + (n = o * (i - _.computeGWlambda() - _.eps * h)) < _.minForce ? n = _.minForce - h : h + n > _.maxForce && (n = _.maxForce - h), 
                    x[A] += n, l += n > 0 ? n : -n, _.addToWlambda(n);
                    if (l * l < p) break;
                }
                for (g = 0; g !== f; g++) {
                    var E, T = (E = y[g]).velocity, B = E.angularVelocity;
                    T.vadd(E.vlambda, T), B && B.vadd(E.wlambda, B);
                }
            }
            return c;
        };
    }, {
        "../math/Quaternion": 28,
        "../math/Vec3": 30,
        "./Solver": 47
    } ],
    47: [ function(t, e, i) {
        function o() {
            this.equations = [];
        }
        e.exports = o, o.prototype.solve = function(t, e) {
            return 0;
        }, o.prototype.addEquation = function(t) {
            t.enabled && this.equations.push(t);
        }, o.prototype.removeEquation = function(t) {
            var e = this.equations, i = e.indexOf(t);
            -1 !== i && e.splice(i, 1);
        }, o.prototype.removeAllEquations = function() {
            this.equations.length = 0;
        };
    }, {} ],
    48: [ function(t, e, i) {
        e.exports = s, t("../math/Vec3"), t("../math/Quaternion");
        var o = t("./Solver"), n = t("../objects/Body");
        function s(t) {
            for (o.call(this), this.iterations = 10, this.tolerance = 1e-7, this.subsolver = t, 
            this.nodes = [], this.nodePool = []; this.nodePool.length < 128; ) this.nodePool.push(this.createNode());
        }
        s.prototype = new o();
        var r = [], a = [], l = {
            bodies: []
        }, h = n.STATIC;
        function c(t) {
            for (var e = t.length, i = 0; i !== e; i++) {
                var o = t[i];
                if (!(o.visited || o.body.type & h)) return o;
            }
            return !1;
        }
        var u = [];
        function p(t, e, i, o) {
            for (u.push(t), t.visited = !0, e(t, i, o); u.length; ) for (var n, s = u.pop(); n = c(s.children); ) n.visited = !0, 
            e(n, i, o), u.push(n);
        }
        function d(t, e, i) {
            e.push(t.body);
            for (var o = t.eqs.length, n = 0; n !== o; n++) {
                var s = t.eqs[n];
                -1 === i.indexOf(s) && i.push(s);
            }
        }
        function v(t, e) {
            return e.id - t.id;
        }
        s.prototype.createNode = function() {
            return {
                body: null,
                children: [],
                eqs: [],
                visited: !1
            };
        }, s.prototype.solve = function(t, e) {
            for (var i = r, o = this.nodePool, n = e.bodies, s = this.equations, h = s.length, u = n.length, y = this.subsolver; o.length < u; ) o.push(this.createNode());
            i.length = u;
            for (var f = 0; f < u; f++) i[f] = o[f];
            for (f = 0; f !== u; f++) {
                var m = i[f];
                m.body = n[f], m.children.length = 0, m.eqs.length = 0, m.visited = !1;
            }
            for (var g = 0; g !== h; g++) {
                var w = s[g], b = (f = n.indexOf(w.bi), n.indexOf(w.bj)), x = i[f], _ = i[b];
                x.children.push(_), x.eqs.push(w), _.children.push(x), _.eqs.push(w);
            }
            var C, S = 0, A = a;
            y.tolerance = this.tolerance, y.iterations = this.iterations;
            for (var E = l; C = c(i); ) {
                A.length = 0, E.bodies.length = 0, p(C, d, E.bodies, A);
                var T = A.length;
                for (A = A.sort(v), f = 0; f !== T; f++) y.addEquation(A[f]);
                y.solve(t, E), y.removeAllEquations(), S++;
            }
            return S;
        };
    }, {
        "../math/Quaternion": 28,
        "../math/Vec3": 30,
        "../objects/Body": 31,
        "./Solver": 47
    } ],
    49: [ function(t, e, i) {
        var o = function() {};
        e.exports = o, o.prototype = {
            constructor: o,
            addEventListener: function(t, e) {
                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;
            },
            hasEventListener: function(t, e) {
                if (void 0 === this._listeners) return !1;
                var i = this._listeners;
                return void 0 !== i[t] && -1 !== i[t].indexOf(e);
            },
            removeEventListener: function(t, e) {
                if (void 0 === this._listeners) return this;
                var i = this._listeners;
                if (void 0 === i[t]) return this;
                var o = i[t].indexOf(e);
                return -1 !== o && i[t].splice(o, 1), this;
            },
            dispatchEvent: function(t) {
                if (void 0 === this._listeners) return this;
                var e = this._listeners[t.type];
                if (void 0 !== e) {
                    t.target = this;
                    for (var i = 0, o = e.length; i < o; i++) e[i].call(this, t);
                }
                return this;
            }
        };
    }, {} ],
    50: [ function(t, e, i) {
        var o = t("../collision/AABB"), n = t("../math/Vec3");
        function s(t) {
            t = t || {}, this.root = t.root || null, this.aabb = t.aabb ? t.aabb.clone() : new o(), 
            this.data = [], this.children = [];
        }
        function r(t, e) {
            (e = e || {}).root = null, e.aabb = t, s.call(this, e), this.maxDepth = void 0 !== e.maxDepth ? e.maxDepth : 8;
        }
        e.exports = r, r.prototype = new s(), s.prototype.reset = function(t, e) {
            this.children.length = this.data.length = 0;
        }, s.prototype.insert = function(t, e, i) {
            var o = this.data;
            if (i = i || 0, !this.aabb.contains(t)) return !1;
            var n = this.children;
            if (i < (this.maxDepth || this.root.maxDepth)) {
                var s = !1;
                n.length || (this.subdivide(), s = !0);
                for (var r = 0; 8 !== r; r++) if (n[r].insert(t, e, i + 1)) return !0;
                s && (n.length = 0);
            }
            return o.push(e), !0;
        };
        var a = new n();
        s.prototype.subdivide = function() {
            var t = this.aabb, e = t.lowerBound, i = t.upperBound, r = this.children;
            r.push(new s({
                aabb: new o({
                    lowerBound: new n(0, 0, 0)
                })
            }), new s({
                aabb: new o({
                    lowerBound: new n(1, 0, 0)
                })
            }), new s({
                aabb: new o({
                    lowerBound: new n(1, 1, 0)
                })
            }), new s({
                aabb: new o({
                    lowerBound: new n(1, 1, 1)
                })
            }), new s({
                aabb: new o({
                    lowerBound: new n(0, 1, 1)
                })
            }), new s({
                aabb: new o({
                    lowerBound: new n(0, 0, 1)
                })
            }), new s({
                aabb: new o({
                    lowerBound: new n(1, 0, 1)
                })
            }), new s({
                aabb: new o({
                    lowerBound: new n(0, 1, 0)
                })
            })), i.vsub(e, a), a.scale(.5, a);
            for (var l = this.root || this, h = 0; 8 !== h; h++) {
                var c = r[h];
                c.root = l;
                var u = c.aabb.lowerBound;
                u.x *= a.x, u.y *= a.y, u.z *= a.z, u.vadd(e, u), u.vadd(a, c.aabb.upperBound);
            }
        }, s.prototype.aabbQuery = function(t, e) {
            this.data, this.children;
            for (var i = [ this ]; i.length; ) {
                var o = i.pop();
                o.aabb.overlaps(t) && Array.prototype.push.apply(e, o.data), Array.prototype.push.apply(i, o.children);
            }
            return e;
        };
        var l = new o();
        s.prototype.rayQuery = function(t, e, i) {
            return t.getAABB(l), l.toLocalFrame(e, l), this.aabbQuery(l, i), i;
        }, s.prototype.removeEmptyNodes = function() {
            for (var t = [ this ]; t.length; ) {
                for (var e = t.pop(), i = e.children.length - 1; i >= 0; i--) e.children[i].data.length || e.children.splice(i, 1);
                Array.prototype.push.apply(t, e.children);
            }
        };
    }, {
        "../collision/AABB": 3,
        "../math/Vec3": 30
    } ],
    51: [ function(t, e, i) {
        function o() {
            this.objects = [], this.type = Object;
        }
        e.exports = o, o.prototype.release = function() {
            for (var t = arguments.length, e = 0; e !== t; e++) this.objects.push(arguments[e]);
        }, o.prototype.get = function() {
            return 0 === this.objects.length ? this.constructObject() : this.objects.pop();
        }, o.prototype.constructObject = function() {
            throw new Error("constructObject() not implemented in this Pool subclass yet!");
        };
    }, {} ],
    52: [ function(t, e, i) {
        function o() {
            this.data = {
                keys: []
            };
        }
        e.exports = o, o.prototype.get = function(t, e) {
            if (t > e) {
                var i = e;
                e = t, t = i;
            }
            return this.data[t + "-" + e];
        }, o.prototype.set = function(t, e, i) {
            if (t > e) {
                var o = e;
                e = t, t = o;
            }
            var n = t + "-" + e;
            this.get(t, e) || this.data.keys.push(n), this.data[n] = i;
        }, o.prototype.reset = function() {
            for (var t = this.data, e = t.keys; e.length > 0; ) delete t[e.pop()];
        };
    }, {} ],
    53: [ function(t, e, i) {
        function o() {}
        e.exports = o, o.defaults = function(t, e) {
            for (var i in t = t || {}, e) i in t || (t[i] = e[i]);
            return t;
        };
    }, {} ],
    54: [ function(t, e, i) {
        e.exports = s;
        var o = t("../math/Vec3"), n = t("./Pool");
        function s() {
            n.call(this), this.type = o;
        }
        s.prototype = new n(), s.prototype.constructObject = function() {
            return new o();
        };
    }, {
        "../math/Vec3": 30,
        "./Pool": 51
    } ],
    55: [ function(t, e, i) {
        e.exports = p;
        var o = t("../collision/AABB"), n = t("../shapes/Shape"), s = t("../collision/Ray"), r = t("../math/Vec3"), a = t("../math/Transform"), l = (t("../shapes/ConvexPolyhedron"), 
        t("../math/Quaternion")), h = (t("../solver/Solver"), t("../utils/Vec3Pool")), c = t("../equations/ContactEquation"), u = t("../equations/FrictionEquation");
        function p(t) {
            this.contactPointPool = [], this.frictionEquationPool = [], this.result = [], this.frictionResult = [], 
            this.v3pool = new h(), this.world = t, this.currentContactMaterial = null, this.enableFrictionReduction = !1;
        }
        p.prototype.createContactEquation = function(t, e, i, o, n, s) {
            var r;
            this.contactPointPool.length ? ((r = this.contactPointPool.pop()).bi = t, r.bj = e) : r = new c(t, e), 
            r.enabled = t.collisionResponse && e.collisionResponse && i.collisionResponse && o.collisionResponse;
            var a = this.currentContactMaterial;
            r.restitution = a.restitution, r.setSpookParams(a.contactEquationStiffness, a.contactEquationRelaxation, this.world.dt);
            var l = i.material || t.material, h = o.material || e.material;
            return l && h && l.restitution >= 0 && h.restitution >= 0 && (r.restitution = l.restitution * h.restitution), 
            r.si = n || i, r.sj = s || o, r;
        }, p.prototype.createFrictionEquationsFromContact = function(t, e) {
            var i = t.bi, o = t.bj, n = t.si, s = t.sj, r = this.world, a = this.currentContactMaterial, l = a.friction, h = n.material || i.material, c = s.material || o.material;
            if (h && c && h.friction >= 0 && c.friction >= 0 && (l = h.friction * c.friction), 
            l > 0) {
                var p = l * r.gravity.length(), d = i.invMass + o.invMass;
                d > 0 && (d = 1 / d);
                var v = this.frictionEquationPool, y = v.length ? v.pop() : new u(i, o, p * d), f = v.length ? v.pop() : new u(i, o, p * d);
                return y.bi = f.bi = i, y.bj = f.bj = o, y.minForce = f.minForce = -p * d, y.maxForce = f.maxForce = p * d, 
                y.ri.copy(t.ri), y.rj.copy(t.rj), f.ri.copy(t.ri), f.rj.copy(t.rj), t.ni.tangents(y.t, f.t), 
                y.setSpookParams(a.frictionEquationStiffness, a.frictionEquationRelaxation, r.dt), 
                f.setSpookParams(a.frictionEquationStiffness, a.frictionEquationRelaxation, r.dt), 
                y.enabled = f.enabled = t.enabled, e.push(y, f), !0;
            }
            return !1;
        };
        var d = new r(), v = new r(), y = new r();
        p.prototype.createFrictionFromAverage = function(t) {
            var e = this.result[this.result.length - 1];
            if (this.createFrictionEquationsFromContact(e, this.frictionResult) && 1 !== t) {
                var i = this.frictionResult[this.frictionResult.length - 2], o = this.frictionResult[this.frictionResult.length - 1];
                d.setZero(), v.setZero(), y.setZero();
                for (var n = e.bi, s = (e.bj, 0); s !== t; s++) (e = this.result[this.result.length - 1 - s]).bodyA !== n ? (d.vadd(e.ni, d), 
                v.vadd(e.ri, v), y.vadd(e.rj, y)) : (d.vsub(e.ni, d), v.vadd(e.rj, v), y.vadd(e.ri, y));
                var r = 1 / t;
                v.scale(r, i.ri), y.scale(r, i.rj), o.ri.copy(i.ri), o.rj.copy(i.rj), d.normalize(), 
                d.tangents(i.t, o.t);
            }
        };
        var f = new r(), m = new r(), g = new l(), w = new l();
        p.prototype.getContacts = function(t, e, i, o, n, s, r) {
            this.contactPointPool = n, this.frictionEquationPool = r, this.result = o, this.frictionResult = s;
            for (var a = g, l = w, h = f, c = m, u = 0, p = t.length; u !== p; u++) {
                var d = t[u], v = e[u], y = !1;
                d.material && v.material && (y = !0);
                for (var b = 0; b < d.shapes.length; b++) {
                    d.quaternion.mult(d.shapeOrientations[b], a), d.quaternion.vmult(d.shapeOffsets[b], h), 
                    h.vadd(d.position, h);
                    for (var x = d.shapes[b], _ = 0; _ < v.shapes.length; _++) {
                        v.quaternion.mult(v.shapeOrientations[_], l), v.quaternion.vmult(v.shapeOffsets[_], c), 
                        c.vadd(v.position, c);
                        var C = v.shapes[_];
                        if (!(h.distanceTo(c) > x.boundingSphereRadius + C.boundingSphereRadius)) {
                            x.material && C.material && i.getContactMaterial(x.material, C.material), y ? (this.currentContactMaterial = i.defaultContactMaterial2, 
                            this.currentContactMaterial.materials[0] = d.material, this.currentContactMaterial.materials[1] = v.material, 
                            this.currentContactMaterial.friction = d.material.friction + v.material.friction, 
                            this.currentContactMaterial.restitution = d.material.restitution * v.material.restitution) : this.currentContactMaterial = i.defaultContactMaterial2, 
                            this.currentContactMaterial = i.defaultContactMaterial2;
                            var S = this[x.type | C.type];
                            S && (x.type < C.type ? S.call(this, x, C, h, c, a, l, d, v, x, C) : S.call(this, C, x, c, h, l, a, v, d, x, C));
                        }
                    }
                }
            }
        }, p.prototype[n.types.BOX | n.types.BOX] = p.prototype.boxBox = function(t, e, i, o, n, s, r, a) {
            t.convexPolyhedronRepresentation.material = t.material, e.convexPolyhedronRepresentation.material = e.material, 
            t.convexPolyhedronRepresentation.collisionResponse = t.collisionResponse, e.convexPolyhedronRepresentation.collisionResponse = e.collisionResponse, 
            this.convexConvex(t.convexPolyhedronRepresentation, e.convexPolyhedronRepresentation, i, o, n, s, r, a, t, e);
        }, p.prototype[n.types.BOX | n.types.CONVEXPOLYHEDRON] = p.prototype.boxConvex = function(t, e, i, o, n, s, r, a) {
            t.convexPolyhedronRepresentation.material = t.material, t.convexPolyhedronRepresentation.collisionResponse = t.collisionResponse, 
            this.convexConvex(t.convexPolyhedronRepresentation, e, i, o, n, s, r, a, t, e);
        }, p.prototype[n.types.BOX | n.types.PARTICLE] = p.prototype.boxParticle = function(t, e, i, o, n, s, r, a) {
            t.convexPolyhedronRepresentation.material = t.material, t.convexPolyhedronRepresentation.collisionResponse = t.collisionResponse, 
            this.convexParticle(t.convexPolyhedronRepresentation, e, i, o, n, s, r, a, t, e);
        }, p.prototype[n.types.SPHERE] = p.prototype.sphereSphere = function(t, e, i, o, n, s, r, a) {
            var l = this.createContactEquation(r, a, t, e);
            o.vsub(i, l.ni), l.ni.normalize(), l.ri.copy(l.ni), l.rj.copy(l.ni), l.ri.mult(t.radius, l.ri), 
            l.rj.mult(-e.radius, l.rj), l.ri.vadd(i, l.ri), l.ri.vsub(r.position, l.ri), l.rj.vadd(o, l.rj), 
            l.rj.vsub(a.position, l.rj), this.result.push(l), this.createFrictionEquationsFromContact(l, this.frictionResult);
        };
        var b = new r(), x = new r(), _ = new r();
        p.prototype[n.types.PLANE | n.types.TRIMESH] = p.prototype.planeTrimesh = function(t, e, i, o, n, s, l, h) {
            var c = new r(), u = b;
            u.set(0, 0, 1), n.vmult(u, u);
            for (var p = 0; p < e.vertices.length / 3; p++) {
                e.getVertex(p, c);
                var d = new r();
                d.copy(c), a.pointToWorldFrame(o, s, d, c);
                var v = x;
                if (c.vsub(i, v), u.dot(v) <= 0) {
                    var y = this.createContactEquation(l, h, t, e);
                    y.ni.copy(u);
                    var f = _;
                    u.scale(v.dot(u), f), c.vsub(f, f), y.ri.copy(f), y.ri.vsub(l.position, y.ri), y.rj.copy(c), 
                    y.rj.vsub(h.position, y.rj), this.result.push(y), this.createFrictionEquationsFromContact(y, this.frictionResult);
                }
            }
        };
        var C = new r(), S = new r(), A = (new r(), new r()), E = new r(), T = new r(), B = new r(), R = new r(), P = new r(), N = new r(), O = new r(), I = new r(), F = new r(), z = new r(), M = new o(), V = [];
        p.prototype[n.types.SPHERE | n.types.TRIMESH] = p.prototype.sphereTrimesh = function(t, e, i, o, n, r, l, h) {
            var c = T, u = B, p = R, d = P, v = N, y = O, f = M, m = E, g = S, w = V;
            a.pointToLocalFrame(o, r, i, v);
            var b = t.radius;
            f.lowerBound.set(v.x - b, v.y - b, v.z - b), f.upperBound.set(v.x + b, v.y + b, v.z + b), 
            e.getTrianglesInAABB(f, w);
            for (var x = A, _ = t.radius * t.radius, L = 0; L < w.length; L++) for (var q = 0; q < 3; q++) e.getVertex(e.indices[3 * w[L] + q], x), 
            x.vsub(v, g), g.norm2() <= _ && (m.copy(x), a.pointToWorldFrame(o, r, m, x), x.vsub(i, g), 
            (k = this.createContactEquation(l, h, t, e)).ni.copy(g), k.ni.normalize(), k.ri.copy(k.ni), 
            k.ri.scale(t.radius, k.ri), k.ri.vadd(i, k.ri), k.ri.vsub(l.position, k.ri), k.rj.copy(x), 
            k.rj.vsub(h.position, k.rj), this.result.push(k), this.createFrictionEquationsFromContact(k, this.frictionResult));
            for (L = 0; L < w.length; L++) for (q = 0; q < 3; q++) {
                e.getVertex(e.indices[3 * w[L] + q], c), e.getVertex(e.indices[3 * w[L] + (q + 1) % 3], u), 
                u.vsub(c, p), v.vsub(u, y);
                var j = y.dot(p);
                v.vsub(c, y);
                var W = y.dot(p);
                if (W > 0 && j < 0 && (v.vsub(c, y), d.copy(p), d.normalize(), W = y.dot(d), d.scale(W, y), 
                y.vadd(c, y), (Q = y.distanceTo(v)) < t.radius)) {
                    var k = this.createContactEquation(l, h, t, e);
                    y.vsub(v, k.ni), k.ni.normalize(), k.ni.scale(t.radius, k.ri), a.pointToWorldFrame(o, r, y, y), 
                    y.vsub(h.position, k.rj), a.vectorToWorldFrame(r, k.ni, k.ni), a.vectorToWorldFrame(r, k.ri, k.ri), 
                    this.result.push(k), this.createFrictionEquationsFromContact(k, this.frictionResult);
                }
            }
            for (var D = I, U = F, H = z, G = C, Y = (L = 0, w.length); L !== Y; L++) {
                e.getTriangleVertices(w[L], D, U, H), e.getNormal(w[L], G), v.vsub(D, y);
                var Q = y.dot(G);
                G.scale(Q, y), v.vsub(y, y), Q = y.distanceTo(v), s.pointInTriangle(y, D, U, H) && Q < t.radius && (k = this.createContactEquation(l, h, t, e), 
                y.vsub(v, k.ni), k.ni.normalize(), k.ni.scale(t.radius, k.ri), a.pointToWorldFrame(o, r, y, y), 
                y.vsub(h.position, k.rj), a.vectorToWorldFrame(r, k.ni, k.ni), a.vectorToWorldFrame(r, k.ri, k.ri), 
                this.result.push(k), this.createFrictionEquationsFromContact(k, this.frictionResult));
            }
            w.length = 0;
        };
        var L = new r(), q = new r();
        p.prototype[n.types.SPHERE | n.types.PLANE] = p.prototype.spherePlane = function(t, e, i, o, n, s, r, a) {
            var l = this.createContactEquation(r, a, t, e);
            if (l.ni.set(0, 0, 1), s.vmult(l.ni, l.ni), l.ni.negate(l.ni), l.ni.normalize(), 
            l.ni.mult(t.radius, l.ri), i.vsub(o, L), l.ni.mult(l.ni.dot(L), q), L.vsub(q, l.rj), 
            -L.dot(l.ni) <= t.radius) {
                var h = l.ri, c = l.rj;
                h.vadd(i, h), h.vsub(r.position, h), c.vadd(o, c), c.vsub(a.position, c), this.result.push(l), 
                this.createFrictionEquationsFromContact(l, this.frictionResult);
            }
        };
        var j = new r(), W = new r(), k = new r();
        function D(t, e, i) {
            for (var o = null, n = t.length, s = 0; s !== n; s++) {
                var r = t[s], a = j;
                t[(s + 1) % n].vsub(r, a);
                var l = W;
                a.cross(e, l);
                var h = k;
                i.vsub(r, h);
                var c = l.dot(h);
                if (!(null === o || c > 0 && !0 === o || c <= 0 && !1 === o)) return !1;
                null === o && (o = c > 0);
            }
            return !0;
        }
        var U = new r(), H = new r(), G = new r(), Y = new r(), Q = [ new r(), new r(), new r(), new r(), new r(), new r() ], X = new r(), Z = new r(), K = new r(), J = new r();
        p.prototype[n.types.SPHERE | n.types.BOX] = p.prototype.sphereBox = function(t, e, i, o, n, s, r, a) {
            var l = this.v3pool, h = Q;
            i.vsub(o, U), e.getSideNormals(h, s);
            for (var c = t.radius, u = !1, p = Z, d = K, v = J, y = null, f = 0, m = 0, g = 0, w = null, b = 0, x = h.length; b !== x && !1 === u; b++) {
                var _ = H;
                _.copy(h[b]);
                var C = _.norm();
                _.normalize();
                var S = U.dot(_);
                if (S < C + c && S > 0) {
                    var A = G, E = Y;
                    A.copy(h[(b + 1) % 3]), E.copy(h[(b + 2) % 3]);
                    var T = A.norm(), B = E.norm();
                    A.normalize(), E.normalize();
                    var R = U.dot(A), P = U.dot(E);
                    if (R < T && R > -T && P < B && P > -B) {
                        var N = Math.abs(S - C - c);
                        (null === w || N < w) && (w = N, m = R, g = P, y = C, p.copy(_), d.copy(A), v.copy(E), 
                        f++);
                    }
                }
            }
            if (f) {
                u = !0;
                var O = this.createContactEquation(r, a, t, e);
                p.mult(-c, O.ri), O.ni.copy(p), O.ni.negate(O.ni), p.mult(y, p), d.mult(m, d), p.vadd(d, p), 
                v.mult(g, v), p.vadd(v, O.rj), O.ri.vadd(i, O.ri), O.ri.vsub(r.position, O.ri), 
                O.rj.vadd(o, O.rj), O.rj.vsub(a.position, O.rj), this.result.push(O), this.createFrictionEquationsFromContact(O, this.frictionResult);
            }
            for (var I = l.get(), F = X, z = 0; 2 !== z && !u; z++) for (var M = 0; 2 !== M && !u; M++) for (var V = 0; 2 !== V && !u; V++) I.set(0, 0, 0), 
            z ? I.vadd(h[0], I) : I.vsub(h[0], I), M ? I.vadd(h[1], I) : I.vsub(h[1], I), V ? I.vadd(h[2], I) : I.vsub(h[2], I), 
            o.vadd(I, F), F.vsub(i, F), F.norm2() < c * c && (u = !0, (O = this.createContactEquation(r, a, t, e)).ri.copy(F), 
            O.ri.normalize(), O.ni.copy(O.ri), O.ri.mult(c, O.ri), O.rj.copy(I), O.ri.vadd(i, O.ri), 
            O.ri.vsub(r.position, O.ri), O.rj.vadd(o, O.rj), O.rj.vsub(a.position, O.rj), this.result.push(O), 
            this.createFrictionEquationsFromContact(O, this.frictionResult));
            l.release(I), I = null;
            var L = l.get(), q = l.get(), j = (O = l.get(), l.get()), W = (N = l.get(), h.length);
            for (z = 0; z !== W && !u; z++) for (M = 0; M !== W && !u; M++) if (z % 3 != M % 3) {
                h[M].cross(h[z], L), L.normalize(), h[z].vadd(h[M], q), O.copy(i), O.vsub(q, O), 
                O.vsub(o, O);
                var k = O.dot(L);
                for (L.mult(k, j), V = 0; V === z % 3 || V === M % 3; ) V++;
                N.copy(i), N.vsub(j, N), N.vsub(q, N), N.vsub(o, N);
                var D = Math.abs(k), $ = N.norm();
                if (D < h[V].norm() && $ < c) {
                    u = !0;
                    var tt = this.createContactEquation(r, a, t, e);
                    q.vadd(j, tt.rj), tt.rj.copy(tt.rj), N.negate(tt.ni), tt.ni.normalize(), tt.ri.copy(tt.rj), 
                    tt.ri.vadd(o, tt.ri), tt.ri.vsub(i, tt.ri), tt.ri.normalize(), tt.ri.mult(c, tt.ri), 
                    tt.ri.vadd(i, tt.ri), tt.ri.vsub(r.position, tt.ri), tt.rj.vadd(o, tt.rj), tt.rj.vsub(a.position, tt.rj), 
                    this.result.push(tt), this.createFrictionEquationsFromContact(tt, this.frictionResult);
                }
            }
            l.release(L, q, O, j, N);
        };
        var $ = new r(), tt = new r(), et = new r(), it = new r(), ot = new r(), nt = new r(), st = new r(), rt = new r(), at = new r(), lt = new r();
        p.prototype[n.types.SPHERE | n.types.CONVEXPOLYHEDRON] = p.prototype.sphereConvex = function(t, e, i, o, n, s, r, a) {
            var l = this.v3pool;
            i.vsub(o, $);
            for (var h = e.faceNormals, c = e.faces, u = e.vertices, p = t.radius, d = 0; d !== u.length; d++) {
                var v = u[d], y = ot;
                s.vmult(v, y), o.vadd(y, y);
                var f = it;
                if (y.vsub(i, f), f.norm2() < p * p) return m = !0, (N = this.createContactEquation(r, a, t, e)).ri.copy(f), 
                N.ri.normalize(), N.ni.copy(N.ri), N.ri.mult(p, N.ri), y.vsub(o, N.rj), N.ri.vadd(i, N.ri), 
                N.ri.vsub(r.position, N.ri), N.rj.vadd(o, N.rj), N.rj.vsub(a.position, N.rj), this.result.push(N), 
                void this.createFrictionEquationsFromContact(N, this.frictionResult);
            }
            for (var m = !1, g = (d = 0, c.length); d !== g && !1 === m; d++) {
                var w = h[d], b = c[d], x = nt;
                s.vmult(w, x);
                var _ = st;
                s.vmult(u[b[0]], _), _.vadd(o, _);
                var C = rt;
                x.mult(-p, C), i.vadd(C, C);
                var S = at;
                C.vsub(_, S);
                var A = S.dot(x), E = lt;
                if (i.vsub(_, E), A < 0 && E.dot(x) > 0) {
                    for (var T = [], B = 0, R = b.length; B !== R; B++) {
                        var P = l.get();
                        s.vmult(u[b[B]], P), o.vadd(P, P), T.push(P);
                    }
                    if (D(T, x, i)) {
                        m = !0;
                        var N = this.createContactEquation(r, a, t, e);
                        x.mult(-p, N.ri), x.negate(N.ni);
                        var O = l.get();
                        x.mult(-A, O);
                        var I = l.get();
                        x.mult(-p, I), i.vsub(o, N.rj), N.rj.vadd(I, N.rj), N.rj.vadd(O, N.rj), N.rj.vadd(o, N.rj), 
                        N.rj.vsub(a.position, N.rj), N.ri.vadd(i, N.ri), N.ri.vsub(r.position, N.ri), l.release(O), 
                        l.release(I), this.result.push(N), this.createFrictionEquationsFromContact(N, this.frictionResult), 
                        B = 0;
                        for (var F = T.length; B !== F; B++) l.release(T[B]);
                        return;
                    }
                    for (B = 0; B !== b.length; B++) {
                        var z = l.get(), M = l.get();
                        s.vmult(u[b[(B + 1) % b.length]], z), s.vmult(u[b[(B + 2) % b.length]], M), o.vadd(z, z), 
                        o.vadd(M, M);
                        var V = tt;
                        M.vsub(z, V);
                        var L = et;
                        V.unit(L);
                        var q = l.get(), j = l.get();
                        i.vsub(z, j);
                        var W = j.dot(L);
                        L.mult(W, q), q.vadd(z, q);
                        var k = l.get();
                        if (q.vsub(i, k), W > 0 && W * W < V.norm2() && k.norm2() < p * p) {
                            for (N = this.createContactEquation(r, a, t, e), q.vsub(o, N.rj), q.vsub(i, N.ni), 
                            N.ni.normalize(), N.ni.mult(p, N.ri), N.rj.vadd(o, N.rj), N.rj.vsub(a.position, N.rj), 
                            N.ri.vadd(i, N.ri), N.ri.vsub(r.position, N.ri), this.result.push(N), this.createFrictionEquationsFromContact(N, this.frictionResult), 
                            B = 0, F = T.length; B !== F; B++) l.release(T[B]);
                            return l.release(z), l.release(M), l.release(q), l.release(k), void l.release(j);
                        }
                        l.release(z), l.release(M), l.release(q), l.release(k), l.release(j);
                    }
                    for (B = 0, F = T.length; B !== F; B++) l.release(T[B]);
                }
            }
        }, new r(), new r(), p.prototype[n.types.PLANE | n.types.BOX] = p.prototype.planeBox = function(t, e, i, o, n, s, r, a) {
            e.convexPolyhedronRepresentation.material = e.material, e.convexPolyhedronRepresentation.collisionResponse = e.collisionResponse, 
            this.planeConvex(t, e.convexPolyhedronRepresentation, i, o, n, s, r, a);
        };
        var ht = new r(), ct = new r(), ut = new r(), pt = new r();
        p.prototype[n.types.PLANE | n.types.CONVEXPOLYHEDRON] = p.prototype.planeConvex = function(t, e, i, o, n, s, r, a) {
            var l = ht, h = ct;
            h.set(0, 0, 1), n.vmult(h, h);
            for (var c = 0, u = ut, p = 0; p !== e.vertices.length; p++) if (l.copy(e.vertices[p]), 
            s.vmult(l, l), o.vadd(l, l), l.vsub(i, u), h.dot(u) <= 0) {
                var d = this.createContactEquation(r, a, t, e), v = pt;
                h.mult(h.dot(u), v), l.vsub(v, v), v.vsub(i, d.ri), d.ni.copy(h), l.vsub(o, d.rj), 
                d.ri.vadd(i, d.ri), d.ri.vsub(r.position, d.ri), d.rj.vadd(o, d.rj), d.rj.vsub(a.position, d.rj), 
                this.result.push(d), c++, this.enableFrictionReduction || this.createFrictionEquationsFromContact(d, this.frictionResult);
            }
            this.enableFrictionReduction && c && this.createFrictionFromAverage(c);
        };
        var dt = new r(), vt = new r();
        p.prototype[n.types.CONVEXPOLYHEDRON] = p.prototype.convexConvex = function(t, e, i, o, n, s, r, a, l, h, c, u) {
            var p = dt;
            if (!(i.distanceTo(o) > t.boundingSphereRadius + e.boundingSphereRadius) && t.findSeparatingAxis(e, i, n, o, s, p, c, u)) {
                var d = [], v = vt;
                t.clipAgainstHull(i, n, e, o, s, p, -100, 100, d);
                for (var y = 0, f = 0; f !== d.length; f++) {
                    var m = this.createContactEquation(r, a, t, e, l, h), g = m.ri, w = m.rj;
                    p.negate(m.ni), d[f].normal.negate(v), v.mult(d[f].depth, v), d[f].point.vadd(v, g), 
                    w.copy(d[f].point), g.vsub(i, g), w.vsub(o, w), g.vadd(i, g), g.vsub(r.position, g), 
                    w.vadd(o, w), w.vsub(a.position, w), this.result.push(m), y++, this.enableFrictionReduction || this.createFrictionEquationsFromContact(m, this.frictionResult);
                }
                this.enableFrictionReduction && y && this.createFrictionFromAverage(y);
            }
        };
        var yt = new r(), ft = new r(), mt = new r();
        p.prototype[n.types.PLANE | n.types.PARTICLE] = p.prototype.planeParticle = function(t, e, i, o, n, s, r, a) {
            var l = yt;
            l.set(0, 0, 1), r.quaternion.vmult(l, l);
            var h = ft;
            if (o.vsub(r.position, h), l.dot(h) <= 0) {
                var c = this.createContactEquation(a, r, e, t);
                c.ni.copy(l), c.ni.negate(c.ni), c.ri.set(0, 0, 0);
                var u = mt;
                l.mult(l.dot(o), u), o.vsub(u, u), c.rj.copy(u), this.result.push(c), this.createFrictionEquationsFromContact(c, this.frictionResult);
            }
        };
        var gt = new r();
        p.prototype[n.types.PARTICLE | n.types.SPHERE] = p.prototype.sphereParticle = function(t, e, i, o, n, s, r, a) {
            var l = gt;
            if (l.set(0, 0, 1), o.vsub(i, l), l.norm2() <= t.radius * t.radius) {
                var h = this.createContactEquation(a, r, e, t);
                l.normalize(), h.rj.copy(l), h.rj.mult(t.radius, h.rj), h.ni.copy(l), h.ni.negate(h.ni), 
                h.ri.set(0, 0, 0), this.result.push(h), this.createFrictionEquationsFromContact(h, this.frictionResult);
            }
        };
        var wt = new l(), bt = new r(), xt = (new r(), new r()), _t = new r(), Ct = new r();
        p.prototype[n.types.PARTICLE | n.types.CONVEXPOLYHEDRON] = p.prototype.convexParticle = function(t, e, i, o, n, s, r, a) {
            var l = -1, h = xt, c = Ct, u = null, p = bt;
            if (p.copy(o), p.vsub(i, p), n.conjugate(wt), wt.vmult(p, p), t.pointIsInside(p)) {
                t.worldVerticesNeedsUpdate && t.computeWorldVertices(i, n), t.worldFaceNormalsNeedsUpdate && t.computeWorldFaceNormals(n);
                for (var d = 0, v = t.faces.length; d !== v; d++) {
                    var y = [ t.worldVertices[t.faces[d][0]] ], f = t.worldFaceNormals[d];
                    o.vsub(y[0], _t);
                    var m = -f.dot(_t);
                    (null === u || Math.abs(m) < Math.abs(u)) && (u = m, l = d, h.copy(f));
                }
                if (-1 !== l) {
                    var g = this.createContactEquation(a, r, e, t);
                    h.mult(u, c), c.vadd(o, c), c.vsub(i, c), g.rj.copy(c), h.negate(g.ni), g.ri.set(0, 0, 0);
                    var w = g.ri, b = g.rj;
                    w.vadd(o, w), w.vsub(a.position, w), b.vadd(i, b), b.vsub(r.position, b), this.result.push(g), 
                    this.createFrictionEquationsFromContact(g, this.frictionResult);
                } else console.warn("Point found inside convex, but did not find penetrating face!");
            }
        }, p.prototype[n.types.BOX | n.types.HEIGHTFIELD] = p.prototype.boxHeightfield = function(t, e, i, o, n, s, r, a) {
            t.convexPolyhedronRepresentation.material = t.material, t.convexPolyhedronRepresentation.collisionResponse = t.collisionResponse, 
            this.convexHeightfield(t.convexPolyhedronRepresentation, e, i, o, n, s, r, a);
        };
        var St = new r(), At = new r(), Et = [ 0 ];
        p.prototype[n.types.CONVEXPOLYHEDRON | n.types.HEIGHTFIELD] = p.prototype.convexHeightfield = function(t, e, i, o, n, s, r, l) {
            var h = e.data, c = e.elementSize, u = t.boundingSphereRadius, p = At, d = Et, v = St;
            a.pointToLocalFrame(o, s, i, v);
            var y = Math.floor((v.x - u) / c) - 1, f = Math.ceil((v.x + u) / c) + 1, m = Math.floor((v.y - u) / c) - 1, g = Math.ceil((v.y + u) / c) + 1;
            if (!(f < 0 || g < 0 || y > h.length || m > h[0].length)) {
                y < 0 && (y = 0), f < 0 && (f = 0), m < 0 && (m = 0), g < 0 && (g = 0), y >= h.length && (y = h.length - 1), 
                f >= h.length && (f = h.length - 1), g >= h[0].length && (g = h[0].length - 1), 
                m >= h[0].length && (m = h[0].length - 1);
                var w = [];
                e.getRectMinMax(y, m, f, g, w);
                var b = w[0], x = w[1];
                if (!(v.z - u > x || v.z + u < b)) for (var _ = y; _ < f; _++) for (var C = m; C < g; C++) e.getConvexTrianglePillar(_, C, !1), 
                a.pointToWorldFrame(o, s, e.pillarOffset, p), i.distanceTo(p) < e.pillarConvex.boundingSphereRadius + t.boundingSphereRadius && this.convexConvex(t, e.pillarConvex, i, p, n, s, r, l, null, null, d, null), 
                e.getConvexTrianglePillar(_, C, !0), a.pointToWorldFrame(o, s, e.pillarOffset, p), 
                i.distanceTo(p) < e.pillarConvex.boundingSphereRadius + t.boundingSphereRadius && this.convexConvex(t, e.pillarConvex, i, p, n, s, r, l, null, null, d, null);
            }
        };
        var Tt = new r(), Bt = new r();
        p.prototype[n.types.SPHERE | n.types.HEIGHTFIELD] = p.prototype.sphereHeightfield = function(t, e, i, o, n, s, r, l) {
            var h = e.data, c = t.radius, u = e.elementSize, p = Bt, d = Tt;
            a.pointToLocalFrame(o, s, i, d);
            var v = Math.floor((d.x - c) / u) - 1, y = Math.ceil((d.x + c) / u) + 1, f = Math.floor((d.y - c) / u) - 1, m = Math.ceil((d.y + c) / u) + 1;
            if (!(y < 0 || m < 0 || v > h.length || m > h[0].length)) {
                v < 0 && (v = 0), y < 0 && (y = 0), f < 0 && (f = 0), m < 0 && (m = 0), v >= h.length && (v = h.length - 1), 
                y >= h.length && (y = h.length - 1), m >= h[0].length && (m = h[0].length - 1), 
                f >= h[0].length && (f = h[0].length - 1);
                var g = [];
                e.getRectMinMax(v, f, y, m, g);
                var w = g[0], b = g[1];
                if (!(d.z - c > b || d.z + c < w)) for (var x = this.result, _ = v; _ < y; _++) for (var C = f; C < m; C++) {
                    var S = x.length;
                    if (e.getConvexTrianglePillar(_, C, !1), a.pointToWorldFrame(o, s, e.pillarOffset, p), 
                    i.distanceTo(p) < e.pillarConvex.boundingSphereRadius + t.boundingSphereRadius && this.sphereConvex(t, e.pillarConvex, i, p, n, s, r, l), 
                    e.getConvexTrianglePillar(_, C, !0), a.pointToWorldFrame(o, s, e.pillarOffset, p), 
                    i.distanceTo(p) < e.pillarConvex.boundingSphereRadius + t.boundingSphereRadius && this.sphereConvex(t, e.pillarConvex, i, p, n, s, r, l), 
                    x.length - S > 2) return;
                }
            }
        };
    }, {
        "../collision/AABB": 3,
        "../collision/Ray": 9,
        "../equations/ContactEquation": 19,
        "../equations/FrictionEquation": 21,
        "../math/Quaternion": 28,
        "../math/Transform": 29,
        "../math/Vec3": 30,
        "../shapes/ConvexPolyhedron": 38,
        "../shapes/Shape": 43,
        "../solver/Solver": 47,
        "../utils/Vec3Pool": 54
    } ],
    56: [ function(t, e, i) {
        e.exports = g;
        var o = t("../shapes/Shape"), n = t("../math/Vec3"), s = t("../math/Quaternion"), r = t("../solver/GSSolver"), a = (t("../utils/Vec3Pool"), 
        t("../equations/ContactEquation"), t("../equations/FrictionEquation"), t("./Narrowphase")), l = t("../utils/EventTarget"), h = t("../collision/ArrayCollisionMatrix"), c = t("../material/Material"), u = t("../material/ContactMaterial"), p = t("../objects/Body"), d = t("../utils/TupleDictionary"), v = t("../collision/RaycastResult"), y = t("../collision/AABB"), f = t("../collision/Ray"), m = t("../collision/NaiveBroadphase");
        function g() {
            l.apply(this), this.dt = -1, this.allowSleep = !1, this.contacts = [], this.allContacts = [], 
            this.frictionEquations = [], this.quatNormalizeSkip = 0, this.quatNormalizeFast = !1, 
            this.time = 0, this.stepnumber = 0, this.default_dt = 1 / 60, this.nextId = 0, this.gravity = new n(), 
            this.broadphase = new m(), this.bodies = [], this.callBackBody = [], this.solver = new r(), 
            this.constraints = [], this.narrowphase = new a(this), this.collisionMatrix = new h(), 
            this.collisionMatrixPrevious = new h(), this.materials = [], this.contactmaterials = [], 
            this.contactMaterialTable = new d(), this.defaultMaterial = new c("default"), this.defaultContactMaterial = new u(this.defaultMaterial, this.defaultMaterial, {
                friction: .3,
                restitution: 0
            }), this.defaultContactMaterial2 = new u(this.defaultMaterial, this.defaultMaterial, {
                friction: .3,
                restitution: 0
            }), this.doProfiling = !1, this.profile = {
                solve: 0,
                makeContactConstraints: 0,
                broadphase: 0,
                integrate: 0,
                narrowphase: 0
            }, this.subsystems = [], this.addBodyEvent = {
                type: "addBody",
                body: null
            }, this.removeBodyEvent = {
                type: "removeBody",
                body: null
            };
        }
        g.prototype = new l(), new y();
        var w = new f();
        if (g.prototype.getContactMaterial = function(t, e) {
            return this.contactMaterialTable.get(t.id, e.id);
        }, g.prototype.numObjects = function() {
            return this.bodies.length;
        }, g.prototype.collisionMatrixTick = function() {
            var t = this.collisionMatrixPrevious;
            this.collisionMatrixPrevious = this.collisionMatrix, this.collisionMatrix = t, this.collisionMatrix.reset();
        }, g.prototype.add = g.prototype.addBody = function(t) {
            -1 === this.bodies.indexOf(t) && (t.index = this.bodies.length, this.bodies.push(t), 
            t.world = this, t.initPosition.copy(t.position), t.initVelocity.copy(t.velocity), 
            t.timeLastSleepy = this.time, t instanceof p && (t.initAngularVelocity.copy(t.angularVelocity), 
            t.initQuaternion.copy(t.quaternion)), this.collisionMatrix.setNumObjects(this.bodies.length), 
            this.addBodyEvent.body = t, this.dispatchEvent(this.addBodyEvent));
        }, g.prototype.addConstraint = function(t) {
            this.constraints.push(t);
        }, g.prototype.removeConstraint = function(t) {
            var e = this.constraints.indexOf(t);
            -1 !== e && this.constraints.splice(e, 1);
        }, g.prototype.rayTest = function(t, e, i) {
            i instanceof v ? this.raycastClosest(t, e, {
                skipBackfaces: !0
            }, i) : this.raycastAll(t, e, {
                skipBackfaces: !0
            }, i);
        }, g.prototype.raycastAll = function(t, e, i, o) {
            return i.mode = f.ALL, i.from = t, i.to = e, i.callback = o, w.intersectWorld(this, i);
        }, g.prototype.raycastAny = function(t, e, i, o) {
            return i.mode = f.ANY, i.from = t, i.to = e, i.result = o, w.intersectWorld(this, i);
        }, g.prototype.raycastClosest = function(t, e, i, o) {
            return i.mode = f.CLOSEST, i.from = t, i.to = e, i.result = o, w.intersectWorld(this, i);
        }, g.prototype.remove = function(t) {
            t.world = null;
            var e = this.bodies.length - 1, i = this.bodies, o = i.indexOf(t);
            if (-1 !== o) {
                i.splice(o, 1);
                for (var n = 0; n !== i.length; n++) i[n].index = n;
                this.collisionMatrix.setNumObjects(e), this.removeBodyEvent.body = t, this.dispatchEvent(this.removeBodyEvent);
            }
        }, g.prototype.removeBody = g.prototype.remove, g.prototype.addMaterial = function(t) {
            this.materials.push(t);
        }, g.prototype.addContactMaterial = function(t) {
            this.contactmaterials.push(t), this.contactMaterialTable.set(t.materials[0].id, t.materials[1].id, t);
        }, "undefined" == typeof performance && (performance = {}), !performance.now) {
            var b = Date.now();
            performance.timing && performance.timing.navigationStart && (b = performance.timing.navigationStart), 
            performance.now = function() {
                return Date.now() - b;
            };
        }
        var x = new n();
        g.prototype.step = function(t, e, i) {
            if (i = i || 10, 0 === (e = e || 0)) this.internalStep(t), this.time += t; else {
                var o = Math.floor((this.time + e) / t) - Math.floor(this.time / t);
                o = Math.min(o, i);
                for (var n = performance.now(), s = 0; s !== o && (this.internalStep(t), !(performance.now() - n > 1e3 * t)); s++) ;
                this.time += e;
                for (var r = this.time % t / t, a = x, l = this.bodies, h = 0; h !== l.length; h++) {
                    var c = l[h];
                    c.type !== p.STATIC && c.sleepState !== p.SLEEPING ? (c.position.vsub(c.previousPosition, a), 
                    a.scale(r, a), c.position.vadd(a, c.interpolatedPosition)) : (c.interpolatedPosition.copy(c.position), 
                    c.interpolatedQuaternion.copy(c.quaternion));
                }
            }
        };
        var _ = {
            type: "postStep"
        }, C = {
            type: "preStep"
        }, S = {
            type: "collide",
            body: null,
            contact: null
        }, A = [], E = [], T = [], B = [], R = (new n(), new n(), new n(), new n(), new n(), 
        new n(), new n(), new n(), new n(), new s(), new s()), P = new s(), N = new n();
        g.prototype.internalStep = function(t) {
            this.dt = t;
            var e, i = this.contacts, n = this.allContacts, s = T, r = B, a = this.numObjects(), l = this.bodies, h = this.solver, c = this.gravity, u = this.doProfiling, d = this.profile, v = p.DYNAMIC, y = this.constraints, f = E, m = (c.norm(), 
            c.x), g = c.y, w = c.z, b = 0;
            for (u && (e = performance.now()), b = 0; b !== a; b++) if ((U = l[b]).type & v) {
                var x = U.force, O = U.mass;
                x.x += O * m, x.y += O * g, x.z += O * w;
            }
            b = 0;
            for (var I = this.subsystems.length; b !== I; b++) this.subsystems[b].update();
            u && (e = performance.now()), s.length = 0, r.length = 0, this.broadphase.collisionPairs(this, s, r), 
            u && (d.broadphase = performance.now() - e);
            var F = y.length;
            for (b = 0; b !== F; b++) if (!(G = y[b]).collideConnected) for (var z = s.length - 1; z >= 0; z -= 1) (G.bodyA === s[z] && G.bodyB === r[z] || G.bodyB === s[z] && G.bodyA === r[z]) && (s.splice(z, 1), 
            r.splice(z, 1));
            this.collisionMatrixTick(), u && (e = performance.now());
            var M = A, V = n.length;
            for (b = 0; b !== V; b++) M.push(n[b]);
            i.length = 0, n.length = 0;
            var L = this.frictionEquations.length;
            for (b = 0; b !== L; b++) f.push(this.frictionEquations[b]);
            this.frictionEquations.length = 0, this.narrowphase.getContacts(s, r, this, n, M, this.frictionEquations, f);
            for (var q = n.length, j = 0; j != q; j++) {
                var W = n[j];
                W.bi.isTrigger || W.bj.isTrigger || i.push(W);
            }
            for (u && (d.narrowphase = performance.now() - e), u && (e = performance.now()), 
            b = 0; b < this.frictionEquations.length; b++) h.addEquation(this.frictionEquations[b]);
            for (var k = i.length, D = 0; D !== k; D++) {
                var U = (G = i[D]).bi, H = G.bj;
                G.si, G.sj, (U.material && H.material && this.getContactMaterial(U.material, H.material) || this.defaultContactMaterial).friction, 
                U.material && H.material && (U.material.friction >= 0 && H.material.friction >= 0 && (U.material.friction, 
                H.material.friction), U.material.restitution >= 0 && H.material.restitution >= 0 && (G.restitution = U.material.restitution * H.material.restitution)), 
                h.addEquation(G), U.allowSleep && U.type === p.DYNAMIC && U.sleepState === p.SLEEPING && H.sleepState === p.AWAKE && H.type !== p.STATIC && H.velocity.norm2() + H.angularVelocity.norm2() >= 2 * Math.pow(H.sleepSpeedLimit, 2) && (U._wakeUpAfterNarrowphase = !0), 
                H.allowSleep && H.type === p.DYNAMIC && H.sleepState === p.SLEEPING && U.sleepState === p.AWAKE && U.type !== p.STATIC && U.velocity.norm2() + U.angularVelocity.norm2() >= 2 * Math.pow(U.sleepSpeedLimit, 2) && (H._wakeUpAfterNarrowphase = !0), 
                this.collisionMatrix.set(U, H, !0), this.collisionMatrixPrevious.get(U, H) || (S.body = H, 
                S.contact = G, U.dispatchEvent(S), S.body = U, H.dispatchEvent(S));
            }
            for (u && (d.makeContactConstraints = performance.now() - e, e = performance.now()), 
            b = 0; b !== a; b++) (U = l[b])._wakeUpAfterNarrowphase && (U.wakeUp(), U._wakeUpAfterNarrowphase = !1);
            for (F = y.length, b = 0; b !== F; b++) {
                var G;
                (G = y[b]).update(), z = 0;
                for (var Y = G.equations.length; z !== Y; z++) {
                    var Q = G.equations[z];
                    h.addEquation(Q);
                }
            }
            h.solve(t, this), u && (d.solve = performance.now() - e), h.removeAllEquations();
            var X = Math.pow;
            for (b = 0; b !== a; b++) if ((U = l[b]).type & v) {
                var Z = X(1 - U.linearDamping, t), K = U.velocity;
                K.mult(Z, K);
                var J = U.angularVelocity;
                if (J) {
                    var $ = X(1 - U.angularDamping, t);
                    J.mult($, J);
                }
            }
            for (this.dispatchEvent(C), b = 0; b !== a; b++) (U = l[b]).preStep && U.preStep.call(U);
            u && (e = performance.now());
            var tt = R, et = P, it = this.stepnumber, ot = p.DYNAMIC | p.KINEMATIC, nt = it % (this.quatNormalizeSkip + 1) == 0, st = this.quatNormalizeFast, rt = .5 * t;
            for (o.types.PLANE, o.types.CONVEXPOLYHEDRON, this.callBackBody.length = 0, b = 0; b !== a; b++) {
                var at = l[b], lt = at.force, ht = at.torque;
                if (at.type & ot && at.sleepState !== p.SLEEPING) {
                    var ct = at.velocity, ut = at.angularVelocity, pt = at.position, dt = at.quaternion, vt = at.invMass, yt = at.invInertiaWorld;
                    ct.x += lt.x * vt * t, ct.y += lt.y * vt * t, ct.z += lt.z * vt * t, at.angularVelocity && (yt.vmult(ht, N), 
                    N.mult(t, N), N.vadd(ut, ut)), pt.x += ct.x * t, pt.y += ct.y * t, pt.z += ct.z * t, 
                    at.angularVelocity && (tt.set(ut.x, ut.y, ut.z, 0), tt.mult(dt, et), dt.x += rt * et.x, 
                    dt.y += rt * et.y, dt.z += rt * et.z, dt.w += rt * et.w, nt && (st ? dt.normalizeFast() : dt.normalize())), 
                    this.callBackBody.push(at), at.aabb && (at.aabbNeedsUpdate = !0), at.updateInertiaWorld && at.updateInertiaWorld();
                }
            }
            for (this.clearForces(), this.broadphase.dirty = !0, u && (d.integrate = performance.now() - e), 
            this.time += t, this.stepnumber += 1, this.dispatchEvent(_), b = 0; b !== a; b++) {
                var ft = (U = l[b]).postStep;
                ft && ft.call(U);
            }
            if (this.allowSleep) for (b = 0; b !== a; b++) l[b].sleepTick(this.time);
        }, g.prototype.clearForces = function() {
            for (var t = this.bodies, e = t.length, i = 0; i !== e; i++) {
                var o = t[i];
                o.force, o.torque, o.force.set(0, 0, 0), o.torque.set(0, 0, 0);
            }
        };
    }, {
        "../collision/AABB": 3,
        "../collision/ArrayCollisionMatrix": 4,
        "../collision/NaiveBroadphase": 7,
        "../collision/Ray": 9,
        "../collision/RaycastResult": 10,
        "../equations/ContactEquation": 19,
        "../equations/FrictionEquation": 21,
        "../material/ContactMaterial": 24,
        "../material/Material": 25,
        "../math/Quaternion": 28,
        "../math/Vec3": 30,
        "../objects/Body": 31,
        "../shapes/Shape": 43,
        "../solver/GSSolver": 46,
        "../utils/EventTarget": 49,
        "../utils/TupleDictionary": 52,
        "../utils/Vec3Pool": 54,
        "./Narrowphase": 55
    } ]
}, {}, [ 2 ])(2), function(t, l) {
    var h = function() {
        function t() {
            r(this, t), this._lastUpdateFrame = -2147483648, this._updateFrame = -2147483648, 
            this._isTrigger = !1, this.contacts = [];
        }
        return a(t, [ {
            key: "_setUpdateFrame",
            value: function(t) {
                this._lastUpdateFrame = this._updateFrame, this._updateFrame = t;
            }
        } ]), t;
    }(), c = a(function t() {
        r(this, t), this._idCounter = 0, this.colliderA = null, this.colliderB = null, this.distance = 0, 
        this.normal = new l.Vector3(), this.positionOnA = new l.Vector3(), this.positionOnB = new l.Vector3(), 
        this._id = ++this._idCounter;
    }), u = a(function t() {
        r(this, t), this.succeeded = !1, this.collider = null, this.point = new l.Vector3(), 
        this.normal = new l.Vector3(), this.hitFraction = 0;
    }), p = function() {
        function t() {
            r(this, t), this._hitResultsPoolIndex = 0, this._hitResultsPool = [], this._contactPonintsPoolIndex = 0, 
            this._contactPointsPool = [], this._collisionsPool = [], this._collisions = {};
        }
        return a(t, [ {
            key: "getHitResult",
            value: function() {
                var t = this._hitResultsPool[this._hitResultsPoolIndex++];
                return t || (t = new u(), this._hitResultsPool.push(t)), t;
            }
        }, {
            key: "recoverAllHitResultsPool",
            value: function() {
                this._hitResultsPoolIndex = 0;
            }
        }, {
            key: "getContactPoints",
            value: function() {
                var t = this._contactPointsPool[this._contactPonintsPoolIndex++];
                return t || (t = new c(), this._contactPointsPool.push(t)), t;
            }
        }, {
            key: "recoverAllContactPointsPool",
            value: function() {
                this._contactPonintsPoolIndex = 0;
            }
        }, {
            key: "getCollision",
            value: function(t, e) {
                var i, o = t.id, n = e.id, s = this._collisions[o];
                return s && (i = s[n]), i || (s || (s = {}, this._collisions[o] = s), (i = 0 === this._collisionsPool.length ? new h() : this._collisionsPool.pop())._colliderA = t, 
                i._colliderB = e, s[n] = i), i;
            }
        }, {
            key: "recoverCollision",
            value: function(t) {
                var e = t._colliderA.id, i = t._colliderB.id;
                this._collisions[e][i] = null, this._collisionsPool.push(t);
            }
        }, {
            key: "garbageCollection",
            value: function() {
                for (var t in this._hitResultsPoolIndex = 0, this._hitResultsPool.length = 0, this._contactPonintsPoolIndex = 0, 
                this._contactPointsPool.length = 0, this._collisionsPool.length = 0, this._collisionsPool) {
                    var e = this._collisionsPool[t], i = !0;
                    for (var o in e) e[o] ? i = !1 : delete e[o];
                    i && delete this._collisionsPool[t];
                }
            }
        } ]), t;
    }(), d = function() {
        function t() {
            r(this, t), this._scale = new l.Vector3(1, 1, 1), this._centerMatrix = new l.Matrix4x4(), 
            this._attatched = !1, this._indexInCompound = -1, this._compoundParent = null, this._attatchedCollisionObject = null, 
            this._referenceCount = 0, this._localOffset = new l.Vector3(0, 0, 0), this._localRotation = new l.Quaternion(0, 0, 0, 1), 
            this.needsCustomCollisionCallback = !1;
        }
        return a(t, [ {
            key: "type",
            get: function() {
                return this._type;
            }
        }, {
            key: "localOffset",
            get: function() {
                return this._localOffset;
            },
            set: function(t) {
                t.cloneTo(this._localOffset);
            }
        }, {
            key: "localRotation",
            get: function() {
                return this._localRotation;
            },
            set: function(t) {
                this._localRotation = t, this._compoundParent && this._compoundParent._updateChildTransform(this);
            }
        }, {
            key: "_setScale",
            value: function(t) {}
        }, {
            key: "_addReference",
            value: function() {
                this._referenceCount++;
            }
        }, {
            key: "_removeReference",
            value: function() {
                this._referenceCount--;
            }
        }, {
            key: "updateLocalTransformations",
            value: function() {
                if (this._compoundParent) {
                    var e = t._tempVector30;
                    l.Vector3.multiply(this.localOffset, this._scale, e), t._createAffineTransformation(e, this.localRotation, this._centerMatrix.elements);
                } else t._createAffineTransformation(this.localOffset, this.localRotation, this._centerMatrix.elements);
            }
        }, {
            key: "cloneTo",
            value: function(t) {
                var e = t;
                this._localOffset.cloneTo(e.localOffset), this._localRotation.cloneTo(e.localRotation), 
                e.localOffset = e.localOffset, e.localRotation = e.localRotation;
            }
        }, {
            key: "clone",
            value: function() {
                return null;
            }
        }, {
            key: "destroy",
            value: function() {
                this._btShape && (this._btShape = null);
            }
        } ], [ {
            key: "__init__",
            value: function() {
                t._btScale = new CANNON.Vec3(), t._btVector30 = new CANNON.Vec3(), t._btQuaternion0 = new CANNON.Quaternion();
            }
        }, {
            key: "_createAffineTransformation",
            value: function(t, e, i) {
                var o = e.x, n = e.y, s = e.z, r = e.w, a = o + o, l = n + n, h = s + s, c = o * a, u = o * l, p = o * h, d = n * l, v = n * h, y = s * h, f = r * a, m = r * l, g = r * h;
                i[0] = 1 - (d + y), i[1] = u + g, i[2] = p - m, i[3] = 0, i[4] = u - g, i[5] = 1 - (c + y), 
                i[6] = v + f, i[7] = 0, i[8] = p + m, i[9] = v - f, i[10] = 1 - (c + d), i[11] = 0, 
                i[12] = t.x, i[13] = t.y, i[14] = t.z, i[15] = 1;
            }
        } ]), t;
    }();
    d.SHAPEORIENTATION_UPX = 0, d.SHAPEORIENTATION_UPY = 1, d.SHAPEORIENTATION_UPZ = 2, 
    d.SHAPETYPES_BOX = 0, d.SHAPETYPES_SPHERE = 1, d.SHAPETYPES_CYLINDER = 2, d.SHAPETYPES_CAPSULE = 3, 
    d.SHAPETYPES_CONVEXHULL = 4, d.SHAPETYPES_COMPOUND = 5, d.SHAPETYPES_STATICPLANE = 6, 
    d.SHAPETYPES_CONE = 7, d._tempVector30 = new l.Vector3();
    var v = function(t) {
        n(i, t);
        var e = s(i);
        function i() {
            var t, o = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1, n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 1, s = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1;
            r(this, i), (t = e.call(this))._sizeX = o, t._sizeY = n, t._sizeZ = s, t._type = d.SHAPETYPES_BOX;
            var a = new CANNON.Vec3(o / 2, n / 2, s / 2);
            return t._btShape = new CANNON.Box(a), t;
        }
        return a(i, [ {
            key: "sizeX",
            get: function() {
                return this._sizeX;
            }
        }, {
            key: "sizeY",
            get: function() {
                return this._sizeY;
            }
        }, {
            key: "sizeZ",
            get: function() {
                return this._sizeZ;
            }
        }, {
            key: "_setScale",
            value: function(t) {
                this._scale.setValue(t.x, t.y, t.z), this._btShape.halfExtents.set(this.sizeX / 2 * t.x, this.sizeY / 2 * t.y, this.sizeZ / 2 * t.z), 
                this._btShape.updateConvexPolyhedronRepresentation(), this._btShape.updateBoundingSphereRadius();
            }
        }, {
            key: "clone",
            value: function() {
                var t = new i(this._sizeX, this._sizeY, this._sizeZ);
                return this.cloneTo(t), t;
            }
        } ], [ {
            key: "__init__",
            value: function() {
                i._btSize = new CANNON.Vec3();
            }
        } ]), i;
    }(d), y = function(t) {
        n(i, t);
        var e = s(i);
        function i() {
            var t, o = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : .5;
            return r(this, i), (t = e.call(this))._radius = o, t._type = d.SHAPETYPES_SPHERE, 
            t._btShape = new CANNON.Sphere(o), t;
        }
        return a(i, [ {
            key: "radius",
            get: function() {
                return this._radius;
            }
        }, {
            key: "_setScale",
            value: function(t) {
                var e = Math.max(t.x, t.y, t.z);
                this._scale.setValue(e, e, e), this._btShape.radius = e * this.radius, this._btShape.updateBoundingSphereRadius();
            }
        }, {
            key: "clone",
            value: function() {
                var t = new i(this._radius);
                return this.cloneTo(t), t;
            }
        } ]), i;
    }(d), f = function(t) {
        n(c, t);
        var h = s(c);
        function c(t, i) {
            var o;
            return r(this, c), (o = h.call(this))._restitution = 0, o._friction = .5, o._collisionGroup = l.Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER, 
            o._canCollideWith = l.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER, o._colliderShape = null, 
            o._transformFlag = 2147483647, o._controlBySimulation = !1, o._enableProcessCollisions = !0, 
            o._inPhysicUpdateListIndex = -1, o.canScaleShape = !0, o._collisionGroup = t, o._canCollideWith = i, 
            c._physicObjectsMap[o.id] = e(o), o;
        }
        return a(c, [ {
            key: "restitution",
            get: function() {
                return this._restitution;
            },
            set: function(t) {
                this._restitution = t, this._btColliderObject && (this._btColliderObject.material.restitution = t);
            }
        }, {
            key: "friction",
            get: function() {
                return this._friction;
            },
            set: function(t) {
                this._friction = t, this._btColliderObject && (this._btColliderObject.material.friction = t);
            }
        }, {
            key: "colliderShape",
            get: function() {
                return this._colliderShape;
            },
            set: function(t) {
                var e = this._colliderShape;
                if (e && (e._attatched = !1, e._attatchedCollisionObject = null), this._colliderShape = t, 
                t) {
                    if (t._attatched) throw "PhysicsComponent: this shape has attatched to other entity.";
                    if (t._attatched = !0, t._attatchedCollisionObject = this, this._btColliderObject) {
                        if (t.type != d.SHAPETYPES_COMPOUND) {
                            this._btColliderObject.shapes.length = 0, this._btColliderObject.shapeOffsets.length = 0, 
                            this._btColliderObject.shapeOrientations.length = 0;
                            var i = t.localOffset, o = t._scale, n = new CANNON.Vec3(i.x * o.x, i.y * o.y, i.z * o.z);
                            this._btColliderObject.addShape(this._colliderShape._btShape, n), this._btColliderObject.updateBoundingRadius();
                        } else t.bindRigidBody(this);
                        var s = this._simulation && this._enabled;
                        s && e && this._removeFromSimulation(), this._onShapeChange(t), s && (this._derivePhysicsTransformation(!0), 
                        this._addToSimulation());
                    }
                } else this._simulation && this._enabled && e && this._removeFromSimulation();
            }
        }, {
            key: "simulation",
            get: function() {
                return this._simulation;
            }
        }, {
            key: "collisionGroup",
            get: function() {
                return this._collisionGroup;
            },
            set: function(t) {
                this._collisionGroup !== t && (this._collisionGroup = t, this._btColliderObject.collisionFilterGroup = t, 
                this._simulation && this._colliderShape && this._enabled && (this._removeFromSimulation(), 
                this._addToSimulation()));
            }
        }, {
            key: "canCollideWith",
            get: function() {
                return this._canCollideWith;
            },
            set: function(t) {
                this._canCollideWith !== t && (this._canCollideWith = t, this._btColliderObject.collisionFilterMask = t, 
                this._simulation && this._colliderShape && this._enabled && (this._removeFromSimulation(), 
                this._addToSimulation()));
            }
        }, {
            key: "_parseShape",
            value: function(t) {
                if (1 === t.length) {
                    var e = c._creatShape(t[0]);
                    this.colliderShape = e;
                }
            }
        }, {
            key: "_onScaleChange",
            value: function(t) {
                this._colliderShape._setScale(t), this._btColliderObject.updateBoundingRadius();
            }
        }, {
            key: "_onEnable",
            value: function() {
                this._simulation = this.owner._scene._cannonPhysicsSimulation, this._colliderShape && (this._derivePhysicsTransformation(!0), 
                this._addToSimulation());
            }
        }, {
            key: "_onDisable",
            value: function() {
                this._colliderShape && (this._removeFromSimulation(), -1 !== this._inPhysicUpdateListIndex && this._simulation._physicsUpdateList.remove(this)), 
                this._simulation = null;
            }
        }, {
            key: "_onDestroy",
            value: function() {
                delete c._physicObjectsMap[this.id], this._btColliderObject = null, this._colliderShape.destroy(), 
                i(o(c.prototype), "_onDestroy", this).call(this), this._btColliderObject = null, 
                this._colliderShape = null, this._simulation = null, this.owner.transform.off(l.Event.TRANSFORM_CHANGED, this, this._onTransformChanged);
            }
        }, {
            key: "_isValid",
            value: function() {
                return this._simulation && this._colliderShape && this._enabled;
            }
        }, {
            key: "_parse",
            value: function(t) {
                null != t.collisionGroup && (this.collisionGroup = t.collisionGroup), null != t.canCollideWith && (this.canCollideWith = t.canCollideWith);
            }
        }, {
            key: "_setTransformFlag",
            value: function(t, e) {
                e ? this._transformFlag |= t : this._transformFlag &= ~t;
            }
        }, {
            key: "_getTransformFlag",
            value: function(t) {
                return 0 != (this._transformFlag & t);
            }
        }, {
            key: "_addToSimulation",
            value: function() {}
        }, {
            key: "_removeFromSimulation",
            value: function() {}
        }, {
            key: "_derivePhysicsTransformation",
            value: function(t) {
                var e = this._btColliderObject;
                this._innerDerivePhysicsTransformation(e, t);
            }
        }, {
            key: "_innerDerivePhysicsTransformation",
            value: function(t, e) {
                var i = this.owner._transform;
                if (e || this._getTransformFlag(l.Transform3D.TRANSFORM_WORLDPOSITION)) {
                    var o = this._colliderShape.localOffset, n = i.position, s = c._btVector30;
                    if (0 !== o.x || 0 !== o.y || 0 !== o.z) {
                        var r = c._tempVector30, a = i.worldMatrix;
                        l.Vector3.transformCoordinate(o, a, r), s.set(r.x, r.y, r.z);
                    } else s.set(n.x, n.y, n.z);
                    t.position.set(s.x, s.y, s.z), this._setTransformFlag(l.Transform3D.TRANSFORM_WORLDPOSITION, !1);
                }
                if (e || this._getTransformFlag(l.Transform3D.TRANSFORM_WORLDQUATERNION)) {
                    var h = this._colliderShape.localRotation, u = c._btQuaternion0, p = i.rotation;
                    if (0 !== h.x || 0 !== h.y || 0 !== h.z || 1 !== h.w) {
                        var d = c._tempQuaternion0;
                        c.physicQuaternionMultiply(p.x, p.y, p.z, p.w, h, d), u.set(d.x, d.y, d.z, d.w);
                    } else u.set(p.x, p.y, p.z, p.w);
                    t.quaternion.set(u.x, u.y, u.z, u.w), this._setTransformFlag(l.Transform3D.TRANSFORM_WORLDQUATERNION, !1);
                }
                (e || this._getTransformFlag(l.Transform3D.TRANSFORM_WORLDSCALE)) && (this._onScaleChange(i.getWorldLossyScale()), 
                this._setTransformFlag(l.Transform3D.TRANSFORM_WORLDSCALE, !1));
            }
        }, {
            key: "_updateTransformComponent",
            value: function(t) {
                var e = this._colliderShape, i = e.localOffset, o = e.localRotation, n = this.owner._transform, s = n.position, r = n.rotation, a = t.position, h = t.quaternion, u = h.x, p = h.y, d = h.z, v = h.w;
                if (0 !== o.x || 0 !== o.y || 0 !== o.z || 1 !== o.w) {
                    var y = c._tempQuaternion0;
                    o.invert(y), c.physicQuaternionMultiply(u, p, d, v, y, r);
                } else r.x = u, r.y = p, r.z = d, r.w = v;
                if (n.rotation = r, 0 !== i.x || 0 !== i.y || 0 !== i.z) {
                    var f = c._tempVector30;
                    f.x = i.x, f.y = i.y, f.z = i.z, l.Vector3.transformQuat(f, r, f), s.x = a.x - f.x, 
                    s.y = a.y - f.z, s.z = a.z - f.y;
                } else s.x = a.x, s.y = a.y, s.z = a.z;
                n.position = s;
            }
        }, {
            key: "_onShapeChange",
            value: function(t) {}
        }, {
            key: "_onAdded",
            value: function() {
                this.enabled = this._enabled, this.restitution = this._restitution, this.friction = this._friction, 
                this.owner.transform.on(l.Event.TRANSFORM_CHANGED, this, this._onTransformChanged);
            }
        }, {
            key: "_onTransformChanged",
            value: function(t) {
                !c._addUpdateList && this._controlBySimulation || (t &= l.Transform3D.TRANSFORM_WORLDPOSITION | l.Transform3D.TRANSFORM_WORLDQUATERNION | l.Transform3D.TRANSFORM_WORLDSCALE) && (this._transformFlag |= t, 
                this._isValid() && -1 === this._inPhysicUpdateListIndex && this._simulation._physicsUpdateList.add(this));
            }
        }, {
            key: "_cloneTo",
            value: function(t) {
                var e = t;
                e.restitution = this._restitution, e.friction = this._friction, e.collisionGroup = this._collisionGroup, 
                e.canCollideWith = this._canCollideWith, e.canScaleShape = this.canScaleShape, this._colliderShape && (e.colliderShape = this._colliderShape.clone());
            }
        } ], [ {
            key: "__init__",
            value: function() {
                c._btVector30 = new CANNON.Vec3(0, 0, 0), c._btQuaternion0 = new CANNON.Quaternion(0, 0, 0, 1);
            }
        }, {
            key: "_creatShape",
            value: function(t) {
                var e;
                switch (t.type) {
                  case "BoxColliderShape":
                    var i = t.size;
                    e = i ? new v(i[0], i[1], i[2]) : new v();
                    break;

                  case "SphereColliderShape":
                    e = new y(t.radius);
                    break;

                  default:
                    throw "unknown shape type.";
                }
                if (t.center) {
                    var o = e.localOffset;
                    o.fromArray(t.center), e.localOffset = o;
                }
                return e;
            }
        }, {
            key: "physicQuaternionMultiply",
            value: function(t, e, i, o, n, s) {
                var r = n.x, a = n.y, l = n.z, h = n.w, c = e * l - i * a, u = i * r - t * l, p = t * a - e * r, d = t * r + e * a + i * l;
                s.x = t * h + r * o + c, s.y = e * h + a * o + u, s.z = i * h + l * o + p, s.w = o * h - d;
            }
        } ]), c;
    }(l.Component);
    f.ACTIVATIONSTATE_ACTIVE_TAG = 1, f.ACTIVATIONSTATE_ISLAND_SLEEPING = 2, f.ACTIVATIONSTATE_WANTS_DEACTIVATION = 3, 
    f.ACTIVATIONSTATE_DISABLE_DEACTIVATION = 4, f.ACTIVATIONSTATE_DISABLE_SIMULATION = 5, 
    f.COLLISIONFLAGS_STATIC_OBJECT = 1, f.COLLISIONFLAGS_KINEMATIC_OBJECT = 2, f.COLLISIONFLAGS_NO_CONTACT_RESPONSE = 4, 
    f.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK = 8, f.COLLISIONFLAGS_CHARACTER_OBJECT = 16, 
    f.COLLISIONFLAGS_DISABLE_VISUALIZE_OBJECT = 32, f.COLLISIONFLAGS_DISABLE_SPU_COLLISION_PROCESSING = 64, 
    f._tempVector30 = new l.Vector3(), f._tempQuaternion0 = new l.Quaternion(), f._tempQuaternion1 = new l.Quaternion(), 
    f._tempMatrix4x40 = new l.Matrix4x4(), f._physicObjectsMap = {}, f._addUpdateList = !0;
    var m = function(t) {
        n(l, t);
        var e = s(l);
        function l(t, i) {
            var o;
            return r(this, l), (o = e.call(this, t, i))._isTrigger = !1, o;
        }
        return a(l, [ {
            key: "isTrigger",
            get: function() {
                return this._isTrigger;
            },
            set: function(t) {
                if (this._isTrigger = t, this._btColliderObject) if (this._btColliderObject.isTrigger = t, 
                t) {
                    var e = this._btColliderObject.type;
                    this._btColliderObject.collisionResponse = !1, 0 == (e & CANNON.Body.STATIC) && (this._btColliderObject.type |= CANNON.Body.STATIC);
                } else this._btColliderObject.collisionResponse = !0, 0 != (e & CANNON.Body.STATIC) && (this._btColliderObject.type ^= CANNON.Body.STATIC);
            }
        }, {
            key: "_onAdded",
            value: function() {
                i(o(l.prototype), "_onAdded", this).call(this), this.isTrigger = this._isTrigger;
            }
        }, {
            key: "_cloneTo",
            value: function(t) {
                i(o(l.prototype), "_cloneTo", this).call(this, t), t.isTrigger = this._isTrigger;
            }
        } ]), l;
    }(f), g = function(t) {
        n(l, t);
        var e = s(l);
        function l() {
            var t, i = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : -1, o = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : -1;
            return r(this, l), (t = e.call(this, i, o))._enableProcessCollisions = !1, t;
        }
        return a(l, [ {
            key: "_addToSimulation",
            value: function() {
                this._simulation._addPhysicsCollider(this);
            }
        }, {
            key: "_removeFromSimulation",
            value: function() {
                this._simulation._removePhysicsCollider(this);
            }
        }, {
            key: "_parse",
            value: function(t) {
                null != t.friction && (this.friction = t.friction), null != t.restitution && (this.restitution = t.restitution), 
                null != t.isTrigger && (this.isTrigger = t.isTrigger), i(o(l.prototype), "_parse", this).call(this, t), 
                this._parseShape(t.shapes);
            }
        }, {
            key: "_onAdded",
            value: function() {
                this._btColliderObject = new CANNON.Body(), this._btColliderObject.material = new CANNON.Material(), 
                this._btColliderObject.layaID = this._id, this._btColliderObject.type = CANNON.Body.STATIC, 
                this._btColliderObject.collisionFilterGroup = this._collisionGroup, this._btColliderObject.collisionFilterMask = this._canCollideWith, 
                i(o(l.prototype), "_onAdded", this).call(this);
            }
        } ]), l;
    }(m), w = function(t) {
        n(i, t);
        var e = s(i);
        function i() {
            return r(this, i), e.call(this);
        }
        return a(i, [ {
            key: "add",
            value: function(t) {
                if (-1 !== t._inPhysicUpdateListIndex) throw "PhysicsUpdateList:element has  in  PhysicsUpdateList.";
                this._add(t), t._inPhysicUpdateListIndex = this.length++;
            }
        }, {
            key: "remove",
            value: function(t) {
                var e = t._inPhysicUpdateListIndex;
                if (this.length--, e !== this.length) {
                    var i = this.elements[this.length];
                    this.elements[e] = i, i._inPhysicUpdateListIndex = e;
                }
                t._inPhysicUpdateListIndex = -1;
            }
        } ]), i;
    }(l.SingletonList), b = function() {
        function t(e) {
            r(this, t), this._gravity = new l.Vector3(0, -10, 0), this._btClosestRayResultCallback = new CANNON.RaycastResult(), 
            this._btRayoption = {}, this._collisionsUtils = new p(), this._previousFrameCollisions = [], 
            this._currentFrameCollisions = [], this._physicsUpdateList = new w(), this._updatedRigidbodies = 0, 
            this.maxSubSteps = 1, this.fixedTimeStep = 1 / 60, this.maxSubSteps = e.maxSubSteps, 
            this.fixedTimeStep = e.fixedTimeStep, this._btDiscreteDynamicsWorld = new CANNON.World(), 
            this._btBroadphase = new CANNON.NaiveBroadphase(), this._btDiscreteDynamicsWorld.broadphase = this._btBroadphase, 
            this._btDiscreteDynamicsWorld.defaultContactMaterial.contactEquationRelaxation = e.contactEquationRelaxation, 
            this._btDiscreteDynamicsWorld.defaultContactMaterial.contactEquationStiffness = e.contactEquationStiffness, 
            this.gravity = this._gravity, t._cannonPhysicsSimulation = this;
        }
        return a(t, [ {
            key: "gravity",
            get: function() {
                if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
                return this._gravity;
            },
            set: function(t) {
                if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
                this._gravity = t, this._btDiscreteDynamicsWorld.gravity.set(t.x, t.y, t.z);
            }
        }, {
            key: "solverIterations",
            get: function() {
                if (!this._btDiscreteDynamicsWorld || !this._btDiscreteDynamicsWorld.solver) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
                return this._iterations;
            },
            set: function(t) {
                if (!this._btDiscreteDynamicsWorld || !this._btDiscreteDynamicsWorld.solver) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
                this._btDiscreteDynamicsWorld.solver.iterations = t, this._iterations = t;
            }
        }, {
            key: "_simulate",
            value: function(t) {
                this._updatedRigidbodies = 0, this._btDiscreteDynamicsWorld && (this._btDiscreteDynamicsWorld.callBackBody.length = 0, 
                this._btDiscreteDynamicsWorld.allContacts.length = 0, this._btDiscreteDynamicsWorld.step(this.fixedTimeStep, t, this.maxSubSteps));
                for (var e = this._btDiscreteDynamicsWorld.callBackBody, i = 0, o = e.length; i < o; i++) {
                    var n = e[i], s = f._physicObjectsMap[n.layaID];
                    s._simulation._updatedRigidbodies++, s._updateTransformComponent(s._btColliderObject);
                }
            }
        }, {
            key: "_destroy",
            value: function() {
                this._btDiscreteDynamicsWorld = null, this._btBroadphase = null;
            }
        }, {
            key: "_addPhysicsCollider",
            value: function(t) {
                this._btDiscreteDynamicsWorld.addBody(t._btColliderObject);
            }
        }, {
            key: "_removePhysicsCollider",
            value: function(t) {
                this._btDiscreteDynamicsWorld.removeBody(t._btColliderObject);
            }
        }, {
            key: "_addRigidBody",
            value: function(t) {
                if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
                this._btDiscreteDynamicsWorld.addBody(t._btColliderObject);
            }
        }, {
            key: "_removeRigidBody",
            value: function(t) {
                if (!this._btDiscreteDynamicsWorld) throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
                this._btDiscreteDynamicsWorld.removeBody(t._btColliderObject);
            }
        }, {
            key: "raycastFromTo",
            value: function(e, i) {
                var o = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : null, n = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : l.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER, s = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : l.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER, r = this._btClosestRayResultCallback;
                r.hasHit = !1;
                var a = this._btRayoption, h = t._btTempVector30, c = t._btTempVector31;
                if (h.set(e.x, e.y, e.z), c.set(i.x, i.y, i.z), a.skipBackfaces = !0, a.collisionFilterMask = s, 
                a.collisionFilterGroup = n, a.result = r, this._btDiscreteDynamicsWorld.raycastClosest(h, c, a, r), 
                r.hasHit) {
                    if (o) {
                        o.succeeded = !0, o.collider = f._physicObjectsMap[r.body.layaID];
                        var u = o.point, p = o.normal, d = r.hitPointWorld, v = r.hitNormalWorld;
                        u.setValue(d.x, d.y, d.z), p.setValue(v.x, v.y, v.z);
                    }
                    return !0;
                }
                return o.succeeded = !1, !1;
            }
        }, {
            key: "raycastAllFromTo",
            value: function(e, i, o) {
                var n = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : l.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER, s = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : l.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER, r = this._btRayoption, a = t._btTempVector30, h = t._btTempVector31;
                return a.set(e.x, e.y, e.z), h.set(i.x, i.y, i.z), r.skipBackfaces = !0, r.collisionFilterMask = s, 
                r.collisionFilterGroup = n, o.length = 0, this._btDiscreteDynamicsWorld.raycastAll(a, h, r, function(e) {
                    var i = t._cannonPhysicsSimulation._collisionsUtils.getHitResult();
                    o.push(i), i.succeeded = !0, i.collider = f._physicObjectsMap[e.body.layaID];
                    var n = i.point, s = i.normal, r = e.hitPointWorld, a = e.hitNormalWorld;
                    n.setValue(r.x, r.y, r.z), s.setValue(a.x, a.y, a.z);
                }), 0 != o.length;
            }
        }, {
            key: "rayCast",
            value: function(e) {
                var i = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null, o = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 2147483647, n = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : l.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER, s = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : l.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER, r = e.origin, a = t._tempVector30;
                return l.Vector3.normalize(e.direction, a), l.Vector3.scale(a, o, a), l.Vector3.add(r, a, a), 
                this.raycastFromTo(r, a, i, n, s);
            }
        }, {
            key: "rayCastAll",
            value: function(e, i) {
                var o = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 2147483647, n = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : l.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER, s = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : l.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER, r = e.origin, a = t._tempVector30;
                return l.Vector3.normalize(e.direction, a), l.Vector3.scale(a, o, a), l.Vector3.add(r, a, a), 
                this.raycastAllFromTo(r, a, i, n, s);
            }
        }, {
            key: "_updatePhysicsTransformFromRender",
            value: function() {
                for (var t = this._physicsUpdateList.elements, e = 0, i = this._physicsUpdateList.length; e < i; e++) {
                    var o = t[e];
                    o._derivePhysicsTransformation(!1), o._inPhysicUpdateListIndex = -1;
                }
                this._physicsUpdateList.length = 0;
            }
        }, {
            key: "_updateCollisions",
            value: function() {
                this._collisionsUtils.recoverAllContactPointsPool();
                var t = this._currentFrameCollisions;
                this._currentFrameCollisions = this._previousFrameCollisions, this._currentFrameCollisions.length = 0, 
                this._previousFrameCollisions = t;
                for (var e = l.Stat.loopCount, i = this._btDiscreteDynamicsWorld.allContacts, o = i.length, n = 0; n < o; n++) {
                    var s, r = i[n], a = f._physicObjectsMap[r.bi.layaID], h = f._physicObjectsMap[r.bj.layaID], c = null, u = null;
                    if ((a.isTrigger || h.isTrigger) && (a.owner._needProcessTriggers || h.owner._needProcessTriggers)) u = (c = this._collisionsUtils.getCollision(a, h)).contacts, 
                    (s = c._updateFrame !== e) && (c._isTrigger = !0, u.length = 0); else if ((a.owner._needProcessCollisions || h.owner._needProcessCollisions) && (a._enableProcessCollisions || h._enableProcessCollisions)) {
                        var p = this._collisionsUtils.getContactPoints();
                        p.colliderA = a, p.colliderB = h;
                        var d = p.normal, v = p.positionOnA, y = p.positionOnB, m = r.ni, g = r.ri, w = r.rj;
                        d.setValue(m.x, m.y, m.z), v.setValue(g.x, g.y, g.z), y.setValue(w.x, w.y, -w.z), 
                        u = (c = this._collisionsUtils.getCollision(a, h)).contacts, (s = c._updateFrame !== e) && (c._isTrigger = !1, 
                        u.length = 0), u.push(p);
                    }
                    c && s && (this._currentFrameCollisions.push(c), c._setUpdateFrame(e));
                }
            }
        }, {
            key: "_eventScripts",
            value: function() {
                for (var t = l.Stat.loopCount, e = 0, i = this._currentFrameCollisions.length; e < i; e++) {
                    var o = this._currentFrameCollisions[e], n = o._colliderA, s = o._colliderB;
                    if (!n.destroyed && !s.destroyed) if (t - o._lastUpdateFrame == 1) {
                        var r = n.owner, a = r._scripts;
                        if (a) if (o._isTrigger) {
                            if (r._needProcessTriggers) for (var h = 0, c = a.length; h < c; h++) a[h].onTriggerStay(s);
                        } else if (r._needProcessCollisions) for (h = 0, c = a.length; h < c; h++) o.other = s, 
                        a[h].onCollisionStay(o);
                        var u = s.owner, p = u._scripts;
                        if (p) if (o._isTrigger) {
                            if (u._needProcessTriggers) for (h = 0, c = p.length; h < c; h++) p[h].onTriggerStay(n);
                        } else if (u._needProcessCollisions) for (h = 0, c = p.length; h < c; h++) o.other = n, 
                        p[h].onCollisionStay(o);
                    } else {
                        if (a = (r = n.owner)._scripts) if (o._isTrigger) {
                            if (r._needProcessTriggers) for (h = 0, c = a.length; h < c; h++) a[h].onTriggerEnter(s);
                        } else if (r._needProcessCollisions) for (h = 0, c = a.length; h < c; h++) o.other = s, 
                        a[h].onCollisionEnter(o);
                        if (p = (u = s.owner)._scripts) if (o._isTrigger) {
                            if (u._needProcessTriggers) for (h = 0, c = p.length; h < c; h++) p[h].onTriggerEnter(n);
                        } else if (u._needProcessCollisions) for (h = 0, c = p.length; h < c; h++) o.other = n, 
                        p[h].onCollisionEnter(o);
                    }
                }
                for (e = 0, i = this._previousFrameCollisions.length; e < i; e++) {
                    var d = this._previousFrameCollisions[e], v = d._colliderA, y = d._colliderB;
                    if (!v.destroyed && !y.destroyed && t - d._updateFrame == 1) {
                        if (this._collisionsUtils.recoverCollision(d), a = (r = v.owner)._scripts) if (d._isTrigger) {
                            if (r._needProcessTriggers) for (h = 0, c = a.length; h < c; h++) a[h].onTriggerExit(y);
                        } else if (r._needProcessCollisions) for (h = 0, c = a.length; h < c; h++) d.other = y, 
                        a[h].onCollisionExit(d);
                        if (p = (u = y.owner)._scripts) if (d._isTrigger) {
                            if (u._needProcessTriggers) for (h = 0, c = p.length; h < c; h++) p[h].onTriggerExit(v);
                        } else if (u._needProcessCollisions) for (h = 0, c = p.length; h < c; h++) d.other = v, 
                        p[h].onCollisionExit(d);
                    }
                }
            }
        }, {
            key: "clearForces",
            value: function() {
                if (!this._btDiscreteDynamicsWorld) throw "Cannot perform this action when the physics engine is set to CollisionsOnly";
            }
        } ], [ {
            key: "__init__",
            value: function() {
                t._btTempVector30 = new CANNON.Vec3(0, 0, 0), t._btTempVector31 = new CANNON.Vec3(0, 0, 0);
            }
        }, {
            key: "createConstraint",
            value: function() {}
        } ]), t;
    }();
    b.PHYSICSENGINEFLAGS_NONE = 0, b.PHYSICSENGINEFLAGS_COLLISIONSONLY = 1, b.PHYSICSENGINEFLAGS_SOFTBODYSUPPORT = 2, 
    b.PHYSICSENGINEFLAGS_MULTITHREADED = 4, b.PHYSICSENGINEFLAGS_USEHARDWAREWHENPOSSIBLE = 8, 
    b.SOLVERMODE_RANDMIZE_ORDER = 1, b.SOLVERMODE_FRICTION_SEPARATE = 2, b.SOLVERMODE_USE_WARMSTARTING = 4, 
    b.SOLVERMODE_USE_2_FRICTION_DIRECTIONS = 16, b.SOLVERMODE_ENABLE_FRICTION_DIRECTION_CACHING = 32, 
    b.SOLVERMODE_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION = 64, b.SOLVERMODE_CACHE_FRIENDLY = 128, 
    b.SOLVERMODE_SIMD = 256, b.SOLVERMODE_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS = 512, 
    b.SOLVERMODE_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS = 1024, b._tempVector30 = new l.Vector3(), 
    b.disableSimulation = !1;
    var x = function(t) {
        n(h, t);
        var e = s(h);
        function h() {
            var t, i = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : -1, o = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : l.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER;
            return r(this, h), (t = e.call(this, i, o))._isKinematic = !1, t._mass = 1, t._gravity = new l.Vector3(0, -10, 0), 
            t._angularDamping = 0, t._linearDamping = 0, t._totalTorque = new l.Vector3(0, 0, 0), 
            t._totalForce = new l.Vector3(0, 0, 0), t._linearVelocity = new l.Vector3(), t._angularVelocity = new l.Vector3(), 
            t._controlBySimulation = !0, t;
        }
        return a(h, [ {
            key: "mass",
            get: function() {
                return this._mass;
            },
            set: function(t) {
                t = Math.max(t, 1e-7), this._mass = t, this._isKinematic || this._updateMass(t);
            }
        }, {
            key: "isKinematic",
            get: function() {
                return this._isKinematic;
            },
            set: function(t) {
                this._isKinematic = t, this._controlBySimulation = !t;
                var e = !!(this._simulation && this._enabled && this._colliderShape);
                e && this._removeFromSimulation();
                var i = this._btColliderObject, o = i.type;
                t ? (o |= CANNON.Body.KINEMATIC, i.type = o, this._enableProcessCollisions = !1, 
                this._updateMass(0)) : ((o & CANNON.Body.KINEMATIC) > 0 && (o ^= CANNON.Body.KINEMATIC), 
                i.allowSleep = !0, i.type = o, this._enableProcessCollisions = !0, this._updateMass(this._mass)), 
                i.velocity.set(0, 0, 0), i.angularVelocity.set(0, 0, 0), e && this._addToSimulation();
            }
        }, {
            key: "linearDamping",
            get: function() {
                return this._linearDamping;
            },
            set: function(t) {
                this._linearDamping = t, this._btColliderObject && (this._btColliderObject.linearDamping = t);
            }
        }, {
            key: "angularDamping",
            get: function() {
                return this._angularDamping;
            },
            set: function(t) {
                this._angularDamping = t, this._btColliderObject && (this._btColliderObject.angularDamping = t);
            }
        }, {
            key: "totalForce",
            get: function() {
                if (this._btColliderObject) {
                    var t = this.btColliderObject.force;
                    return this.totalForce.setValue(t.x, t.y, t.z), this._totalForce;
                }
                return null;
            }
        }, {
            key: "linearVelocity",
            get: function() {
                if (this._btColliderObject) {
                    var t = this.btColliderObject.velocity;
                    this._linearVelocity.setValue(t.x, t.y, t.z);
                }
                return this._linearVelocity;
            },
            set: function(t) {
                if (this._linearVelocity = t, this._btColliderObject) {
                    var e = this.btColliderObject.velocity;
                    this.isSleeping && this.wakeUp(), e.set(t.x, t.y, t.z), this.btColliderObject.velocity = e;
                }
            }
        }, {
            key: "angularVelocity",
            get: function() {
                if (this._btColliderObject) {
                    var t = this._btColliderObject.angularVelocity;
                    this._angularVelocity.setValue(t.x, t.y, t.z);
                }
                return this._angularVelocity;
            },
            set: function(t) {
                if (this._angularVelocity = t, this._btColliderObject) {
                    var e = this.btColliderObject.angularVelocity;
                    this.isSleeping && this.wakeUp(), e.set(t.x, t.y, t.z), this.btColliderObject.angularVelocity = e;
                }
            }
        }, {
            key: "totalTorque",
            get: function() {
                if (this._btColliderObject) {
                    var t = this._btColliderObject.torque;
                    return this._totalTorque.setValue(t.x, t.y, t.z), this._totalTorque;
                }
                return null;
            }
        }, {
            key: "isSleeping",
            get: function() {
                return !!this._btColliderObject && this._btColliderObject.sleepState != CANNON.Body.AWAKE;
            }
        }, {
            key: "sleepLinearVelocity",
            get: function() {
                return this._btColliderObject.sleepSpeedLimit;
            },
            set: function(t) {
                this._btColliderObject.sleepSpeedLimit = t;
            }
        }, {
            key: "btColliderObject",
            get: function() {
                return this._btColliderObject;
            }
        }, {
            key: "_updateMass",
            value: function(t) {
                this._btColliderObject && this._colliderShape && (this._btColliderObject.mass = t, 
                this._btColliderObject.updateMassProperties(), this._btColliderObject.updateSolveMassProperties());
            }
        }, {
            key: "_onScaleChange",
            value: function(t) {
                i(o(h.prototype), "_onScaleChange", this).call(this, t), this._updateMass(this._isKinematic ? 0 : this._mass);
            }
        }, {
            key: "_derivePhysicsTransformation",
            value: function(t) {
                this._innerDerivePhysicsTransformation(this.btColliderObject, t);
            }
        }, {
            key: "_onAdded",
            value: function() {
                var t = new CANNON.Body();
                t.material = new CANNON.Material(), t.layaID = this.id, t.collisionFilterGroup = this.collisionGroup, 
                t.collisionFilterMask = this._canCollideWith, this._btColliderObject = t, i(o(h.prototype), "_onAdded", this).call(this), 
                this.mass = this._mass, this.linearDamping = this._linearDamping, this.angularDamping = this._angularDamping, 
                this.isKinematic = this._isKinematic, this.isKinematic ? this._btColliderObject.type = CANNON.Body.KINEMATIC : this._btColliderObject.type = CANNON.Body.DYNAMIC;
            }
        }, {
            key: "_onShapeChange",
            value: function(t) {
                i(o(h.prototype), "_onShapeChange", this).call(this, t), this._isKinematic ? this._updateMass(0) : this._updateMass(this._mass);
            }
        }, {
            key: "_parse",
            value: function(t) {
                null != t.friction && (this.friction = t.friction), null != t.restitution && (this.restitution = t.restitution), 
                null != t.isTrigger && (this.isTrigger = t.isTrigger), null != t.mass && (this.mass = t.mass), 
                null != t.isKinematic && (this.isKinematic = t.isKinematic), null != t.linearDamping && (this.linearDamping = t.linearDamping), 
                null != t.angularDamping && (this.angularDamping = t.angularDamping), i(o(h.prototype), "_parse", this).call(this, t), 
                this._parseShape(t.shapes);
            }
        }, {
            key: "_onDestroy",
            value: function() {
                i(o(h.prototype), "_onDestroy", this).call(this), this._gravity = null, this._totalTorque = null, 
                this._linearVelocity = null, this._angularVelocity = null;
            }
        }, {
            key: "_addToSimulation",
            value: function() {
                this._simulation._addRigidBody(this);
            }
        }, {
            key: "_removeFromSimulation",
            value: function() {
                this._simulation._removeRigidBody(this);
            }
        }, {
            key: "_cloneTo",
            value: function(t) {
                i(o(h.prototype), "_cloneTo", this).call(this, t);
                var e = t;
                e.isKinematic = this._isKinematic, e.mass = this._mass, e.angularDamping = this._angularDamping, 
                e.linearDamping = this._linearDamping, e.linearVelocity = this._linearVelocity, 
                e.angularVelocity = this._angularVelocity;
            }
        }, {
            key: "applyForce",
            value: function(t) {
                var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null;
                if (null == this._btColliderObject) throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
                var i = h._btTempVector30;
                i.set(t.x, t.y, t.z);
                var o = h._btTempVector31;
                e ? o.set(e.x, e.y, e.z) : o.set(0, 0, 0), this.btColliderObject.applyLocalForce(i, o);
            }
        }, {
            key: "applyTorque",
            value: function(t) {
                if (null == this._btColliderObject) throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
                var e = h._btTempVector30;
                e.set(t.x, t.y, t.z);
                var i = this.btColliderObject.torque;
                i.set(i.x + e.x, i.y + e.y, i.z + e.z), this.btColliderObject.torque = i;
            }
        }, {
            key: "applyImpulse",
            value: function(t) {
                var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null;
                if (null == this._btColliderObject) throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
                if (null == this._btColliderObject) throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
                var i = h._btTempVector30;
                i.set(t.x, t.y, t.z);
                var o = h._btTempVector31;
                e ? o.set(e.x, e.y, e.z) : o.set(0, 0, 0), this.btColliderObject.applyImpulse(i, o);
            }
        }, {
            key: "wakeUp",
            value: function() {
                this._btColliderObject && this._btColliderObject.wakeUp();
            }
        }, {
            key: "clearForces",
            value: function() {
                var t = this._btColliderObject;
                if (null == t) throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
                t.velocity.set(0, 0, 0), t.velocity = t.velocity, t.angularVelocity.set(0, 0, 0), 
                t.angularVelocity = t.angularVelocity;
            }
        } ], [ {
            key: "__init__",
            value: function() {
                h._btTempVector30 = new CANNON.Vec3(), h._btTempVector31 = new CANNON.Vec3();
            }
        } ]), h;
    }(g);
    x.TYPE_STATIC = 0, x.TYPE_DYNAMIC = 1, x.TYPE_KINEMATIC = 2, x._BT_DISABLE_WORLD_GRAVITY = 1, 
    x._BT_ENABLE_GYROPSCOPIC_FORCE = 2;
    var _ = function(t) {
        n(l, t);
        var e = s(l);
        function l() {
            var t;
            return r(this, l), (t = e.call(this))._childColliderShapes = [], t._type = d.SHAPETYPES_COMPOUND, 
            t;
        }
        return a(l, [ {
            key: "_clearChildShape",
            value: function(t) {
                t._attatched = !1, t._compoundParent = null, t._indexInCompound = -1;
            }
        }, {
            key: "_addReference",
            value: function() {
                this._referenceCount++;
            }
        }, {
            key: "_removeReference",
            value: function() {
                this._referenceCount--;
            }
        }, {
            key: "addChildShape",
            value: function(t) {
                var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null;
                if (t._attatched) throw "CompoundColliderShape: this shape has attatched to other entity.";
                t._attatched = !0, t._compoundParent = this, t._indexInCompound = this._childColliderShapes.length, 
                this._childColliderShapes.push(t), t.localOffset = e, this.physicColliderObject && (l._tempCannonQue.set(0, 0, 0, 1), 
                l._tempCannonVec.set(e.x * this._scale.x, e.y * this._scale.y, e.z * this._scale.z), 
                this.physicColliderObject._btColliderObject.addShape(t._btShape, l._tempCannonVec, CANNON.Vec3.ZERO));
            }
        }, {
            key: "removeChildShape",
            value: function(t) {
                if (t._compoundParent === this) {
                    var e = t._indexInCompound;
                    this._clearChildShape(t);
                    var i = this._childColliderShapes[this._childColliderShapes.length - 1];
                    i._indexInCompound = e, this._childColliderShapes[e] = i, this._childColliderShapes.pop(), 
                    this.physicColliderObject && this.bindRigidBody(this.physicColliderObject);
                }
            }
        }, {
            key: "bindRigidBody",
            value: function(t) {
                this.physicColliderObject = t;
                var e, i = t._btColliderObject;
                i.shapes.length = 0, i.shapeOffsets.length = 0, i.shapeOrientations.length = 0;
                for (var o = 0, n = this._childColliderShapes.length; o != n; o++) {
                    var s = this._childColliderShapes[o];
                    i.shapes.push(s._btShape), e = s.localOffset, i.shapeOffsets.push(new CANNON.Vec3(e.x * this._scale.x, e.y * this._scale.y, e.z * this._scale.z)), 
                    i.shapeOrientations.push(l._tempCannonQue);
                }
                i.updateMassProperties(), i.updateBoundingRadius(), i.aabbNeedsUpdate = !0;
            }
        }, {
            key: "_setScale",
            value: function(t) {
                this._scale.setValue(t.x, t.y, t.z);
                for (var e = this.physicColliderObject._btColliderObject, i = this.getChildShapeCount(), o = e.shapeOffsets, n = 0; n < i; n++) {
                    var s = o[n], r = this._childColliderShapes[n];
                    r._setScale(t);
                    var a = r.localOffset;
                    s.set(a.x * t.x, a.y * t.y, a.z * t.z);
                }
                e.updateMassProperties(), e.updateBoundingRadius(), e.aabbNeedsUpdate = !0;
            }
        }, {
            key: "getChildShapeCount",
            value: function() {
                return this._childColliderShapes.length;
            }
        }, {
            key: "cloneTo",
            value: function(t) {
                for (var e = t, i = 0, o = this._childColliderShapes.length; i < o; i++) e.addChildShape(this._childColliderShapes[i].clone());
            }
        }, {
            key: "clone",
            value: function() {
                var t = new l();
                return this.cloneTo(t), t;
            }
        }, {
            key: "destroy",
            value: function() {
                i(o(l.prototype), "destroy", this).call(this);
                for (var t = 0, e = this._childColliderShapes.length; t < e; t++) {
                    var n = this._childColliderShapes[t];
                    0 === n._referenceCount && n.destroy();
                }
            }
        } ], [ {
            key: "__init__",
            value: function() {}
        } ]), l;
    }(d);
    _._tempCannonQue = new CANNON.Quaternion(0, 0, 0, 1), _._tempCannonVec = new CANNON.Vec3(0, 0, 0), 
    t.CannonBoxColliderShape = v, t.CannonColliderShape = d, t.CannonCollision = h, 
    t.CannonCollisionTool = p, t.CannonCompoundColliderShape = _, t.CannonContactPoint = c, 
    t.CannonHitResult = u, t.CannonPhysicsCollider = g, t.CannonPhysicsComponent = f, 
    t.CannonPhysicsSettings = function() {
        return a(function t() {
            r(this, t), this.flags = 0, this.maxSubSteps = 3, this.fixedTimeStep = 1 / 60, this.contactEquationRelaxation = 10, 
            this.contactEquationStiffness = 1e6;
        });
    }(), t.CannonPhysicsSimulation = b, t.CannonPhysicsTriggerComponent = m, t.CannonPhysicsUpdateList = w, 
    t.CannonRigidbody3D = x, t.CannonSphereColliderShape = y;
}(window.Laya = window.Laya || {}, Laya);