(function (global, factory) { if (typeof define === "function" && define.amd) { define(["exports"], factory); } else if (typeof exports !== "undefined") { factory(exports); } else { var mod = { exports: {} }; factory(mod.exports); global.OimoPhysics = mod.exports; } })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { value: true }); _exports.oimo = void 0; function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); } function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } // Generated by Haxe 4.2.0 var oimo = oimo || {}; _exports.oimo = oimo; if (!oimo.collision) oimo.collision = {}; if (!oimo.collision.broadphase) oimo.collision.broadphase = {}; oimo.collision.broadphase.BroadPhase = /*#__PURE__*/function () { function oimo_collision_broadphase_BroadPhase(type) { _classCallCheck(this, oimo_collision_broadphase_BroadPhase); this._type = type; this._numProxies = 0; this._proxyList = null; this._proxyListLast = null; this._proxyPairList = null; this._incremental = false; this._testCount = 0; this._proxyPairPool = null; this._idCount = 0; this._convexSweep = new oimo.collision.broadphase._BroadPhase.ConvexSweepGeometry(); this._aabb = new oimo.collision.broadphase._BroadPhase.AabbGeometry(); this.identity = new oimo.common.Transform(); this.zero = new oimo.common.Vec3(); this.rayCastHit = new oimo.collision.geometry.RayCastHit(); } _createClass(oimo_collision_broadphase_BroadPhase, [{ key: "createProxy", value: function createProxy(userData, aabb) { return null; } }, { key: "destroyProxy", value: function destroyProxy(proxy) {} }, { key: "moveProxy", value: function moveProxy(proxy, aabb, displacement) {} }, { key: "isOverlapping", value: function isOverlapping(proxy1, proxy2) { if (proxy1._aabbMinX < proxy2._aabbMaxX && proxy1._aabbMaxX > proxy2._aabbMinX && proxy1._aabbMinY < proxy2._aabbMaxY && proxy1._aabbMaxY > proxy2._aabbMinY && proxy1._aabbMinZ < proxy2._aabbMaxZ) { return proxy1._aabbMaxZ > proxy2._aabbMinZ; } else { return false; } } }, { key: "collectPairs", value: function collectPairs() {} }, { key: "getProxyPairList", value: function getProxyPairList() { return this._proxyPairList; } }, { key: "isIncremental", value: function isIncremental() { return this._incremental; } }, { key: "getTestCount", value: function getTestCount() { return this._testCount; } }, { key: "rayCast", value: function rayCast(begin, end, callback) {} }, { key: "convexCast", value: function convexCast(convex, begin, translation, callback) {} }, { key: "aabbTest", value: function aabbTest(aabb, callback) {} }]); return oimo_collision_broadphase_BroadPhase; }(); if (!oimo.collision.geometry) oimo.collision.geometry = {}; oimo.collision.geometry.Geometry = /*#__PURE__*/function () { function oimo_collision_geometry_Geometry(type) { _classCallCheck(this, oimo_collision_geometry_Geometry); this._type = type; this._volume = 0; } _createClass(oimo_collision_geometry_Geometry, [{ key: "_updateMass", value: function _updateMass() {} }, { key: "_computeAabb", value: function _computeAabb(aabb, tf) {} }, { key: "_rayCastLocal", value: function _rayCastLocal(beginX, beginY, beginZ, endX, endY, endZ, hit) { return false; } }, { key: "getType", value: function getType() { return this._type; } }, { key: "getVolume", value: function getVolume() { return this._volume; } }, { key: "rayCast", value: function rayCast(begin, end, transform, hit) { var beginLocalX; var beginLocalY; var beginLocalZ; var endLocalX; var endLocalY; var endLocalZ; beginLocalX = begin.x; beginLocalY = begin.y; beginLocalZ = begin.z; endLocalX = end.x; endLocalY = end.y; endLocalZ = end.z; beginLocalX -= transform._positionX; beginLocalY -= transform._positionY; beginLocalZ -= transform._positionZ; endLocalX -= transform._positionX; endLocalY -= transform._positionY; endLocalZ -= transform._positionZ; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = transform._rotation00 * beginLocalX + transform._rotation10 * beginLocalY + transform._rotation20 * beginLocalZ; __tmp__Y = transform._rotation01 * beginLocalX + transform._rotation11 * beginLocalY + transform._rotation21 * beginLocalZ; __tmp__Z = transform._rotation02 * beginLocalX + transform._rotation12 * beginLocalY + transform._rotation22 * beginLocalZ; beginLocalX = __tmp__X; beginLocalY = __tmp__Y; beginLocalZ = __tmp__Z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = transform._rotation00 * endLocalX + transform._rotation10 * endLocalY + transform._rotation20 * endLocalZ; __tmp__Y1 = transform._rotation01 * endLocalX + transform._rotation11 * endLocalY + transform._rotation21 * endLocalZ; __tmp__Z1 = transform._rotation02 * endLocalX + transform._rotation12 * endLocalY + transform._rotation22 * endLocalZ; endLocalX = __tmp__X1; endLocalY = __tmp__Y1; endLocalZ = __tmp__Z1; if (this._rayCastLocal(beginLocalX, beginLocalY, beginLocalZ, endLocalX, endLocalY, endLocalZ, hit)) { var localPosX; var localPosY; var localPosZ; var localNormalX; var localNormalY; var localNormalZ; var v = hit.position; localPosX = v.x; localPosY = v.y; localPosZ = v.z; var v1 = hit.normal; localNormalX = v1.x; localNormalY = v1.y; localNormalZ = v1.z; var _tmp__X; var _tmp__Y; var _tmp__Z; _tmp__X = transform._rotation00 * localPosX + transform._rotation01 * localPosY + transform._rotation02 * localPosZ; _tmp__Y = transform._rotation10 * localPosX + transform._rotation11 * localPosY + transform._rotation12 * localPosZ; _tmp__Z = transform._rotation20 * localPosX + transform._rotation21 * localPosY + transform._rotation22 * localPosZ; localPosX = _tmp__X; localPosY = _tmp__Y; localPosZ = _tmp__Z; var _tmp__X2; var _tmp__Y2; var _tmp__Z2; _tmp__X2 = transform._rotation00 * localNormalX + transform._rotation01 * localNormalY + transform._rotation02 * localNormalZ; _tmp__Y2 = transform._rotation10 * localNormalX + transform._rotation11 * localNormalY + transform._rotation12 * localNormalZ; _tmp__Z2 = transform._rotation20 * localNormalX + transform._rotation21 * localNormalY + transform._rotation22 * localNormalZ; localNormalX = _tmp__X2; localNormalY = _tmp__Y2; localNormalZ = _tmp__Z2; localPosX += transform._positionX; localPosY += transform._positionY; localPosZ += transform._positionZ; var v2 = hit.position; v2.x = localPosX; v2.y = localPosY; v2.z = localPosZ; var v3 = hit.normal; v3.x = localNormalX; v3.y = localNormalY; v3.z = localNormalZ; return true; } return false; } }]); return oimo_collision_geometry_Geometry; }(); oimo.collision.geometry.ConvexGeometry = /*#__PURE__*/function (_oimo$collision$geome) { _inherits(oimo_collision_geometry_ConvexGeometry, _oimo$collision$geome); var _super = _createSuper(oimo_collision_geometry_ConvexGeometry); function oimo_collision_geometry_ConvexGeometry(type) { var _this42; _classCallCheck(this, oimo_collision_geometry_ConvexGeometry); _this42 = _super.call(this, type); _this42._gjkMargin = oimo.common.Setting.defaultGJKMargin; _this42._useGjkRayCast = false; return _this42; } _createClass(oimo_collision_geometry_ConvexGeometry, [{ key: "getGjkMergin", value: function getGjkMergin() { return this._gjkMargin; } }, { key: "setGjkMergin", value: function setGjkMergin(gjkMergin) { if (gjkMergin < 0) { gjkMergin = 0; } this._gjkMargin = gjkMergin; } }, { key: "computeLocalSupportingVertex", value: function computeLocalSupportingVertex(dir, out) {} }, { key: "rayCast", value: function rayCast(begin, end, transform, hit) { if (this._useGjkRayCast) { return oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance.rayCast(this, transform, begin, end, hit); } else { return _get(_getPrototypeOf(oimo_collision_geometry_ConvexGeometry.prototype), "rayCast", this).call(this, begin, end, transform, hit); } } }]); return oimo_collision_geometry_ConvexGeometry; }(oimo.collision.geometry.Geometry); if (!oimo.collision.broadphase._BroadPhase) oimo.collision.broadphase._BroadPhase = {}; oimo.collision.broadphase._BroadPhase.ConvexSweepGeometry = /*#__PURE__*/function (_oimo$collision$geome2) { _inherits(oimo_collision_broadphase__$BroadPhase_ConvexSweepGeometry, _oimo$collision$geome2); var _super2 = _createSuper(oimo_collision_broadphase__$BroadPhase_ConvexSweepGeometry); function oimo_collision_broadphase__$BroadPhase_ConvexSweepGeometry() { _classCallCheck(this, oimo_collision_broadphase__$BroadPhase_ConvexSweepGeometry); return _super2.call(this, -1); } _createClass(oimo_collision_broadphase__$BroadPhase_ConvexSweepGeometry, [{ key: "init", value: function init(c, transform, translation) { this.c = c; var trX; var trY; var trZ; trX = translation.x; trY = translation.y; trZ = translation.z; var localTrX; var localTrY; var localTrZ; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = transform._rotation00 * trX + transform._rotation10 * trY + transform._rotation20 * trZ; __tmp__Y = transform._rotation01 * trX + transform._rotation11 * trY + transform._rotation21 * trZ; __tmp__Z = transform._rotation02 * trX + transform._rotation12 * trY + transform._rotation22 * trZ; localTrX = __tmp__X; localTrY = __tmp__Y; localTrZ = __tmp__Z; this.localTranslation = new oimo.common.Vec3(); var v = this.localTranslation; v.x = localTrX; v.y = localTrY; v.z = localTrZ; this._gjkMargin = c._gjkMargin; } }, { key: "computeLocalSupportingVertex", value: function computeLocalSupportingVertex(dir, out) { this.c.computeLocalSupportingVertex(dir, out); var v = this.localTranslation; if (dir.x * v.x + dir.y * v.y + dir.z * v.z > 0) { var _v = this.localTranslation; out.x += _v.x; out.y += _v.y; out.z += _v.z; } } }]); return oimo_collision_broadphase__$BroadPhase_ConvexSweepGeometry; }(oimo.collision.geometry.ConvexGeometry); oimo.collision.broadphase._BroadPhase.AabbGeometry = /*#__PURE__*/function (_oimo$collision$geome3) { _inherits(oimo_collision_broadphase__$BroadPhase_AabbGeometry, _oimo$collision$geome3); var _super3 = _createSuper(oimo_collision_broadphase__$BroadPhase_AabbGeometry); function oimo_collision_broadphase__$BroadPhase_AabbGeometry() { var _this43; _classCallCheck(this, oimo_collision_broadphase__$BroadPhase_AabbGeometry); _this43 = _super3.call(this, -1); _this43.min = new oimo.common.Vec3(); _this43.max = new oimo.common.Vec3(); return _this43; } _createClass(oimo_collision_broadphase__$BroadPhase_AabbGeometry, [{ key: "computeLocalSupportingVertex", value: function computeLocalSupportingVertex(dir, out) { out.x = dir.x > 0 ? this.max.x : this.min.x; out.y = dir.y > 0 ? this.max.y : this.min.y; out.z = dir.z > 0 ? this.max.z : this.min.z; } }]); return oimo_collision_broadphase__$BroadPhase_AabbGeometry; }(oimo.collision.geometry.ConvexGeometry); oimo.collision.broadphase.BroadPhaseProxyCallback = /*#__PURE__*/function () { function oimo_collision_broadphase_BroadPhaseProxyCallback() { _classCallCheck(this, oimo_collision_broadphase_BroadPhaseProxyCallback); } _createClass(oimo_collision_broadphase_BroadPhaseProxyCallback, [{ key: "process", value: function process(proxy) {} }]); return oimo_collision_broadphase_BroadPhaseProxyCallback; }(); oimo.collision.broadphase.BroadPhaseType = /*#__PURE__*/_createClass(function oimo_collision_broadphase_BroadPhaseType() { _classCallCheck(this, oimo_collision_broadphase_BroadPhaseType); }); oimo.collision.broadphase.Proxy = /*#__PURE__*/function () { function oimo_collision_broadphase_Proxy(userData, id) { _classCallCheck(this, oimo_collision_broadphase_Proxy); this.userData = userData; this._id = id; this._prev = null; this._next = null; this._aabbMinX = 0; this._aabbMinY = 0; this._aabbMinZ = 0; this._aabbMaxX = 0; this._aabbMaxY = 0; this._aabbMaxZ = 0; } _createClass(oimo_collision_broadphase_Proxy, [{ key: "getId", value: function getId() { return this._id; } }, { key: "getFatAabb", value: function getFatAabb() { var aabb = new oimo.collision.geometry.Aabb(); aabb._minX = this._aabbMinX; aabb._minY = this._aabbMinY; aabb._minZ = this._aabbMinZ; aabb._maxX = this._aabbMaxX; aabb._maxY = this._aabbMaxY; aabb._maxZ = this._aabbMaxZ; return aabb; } }, { key: "getFatAabbTo", value: function getFatAabbTo(aabb) { aabb._minX = this._aabbMinX; aabb._minY = this._aabbMinY; aabb._minZ = this._aabbMinZ; aabb._maxX = this._aabbMaxX; aabb._maxY = this._aabbMaxY; aabb._maxZ = this._aabbMaxZ; } }]); return oimo_collision_broadphase_Proxy; }(); oimo.collision.broadphase.ProxyPair = /*#__PURE__*/function () { function oimo_collision_broadphase_ProxyPair() { _classCallCheck(this, oimo_collision_broadphase_ProxyPair); this._p1 = null; this._p2 = null; } _createClass(oimo_collision_broadphase_ProxyPair, [{ key: "getProxy1", value: function getProxy1() { return this._p1; } }, { key: "getProxy2", value: function getProxy2() { return this._p2; } }, { key: "getNext", value: function getNext() { return this._next; } }]); return oimo_collision_broadphase_ProxyPair; }(); if (!oimo.collision.broadphase.bruteforce) oimo.collision.broadphase.bruteforce = {}; oimo.collision.broadphase.bruteforce.BruteForceBroadPhase = /*#__PURE__*/function (_oimo$collision$broad) { _inherits(oimo_collision_broadphase_bruteforce_BruteForceBroadPhase, _oimo$collision$broad); var _super4 = _createSuper(oimo_collision_broadphase_bruteforce_BruteForceBroadPhase); function oimo_collision_broadphase_bruteforce_BruteForceBroadPhase() { var _this44; _classCallCheck(this, oimo_collision_broadphase_bruteforce_BruteForceBroadPhase); _this44 = _super4.call(this, 1); _this44._incremental = false; return _this44; } _createClass(oimo_collision_broadphase_bruteforce_BruteForceBroadPhase, [{ key: "createProxy", value: function createProxy(userData, aabb) { var proxy = new oimo.collision.broadphase.Proxy(userData, this._idCount++); this._numProxies++; if (this._proxyList == null) { this._proxyList = proxy; this._proxyListLast = proxy; } else { this._proxyListLast._next = proxy; proxy._prev = this._proxyListLast; this._proxyListLast = proxy; } proxy._aabbMinX = aabb._minX; proxy._aabbMinY = aabb._minY; proxy._aabbMinZ = aabb._minZ; proxy._aabbMaxX = aabb._maxX; proxy._aabbMaxY = aabb._maxY; proxy._aabbMaxZ = aabb._maxZ; return proxy; } }, { key: "destroyProxy", value: function destroyProxy(proxy) { this._numProxies--; var prev = proxy._prev; var next = proxy._next; if (prev != null) { prev._next = next; } if (next != null) { next._prev = prev; } if (proxy == this._proxyList) { this._proxyList = this._proxyList._next; } if (proxy == this._proxyListLast) { this._proxyListLast = this._proxyListLast._prev; } proxy._next = null; proxy._prev = null; proxy.userData = null; } }, { key: "moveProxy", value: function moveProxy(proxy, aabb, dislacement) { proxy._aabbMinX = aabb._minX; proxy._aabbMinY = aabb._minY; proxy._aabbMinZ = aabb._minZ; proxy._aabbMaxX = aabb._maxX; proxy._aabbMaxY = aabb._maxY; proxy._aabbMaxZ = aabb._maxZ; } }, { key: "collectPairs", value: function collectPairs() { var p = this._proxyPairList; if (p != null) { while (true) { p._p1 = null; p._p2 = null; p = p._next; if (!(p != null)) { break; } } this._proxyPairList._next = this._proxyPairPool; this._proxyPairPool = this._proxyPairList; this._proxyPairList = null; } this._testCount = 0; var p1 = this._proxyList; while (p1 != null) { var n = p1._next; var p2 = p1._next; while (p2 != null) { var _n = p2._next; this._testCount++; if (p1._aabbMinX < p2._aabbMaxX && p1._aabbMaxX > p2._aabbMinX && p1._aabbMinY < p2._aabbMaxY && p1._aabbMaxY > p2._aabbMinY && p1._aabbMinZ < p2._aabbMaxZ && p1._aabbMaxZ > p2._aabbMinZ) { var first = this._proxyPairPool; if (first != null) { this._proxyPairPool = first._next; first._next = null; } else { first = new oimo.collision.broadphase.ProxyPair(); } var pp = first; if (this._proxyPairList == null) { this._proxyPairList = pp; } else { pp._next = this._proxyPairList; this._proxyPairList = pp; } pp._p1 = p1; pp._p2 = p2; } p2 = _n; } p1 = n; } } }, { key: "rayCast", value: function rayCast(begin, end, callback) { var p1X; var p1Y; var p1Z; var p2X; var p2Y; var p2Z; p1X = begin.x; p1Y = begin.y; p1Z = begin.z; p2X = end.x; p2Y = end.y; p2Z = end.z; var p = this._proxyList; while (p != null) { var n = p._next; var x1 = p1X; var y1 = p1Y; var z1 = p1Z; var x2 = p2X; var y2 = p2Y; var z2 = p2Z; var pminx = p._aabbMinX; var pminy = p._aabbMinY; var pminz = p._aabbMinZ; var pmaxx = p._aabbMaxX; var pmaxy = p._aabbMaxY; var pmaxz = p._aabbMaxZ; var tmp = void 0; if (pminx > (x1 > x2 ? x1 : x2) || pmaxx < (x1 < x2 ? x1 : x2) || pminy > (y1 > y2 ? y1 : y2) || pmaxy < (y1 < y2 ? y1 : y2) || pminz > (z1 > z2 ? z1 : z2) || pmaxz < (z1 < z2 ? z1 : z2)) { tmp = false; } else { var dx = x2 - x1; var dy = y2 - y1; var dz = z2 - z1; var adx = dx < 0 ? -dx : dx; var ady = dy < 0 ? -dy : dy; var adz = dz < 0 ? -dz : dz; var pextx = (pmaxx - pminx) * 0.5; var pexty = (pmaxy - pminy) * 0.5; var pextz = (pmaxz - pminz) * 0.5; var cpx = x1 - (pmaxx + pminx) * 0.5; var cpy = y1 - (pmaxy + pminy) * 0.5; var cpz = z1 - (pmaxz + pminz) * 0.5; var tmp1 = void 0; var tmp2 = void 0; var x = cpy * dz - cpz * dy; if (!((x < 0 ? -x : x) - (pexty * adz + pextz * ady) > 0)) { var _x = cpz * dx - cpx * dz; tmp2 = (_x < 0 ? -_x : _x) - (pextz * adx + pextx * adz) > 0; } else { tmp2 = true; } if (!tmp2) { var _x2 = cpx * dy - cpy * dx; tmp1 = (_x2 < 0 ? -_x2 : _x2) - (pextx * ady + pexty * adx) > 0; } else { tmp1 = true; } tmp = tmp1 ? false : true; } if (tmp) { callback.process(p); } p = n; } } }, { key: "convexCast", value: function convexCast(convex, begin, translation, callback) { var p = this._proxyList; while (p != null) { var n = p._next; var v = this._aabb.min; v.x = p._aabbMinX; v.y = p._aabbMinY; v.z = p._aabbMinZ; var v1 = this._aabb.max; v1.x = p._aabbMaxX; v1.y = p._aabbMaxY; v1.z = p._aabbMaxZ; this._convexSweep.init(convex, begin, translation); var gjkEpa = oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance; if (gjkEpa.computeClosestPointsImpl(this._convexSweep, this._aabb, begin, this.identity, null, false) == 0 && gjkEpa.distance <= 0) { callback.process(p); } p = n; } } }, { key: "aabbTest", value: function aabbTest(aabb, callback) { var p = this._proxyList; while (p != null) { var n = p._next; if (aabb._minX < p._aabbMaxX && aabb._maxX > p._aabbMinX && aabb._minY < p._aabbMaxY && aabb._maxY > p._aabbMinY && aabb._minZ < p._aabbMaxZ && aabb._maxZ > p._aabbMinZ) { callback.process(p); } p = n; } } }]); return oimo_collision_broadphase_bruteforce_BruteForceBroadPhase; }(oimo.collision.broadphase.BroadPhase); if (!oimo.collision.broadphase.bvh) oimo.collision.broadphase.bvh = {}; oimo.collision.broadphase.bvh.BvhBroadPhase = /*#__PURE__*/function (_oimo$collision$broad2) { _inherits(oimo_collision_broadphase_bvh_BvhBroadPhase, _oimo$collision$broad2); var _super5 = _createSuper(oimo_collision_broadphase_bvh_BvhBroadPhase); function oimo_collision_broadphase_bvh_BvhBroadPhase() { var _this45; _classCallCheck(this, oimo_collision_broadphase_bvh_BvhBroadPhase); _this45 = _super5.call(this, 2); _this45._incremental = true; _this45._tree = new oimo.collision.broadphase.bvh.BvhTree(); _this45.movedProxies = new Array(1024); _this45.numMovedProxies = 0; return _this45; } _createClass(oimo_collision_broadphase_bvh_BvhBroadPhase, [{ key: "collide", value: function collide(n1, n2) { this._testCount++; var l1 = n1._height == 0; var l2 = n2._height == 0; if (n1 == n2) { if (l1) { return; } this.collide(n1._children[0], n2); this.collide(n1._children[1], n2); return; } if (!(n1._aabbMinX < n2._aabbMaxX && n1._aabbMaxX > n2._aabbMinX && n1._aabbMinY < n2._aabbMaxY && n1._aabbMaxY > n2._aabbMinY && n1._aabbMinZ < n2._aabbMaxZ && n1._aabbMaxZ > n2._aabbMinZ)) { return; } if (l1 && l2) { var first = this._proxyPairPool; if (first != null) { this._proxyPairPool = first._next; first._next = null; } else { first = new oimo.collision.broadphase.ProxyPair(); } var pp = first; if (this._proxyPairList == null) { this._proxyPairList = pp; } else { pp._next = this._proxyPairList; this._proxyPairList = pp; } pp._p1 = n1._proxy; pp._p2 = n2._proxy; return; } if (l2 || n1._height > n2._height) { this.collide(n1._children[0], n2); this.collide(n1._children[1], n2); } else { this.collide(n2._children[0], n1); this.collide(n2._children[1], n1); } } }, { key: "rayCastRecursive", value: function rayCastRecursive(node, _p1X, _p1Y, _p1Z, _p2X, _p2Y, _p2Z, callback) { var x1 = _p1X; var y1 = _p1Y; var z1 = _p1Z; var x2 = _p2X; var y2 = _p2Y; var z2 = _p2Z; var pminx = node._aabbMinX; var pminy = node._aabbMinY; var pminz = node._aabbMinZ; var pmaxx = node._aabbMaxX; var pmaxy = node._aabbMaxY; var pmaxz = node._aabbMaxZ; var tmp; if (pminx > (x1 > x2 ? x1 : x2) || pmaxx < (x1 < x2 ? x1 : x2) || pminy > (y1 > y2 ? y1 : y2) || pmaxy < (y1 < y2 ? y1 : y2) || pminz > (z1 > z2 ? z1 : z2) || pmaxz < (z1 < z2 ? z1 : z2)) { tmp = false; } else { var dx = x2 - x1; var dy = y2 - y1; var dz = z2 - z1; var adx = dx < 0 ? -dx : dx; var ady = dy < 0 ? -dy : dy; var adz = dz < 0 ? -dz : dz; var pextx = (pmaxx - pminx) * 0.5; var pexty = (pmaxy - pminy) * 0.5; var pextz = (pmaxz - pminz) * 0.5; var cpx = x1 - (pmaxx + pminx) * 0.5; var cpy = y1 - (pmaxy + pminy) * 0.5; var cpz = z1 - (pmaxz + pminz) * 0.5; var tmp1; var tmp2; var x = cpy * dz - cpz * dy; if (!((x < 0 ? -x : x) - (pexty * adz + pextz * ady) > 0)) { var _x3 = cpz * dx - cpx * dz; tmp2 = (_x3 < 0 ? -_x3 : _x3) - (pextz * adx + pextx * adz) > 0; } else { tmp2 = true; } if (!tmp2) { var _x4 = cpx * dy - cpy * dx; tmp1 = (_x4 < 0 ? -_x4 : _x4) - (pextx * ady + pexty * adx) > 0; } else { tmp1 = true; } tmp = tmp1 ? false : true; } if (!tmp) { return; } if (node._height == 0) { callback.process(node._proxy); return; } this.rayCastRecursive(node._children[0], _p1X, _p1Y, _p1Z, _p2X, _p2Y, _p2Z, callback); this.rayCastRecursive(node._children[1], _p1X, _p1Y, _p1Z, _p2X, _p2Y, _p2Z, callback); } }, { key: "convexCastRecursive", value: function convexCastRecursive(node, convex, begin, translation, callback) { var v = this._aabb.min; v.x = node._aabbMinX; v.y = node._aabbMinY; v.z = node._aabbMinZ; var v1 = this._aabb.max; v1.x = node._aabbMaxX; v1.y = node._aabbMaxY; v1.z = node._aabbMaxZ; this._convexSweep.init(convex, begin, translation); var gjkEpa = oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance; if (!(gjkEpa.computeClosestPointsImpl(this._convexSweep, this._aabb, begin, this.identity, null, false) == 0 && gjkEpa.distance <= 0)) { return; } if (node._height == 0) { callback.process(node._proxy); return; } this.convexCastRecursive(node._children[0], convex, begin, translation, callback); this.convexCastRecursive(node._children[1], convex, begin, translation, callback); } }, { key: "aabbTestRecursive", value: function aabbTestRecursive(node, aabb, callback) { if (!(node._aabbMinX < aabb._maxX && node._aabbMaxX > aabb._minX && node._aabbMinY < aabb._maxY && node._aabbMaxY > aabb._minY && node._aabbMinZ < aabb._maxZ && node._aabbMaxZ > aabb._minZ)) { return; } if (node._height == 0) { callback.process(node._proxy); return; } this.aabbTestRecursive(node._children[0], aabb, callback); this.aabbTestRecursive(node._children[1], aabb, callback); } }, { key: "createProxy", value: function createProxy(userData, aabb) { var p = new oimo.collision.broadphase.bvh.BvhProxy(userData, this._idCount++); this._numProxies++; if (this._proxyList == null) { this._proxyList = p; this._proxyListLast = p; } else { this._proxyListLast._next = p; p._prev = this._proxyListLast; this._proxyListLast = p; } p._aabbMinX = aabb._minX; p._aabbMinY = aabb._minY; p._aabbMinZ = aabb._minZ; p._aabbMaxX = aabb._maxX; p._aabbMaxY = aabb._maxY; p._aabbMaxZ = aabb._maxZ; var padding = oimo.common.Setting.bvhProxyPadding; p._aabbMinX -= padding; p._aabbMinY -= padding; p._aabbMinZ -= padding; p._aabbMaxX += padding; p._aabbMaxY += padding; p._aabbMaxZ += padding; var _this = this._tree; var first = _this._nodePool; if (first != null) { _this._nodePool = first._next; first._next = null; } else { first = new oimo.collision.broadphase.bvh.BvhNode(); } var leaf = first; leaf._proxy = p; p._leaf = leaf; leaf._aabbMinX = p._aabbMinX; leaf._aabbMinY = p._aabbMinY; leaf._aabbMinZ = p._aabbMinZ; leaf._aabbMaxX = p._aabbMaxX; leaf._aabbMaxY = p._aabbMaxY; leaf._aabbMaxZ = p._aabbMaxZ; _this._numLeaves++; if (_this.leafList == null) { _this.leafList = leaf; _this.leafListLast = leaf; } else { _this.leafListLast._nextLeaf = leaf; leaf._prevLeaf = _this.leafListLast; _this.leafListLast = leaf; } if (_this._root == null) { _this._root = leaf; } else { var sibling = _this._root; while (sibling._height > 0) { var nextStep = _this._strategy._decideInsertion(sibling, leaf); if (nextStep == -1) { break; } else { sibling = sibling._children[nextStep]; } } var parent = sibling._parent; var _first = _this._nodePool; if (_first != null) { _this._nodePool = _first._next; _first._next = null; } else { _first = new oimo.collision.broadphase.bvh.BvhNode(); } var node = _first; if (parent == null) { _this._root = node; } else { var _index = sibling._childIndex; parent._children[_index] = node; node._parent = parent; node._childIndex = _index; } var index = sibling._childIndex; node._children[index] = sibling; sibling._parent = node; sibling._childIndex = index; var index1 = sibling._childIndex ^ 1; node._children[index1] = leaf; leaf._parent = node; leaf._childIndex = index1; while (node != null) { if (_this._strategy._balancingEnabled) { if (node._height >= 2) { var _p = node._parent; var l = node._children[0]; var r = node._children[1]; var balance = l._height - r._height; var nodeIndex = node._childIndex; if (balance > 1) { var ll = l._children[0]; var lr = l._children[1]; if (ll._height > lr._height) { l._children[1] = node; node._parent = l; node._childIndex = 1; node._children[0] = lr; lr._parent = node; lr._childIndex = 0; var _c = l._children[0]; var _c2 = l._children[1]; l._aabbMinX = _c._aabbMinX < _c2._aabbMinX ? _c._aabbMinX : _c2._aabbMinX; l._aabbMinY = _c._aabbMinY < _c2._aabbMinY ? _c._aabbMinY : _c2._aabbMinY; l._aabbMinZ = _c._aabbMinZ < _c2._aabbMinZ ? _c._aabbMinZ : _c2._aabbMinZ; l._aabbMaxX = _c._aabbMaxX > _c2._aabbMaxX ? _c._aabbMaxX : _c2._aabbMaxX; l._aabbMaxY = _c._aabbMaxY > _c2._aabbMaxY ? _c._aabbMaxY : _c2._aabbMaxY; l._aabbMaxZ = _c._aabbMaxZ > _c2._aabbMaxZ ? _c._aabbMaxZ : _c2._aabbMaxZ; var _h = l._children[0]._height; var _h2 = l._children[1]._height; l._height = (_h > _h2 ? _h : _h2) + 1; var c11 = node._children[0]; var c21 = node._children[1]; node._aabbMinX = c11._aabbMinX < c21._aabbMinX ? c11._aabbMinX : c21._aabbMinX; node._aabbMinY = c11._aabbMinY < c21._aabbMinY ? c11._aabbMinY : c21._aabbMinY; node._aabbMinZ = c11._aabbMinZ < c21._aabbMinZ ? c11._aabbMinZ : c21._aabbMinZ; node._aabbMaxX = c11._aabbMaxX > c21._aabbMaxX ? c11._aabbMaxX : c21._aabbMaxX; node._aabbMaxY = c11._aabbMaxY > c21._aabbMaxY ? c11._aabbMaxY : c21._aabbMaxY; node._aabbMaxZ = c11._aabbMaxZ > c21._aabbMaxZ ? c11._aabbMaxZ : c21._aabbMaxZ; var h11 = node._children[0]._height; var h21 = node._children[1]._height; node._height = (h11 > h21 ? h11 : h21) + 1; } else { l._children[0] = node; node._parent = l; node._childIndex = 0; node._children[0] = ll; ll._parent = node; ll._childIndex = 0; var _c3 = l._children[0]; var _c4 = l._children[1]; l._aabbMinX = _c3._aabbMinX < _c4._aabbMinX ? _c3._aabbMinX : _c4._aabbMinX; l._aabbMinY = _c3._aabbMinY < _c4._aabbMinY ? _c3._aabbMinY : _c4._aabbMinY; l._aabbMinZ = _c3._aabbMinZ < _c4._aabbMinZ ? _c3._aabbMinZ : _c4._aabbMinZ; l._aabbMaxX = _c3._aabbMaxX > _c4._aabbMaxX ? _c3._aabbMaxX : _c4._aabbMaxX; l._aabbMaxY = _c3._aabbMaxY > _c4._aabbMaxY ? _c3._aabbMaxY : _c4._aabbMaxY; l._aabbMaxZ = _c3._aabbMaxZ > _c4._aabbMaxZ ? _c3._aabbMaxZ : _c4._aabbMaxZ; var _h3 = l._children[0]._height; var _h4 = l._children[1]._height; l._height = (_h3 > _h4 ? _h3 : _h4) + 1; var _c5 = node._children[0]; var _c6 = node._children[1]; node._aabbMinX = _c5._aabbMinX < _c6._aabbMinX ? _c5._aabbMinX : _c6._aabbMinX; node._aabbMinY = _c5._aabbMinY < _c6._aabbMinY ? _c5._aabbMinY : _c6._aabbMinY; node._aabbMinZ = _c5._aabbMinZ < _c6._aabbMinZ ? _c5._aabbMinZ : _c6._aabbMinZ; node._aabbMaxX = _c5._aabbMaxX > _c6._aabbMaxX ? _c5._aabbMaxX : _c6._aabbMaxX; node._aabbMaxY = _c5._aabbMaxY > _c6._aabbMaxY ? _c5._aabbMaxY : _c6._aabbMaxY; node._aabbMaxZ = _c5._aabbMaxZ > _c6._aabbMaxZ ? _c5._aabbMaxZ : _c6._aabbMaxZ; var _h5 = node._children[0]._height; var _h6 = node._children[1]._height; node._height = (_h5 > _h6 ? _h5 : _h6) + 1; } if (_p != null) { _p._children[nodeIndex] = l; l._parent = _p; l._childIndex = nodeIndex; } else { _this._root = l; l._parent = null; } node = l; } else if (balance < -1) { var rl = r._children[0]; var rr = r._children[1]; if (rl._height > rr._height) { r._children[1] = node; node._parent = r; node._childIndex = 1; node._children[1] = rr; rr._parent = node; rr._childIndex = 1; var _c7 = r._children[0]; var _c8 = r._children[1]; r._aabbMinX = _c7._aabbMinX < _c8._aabbMinX ? _c7._aabbMinX : _c8._aabbMinX; r._aabbMinY = _c7._aabbMinY < _c8._aabbMinY ? _c7._aabbMinY : _c8._aabbMinY; r._aabbMinZ = _c7._aabbMinZ < _c8._aabbMinZ ? _c7._aabbMinZ : _c8._aabbMinZ; r._aabbMaxX = _c7._aabbMaxX > _c8._aabbMaxX ? _c7._aabbMaxX : _c8._aabbMaxX; r._aabbMaxY = _c7._aabbMaxY > _c8._aabbMaxY ? _c7._aabbMaxY : _c8._aabbMaxY; r._aabbMaxZ = _c7._aabbMaxZ > _c8._aabbMaxZ ? _c7._aabbMaxZ : _c8._aabbMaxZ; var _h7 = r._children[0]._height; var _h8 = r._children[1]._height; r._height = (_h7 > _h8 ? _h7 : _h8) + 1; var _c9 = node._children[0]; var _c10 = node._children[1]; node._aabbMinX = _c9._aabbMinX < _c10._aabbMinX ? _c9._aabbMinX : _c10._aabbMinX; node._aabbMinY = _c9._aabbMinY < _c10._aabbMinY ? _c9._aabbMinY : _c10._aabbMinY; node._aabbMinZ = _c9._aabbMinZ < _c10._aabbMinZ ? _c9._aabbMinZ : _c10._aabbMinZ; node._aabbMaxX = _c9._aabbMaxX > _c10._aabbMaxX ? _c9._aabbMaxX : _c10._aabbMaxX; node._aabbMaxY = _c9._aabbMaxY > _c10._aabbMaxY ? _c9._aabbMaxY : _c10._aabbMaxY; node._aabbMaxZ = _c9._aabbMaxZ > _c10._aabbMaxZ ? _c9._aabbMaxZ : _c10._aabbMaxZ; var _h9 = node._children[0]._height; var _h10 = node._children[1]._height; node._height = (_h9 > _h10 ? _h9 : _h10) + 1; } else { r._children[0] = node; node._parent = r; node._childIndex = 0; node._children[1] = rl; rl._parent = node; rl._childIndex = 1; var _c11 = r._children[0]; var _c12 = r._children[1]; r._aabbMinX = _c11._aabbMinX < _c12._aabbMinX ? _c11._aabbMinX : _c12._aabbMinX; r._aabbMinY = _c11._aabbMinY < _c12._aabbMinY ? _c11._aabbMinY : _c12._aabbMinY; r._aabbMinZ = _c11._aabbMinZ < _c12._aabbMinZ ? _c11._aabbMinZ : _c12._aabbMinZ; r._aabbMaxX = _c11._aabbMaxX > _c12._aabbMaxX ? _c11._aabbMaxX : _c12._aabbMaxX; r._aabbMaxY = _c11._aabbMaxY > _c12._aabbMaxY ? _c11._aabbMaxY : _c12._aabbMaxY; r._aabbMaxZ = _c11._aabbMaxZ > _c12._aabbMaxZ ? _c11._aabbMaxZ : _c12._aabbMaxZ; var _h11 = r._children[0]._height; var _h12 = r._children[1]._height; r._height = (_h11 > _h12 ? _h11 : _h12) + 1; var _c13 = node._children[0]; var _c14 = node._children[1]; node._aabbMinX = _c13._aabbMinX < _c14._aabbMinX ? _c13._aabbMinX : _c14._aabbMinX; node._aabbMinY = _c13._aabbMinY < _c14._aabbMinY ? _c13._aabbMinY : _c14._aabbMinY; node._aabbMinZ = _c13._aabbMinZ < _c14._aabbMinZ ? _c13._aabbMinZ : _c14._aabbMinZ; node._aabbMaxX = _c13._aabbMaxX > _c14._aabbMaxX ? _c13._aabbMaxX : _c14._aabbMaxX; node._aabbMaxY = _c13._aabbMaxY > _c14._aabbMaxY ? _c13._aabbMaxY : _c14._aabbMaxY; node._aabbMaxZ = _c13._aabbMaxZ > _c14._aabbMaxZ ? _c13._aabbMaxZ : _c14._aabbMaxZ; var _h13 = node._children[0]._height; var _h14 = node._children[1]._height; node._height = (_h13 > _h14 ? _h13 : _h14) + 1; } if (_p != null) { _p._children[nodeIndex] = r; r._parent = _p; r._childIndex = nodeIndex; } else { _this._root = r; r._parent = null; } node = r; } } } var h1 = node._children[0]._height; var h2 = node._children[1]._height; node._height = (h1 > h2 ? h1 : h2) + 1; var c1 = node._children[0]; var c2 = node._children[1]; node._aabbMinX = c1._aabbMinX < c2._aabbMinX ? c1._aabbMinX : c2._aabbMinX; node._aabbMinY = c1._aabbMinY < c2._aabbMinY ? c1._aabbMinY : c2._aabbMinY; node._aabbMinZ = c1._aabbMinZ < c2._aabbMinZ ? c1._aabbMinZ : c2._aabbMinZ; node._aabbMaxX = c1._aabbMaxX > c2._aabbMaxX ? c1._aabbMaxX : c2._aabbMaxX; node._aabbMaxY = c1._aabbMaxY > c2._aabbMaxY ? c1._aabbMaxY : c2._aabbMaxY; node._aabbMaxZ = c1._aabbMaxZ > c2._aabbMaxZ ? c1._aabbMaxZ : c2._aabbMaxZ; node = node._parent; } } if (!p._moved) { p._moved = true; if (this.movedProxies.length == this.numMovedProxies) { var newArray = new Array(this.numMovedProxies << 1); var _g = 0; var _g1 = this.numMovedProxies; while (_g < _g1) { var i = _g++; newArray[i] = this.movedProxies[i]; this.movedProxies[i] = null; } this.movedProxies = newArray; } this.movedProxies[this.numMovedProxies++] = p; } return p; } }, { key: "destroyProxy", value: function destroyProxy(proxy) { this._numProxies--; var prev = proxy._prev; var next = proxy._next; if (prev != null) { prev._next = next; } if (next != null) { next._prev = prev; } if (proxy == this._proxyList) { this._proxyList = this._proxyList._next; } if (proxy == this._proxyListLast) { this._proxyListLast = this._proxyListLast._prev; } proxy._next = null; proxy._prev = null; var bvhProxy = proxy; var _this = this._tree; var leaf = bvhProxy._leaf; _this._numLeaves--; var prev1 = leaf._prevLeaf; var next1 = leaf._nextLeaf; if (prev1 != null) { prev1._nextLeaf = next1; } if (next1 != null) { next1._prevLeaf = prev1; } if (leaf == _this.leafList) { _this.leafList = _this.leafList._nextLeaf; } if (leaf == _this.leafListLast) { _this.leafListLast = _this.leafListLast._prevLeaf; } leaf._nextLeaf = null; leaf._prevLeaf = null; if (_this._root == leaf) { _this._root = null; } else { var parent = leaf._parent; var sibling = parent._children[leaf._childIndex ^ 1]; var grandParent = parent._parent; if (grandParent == null) { sibling._parent = null; sibling._childIndex = 0; _this._root = sibling; parent._next = null; parent._childIndex = 0; parent._children[0] = null; parent._children[1] = null; parent._childIndex = 0; parent._parent = null; parent._height = 0; parent._proxy = null; parent._next = _this._nodePool; _this._nodePool = parent; } else { sibling._parent = grandParent; var index = parent._childIndex; grandParent._children[index] = sibling; sibling._parent = grandParent; sibling._childIndex = index; parent._next = null; parent._childIndex = 0; parent._children[0] = null; parent._children[1] = null; parent._childIndex = 0; parent._parent = null; parent._height = 0; parent._proxy = null; parent._next = _this._nodePool; _this._nodePool = parent; var node = grandParent; while (node != null) { if (_this._strategy._balancingEnabled) { if (node._height >= 2) { var p = node._parent; var l = node._children[0]; var r = node._children[1]; var balance = l._height - r._height; var nodeIndex = node._childIndex; if (balance > 1) { var ll = l._children[0]; var lr = l._children[1]; if (ll._height > lr._height) { l._children[1] = node; node._parent = l; node._childIndex = 1; node._children[0] = lr; lr._parent = node; lr._childIndex = 0; var _c15 = l._children[0]; var _c16 = l._children[1]; l._aabbMinX = _c15._aabbMinX < _c16._aabbMinX ? _c15._aabbMinX : _c16._aabbMinX; l._aabbMinY = _c15._aabbMinY < _c16._aabbMinY ? _c15._aabbMinY : _c16._aabbMinY; l._aabbMinZ = _c15._aabbMinZ < _c16._aabbMinZ ? _c15._aabbMinZ : _c16._aabbMinZ; l._aabbMaxX = _c15._aabbMaxX > _c16._aabbMaxX ? _c15._aabbMaxX : _c16._aabbMaxX; l._aabbMaxY = _c15._aabbMaxY > _c16._aabbMaxY ? _c15._aabbMaxY : _c16._aabbMaxY; l._aabbMaxZ = _c15._aabbMaxZ > _c16._aabbMaxZ ? _c15._aabbMaxZ : _c16._aabbMaxZ; var _h15 = l._children[0]._height; var _h16 = l._children[1]._height; l._height = (_h15 > _h16 ? _h15 : _h16) + 1; var c11 = node._children[0]; var c21 = node._children[1]; node._aabbMinX = c11._aabbMinX < c21._aabbMinX ? c11._aabbMinX : c21._aabbMinX; node._aabbMinY = c11._aabbMinY < c21._aabbMinY ? c11._aabbMinY : c21._aabbMinY; node._aabbMinZ = c11._aabbMinZ < c21._aabbMinZ ? c11._aabbMinZ : c21._aabbMinZ; node._aabbMaxX = c11._aabbMaxX > c21._aabbMaxX ? c11._aabbMaxX : c21._aabbMaxX; node._aabbMaxY = c11._aabbMaxY > c21._aabbMaxY ? c11._aabbMaxY : c21._aabbMaxY; node._aabbMaxZ = c11._aabbMaxZ > c21._aabbMaxZ ? c11._aabbMaxZ : c21._aabbMaxZ; var h11 = node._children[0]._height; var h21 = node._children[1]._height; node._height = (h11 > h21 ? h11 : h21) + 1; } else { l._children[0] = node; node._parent = l; node._childIndex = 0; node._children[0] = ll; ll._parent = node; ll._childIndex = 0; var _c17 = l._children[0]; var _c18 = l._children[1]; l._aabbMinX = _c17._aabbMinX < _c18._aabbMinX ? _c17._aabbMinX : _c18._aabbMinX; l._aabbMinY = _c17._aabbMinY < _c18._aabbMinY ? _c17._aabbMinY : _c18._aabbMinY; l._aabbMinZ = _c17._aabbMinZ < _c18._aabbMinZ ? _c17._aabbMinZ : _c18._aabbMinZ; l._aabbMaxX = _c17._aabbMaxX > _c18._aabbMaxX ? _c17._aabbMaxX : _c18._aabbMaxX; l._aabbMaxY = _c17._aabbMaxY > _c18._aabbMaxY ? _c17._aabbMaxY : _c18._aabbMaxY; l._aabbMaxZ = _c17._aabbMaxZ > _c18._aabbMaxZ ? _c17._aabbMaxZ : _c18._aabbMaxZ; var _h17 = l._children[0]._height; var _h18 = l._children[1]._height; l._height = (_h17 > _h18 ? _h17 : _h18) + 1; var _c19 = node._children[0]; var _c20 = node._children[1]; node._aabbMinX = _c19._aabbMinX < _c20._aabbMinX ? _c19._aabbMinX : _c20._aabbMinX; node._aabbMinY = _c19._aabbMinY < _c20._aabbMinY ? _c19._aabbMinY : _c20._aabbMinY; node._aabbMinZ = _c19._aabbMinZ < _c20._aabbMinZ ? _c19._aabbMinZ : _c20._aabbMinZ; node._aabbMaxX = _c19._aabbMaxX > _c20._aabbMaxX ? _c19._aabbMaxX : _c20._aabbMaxX; node._aabbMaxY = _c19._aabbMaxY > _c20._aabbMaxY ? _c19._aabbMaxY : _c20._aabbMaxY; node._aabbMaxZ = _c19._aabbMaxZ > _c20._aabbMaxZ ? _c19._aabbMaxZ : _c20._aabbMaxZ; var _h19 = node._children[0]._height; var _h20 = node._children[1]._height; node._height = (_h19 > _h20 ? _h19 : _h20) + 1; } if (p != null) { p._children[nodeIndex] = l; l._parent = p; l._childIndex = nodeIndex; } else { _this._root = l; l._parent = null; } node = l; } else if (balance < -1) { var rl = r._children[0]; var rr = r._children[1]; if (rl._height > rr._height) { r._children[1] = node; node._parent = r; node._childIndex = 1; node._children[1] = rr; rr._parent = node; rr._childIndex = 1; var _c21 = r._children[0]; var _c22 = r._children[1]; r._aabbMinX = _c21._aabbMinX < _c22._aabbMinX ? _c21._aabbMinX : _c22._aabbMinX; r._aabbMinY = _c21._aabbMinY < _c22._aabbMinY ? _c21._aabbMinY : _c22._aabbMinY; r._aabbMinZ = _c21._aabbMinZ < _c22._aabbMinZ ? _c21._aabbMinZ : _c22._aabbMinZ; r._aabbMaxX = _c21._aabbMaxX > _c22._aabbMaxX ? _c21._aabbMaxX : _c22._aabbMaxX; r._aabbMaxY = _c21._aabbMaxY > _c22._aabbMaxY ? _c21._aabbMaxY : _c22._aabbMaxY; r._aabbMaxZ = _c21._aabbMaxZ > _c22._aabbMaxZ ? _c21._aabbMaxZ : _c22._aabbMaxZ; var _h21 = r._children[0]._height; var _h22 = r._children[1]._height; r._height = (_h21 > _h22 ? _h21 : _h22) + 1; var _c23 = node._children[0]; var _c24 = node._children[1]; node._aabbMinX = _c23._aabbMinX < _c24._aabbMinX ? _c23._aabbMinX : _c24._aabbMinX; node._aabbMinY = _c23._aabbMinY < _c24._aabbMinY ? _c23._aabbMinY : _c24._aabbMinY; node._aabbMinZ = _c23._aabbMinZ < _c24._aabbMinZ ? _c23._aabbMinZ : _c24._aabbMinZ; node._aabbMaxX = _c23._aabbMaxX > _c24._aabbMaxX ? _c23._aabbMaxX : _c24._aabbMaxX; node._aabbMaxY = _c23._aabbMaxY > _c24._aabbMaxY ? _c23._aabbMaxY : _c24._aabbMaxY; node._aabbMaxZ = _c23._aabbMaxZ > _c24._aabbMaxZ ? _c23._aabbMaxZ : _c24._aabbMaxZ; var _h23 = node._children[0]._height; var _h24 = node._children[1]._height; node._height = (_h23 > _h24 ? _h23 : _h24) + 1; } else { r._children[0] = node; node._parent = r; node._childIndex = 0; node._children[1] = rl; rl._parent = node; rl._childIndex = 1; var _c25 = r._children[0]; var _c26 = r._children[1]; r._aabbMinX = _c25._aabbMinX < _c26._aabbMinX ? _c25._aabbMinX : _c26._aabbMinX; r._aabbMinY = _c25._aabbMinY < _c26._aabbMinY ? _c25._aabbMinY : _c26._aabbMinY; r._aabbMinZ = _c25._aabbMinZ < _c26._aabbMinZ ? _c25._aabbMinZ : _c26._aabbMinZ; r._aabbMaxX = _c25._aabbMaxX > _c26._aabbMaxX ? _c25._aabbMaxX : _c26._aabbMaxX; r._aabbMaxY = _c25._aabbMaxY > _c26._aabbMaxY ? _c25._aabbMaxY : _c26._aabbMaxY; r._aabbMaxZ = _c25._aabbMaxZ > _c26._aabbMaxZ ? _c25._aabbMaxZ : _c26._aabbMaxZ; var _h25 = r._children[0]._height; var _h26 = r._children[1]._height; r._height = (_h25 > _h26 ? _h25 : _h26) + 1; var _c27 = node._children[0]; var _c28 = node._children[1]; node._aabbMinX = _c27._aabbMinX < _c28._aabbMinX ? _c27._aabbMinX : _c28._aabbMinX; node._aabbMinY = _c27._aabbMinY < _c28._aabbMinY ? _c27._aabbMinY : _c28._aabbMinY; node._aabbMinZ = _c27._aabbMinZ < _c28._aabbMinZ ? _c27._aabbMinZ : _c28._aabbMinZ; node._aabbMaxX = _c27._aabbMaxX > _c28._aabbMaxX ? _c27._aabbMaxX : _c28._aabbMaxX; node._aabbMaxY = _c27._aabbMaxY > _c28._aabbMaxY ? _c27._aabbMaxY : _c28._aabbMaxY; node._aabbMaxZ = _c27._aabbMaxZ > _c28._aabbMaxZ ? _c27._aabbMaxZ : _c28._aabbMaxZ; var _h27 = node._children[0]._height; var _h28 = node._children[1]._height; node._height = (_h27 > _h28 ? _h27 : _h28) + 1; } if (p != null) { p._children[nodeIndex] = r; r._parent = p; r._childIndex = nodeIndex; } else { _this._root = r; r._parent = null; } node = r; } } } var h1 = node._children[0]._height; var h2 = node._children[1]._height; node._height = (h1 > h2 ? h1 : h2) + 1; var c1 = node._children[0]; var c2 = node._children[1]; node._aabbMinX = c1._aabbMinX < c2._aabbMinX ? c1._aabbMinX : c2._aabbMinX; node._aabbMinY = c1._aabbMinY < c2._aabbMinY ? c1._aabbMinY : c2._aabbMinY; node._aabbMinZ = c1._aabbMinZ < c2._aabbMinZ ? c1._aabbMinZ : c2._aabbMinZ; node._aabbMaxX = c1._aabbMaxX > c2._aabbMaxX ? c1._aabbMaxX : c2._aabbMaxX; node._aabbMaxY = c1._aabbMaxY > c2._aabbMaxY ? c1._aabbMaxY : c2._aabbMaxY; node._aabbMaxZ = c1._aabbMaxZ > c2._aabbMaxZ ? c1._aabbMaxZ : c2._aabbMaxZ; node = node._parent; } } } bvhProxy._leaf = null; leaf._next = null; leaf._childIndex = 0; leaf._children[0] = null; leaf._children[1] = null; leaf._childIndex = 0; leaf._parent = null; leaf._height = 0; leaf._proxy = null; leaf._next = _this._nodePool; _this._nodePool = leaf; bvhProxy.userData = null; bvhProxy._next = null; bvhProxy._prev = null; if (bvhProxy._moved) { bvhProxy._moved = false; } } }, { key: "moveProxy", value: function moveProxy(proxy, aabb, displacement) { var p = proxy; if (p._aabbMinX <= aabb._minX && p._aabbMaxX >= aabb._maxX && p._aabbMinY <= aabb._minY && p._aabbMaxY >= aabb._maxY && p._aabbMinZ <= aabb._minZ && p._aabbMaxZ >= aabb._maxZ) { return; } p._aabbMinX = aabb._minX; p._aabbMinY = aabb._minY; p._aabbMinZ = aabb._minZ; p._aabbMaxX = aabb._maxX; p._aabbMaxY = aabb._maxY; p._aabbMaxZ = aabb._maxZ; var padding = oimo.common.Setting.bvhProxyPadding; p._aabbMinX -= padding; p._aabbMinY -= padding; p._aabbMinZ -= padding; p._aabbMaxX += padding; p._aabbMaxY += padding; p._aabbMaxZ += padding; if (displacement != null) { var dX; var dY; var dZ; var zeroX; var zeroY; var zeroZ; var addToMinX; var addToMinY; var addToMinZ; var addToMaxX; var addToMaxY; var addToMaxZ; zeroX = 0; zeroY = 0; zeroZ = 0; dX = displacement.x; dY = displacement.y; dZ = displacement.z; addToMinX = zeroX < dX ? zeroX : dX; addToMinY = zeroY < dY ? zeroY : dY; addToMinZ = zeroZ < dZ ? zeroZ : dZ; addToMaxX = zeroX > dX ? zeroX : dX; addToMaxY = zeroY > dY ? zeroY : dY; addToMaxZ = zeroZ > dZ ? zeroZ : dZ; p._aabbMinX += addToMinX; p._aabbMinY += addToMinY; p._aabbMinZ += addToMinZ; p._aabbMaxX += addToMaxX; p._aabbMaxY += addToMaxY; p._aabbMaxZ += addToMaxZ; } if (!p._moved) { p._moved = true; if (this.movedProxies.length == this.numMovedProxies) { var newArray = new Array(this.numMovedProxies << 1); var _g = 0; var _g1 = this.numMovedProxies; while (_g < _g1) { var i = _g++; newArray[i] = this.movedProxies[i]; this.movedProxies[i] = null; } this.movedProxies = newArray; } this.movedProxies[this.numMovedProxies++] = p; } } }, { key: "collectPairs", value: function collectPairs() { var p = this._proxyPairList; if (p != null) { while (true) { p._p1 = null; p._p2 = null; p = p._next; if (!(p != null)) { break; } } this._proxyPairList._next = this._proxyPairPool; this._proxyPairPool = this._proxyPairList; this._proxyPairList = null; } this._testCount = 0; if (this._numProxies < 2) { return; } var incrementalCollision = this.numMovedProxies / this._numProxies < oimo.common.Setting.bvhIncrementalCollisionThreshold; var _g = 0; var _g1 = this.numMovedProxies; while (_g < _g1) { var i = _g++; var _p2 = this.movedProxies[i]; if (_p2._moved) { var _this = this._tree; var leaf = _p2._leaf; _this._numLeaves--; var prev = leaf._prevLeaf; var next = leaf._nextLeaf; if (prev != null) { prev._nextLeaf = next; } if (next != null) { next._prevLeaf = prev; } if (leaf == _this.leafList) { _this.leafList = _this.leafList._nextLeaf; } if (leaf == _this.leafListLast) { _this.leafListLast = _this.leafListLast._prevLeaf; } leaf._nextLeaf = null; leaf._prevLeaf = null; if (_this._root == leaf) { _this._root = null; } else { var parent = leaf._parent; var sibling = parent._children[leaf._childIndex ^ 1]; var grandParent = parent._parent; if (grandParent == null) { sibling._parent = null; sibling._childIndex = 0; _this._root = sibling; parent._next = null; parent._childIndex = 0; parent._children[0] = null; parent._children[1] = null; parent._childIndex = 0; parent._parent = null; parent._height = 0; parent._proxy = null; parent._next = _this._nodePool; _this._nodePool = parent; } else { sibling._parent = grandParent; var index = parent._childIndex; grandParent._children[index] = sibling; sibling._parent = grandParent; sibling._childIndex = index; parent._next = null; parent._childIndex = 0; parent._children[0] = null; parent._children[1] = null; parent._childIndex = 0; parent._parent = null; parent._height = 0; parent._proxy = null; parent._next = _this._nodePool; _this._nodePool = parent; var node = grandParent; while (node != null) { if (_this._strategy._balancingEnabled) { if (node._height >= 2) { var _p3 = node._parent; var l = node._children[0]; var r = node._children[1]; var balance = l._height - r._height; var nodeIndex = node._childIndex; if (balance > 1) { var ll = l._children[0]; var lr = l._children[1]; if (ll._height > lr._height) { l._children[1] = node; node._parent = l; node._childIndex = 1; node._children[0] = lr; lr._parent = node; lr._childIndex = 0; var _c29 = l._children[0]; var _c30 = l._children[1]; l._aabbMinX = _c29._aabbMinX < _c30._aabbMinX ? _c29._aabbMinX : _c30._aabbMinX; l._aabbMinY = _c29._aabbMinY < _c30._aabbMinY ? _c29._aabbMinY : _c30._aabbMinY; l._aabbMinZ = _c29._aabbMinZ < _c30._aabbMinZ ? _c29._aabbMinZ : _c30._aabbMinZ; l._aabbMaxX = _c29._aabbMaxX > _c30._aabbMaxX ? _c29._aabbMaxX : _c30._aabbMaxX; l._aabbMaxY = _c29._aabbMaxY > _c30._aabbMaxY ? _c29._aabbMaxY : _c30._aabbMaxY; l._aabbMaxZ = _c29._aabbMaxZ > _c30._aabbMaxZ ? _c29._aabbMaxZ : _c30._aabbMaxZ; var _h29 = l._children[0]._height; var _h30 = l._children[1]._height; l._height = (_h29 > _h30 ? _h29 : _h30) + 1; var c11 = node._children[0]; var c21 = node._children[1]; node._aabbMinX = c11._aabbMinX < c21._aabbMinX ? c11._aabbMinX : c21._aabbMinX; node._aabbMinY = c11._aabbMinY < c21._aabbMinY ? c11._aabbMinY : c21._aabbMinY; node._aabbMinZ = c11._aabbMinZ < c21._aabbMinZ ? c11._aabbMinZ : c21._aabbMinZ; node._aabbMaxX = c11._aabbMaxX > c21._aabbMaxX ? c11._aabbMaxX : c21._aabbMaxX; node._aabbMaxY = c11._aabbMaxY > c21._aabbMaxY ? c11._aabbMaxY : c21._aabbMaxY; node._aabbMaxZ = c11._aabbMaxZ > c21._aabbMaxZ ? c11._aabbMaxZ : c21._aabbMaxZ; var h11 = node._children[0]._height; var h21 = node._children[1]._height; node._height = (h11 > h21 ? h11 : h21) + 1; } else { l._children[0] = node; node._parent = l; node._childIndex = 0; node._children[0] = ll; ll._parent = node; ll._childIndex = 0; var _c31 = l._children[0]; var _c32 = l._children[1]; l._aabbMinX = _c31._aabbMinX < _c32._aabbMinX ? _c31._aabbMinX : _c32._aabbMinX; l._aabbMinY = _c31._aabbMinY < _c32._aabbMinY ? _c31._aabbMinY : _c32._aabbMinY; l._aabbMinZ = _c31._aabbMinZ < _c32._aabbMinZ ? _c31._aabbMinZ : _c32._aabbMinZ; l._aabbMaxX = _c31._aabbMaxX > _c32._aabbMaxX ? _c31._aabbMaxX : _c32._aabbMaxX; l._aabbMaxY = _c31._aabbMaxY > _c32._aabbMaxY ? _c31._aabbMaxY : _c32._aabbMaxY; l._aabbMaxZ = _c31._aabbMaxZ > _c32._aabbMaxZ ? _c31._aabbMaxZ : _c32._aabbMaxZ; var _h31 = l._children[0]._height; var _h32 = l._children[1]._height; l._height = (_h31 > _h32 ? _h31 : _h32) + 1; var _c33 = node._children[0]; var _c34 = node._children[1]; node._aabbMinX = _c33._aabbMinX < _c34._aabbMinX ? _c33._aabbMinX : _c34._aabbMinX; node._aabbMinY = _c33._aabbMinY < _c34._aabbMinY ? _c33._aabbMinY : _c34._aabbMinY; node._aabbMinZ = _c33._aabbMinZ < _c34._aabbMinZ ? _c33._aabbMinZ : _c34._aabbMinZ; node._aabbMaxX = _c33._aabbMaxX > _c34._aabbMaxX ? _c33._aabbMaxX : _c34._aabbMaxX; node._aabbMaxY = _c33._aabbMaxY > _c34._aabbMaxY ? _c33._aabbMaxY : _c34._aabbMaxY; node._aabbMaxZ = _c33._aabbMaxZ > _c34._aabbMaxZ ? _c33._aabbMaxZ : _c34._aabbMaxZ; var _h33 = node._children[0]._height; var _h34 = node._children[1]._height; node._height = (_h33 > _h34 ? _h33 : _h34) + 1; } if (_p3 != null) { _p3._children[nodeIndex] = l; l._parent = _p3; l._childIndex = nodeIndex; } else { _this._root = l; l._parent = null; } node = l; } else if (balance < -1) { var rl = r._children[0]; var rr = r._children[1]; if (rl._height > rr._height) { r._children[1] = node; node._parent = r; node._childIndex = 1; node._children[1] = rr; rr._parent = node; rr._childIndex = 1; var _c35 = r._children[0]; var _c36 = r._children[1]; r._aabbMinX = _c35._aabbMinX < _c36._aabbMinX ? _c35._aabbMinX : _c36._aabbMinX; r._aabbMinY = _c35._aabbMinY < _c36._aabbMinY ? _c35._aabbMinY : _c36._aabbMinY; r._aabbMinZ = _c35._aabbMinZ < _c36._aabbMinZ ? _c35._aabbMinZ : _c36._aabbMinZ; r._aabbMaxX = _c35._aabbMaxX > _c36._aabbMaxX ? _c35._aabbMaxX : _c36._aabbMaxX; r._aabbMaxY = _c35._aabbMaxY > _c36._aabbMaxY ? _c35._aabbMaxY : _c36._aabbMaxY; r._aabbMaxZ = _c35._aabbMaxZ > _c36._aabbMaxZ ? _c35._aabbMaxZ : _c36._aabbMaxZ; var _h35 = r._children[0]._height; var _h36 = r._children[1]._height; r._height = (_h35 > _h36 ? _h35 : _h36) + 1; var _c37 = node._children[0]; var _c38 = node._children[1]; node._aabbMinX = _c37._aabbMinX < _c38._aabbMinX ? _c37._aabbMinX : _c38._aabbMinX; node._aabbMinY = _c37._aabbMinY < _c38._aabbMinY ? _c37._aabbMinY : _c38._aabbMinY; node._aabbMinZ = _c37._aabbMinZ < _c38._aabbMinZ ? _c37._aabbMinZ : _c38._aabbMinZ; node._aabbMaxX = _c37._aabbMaxX > _c38._aabbMaxX ? _c37._aabbMaxX : _c38._aabbMaxX; node._aabbMaxY = _c37._aabbMaxY > _c38._aabbMaxY ? _c37._aabbMaxY : _c38._aabbMaxY; node._aabbMaxZ = _c37._aabbMaxZ > _c38._aabbMaxZ ? _c37._aabbMaxZ : _c38._aabbMaxZ; var _h37 = node._children[0]._height; var _h38 = node._children[1]._height; node._height = (_h37 > _h38 ? _h37 : _h38) + 1; } else { r._children[0] = node; node._parent = r; node._childIndex = 0; node._children[1] = rl; rl._parent = node; rl._childIndex = 1; var _c39 = r._children[0]; var _c40 = r._children[1]; r._aabbMinX = _c39._aabbMinX < _c40._aabbMinX ? _c39._aabbMinX : _c40._aabbMinX; r._aabbMinY = _c39._aabbMinY < _c40._aabbMinY ? _c39._aabbMinY : _c40._aabbMinY; r._aabbMinZ = _c39._aabbMinZ < _c40._aabbMinZ ? _c39._aabbMinZ : _c40._aabbMinZ; r._aabbMaxX = _c39._aabbMaxX > _c40._aabbMaxX ? _c39._aabbMaxX : _c40._aabbMaxX; r._aabbMaxY = _c39._aabbMaxY > _c40._aabbMaxY ? _c39._aabbMaxY : _c40._aabbMaxY; r._aabbMaxZ = _c39._aabbMaxZ > _c40._aabbMaxZ ? _c39._aabbMaxZ : _c40._aabbMaxZ; var _h39 = r._children[0]._height; var _h40 = r._children[1]._height; r._height = (_h39 > _h40 ? _h39 : _h40) + 1; var _c41 = node._children[0]; var _c42 = node._children[1]; node._aabbMinX = _c41._aabbMinX < _c42._aabbMinX ? _c41._aabbMinX : _c42._aabbMinX; node._aabbMinY = _c41._aabbMinY < _c42._aabbMinY ? _c41._aabbMinY : _c42._aabbMinY; node._aabbMinZ = _c41._aabbMinZ < _c42._aabbMinZ ? _c41._aabbMinZ : _c42._aabbMinZ; node._aabbMaxX = _c41._aabbMaxX > _c42._aabbMaxX ? _c41._aabbMaxX : _c42._aabbMaxX; node._aabbMaxY = _c41._aabbMaxY > _c42._aabbMaxY ? _c41._aabbMaxY : _c42._aabbMaxY; node._aabbMaxZ = _c41._aabbMaxZ > _c42._aabbMaxZ ? _c41._aabbMaxZ : _c42._aabbMaxZ; var _h41 = node._children[0]._height; var _h42 = node._children[1]._height; node._height = (_h41 > _h42 ? _h41 : _h42) + 1; } if (_p3 != null) { _p3._children[nodeIndex] = r; r._parent = _p3; r._childIndex = nodeIndex; } else { _this._root = r; r._parent = null; } node = r; } } } var h1 = node._children[0]._height; var h2 = node._children[1]._height; node._height = (h1 > h2 ? h1 : h2) + 1; var c1 = node._children[0]; var c2 = node._children[1]; node._aabbMinX = c1._aabbMinX < c2._aabbMinX ? c1._aabbMinX : c2._aabbMinX; node._aabbMinY = c1._aabbMinY < c2._aabbMinY ? c1._aabbMinY : c2._aabbMinY; node._aabbMinZ = c1._aabbMinZ < c2._aabbMinZ ? c1._aabbMinZ : c2._aabbMinZ; node._aabbMaxX = c1._aabbMaxX > c2._aabbMaxX ? c1._aabbMaxX : c2._aabbMaxX; node._aabbMaxY = c1._aabbMaxY > c2._aabbMaxY ? c1._aabbMaxY : c2._aabbMaxY; node._aabbMaxZ = c1._aabbMaxZ > c2._aabbMaxZ ? c1._aabbMaxZ : c2._aabbMaxZ; node = node._parent; } } } _p2._leaf = null; leaf._next = null; leaf._childIndex = 0; leaf._children[0] = null; leaf._children[1] = null; leaf._childIndex = 0; leaf._parent = null; leaf._height = 0; leaf._proxy = null; leaf._next = _this._nodePool; _this._nodePool = leaf; var _this1 = this._tree; var first = _this1._nodePool; if (first != null) { _this1._nodePool = first._next; first._next = null; } else { first = new oimo.collision.broadphase.bvh.BvhNode(); } var leaf1 = first; leaf1._proxy = _p2; _p2._leaf = leaf1; leaf1._aabbMinX = _p2._aabbMinX; leaf1._aabbMinY = _p2._aabbMinY; leaf1._aabbMinZ = _p2._aabbMinZ; leaf1._aabbMaxX = _p2._aabbMaxX; leaf1._aabbMaxY = _p2._aabbMaxY; leaf1._aabbMaxZ = _p2._aabbMaxZ; _this1._numLeaves++; if (_this1.leafList == null) { _this1.leafList = leaf1; _this1.leafListLast = leaf1; } else { _this1.leafListLast._nextLeaf = leaf1; leaf1._prevLeaf = _this1.leafListLast; _this1.leafListLast = leaf1; } if (_this1._root == null) { _this1._root = leaf1; } else { var _sibling = _this1._root; while (_sibling._height > 0) { var nextStep = _this1._strategy._decideInsertion(_sibling, leaf1); if (nextStep == -1) { break; } else { _sibling = _sibling._children[nextStep]; } } var _parent = _sibling._parent; var _first2 = _this1._nodePool; if (_first2 != null) { _this1._nodePool = _first2._next; _first2._next = null; } else { _first2 = new oimo.collision.broadphase.bvh.BvhNode(); } var _node = _first2; if (_parent == null) { _this1._root = _node; } else { var _index3 = _sibling._childIndex; _parent._children[_index3] = _node; _node._parent = _parent; _node._childIndex = _index3; } var _index2 = _sibling._childIndex; _node._children[_index2] = _sibling; _sibling._parent = _node; _sibling._childIndex = _index2; var index1 = _sibling._childIndex ^ 1; _node._children[index1] = leaf1; leaf1._parent = _node; leaf1._childIndex = index1; while (_node != null) { if (_this1._strategy._balancingEnabled) { if (_node._height >= 2) { var _p4 = _node._parent; var _l = _node._children[0]; var _r = _node._children[1]; var _balance = _l._height - _r._height; var _nodeIndex = _node._childIndex; if (_balance > 1) { var _ll = _l._children[0]; var _lr = _l._children[1]; if (_ll._height > _lr._height) { _l._children[1] = _node; _node._parent = _l; _node._childIndex = 1; _node._children[0] = _lr; _lr._parent = _node; _lr._childIndex = 0; var _c45 = _l._children[0]; var _c46 = _l._children[1]; _l._aabbMinX = _c45._aabbMinX < _c46._aabbMinX ? _c45._aabbMinX : _c46._aabbMinX; _l._aabbMinY = _c45._aabbMinY < _c46._aabbMinY ? _c45._aabbMinY : _c46._aabbMinY; _l._aabbMinZ = _c45._aabbMinZ < _c46._aabbMinZ ? _c45._aabbMinZ : _c46._aabbMinZ; _l._aabbMaxX = _c45._aabbMaxX > _c46._aabbMaxX ? _c45._aabbMaxX : _c46._aabbMaxX; _l._aabbMaxY = _c45._aabbMaxY > _c46._aabbMaxY ? _c45._aabbMaxY : _c46._aabbMaxY; _l._aabbMaxZ = _c45._aabbMaxZ > _c46._aabbMaxZ ? _c45._aabbMaxZ : _c46._aabbMaxZ; var _h45 = _l._children[0]._height; var _h46 = _l._children[1]._height; _l._height = (_h45 > _h46 ? _h45 : _h46) + 1; var _c47 = _node._children[0]; var _c48 = _node._children[1]; _node._aabbMinX = _c47._aabbMinX < _c48._aabbMinX ? _c47._aabbMinX : _c48._aabbMinX; _node._aabbMinY = _c47._aabbMinY < _c48._aabbMinY ? _c47._aabbMinY : _c48._aabbMinY; _node._aabbMinZ = _c47._aabbMinZ < _c48._aabbMinZ ? _c47._aabbMinZ : _c48._aabbMinZ; _node._aabbMaxX = _c47._aabbMaxX > _c48._aabbMaxX ? _c47._aabbMaxX : _c48._aabbMaxX; _node._aabbMaxY = _c47._aabbMaxY > _c48._aabbMaxY ? _c47._aabbMaxY : _c48._aabbMaxY; _node._aabbMaxZ = _c47._aabbMaxZ > _c48._aabbMaxZ ? _c47._aabbMaxZ : _c48._aabbMaxZ; var _h47 = _node._children[0]._height; var _h48 = _node._children[1]._height; _node._height = (_h47 > _h48 ? _h47 : _h48) + 1; } else { _l._children[0] = _node; _node._parent = _l; _node._childIndex = 0; _node._children[0] = _ll; _ll._parent = _node; _ll._childIndex = 0; var _c49 = _l._children[0]; var _c50 = _l._children[1]; _l._aabbMinX = _c49._aabbMinX < _c50._aabbMinX ? _c49._aabbMinX : _c50._aabbMinX; _l._aabbMinY = _c49._aabbMinY < _c50._aabbMinY ? _c49._aabbMinY : _c50._aabbMinY; _l._aabbMinZ = _c49._aabbMinZ < _c50._aabbMinZ ? _c49._aabbMinZ : _c50._aabbMinZ; _l._aabbMaxX = _c49._aabbMaxX > _c50._aabbMaxX ? _c49._aabbMaxX : _c50._aabbMaxX; _l._aabbMaxY = _c49._aabbMaxY > _c50._aabbMaxY ? _c49._aabbMaxY : _c50._aabbMaxY; _l._aabbMaxZ = _c49._aabbMaxZ > _c50._aabbMaxZ ? _c49._aabbMaxZ : _c50._aabbMaxZ; var _h49 = _l._children[0]._height; var _h50 = _l._children[1]._height; _l._height = (_h49 > _h50 ? _h49 : _h50) + 1; var _c51 = _node._children[0]; var _c52 = _node._children[1]; _node._aabbMinX = _c51._aabbMinX < _c52._aabbMinX ? _c51._aabbMinX : _c52._aabbMinX; _node._aabbMinY = _c51._aabbMinY < _c52._aabbMinY ? _c51._aabbMinY : _c52._aabbMinY; _node._aabbMinZ = _c51._aabbMinZ < _c52._aabbMinZ ? _c51._aabbMinZ : _c52._aabbMinZ; _node._aabbMaxX = _c51._aabbMaxX > _c52._aabbMaxX ? _c51._aabbMaxX : _c52._aabbMaxX; _node._aabbMaxY = _c51._aabbMaxY > _c52._aabbMaxY ? _c51._aabbMaxY : _c52._aabbMaxY; _node._aabbMaxZ = _c51._aabbMaxZ > _c52._aabbMaxZ ? _c51._aabbMaxZ : _c52._aabbMaxZ; var _h51 = _node._children[0]._height; var _h52 = _node._children[1]._height; _node._height = (_h51 > _h52 ? _h51 : _h52) + 1; } if (_p4 != null) { _p4._children[_nodeIndex] = _l; _l._parent = _p4; _l._childIndex = _nodeIndex; } else { _this1._root = _l; _l._parent = null; } _node = _l; } else if (_balance < -1) { var _rl = _r._children[0]; var _rr = _r._children[1]; if (_rl._height > _rr._height) { _r._children[1] = _node; _node._parent = _r; _node._childIndex = 1; _node._children[1] = _rr; _rr._parent = _node; _rr._childIndex = 1; var _c53 = _r._children[0]; var _c54 = _r._children[1]; _r._aabbMinX = _c53._aabbMinX < _c54._aabbMinX ? _c53._aabbMinX : _c54._aabbMinX; _r._aabbMinY = _c53._aabbMinY < _c54._aabbMinY ? _c53._aabbMinY : _c54._aabbMinY; _r._aabbMinZ = _c53._aabbMinZ < _c54._aabbMinZ ? _c53._aabbMinZ : _c54._aabbMinZ; _r._aabbMaxX = _c53._aabbMaxX > _c54._aabbMaxX ? _c53._aabbMaxX : _c54._aabbMaxX; _r._aabbMaxY = _c53._aabbMaxY > _c54._aabbMaxY ? _c53._aabbMaxY : _c54._aabbMaxY; _r._aabbMaxZ = _c53._aabbMaxZ > _c54._aabbMaxZ ? _c53._aabbMaxZ : _c54._aabbMaxZ; var _h53 = _r._children[0]._height; var _h54 = _r._children[1]._height; _r._height = (_h53 > _h54 ? _h53 : _h54) + 1; var _c55 = _node._children[0]; var _c56 = _node._children[1]; _node._aabbMinX = _c55._aabbMinX < _c56._aabbMinX ? _c55._aabbMinX : _c56._aabbMinX; _node._aabbMinY = _c55._aabbMinY < _c56._aabbMinY ? _c55._aabbMinY : _c56._aabbMinY; _node._aabbMinZ = _c55._aabbMinZ < _c56._aabbMinZ ? _c55._aabbMinZ : _c56._aabbMinZ; _node._aabbMaxX = _c55._aabbMaxX > _c56._aabbMaxX ? _c55._aabbMaxX : _c56._aabbMaxX; _node._aabbMaxY = _c55._aabbMaxY > _c56._aabbMaxY ? _c55._aabbMaxY : _c56._aabbMaxY; _node._aabbMaxZ = _c55._aabbMaxZ > _c56._aabbMaxZ ? _c55._aabbMaxZ : _c56._aabbMaxZ; var _h55 = _node._children[0]._height; var _h56 = _node._children[1]._height; _node._height = (_h55 > _h56 ? _h55 : _h56) + 1; } else { _r._children[0] = _node; _node._parent = _r; _node._childIndex = 0; _node._children[1] = _rl; _rl._parent = _node; _rl._childIndex = 1; var _c57 = _r._children[0]; var _c58 = _r._children[1]; _r._aabbMinX = _c57._aabbMinX < _c58._aabbMinX ? _c57._aabbMinX : _c58._aabbMinX; _r._aabbMinY = _c57._aabbMinY < _c58._aabbMinY ? _c57._aabbMinY : _c58._aabbMinY; _r._aabbMinZ = _c57._aabbMinZ < _c58._aabbMinZ ? _c57._aabbMinZ : _c58._aabbMinZ; _r._aabbMaxX = _c57._aabbMaxX > _c58._aabbMaxX ? _c57._aabbMaxX : _c58._aabbMaxX; _r._aabbMaxY = _c57._aabbMaxY > _c58._aabbMaxY ? _c57._aabbMaxY : _c58._aabbMaxY; _r._aabbMaxZ = _c57._aabbMaxZ > _c58._aabbMaxZ ? _c57._aabbMaxZ : _c58._aabbMaxZ; var _h57 = _r._children[0]._height; var _h58 = _r._children[1]._height; _r._height = (_h57 > _h58 ? _h57 : _h58) + 1; var _c59 = _node._children[0]; var _c60 = _node._children[1]; _node._aabbMinX = _c59._aabbMinX < _c60._aabbMinX ? _c59._aabbMinX : _c60._aabbMinX; _node._aabbMinY = _c59._aabbMinY < _c60._aabbMinY ? _c59._aabbMinY : _c60._aabbMinY; _node._aabbMinZ = _c59._aabbMinZ < _c60._aabbMinZ ? _c59._aabbMinZ : _c60._aabbMinZ; _node._aabbMaxX = _c59._aabbMaxX > _c60._aabbMaxX ? _c59._aabbMaxX : _c60._aabbMaxX; _node._aabbMaxY = _c59._aabbMaxY > _c60._aabbMaxY ? _c59._aabbMaxY : _c60._aabbMaxY; _node._aabbMaxZ = _c59._aabbMaxZ > _c60._aabbMaxZ ? _c59._aabbMaxZ : _c60._aabbMaxZ; var _h59 = _node._children[0]._height; var _h60 = _node._children[1]._height; _node._height = (_h59 > _h60 ? _h59 : _h60) + 1; } if (_p4 != null) { _p4._children[_nodeIndex] = _r; _r._parent = _p4; _r._childIndex = _nodeIndex; } else { _this1._root = _r; _r._parent = null; } _node = _r; } } } var _h43 = _node._children[0]._height; var _h44 = _node._children[1]._height; _node._height = (_h43 > _h44 ? _h43 : _h44) + 1; var _c43 = _node._children[0]; var _c44 = _node._children[1]; _node._aabbMinX = _c43._aabbMinX < _c44._aabbMinX ? _c43._aabbMinX : _c44._aabbMinX; _node._aabbMinY = _c43._aabbMinY < _c44._aabbMinY ? _c43._aabbMinY : _c44._aabbMinY; _node._aabbMinZ = _c43._aabbMinZ < _c44._aabbMinZ ? _c43._aabbMinZ : _c44._aabbMinZ; _node._aabbMaxX = _c43._aabbMaxX > _c44._aabbMaxX ? _c43._aabbMaxX : _c44._aabbMaxX; _node._aabbMaxY = _c43._aabbMaxY > _c44._aabbMaxY ? _c43._aabbMaxY : _c44._aabbMaxY; _node._aabbMaxZ = _c43._aabbMaxZ > _c44._aabbMaxZ ? _c43._aabbMaxZ : _c44._aabbMaxZ; _node = _node._parent; } } if (incrementalCollision) { this.collide(this._tree._root, _p2._leaf); } _p2._moved = false; } this.movedProxies[i] = null; } if (!incrementalCollision) { this.collide(this._tree._root, this._tree._root); } this.numMovedProxies = 0; } }, { key: "rayCast", value: function rayCast(begin, end, callback) { if (this._tree._root == null) { return; } var p1X; var p1Y; var p1Z; var p2X; var p2Y; var p2Z; p1X = begin.x; p1Y = begin.y; p1Z = begin.z; p2X = end.x; p2Y = end.y; p2Z = end.z; this.rayCastRecursive(this._tree._root, p1X, p1Y, p1Z, p2X, p2Y, p2Z, callback); } }, { key: "convexCast", value: function convexCast(convex, begin, translation, callback) { if (this._tree._root == null) { return; } this.convexCastRecursive(this._tree._root, convex, begin, translation, callback); } }, { key: "aabbTest", value: function aabbTest(aabb, callback) { if (this._tree._root == null) { return; } this.aabbTestRecursive(this._tree._root, aabb, callback); } }, { key: "getTreeBalance", value: function getTreeBalance() { return this._tree._getBalance(); } }]); return oimo_collision_broadphase_bvh_BvhBroadPhase; }(oimo.collision.broadphase.BroadPhase); oimo.collision.broadphase.bvh.BvhInsertionStrategy = /*#__PURE__*/_createClass(function oimo_collision_broadphase_bvh_BvhInsertionStrategy() { _classCallCheck(this, oimo_collision_broadphase_bvh_BvhInsertionStrategy); }); oimo.collision.broadphase.bvh.BvhNode = /*#__PURE__*/_createClass(function oimo_collision_broadphase_bvh_BvhNode() { _classCallCheck(this, oimo_collision_broadphase_bvh_BvhNode); this._next = null; this._prevLeaf = null; this._nextLeaf = null; this._children = new Array(2); this._childIndex = 0; this._parent = null; this._height = 0; this._proxy = null; this._aabbMinX = 0; this._aabbMinY = 0; this._aabbMinZ = 0; this._aabbMaxX = 0; this._aabbMaxY = 0; this._aabbMaxZ = 0; }); oimo.collision.broadphase.bvh.BvhProxy = /*#__PURE__*/function (_oimo$collision$broad3) { _inherits(oimo_collision_broadphase_bvh_BvhProxy, _oimo$collision$broad3); var _super6 = _createSuper(oimo_collision_broadphase_bvh_BvhProxy); function oimo_collision_broadphase_bvh_BvhProxy(userData, id) { var _this46; _classCallCheck(this, oimo_collision_broadphase_bvh_BvhProxy); _this46 = _super6.call(this, userData, id); _this46._leaf = null; _this46._moved = false; return _this46; } return _createClass(oimo_collision_broadphase_bvh_BvhProxy); }(oimo.collision.broadphase.Proxy); oimo.collision.broadphase.bvh.BvhStrategy = /*#__PURE__*/function () { function oimo_collision_broadphase_bvh_BvhStrategy() { _classCallCheck(this, oimo_collision_broadphase_bvh_BvhStrategy); this._insertionStrategy = 0; this._balancingEnabled = false; } _createClass(oimo_collision_broadphase_bvh_BvhStrategy, [{ key: "_decideInsertion", value: function _decideInsertion(currentNode, leaf) { switch (this._insertionStrategy) { case 0: var centerX; var centerY; var centerZ; centerX = leaf._aabbMinX + leaf._aabbMaxX; centerY = leaf._aabbMinY + leaf._aabbMaxY; centerZ = leaf._aabbMinZ + leaf._aabbMaxZ; var c1 = currentNode._children[0]; var c2 = currentNode._children[1]; var diff1X; var diff1Y; var diff1Z; var diff2X; var diff2Y; var diff2Z; diff1X = c1._aabbMinX + c1._aabbMaxX; diff1Y = c1._aabbMinY + c1._aabbMaxY; diff1Z = c1._aabbMinZ + c1._aabbMaxZ; diff2X = c2._aabbMinX + c2._aabbMaxX; diff2Y = c2._aabbMinY + c2._aabbMaxY; diff2Z = c2._aabbMinZ + c2._aabbMaxZ; diff1X -= centerX; diff1Y -= centerY; diff1Z -= centerZ; diff2X -= centerX; diff2Y -= centerY; diff2Z -= centerZ; if (diff1X * diff1X + diff1Y * diff1Y + diff1Z * diff1Z < diff2X * diff2X + diff2Y * diff2Y + diff2Z * diff2Z) { return 0; } else { return 1; } break; case 1: var c11 = currentNode._children[0]; var c21 = currentNode._children[1]; var ey = currentNode._aabbMaxY - currentNode._aabbMinY; var ez = currentNode._aabbMaxZ - currentNode._aabbMinZ; var combinedMinX; var combinedMinY; var combinedMinZ; var combinedMaxX; var combinedMaxY; var combinedMaxZ; combinedMinX = currentNode._aabbMinX < leaf._aabbMinX ? currentNode._aabbMinX : leaf._aabbMinX; combinedMinY = currentNode._aabbMinY < leaf._aabbMinY ? currentNode._aabbMinY : leaf._aabbMinY; combinedMinZ = currentNode._aabbMinZ < leaf._aabbMinZ ? currentNode._aabbMinZ : leaf._aabbMinZ; combinedMaxX = currentNode._aabbMaxX > leaf._aabbMaxX ? currentNode._aabbMaxX : leaf._aabbMaxX; combinedMaxY = currentNode._aabbMaxY > leaf._aabbMaxY ? currentNode._aabbMaxY : leaf._aabbMaxY; combinedMaxZ = currentNode._aabbMaxZ > leaf._aabbMaxZ ? currentNode._aabbMaxZ : leaf._aabbMaxZ; var ey1 = combinedMaxY - combinedMinY; var ez1 = combinedMaxZ - combinedMinZ; var newArea = ((combinedMaxX - combinedMinX) * (ey1 + ez1) + ey1 * ez1) * 2; var creatingCost = newArea * 2; var incrementalCost = (newArea - ((currentNode._aabbMaxX - currentNode._aabbMinX) * (ey + ez) + ey * ez) * 2) * 2; var descendingCost1; combinedMinX = c11._aabbMinX < leaf._aabbMinX ? c11._aabbMinX : leaf._aabbMinX; combinedMinY = c11._aabbMinY < leaf._aabbMinY ? c11._aabbMinY : leaf._aabbMinY; combinedMinZ = c11._aabbMinZ < leaf._aabbMinZ ? c11._aabbMinZ : leaf._aabbMinZ; combinedMaxX = c11._aabbMaxX > leaf._aabbMaxX ? c11._aabbMaxX : leaf._aabbMaxX; combinedMaxY = c11._aabbMaxY > leaf._aabbMaxY ? c11._aabbMaxY : leaf._aabbMaxY; combinedMaxZ = c11._aabbMaxZ > leaf._aabbMaxZ ? c11._aabbMaxZ : leaf._aabbMaxZ; if (c11._height == 0) { var _ey = combinedMaxY - combinedMinY; var _ez = combinedMaxZ - combinedMinZ; descendingCost1 = incrementalCost + ((combinedMaxX - combinedMinX) * (_ey + _ez) + _ey * _ez) * 2; } else { var _ey2 = combinedMaxY - combinedMinY; var _ez2 = combinedMaxZ - combinedMinZ; var _ey3 = c11._aabbMaxY - c11._aabbMinY; var _ez3 = c11._aabbMaxZ - c11._aabbMinZ; descendingCost1 = incrementalCost + (((combinedMaxX - combinedMinX) * (_ey2 + _ez2) + _ey2 * _ez2) * 2 - ((c11._aabbMaxX - c11._aabbMinX) * (_ey3 + _ez3) + _ey3 * _ez3) * 2); } var descendingCost2; combinedMinX = c21._aabbMinX < leaf._aabbMinX ? c21._aabbMinX : leaf._aabbMinX; combinedMinY = c21._aabbMinY < leaf._aabbMinY ? c21._aabbMinY : leaf._aabbMinY; combinedMinZ = c21._aabbMinZ < leaf._aabbMinZ ? c21._aabbMinZ : leaf._aabbMinZ; combinedMaxX = c21._aabbMaxX > leaf._aabbMaxX ? c21._aabbMaxX : leaf._aabbMaxX; combinedMaxY = c21._aabbMaxY > leaf._aabbMaxY ? c21._aabbMaxY : leaf._aabbMaxY; combinedMaxZ = c21._aabbMaxZ > leaf._aabbMaxZ ? c21._aabbMaxZ : leaf._aabbMaxZ; if (c21._height == 0) { var _ey4 = combinedMaxY - combinedMinY; var _ez4 = combinedMaxZ - combinedMinZ; descendingCost2 = incrementalCost + ((combinedMaxX - combinedMinX) * (_ey4 + _ez4) + _ey4 * _ez4) * 2; } else { var _ey5 = combinedMaxY - combinedMinY; var _ez5 = combinedMaxZ - combinedMinZ; var _ey6 = c21._aabbMaxY - c21._aabbMinY; var _ez6 = c21._aabbMaxZ - c21._aabbMinZ; descendingCost2 = incrementalCost + (((combinedMaxX - combinedMinX) * (_ey5 + _ez5) + _ey5 * _ez5) * 2 - ((c21._aabbMaxX - c21._aabbMinX) * (_ey6 + _ez6) + _ey6 * _ez6) * 2); } if (creatingCost < descendingCost1) { if (creatingCost < descendingCost2) { return -1; } else { return 1; } } else if (descendingCost1 < descendingCost2) { return 0; } else { return 1; } break; default: console.log("src/oimo/collision/broadphase/bvh/BvhStrategy.hx:37:", "invalid BVH insertion strategy: " + this._insertionStrategy); return -1; } } }, { key: "_splitLeaves", value: function _splitLeaves(leaves, from, until) { var invN = 1.0 / (until - from); var centerMeanX; var centerMeanY; var centerMeanZ; centerMeanX = 0; centerMeanY = 0; centerMeanZ = 0; var _g = from; while (_g < until) { var leaf = leaves[_g++]; leaf._tmpX = leaf._aabbMaxX + leaf._aabbMinX; leaf._tmpY = leaf._aabbMaxY + leaf._aabbMinY; leaf._tmpZ = leaf._aabbMaxZ + leaf._aabbMinZ; centerMeanX += leaf._tmpX; centerMeanY += leaf._tmpY; centerMeanZ += leaf._tmpZ; } centerMeanX *= invN; centerMeanY *= invN; centerMeanZ *= invN; var varianceX; var varianceY; var varianceZ; varianceX = 0; varianceY = 0; varianceZ = 0; var _g1 = from; while (_g1 < until) { var _leaf = leaves[_g1++]; var diffX = void 0; var diffY = void 0; var diffZ = void 0; diffX = _leaf._tmpX - centerMeanX; diffY = _leaf._tmpY - centerMeanY; diffZ = _leaf._tmpZ - centerMeanZ; diffX *= diffX; diffY *= diffY; diffZ *= diffZ; varianceX += diffX; varianceY += diffY; varianceZ += diffZ; } var varX = varianceX; var varY = varianceY; var varZ = varianceZ; var l = from; var r = until - 1; if (varX > varY) { if (varX > varZ) { var mean = centerMeanX; while (true) { while (!(leaves[l]._tmpX <= mean)) { ++l; } while (!(leaves[r]._tmpX >= mean)) { --r; } if (l >= r) { break; } var tmp = leaves[l]; leaves[l] = leaves[r]; leaves[r] = tmp; ++l; --r; } } else { var _mean = centerMeanZ; while (true) { while (!(leaves[l]._tmpZ <= _mean)) { ++l; } while (!(leaves[r]._tmpZ >= _mean)) { --r; } if (l >= r) { break; } var _tmp = leaves[l]; leaves[l] = leaves[r]; leaves[r] = _tmp; ++l; --r; } } } else if (varY > varZ) { var _mean2 = centerMeanY; while (true) { while (!(leaves[l]._tmpY <= _mean2)) { ++l; } while (!(leaves[r]._tmpY >= _mean2)) { --r; } if (l >= r) { break; } var _tmp2 = leaves[l]; leaves[l] = leaves[r]; leaves[r] = _tmp2; ++l; --r; } } else { var _mean3 = centerMeanZ; while (true) { while (!(leaves[l]._tmpZ <= _mean3)) { ++l; } while (!(leaves[r]._tmpZ >= _mean3)) { --r; } if (l >= r) { break; } var _tmp3 = leaves[l]; leaves[l] = leaves[r]; leaves[r] = _tmp3; ++l; --r; } } return l; } }]); return oimo_collision_broadphase_bvh_BvhStrategy; }(); oimo.collision.broadphase.bvh.BvhTree = /*#__PURE__*/function () { function oimo_collision_broadphase_bvh_BvhTree() { _classCallCheck(this, oimo_collision_broadphase_bvh_BvhTree); this._root = null; this._numLeaves = 0; this._strategy = new oimo.collision.broadphase.bvh.BvhStrategy(); this._nodePool = null; this.leafList = null; this.leafListLast = null; this.tmp = new Array(1024); } _createClass(oimo_collision_broadphase_bvh_BvhTree, [{ key: "_print", value: function _print(root, indent) { if (indent == null) { indent = ""; } if (root == null) { return; } if (root._height == 0) { console.log("src/oimo/collision/broadphase/bvh/BvhTree.hx:39:", indent + root._proxy._id); } else { this._print(root._children[0], indent + " "); var tmp; var sizeX; var sizeY; var sizeZ; sizeX = root._aabbMaxX - root._aabbMinX; sizeY = root._aabbMaxY - root._aabbMinY; sizeZ = root._aabbMaxZ - root._aabbMinZ; var y = sizeY; var z = sizeZ; if (sizeX * (y + z) + y * z > 0) { var _sizeX; var _sizeY; var _sizeZ; _sizeX = root._aabbMaxX - root._aabbMinX; _sizeY = root._aabbMaxY - root._aabbMinY; _sizeZ = root._aabbMaxZ - root._aabbMinZ; var _y = _sizeY; var _z = _sizeZ; tmp = ((_sizeX * (_y + _z) + _y * _z) * 1000 + 0.5 | 0) / 1000; } else { var _sizeX2; var _sizeY2; var _sizeZ2; _sizeX2 = root._aabbMaxX - root._aabbMinX; _sizeY2 = root._aabbMaxY - root._aabbMinY; _sizeZ2 = root._aabbMaxZ - root._aabbMinZ; var _y2 = _sizeY2; var _z2 = _sizeZ2; tmp = ((_sizeX2 * (_y2 + _z2) + _y2 * _z2) * 1000 - 0.5 | 0) / 1000; } console.log("src/oimo/collision/broadphase/bvh/BvhTree.hx:42:", indent + "#" + root._height + ", " + tmp); this._print(root._children[1], indent + " "); } } }, { key: "_getBalance", value: function _getBalance() { return this.getBalanceRecursive(this._root); } }, { key: "deleteRecursive", value: function deleteRecursive(root) { if (root._height == 0) { var prev = root._prevLeaf; var next = root._nextLeaf; if (prev != null) { prev._nextLeaf = next; } if (next != null) { next._prevLeaf = prev; } if (root == this.leafList) { this.leafList = this.leafList._nextLeaf; } if (root == this.leafListLast) { this.leafListLast = this.leafListLast._prevLeaf; } root._nextLeaf = null; root._prevLeaf = null; root._proxy._leaf = null; root._next = null; root._childIndex = 0; root._children[0] = null; root._children[1] = null; root._childIndex = 0; root._parent = null; root._height = 0; root._proxy = null; root._next = this._nodePool; this._nodePool = root; return; } this.deleteRecursive(root._children[0]); this.deleteRecursive(root._children[1]); root._next = null; root._childIndex = 0; root._children[0] = null; root._children[1] = null; root._childIndex = 0; root._parent = null; root._height = 0; root._proxy = null; root._next = this._nodePool; this._nodePool = root; } }, { key: "decomposeRecursive", value: function decomposeRecursive(root) { if (root._height == 0) { root._childIndex = 0; root._parent = null; return; } this.decomposeRecursive(root._children[0]); this.decomposeRecursive(root._children[1]); root._next = null; root._childIndex = 0; root._children[0] = null; root._children[1] = null; root._childIndex = 0; root._parent = null; root._height = 0; root._proxy = null; root._next = this._nodePool; this._nodePool = root; } }, { key: "buildTopDownRecursive", value: function buildTopDownRecursive(leaves, from, until) { if (until - from == 1) { var leaf = leaves[from]; var proxy = leaf._proxy; leaf._aabbMinX = proxy._aabbMinX; leaf._aabbMinY = proxy._aabbMinY; leaf._aabbMinZ = proxy._aabbMinZ; leaf._aabbMaxX = proxy._aabbMaxX; leaf._aabbMaxY = proxy._aabbMaxY; leaf._aabbMaxZ = proxy._aabbMaxZ; return leaf; } var splitAt = this._strategy._splitLeaves(leaves, from, until); var child1 = this.buildTopDownRecursive(leaves, from, splitAt); var child2 = this.buildTopDownRecursive(leaves, splitAt, until); var first = this._nodePool; if (first != null) { this._nodePool = first._next; first._next = null; } else { first = new oimo.collision.broadphase.bvh.BvhNode(); } var parent = first; parent._children[0] = child1; child1._parent = parent; child1._childIndex = 0; parent._children[1] = child2; child2._parent = parent; child2._childIndex = 1; var c1 = parent._children[0]; var c2 = parent._children[1]; parent._aabbMinX = c1._aabbMinX < c2._aabbMinX ? c1._aabbMinX : c2._aabbMinX; parent._aabbMinY = c1._aabbMinY < c2._aabbMinY ? c1._aabbMinY : c2._aabbMinY; parent._aabbMinZ = c1._aabbMinZ < c2._aabbMinZ ? c1._aabbMinZ : c2._aabbMinZ; parent._aabbMaxX = c1._aabbMaxX > c2._aabbMaxX ? c1._aabbMaxX : c2._aabbMaxX; parent._aabbMaxY = c1._aabbMaxY > c2._aabbMaxY ? c1._aabbMaxY : c2._aabbMaxY; parent._aabbMaxZ = c1._aabbMaxZ > c2._aabbMaxZ ? c1._aabbMaxZ : c2._aabbMaxZ; var h1 = parent._children[0]._height; var h2 = parent._children[1]._height; parent._height = (h1 > h2 ? h1 : h2) + 1; return parent; } }, { key: "getBalanceRecursive", value: function getBalanceRecursive(root) { if (root == null || root._height == 0) { return 0; } var balance = root._children[0]._height - root._children[1]._height; if (balance < 0) { balance = -balance; } return balance + this.getBalanceRecursive(root._children[0]) + this.getBalanceRecursive(root._children[1]); } }]); return oimo_collision_broadphase_bvh_BvhTree; }(); oimo.collision.geometry.Aabb = /*#__PURE__*/function () { function oimo_collision_geometry_Aabb() { _classCallCheck(this, oimo_collision_geometry_Aabb); this._minX = 0; this._minY = 0; this._minZ = 0; this._maxX = 0; this._maxY = 0; this._maxZ = 0; } _createClass(oimo_collision_geometry_Aabb, [{ key: "init", value: function init(min, max) { this._minX = min.x; this._minY = min.y; this._minZ = min.z; this._maxX = max.x; this._maxY = max.y; this._maxZ = max.z; return this; } }, { key: "getMin", value: function getMin() { var min = new oimo.common.Vec3(); min.x = this._minX; min.y = this._minY; min.z = this._minZ; return min; } }, { key: "getMinTo", value: function getMinTo(min) { min.x = this._minX; min.y = this._minY; min.z = this._minZ; } }, { key: "setMin", value: function setMin(min) { this._minX = min.x; this._minY = min.y; this._minZ = min.z; return this; } }, { key: "getMax", value: function getMax() { var max = new oimo.common.Vec3(); max.x = this._maxX; max.y = this._maxY; max.z = this._maxZ; return max; } }, { key: "getMaxTo", value: function getMaxTo(max) { max.x = this._maxX; max.y = this._maxY; max.z = this._maxZ; } }, { key: "setMax", value: function setMax(max) { this._maxX = max.x; this._maxY = max.y; this._maxZ = max.z; return this; } }, { key: "getCenter", value: function getCenter() { var v = new oimo.common.Vec3(); var cX; var cY; var cZ; cX = this._minX + this._maxX; cY = this._minY + this._maxY; cZ = this._minZ + this._maxZ; cX *= 0.5; cY *= 0.5; cZ *= 0.5; v.x = cX; v.y = cY; v.z = cZ; return v; } }, { key: "getCenterTo", value: function getCenterTo(center) { var cX; var cY; var cZ; cX = this._minX + this._maxX; cY = this._minY + this._maxY; cZ = this._minZ + this._maxZ; cX *= 0.5; cY *= 0.5; cZ *= 0.5; center.x = cX; center.y = cY; center.z = cZ; } }, { key: "getExtents", value: function getExtents() { var v = new oimo.common.Vec3(); var cX; var cY; var cZ; cX = this._maxX - this._minX; cY = this._maxY - this._minY; cZ = this._maxZ - this._minZ; cX *= 0.5; cY *= 0.5; cZ *= 0.5; v.x = cX; v.y = cY; v.z = cZ; return v; } }, { key: "getExtentsTo", value: function getExtentsTo(halfExtents) { var cX; var cY; var cZ; cX = this._maxX - this._minX; cY = this._maxY - this._minY; cZ = this._maxZ - this._minZ; cX *= 0.5; cY *= 0.5; cZ *= 0.5; halfExtents.x = cX; halfExtents.y = cY; halfExtents.z = cZ; } }, { key: "combine", value: function combine(other) { this._minX = this._minX < other._minX ? this._minX : other._minX; this._minY = this._minY < other._minY ? this._minY : other._minY; this._minZ = this._minZ < other._minZ ? this._minZ : other._minZ; this._maxX = this._maxX > other._maxX ? this._maxX : other._maxX; this._maxY = this._maxY > other._maxY ? this._maxY : other._maxY; this._maxZ = this._maxZ > other._maxZ ? this._maxZ : other._maxZ; return this; } }, { key: "combined", value: function combined(other) { var aabb = new oimo.collision.geometry.Aabb(); aabb._minX = this._minX < other._minX ? this._minX : other._minX; aabb._minY = this._minY < other._minY ? this._minY : other._minY; aabb._minZ = this._minZ < other._minZ ? this._minZ : other._minZ; aabb._maxX = this._maxX > other._maxX ? this._maxX : other._maxX; aabb._maxY = this._maxY > other._maxY ? this._maxY : other._maxY; aabb._maxZ = this._maxZ > other._maxZ ? this._maxZ : other._maxZ; return aabb; } }, { key: "overlap", value: function overlap(other) { if (this._minX < other._maxX && this._maxX > other._minX && this._minY < other._maxY && this._maxY > other._minY && this._minZ < other._maxZ) { return this._maxZ > other._minZ; } else { return false; } } }, { key: "getIntersection", value: function getIntersection(other) { var aabb = new oimo.collision.geometry.Aabb(); aabb._minX = this._minX > other._minX ? this._minX : other._minX; aabb._minY = this._minY > other._minY ? this._minY : other._minY; aabb._minZ = this._minZ > other._minZ ? this._minZ : other._minZ; aabb._maxX = this._maxX < other._maxX ? this._maxX : other._maxX; aabb._maxY = this._maxY < other._maxY ? this._maxY : other._maxY; aabb._maxZ = this._maxZ < other._maxZ ? this._maxZ : other._maxZ; return aabb; } }, { key: "getIntersectionTo", value: function getIntersectionTo(other, intersection) { intersection._minX = this._minX > other._minX ? this._minX : other._minX; intersection._minY = this._minY > other._minY ? this._minY : other._minY; intersection._minZ = this._minZ > other._minZ ? this._minZ : other._minZ; intersection._maxX = this._maxX < other._maxX ? this._maxX : other._maxX; intersection._maxY = this._maxY < other._maxY ? this._maxY : other._maxY; intersection._maxZ = this._maxZ < other._maxZ ? this._maxZ : other._maxZ; } }, { key: "copyFrom", value: function copyFrom(aabb) { this._minX = aabb._minX; this._minY = aabb._minY; this._minZ = aabb._minZ; this._maxX = aabb._maxX; this._maxY = aabb._maxY; this._maxZ = aabb._maxZ; return this; } }, { key: "clone", value: function clone() { var aabb = new oimo.collision.geometry.Aabb(); aabb._minX = this._minX; aabb._minY = this._minY; aabb._minZ = this._minZ; aabb._maxX = this._maxX; aabb._maxY = this._maxY; aabb._maxZ = this._maxZ; return aabb; } }]); return oimo_collision_geometry_Aabb; }(); oimo.collision.geometry.BoxGeometry = /*#__PURE__*/function (_oimo$collision$geome4) { _inherits(oimo_collision_geometry_BoxGeometry, _oimo$collision$geome4); var _super7 = _createSuper(oimo_collision_geometry_BoxGeometry); function oimo_collision_geometry_BoxGeometry(halfExtents) { var _this47; _classCallCheck(this, oimo_collision_geometry_BoxGeometry); _this47 = _super7.call(this, 1); _this47._halfExtentsX = halfExtents.x; _this47._halfExtentsY = halfExtents.y; _this47._halfExtentsZ = halfExtents.z; _this47._halfAxisXX = halfExtents.x; _this47._halfAxisXY = 0; _this47._halfAxisXZ = 0; _this47._halfAxisYX = 0; _this47._halfAxisYY = halfExtents.y; _this47._halfAxisYZ = 0; _this47._halfAxisZX = 0; _this47._halfAxisZY = 0; _this47._halfAxisZZ = halfExtents.z; _this47._updateMass(); var minHalfExtents = halfExtents.x < halfExtents.y ? halfExtents.z < halfExtents.x ? halfExtents.z : halfExtents.x : halfExtents.z < halfExtents.y ? halfExtents.z : halfExtents.y; if (_this47._gjkMargin > minHalfExtents * 0.2) { _this47._gjkMargin = minHalfExtents * 0.2; } return _this47; } _createClass(oimo_collision_geometry_BoxGeometry, [{ key: "getHalfExtents", value: function getHalfExtents() { var v = new oimo.common.Vec3(); v.x = this._halfExtentsX; v.y = this._halfExtentsY; v.z = this._halfExtentsZ; return v; } }, { key: "getHalfExtentsTo", value: function getHalfExtentsTo(halfExtents) { halfExtents.x = this._halfExtentsX; halfExtents.y = this._halfExtentsY; halfExtents.z = this._halfExtentsZ; } }, { key: "_updateMass", value: function _updateMass() { this._volume = 8 * (this._halfExtentsX * this._halfExtentsY * this._halfExtentsZ); var sqX; var sqY; var sqZ; sqX = this._halfExtentsX * this._halfExtentsX; sqY = this._halfExtentsY * this._halfExtentsY; sqZ = this._halfExtentsZ * this._halfExtentsZ; this._inertiaCoeff00 = 0.33333333333333331 * (sqY + sqZ); this._inertiaCoeff01 = 0; this._inertiaCoeff02 = 0; this._inertiaCoeff10 = 0; this._inertiaCoeff11 = 0.33333333333333331 * (sqZ + sqX); this._inertiaCoeff12 = 0; this._inertiaCoeff20 = 0; this._inertiaCoeff21 = 0; this._inertiaCoeff22 = 0.33333333333333331 * (sqX + sqY); } }, { key: "_computeAabb", value: function _computeAabb(aabb, tf) { var tfxX; var tfxY; var tfxZ; var tfyX; var tfyY; var tfyZ; var tfzX; var tfzY; var tfzZ; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = tf._rotation00 * this._halfAxisXX + tf._rotation01 * this._halfAxisXY + tf._rotation02 * this._halfAxisXZ; __tmp__Y = tf._rotation10 * this._halfAxisXX + tf._rotation11 * this._halfAxisXY + tf._rotation12 * this._halfAxisXZ; __tmp__Z = tf._rotation20 * this._halfAxisXX + tf._rotation21 * this._halfAxisXY + tf._rotation22 * this._halfAxisXZ; tfxX = __tmp__X; tfxY = __tmp__Y; tfxZ = __tmp__Z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = tf._rotation00 * this._halfAxisYX + tf._rotation01 * this._halfAxisYY + tf._rotation02 * this._halfAxisYZ; __tmp__Y1 = tf._rotation10 * this._halfAxisYX + tf._rotation11 * this._halfAxisYY + tf._rotation12 * this._halfAxisYZ; __tmp__Z1 = tf._rotation20 * this._halfAxisYX + tf._rotation21 * this._halfAxisYY + tf._rotation22 * this._halfAxisYZ; tfyX = __tmp__X1; tfyY = __tmp__Y1; tfyZ = __tmp__Z1; var __tmp__X2; var __tmp__Y2; var __tmp__Z2; __tmp__X2 = tf._rotation00 * this._halfAxisZX + tf._rotation01 * this._halfAxisZY + tf._rotation02 * this._halfAxisZZ; __tmp__Y2 = tf._rotation10 * this._halfAxisZX + tf._rotation11 * this._halfAxisZY + tf._rotation12 * this._halfAxisZZ; __tmp__Z2 = tf._rotation20 * this._halfAxisZX + tf._rotation21 * this._halfAxisZY + tf._rotation22 * this._halfAxisZZ; tfzX = __tmp__X2; tfzY = __tmp__Y2; tfzZ = __tmp__Z2; if (tfxX < 0) { tfxX = -tfxX; } if (tfxY < 0) { tfxY = -tfxY; } if (tfxZ < 0) { tfxZ = -tfxZ; } if (tfyX < 0) { tfyX = -tfyX; } if (tfyY < 0) { tfyY = -tfyY; } if (tfyZ < 0) { tfyZ = -tfyZ; } if (tfzX < 0) { tfzX = -tfzX; } if (tfzY < 0) { tfzY = -tfzY; } if (tfzZ < 0) { tfzZ = -tfzZ; } var tfsX; var tfsY; var tfsZ; tfsX = tfxX + tfyX; tfsY = tfxY + tfyY; tfsZ = tfxZ + tfyZ; tfsX += tfzX; tfsY += tfzY; tfsZ += tfzZ; aabb._minX = tf._positionX - tfsX; aabb._minY = tf._positionY - tfsY; aabb._minZ = tf._positionZ - tfsZ; aabb._maxX = tf._positionX + tfsX; aabb._maxY = tf._positionY + tfsY; aabb._maxZ = tf._positionZ + tfsZ; } }, { key: "computeLocalSupportingVertex", value: function computeLocalSupportingVertex(dir, out) { var gjkMarginsX; var gjkMarginsY; var gjkMarginsZ; var coreExtentsX; var coreExtentsY; var coreExtentsZ; gjkMarginsX = this._gjkMargin; gjkMarginsY = this._gjkMargin; gjkMarginsZ = this._gjkMargin; if (!(gjkMarginsX < this._halfExtentsX)) { gjkMarginsX = this._halfExtentsX; } if (!(gjkMarginsY < this._halfExtentsY)) { gjkMarginsY = this._halfExtentsY; } if (!(gjkMarginsZ < this._halfExtentsZ)) { gjkMarginsZ = this._halfExtentsZ; } coreExtentsX = this._halfExtentsX - gjkMarginsX; coreExtentsY = this._halfExtentsY - gjkMarginsY; coreExtentsZ = this._halfExtentsZ - gjkMarginsZ; out.x = dir.x > 0 ? coreExtentsX : -coreExtentsX; out.y = dir.y > 0 ? coreExtentsY : -coreExtentsY; out.z = dir.z > 0 ? coreExtentsZ : -coreExtentsZ; } }, { key: "_rayCastLocal", value: function _rayCastLocal(beginX, beginY, beginZ, endX, endY, endZ, hit) { var halfW = this._halfExtentsX; var halfH = this._halfExtentsY; var halfD = this._halfExtentsZ; var dx = endX - beginX; var dy = endY - beginY; var dz = endZ - beginZ; var tminx = 0; var tminy = 0; var tminz = 0; var tmaxx = 1; var tmaxy = 1; var tmaxz = 1; if (dx > -1e-6 && dx < 1e-6) { if (beginX <= -halfW || beginX >= halfW) { return false; } } else { var invDx = 1 / dx; var t1 = (-halfW - beginX) * invDx; var t2 = (halfW - beginX) * invDx; if (t1 > t2) { var tmp = t1; t1 = t2; t2 = tmp; } if (t1 > 0) { tminx = t1; } if (t2 < 1) { tmaxx = t2; } } if (dy > -1e-6 && dy < 1e-6) { if (beginY <= -halfH || beginY >= halfH) { return false; } } else { var invDy = 1 / dy; var _t = (-halfH - beginY) * invDy; var _t2 = (halfH - beginY) * invDy; if (_t > _t2) { var _tmp4 = _t; _t = _t2; _t2 = _tmp4; } if (_t > 0) { tminy = _t; } if (_t2 < 1) { tmaxy = _t2; } } if (dz > -1e-6 && dz < 1e-6) { if (beginZ <= -halfD || beginZ >= halfD) { return false; } } else { var invDz = 1 / dz; var _t3 = (-halfD - beginZ) * invDz; var _t4 = (halfD - beginZ) * invDz; if (_t3 > _t4) { var _tmp5 = _t3; _t3 = _t4; _t4 = _tmp5; } if (_t3 > 0) { tminz = _t3; } if (_t4 < 1) { tmaxz = _t4; } } if (tminx >= 1 || tminy >= 1 || tminz >= 1 || tmaxx <= 0 || tmaxy <= 0 || tmaxz <= 0) { return false; } var min = tminx; var max = tmaxx; var hitDirection = 0; if (tminy > min) { min = tminy; hitDirection = 1; } if (tminz > min) { min = tminz; hitDirection = 2; } if (tmaxy < max) { max = tmaxy; } if (tmaxz < max) { max = tmaxz; } if (min > max) { return false; } if (min == 0) { return false; } switch (hitDirection) { case 0: hit.normal.init(dx > 0 ? -1 : 1, 0, 0); break; case 1: hit.normal.init(0, dy > 0 ? -1 : 1, 0); break; case 2: hit.normal.init(0, 0, dz > 0 ? -1 : 1); break; } hit.position.init(beginX + min * dx, beginY + min * dy, beginZ + min * dz); hit.fraction = min; return true; } }]); return oimo_collision_geometry_BoxGeometry; }(oimo.collision.geometry.ConvexGeometry); oimo.collision.geometry.CapsuleGeometry = /*#__PURE__*/function (_oimo$collision$geome5) { _inherits(oimo_collision_geometry_CapsuleGeometry, _oimo$collision$geome5); var _super8 = _createSuper(oimo_collision_geometry_CapsuleGeometry); function oimo_collision_geometry_CapsuleGeometry(radius, halfHeight) { var _this48; _classCallCheck(this, oimo_collision_geometry_CapsuleGeometry); _this48 = _super8.call(this, 4); _this48._radius = radius; _this48._halfHeight = halfHeight; _this48._gjkMargin = _this48._radius; _this48._updateMass(); return _this48; } _createClass(oimo_collision_geometry_CapsuleGeometry, [{ key: "getRadius", value: function getRadius() { return this._radius; } }, { key: "getHalfHeight", value: function getHalfHeight() { return this._halfHeight; } }, { key: "_updateMass", value: function _updateMass() { var r2 = this._radius * this._radius; var hh2 = this._halfHeight * this._halfHeight; var cylinderVolume = 6.28318530717958 * r2 * this._halfHeight; var sphereVolume = 3.14159265358979 * r2 * this._radius * 4 / 3; this._volume = cylinderVolume + sphereVolume; var invVolume = this._volume == 0 ? 0 : 1 / this._volume; var inertiaXZ = invVolume * (cylinderVolume * (r2 * 0.25 + hh2 / 3) + sphereVolume * (r2 * 0.4 + this._halfHeight * this._radius * 0.75 + hh2)); this._inertiaCoeff00 = inertiaXZ; this._inertiaCoeff01 = 0; this._inertiaCoeff02 = 0; this._inertiaCoeff10 = 0; this._inertiaCoeff11 = invVolume * (cylinderVolume * r2 * 0.5 + sphereVolume * r2 * 0.4); this._inertiaCoeff12 = 0; this._inertiaCoeff20 = 0; this._inertiaCoeff21 = 0; this._inertiaCoeff22 = inertiaXZ; } }, { key: "_computeAabb", value: function _computeAabb(aabb, tf) { var radVecX; var radVecY; var radVecZ; radVecX = this._radius; radVecY = this._radius; radVecZ = this._radius; var axisX; var axisY; var axisZ; axisX = tf._rotation01; axisY = tf._rotation11; axisZ = tf._rotation21; if (axisX < 0) { axisX = -axisX; } if (axisY < 0) { axisY = -axisY; } if (axisZ < 0) { axisZ = -axisZ; } axisX *= this._halfHeight; axisY *= this._halfHeight; axisZ *= this._halfHeight; radVecX += axisX; radVecY += axisY; radVecZ += axisZ; aabb._minX = tf._positionX - radVecX; aabb._minY = tf._positionY - radVecY; aabb._minZ = tf._positionZ - radVecZ; aabb._maxX = tf._positionX + radVecX; aabb._maxY = tf._positionY + radVecY; aabb._maxZ = tf._positionZ + radVecZ; } }, { key: "computeLocalSupportingVertex", value: function computeLocalSupportingVertex(dir, out) { if (dir.y > 0) { out.init(0, this._halfHeight, 0); } else { out.init(0, -this._halfHeight, 0); } } }, { key: "_rayCastLocal", value: function _rayCastLocal(beginX, beginY, beginZ, endX, endY, endZ, hit) { var halfH = this._halfHeight; var dx = endX - beginX; var dz = endZ - beginZ; var tminxz = 0; var tmaxxz; var a = dx * dx + dz * dz; var b = beginX * dx + beginZ * dz; var c = beginX * beginX + beginZ * beginZ - this._radius * this._radius; var D = b * b - a * c; if (D < 0) { return false; } if (a > 0) { var sqrtD = Math.sqrt(D); tminxz = (-b - sqrtD) / a; tmaxxz = (-b + sqrtD) / a; if (tminxz >= 1 || tmaxxz <= 0) { return false; } } else { if (c >= 0) { return false; } tminxz = 0; } var crossY = beginY + (endY - beginY) * tminxz; var min; if (crossY > -halfH && crossY < halfH) { if (tminxz > 0) { min = tminxz; var _this = hit.normal.init(beginX + dx * min, 0, beginZ + dz * min); var invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z); if (invLen > 0) { invLen = 1 / invLen; } _this.x *= invLen; _this.y *= invLen; _this.z *= invLen; hit.position.init(beginX + min * dx, crossY, beginZ + min * dz); hit.fraction = min; return true; } return false; } var spherePosX; var spherePosY; var spherePosZ; var sphereToBeginX; var sphereToBeginY; var sphereToBeginZ; spherePosX = 0; spherePosY = crossY < 0 ? -halfH : halfH; spherePosZ = 0; sphereToBeginX = beginX - spherePosX; sphereToBeginY = beginY - spherePosY; sphereToBeginZ = beginZ - spherePosZ; var dX; var dY; var dZ; dX = endX - beginX; dY = endY - beginY; dZ = endZ - beginZ; a = dX * dX + dY * dY + dZ * dZ; b = sphereToBeginX * dX + sphereToBeginY * dY + sphereToBeginZ * dZ; c = sphereToBeginX * sphereToBeginX + sphereToBeginY * sphereToBeginY + sphereToBeginZ * sphereToBeginZ - this._radius * this._radius; D = b * b - a * c; if (D < 0) { return false; } var t = (-b - Math.sqrt(D)) / a; if (t < 0 || t > 1) { return false; } var hitPosX; var hitPosY; var hitPosZ; var hitNormalX; var hitNormalY; var hitNormalZ; hitPosX = sphereToBeginX + dX * t; hitPosY = sphereToBeginY + dY * t; hitPosZ = sphereToBeginZ + dZ * t; var l = hitPosX * hitPosX + hitPosY * hitPosY + hitPosZ * hitPosZ; if (l > 0) { l = 1 / Math.sqrt(l); } hitNormalX = hitPosX * l; hitNormalY = hitPosY * l; hitNormalZ = hitPosZ * l; hitPosX += spherePosX; hitPosY += spherePosY; hitPosZ += spherePosZ; var v = hit.position; v.x = hitPosX; v.y = hitPosY; v.z = hitPosZ; var v1 = hit.normal; v1.x = hitNormalX; v1.y = hitNormalY; v1.z = hitNormalZ; hit.fraction = t; return true; } }]); return oimo_collision_geometry_CapsuleGeometry; }(oimo.collision.geometry.ConvexGeometry); oimo.collision.geometry.ConeGeometry = /*#__PURE__*/function (_oimo$collision$geome6) { _inherits(oimo_collision_geometry_ConeGeometry, _oimo$collision$geome6); var _super9 = _createSuper(oimo_collision_geometry_ConeGeometry); function oimo_collision_geometry_ConeGeometry(radius, halfHeight) { var _this49; _classCallCheck(this, oimo_collision_geometry_ConeGeometry); _this49 = _super9.call(this, 3); _this49._radius = radius; _this49._halfHeight = halfHeight; _this49.sinTheta = radius / Math.sqrt(radius * radius + 4 * halfHeight * halfHeight); _this49.cosTheta = 2 * halfHeight / Math.sqrt(radius * radius + 4 * halfHeight * halfHeight); _this49._updateMass(); return _this49; } _createClass(oimo_collision_geometry_ConeGeometry, [{ key: "getRadius", value: function getRadius() { return this._radius; } }, { key: "getHalfHeight", value: function getHalfHeight() { return this._halfHeight; } }, { key: "_updateMass", value: function _updateMass() { var r2 = this._radius * this._radius; var h2 = this._halfHeight * this._halfHeight * 4; this._volume = 3.14159265358979 * r2 * this._halfHeight * 2 / 3; this._inertiaCoeff00 = 0.05 * (3 * r2 + 2 * h2); this._inertiaCoeff01 = 0; this._inertiaCoeff02 = 0; this._inertiaCoeff10 = 0; this._inertiaCoeff11 = 0.3 * r2; this._inertiaCoeff12 = 0; this._inertiaCoeff20 = 0; this._inertiaCoeff21 = 0; this._inertiaCoeff22 = 0.05 * (3 * r2 + 2 * h2); } }, { key: "_computeAabb", value: function _computeAabb(aabb, tf) { var axisX; var axisY; var axisZ; var axis2X; var axis2Y; var axis2Z; var ehX; var ehY; var ehZ; var erX; var erY; var erZ; axisX = tf._rotation01; axisY = tf._rotation11; axisZ = tf._rotation21; axis2X = axisX * axisX; axis2Y = axisY * axisY; axis2Z = axisZ * axisZ; erX = Math.sqrt(1 - axis2X); erY = Math.sqrt(1 - axis2Y); erZ = Math.sqrt(1 - axis2Z); erX *= this._radius; erY *= this._radius; erZ *= this._radius; ehX = axisX * this._halfHeight; ehY = axisY * this._halfHeight; ehZ = axisZ * this._halfHeight; var rminX; var rminY; var rminZ; var rmaxX; var rmaxY; var rmaxZ; rminX = -ehX; rminY = -ehY; rminZ = -ehZ; rminX -= erX; rminY -= erY; rminZ -= erZ; rmaxX = -ehX; rmaxY = -ehY; rmaxZ = -ehZ; rmaxX += erX; rmaxY += erY; rmaxZ += erZ; var maxX; var maxY; var maxZ; var minX; var minY; var minZ; maxX = rminX > rmaxX ? rminX : rmaxX; maxY = rminY > rmaxY ? rminY : rmaxY; maxZ = rminZ > rmaxZ ? rminZ : rmaxZ; if (!(maxX > ehX)) { maxX = ehX; } if (!(maxY > ehY)) { maxY = ehY; } if (!(maxZ > ehZ)) { maxZ = ehZ; } minX = rminX < rmaxX ? rminX : rmaxX; minY = rminY < rmaxY ? rminY : rmaxY; minZ = rminZ < rmaxZ ? rminZ : rmaxZ; if (!(minX < ehX)) { minX = ehX; } if (!(minY < ehY)) { minY = ehY; } if (!(minZ < ehZ)) { minZ = ehZ; } aabb._minX = tf._positionX + minX; aabb._minY = tf._positionY + minY; aabb._minZ = tf._positionZ + minZ; aabb._maxX = tf._positionX + maxX; aabb._maxY = tf._positionY + maxY; aabb._maxZ = tf._positionZ + maxZ; } }, { key: "computeLocalSupportingVertex", value: function computeLocalSupportingVertex(dir, out) { var dx = dir.x; var dy = dir.y; var dz = dir.z; if (dy > 0 && dy * dy > this.sinTheta * this.sinTheta * (dx * dx + dy * dy + dz * dz)) { out.init(0, this._halfHeight - this._gjkMargin / this.sinTheta, 0); if (out.y < 0) { out.y = 0; } return; } var rx = dir.x; var rz = dir.z; var len = rx * rx + rz * rz; var height = 2 * this._halfHeight; var coreRadius = (height - this._gjkMargin) / height * this._radius - this._gjkMargin / this.cosTheta; if (coreRadius < 0) { coreRadius = 0; } var invLen = len > 0 ? coreRadius / Math.sqrt(len) : 0; var coreHalfHeight = this._halfHeight - this._gjkMargin; if (coreHalfHeight < 0) { coreHalfHeight = 0; } out.x = rx * invLen; out.y = -coreHalfHeight; out.z = rz * invLen; } }, { key: "_rayCastLocal", value: function _rayCastLocal(beginX, beginY, beginZ, endX, endY, endZ, hit) { var p1y; var halfH = this._halfHeight; var dx = endX - beginX; var dy = endY - beginY; var dz = endZ - beginZ; var tminy = 0; var tmaxy = 1; if (dy > -1e-6 && dy < 1e-6) { if (beginY <= -halfH || beginY >= halfH) { return false; } } else { var invDy = 1 / dy; var t1 = (-halfH - beginY) * invDy; var t2 = (halfH - beginY) * invDy; if (t1 > t2) { var tmp = t1; t1 = t2; t2 = tmp; } if (t1 > 0) { tminy = t1; } if (t2 < 1) { tmaxy = t2; } } if (tminy >= 1 || tmaxy <= 0) { return false; } var tminxz = 0; var tmaxxz = 0; p1y = beginY - halfH; var cos2 = this.cosTheta * this.cosTheta; var a = cos2 * (dx * dx + dy * dy + dz * dz) - dy * dy; var b = cos2 * (beginX * dx + p1y * dy + beginZ * dz) - p1y * dy; var c = cos2 * (beginX * beginX + p1y * p1y + beginZ * beginZ) - p1y * p1y; var D = b * b - a * c; if (a != 0) { if (D < 0) { return false; } var sqrtD = Math.sqrt(D); if (a < 0) { if (dy > 0) { tminxz = 0; tmaxxz = (-b + sqrtD) / a; if (tmaxxz <= 0) { return false; } } else { tminxz = (-b - sqrtD) / a; tmaxxz = 1; if (tminxz >= 1) { return false; } } } else { tminxz = (-b - sqrtD) / a; tmaxxz = (-b + sqrtD) / a; if (tminxz >= 1 || tmaxxz <= 0) { return false; } } } else { var t = -c / (2 * b); if (b > 0) { tminxz = 0; tmaxxz = t; if (t <= 0) { return false; } } else { tminxz = t; tmaxxz = 1; if (t >= 1) { return false; } } } p1y += halfH; var min; if (tmaxxz <= tminy || tmaxy <= tminxz) { return false; } if (tminxz < tminy) { min = tminy; if (min == 0) { return false; } hit.normal.init(0, dy > 0 ? -1 : 1, 0); } else { min = tminxz; if (min == 0) { return false; } var _this = hit.normal.init(beginX + dx * min, 0, beginZ + dz * min); var invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z); if (invLen > 0) { invLen = 1 / invLen; } _this.x *= invLen; _this.y *= invLen; _this.z *= invLen; var s = this.cosTheta; _this.x *= s; _this.y *= s; _this.z *= s; hit.normal.y += this.sinTheta; } hit.position.init(beginX + min * dx, p1y + min * dy, beginZ + min * dz); hit.fraction = min; return true; } }]); return oimo_collision_geometry_ConeGeometry; }(oimo.collision.geometry.ConvexGeometry); oimo.collision.geometry.ConvexHullGeometry = /*#__PURE__*/function (_oimo$collision$geome7) { _inherits(oimo_collision_geometry_ConvexHullGeometry, _oimo$collision$geome7); var _super10 = _createSuper(oimo_collision_geometry_ConvexHullGeometry); function oimo_collision_geometry_ConvexHullGeometry(vertices) { var _this50; _classCallCheck(this, oimo_collision_geometry_ConvexHullGeometry); _this50 = _super10.call(this, 5); _this50._numVertices = vertices.length; _this50._vertices = new Array(_this50._numVertices); _this50._tmpVertices = new Array(_this50._numVertices); var _g = 0; var _g1 = _this50._numVertices; while (_g < _g1) { var i = _g++; _this50._vertices[i] = vertices[i]; _this50._tmpVertices[i] = new oimo.common.Vec3(); } _this50._useGjkRayCast = true; _this50._updateMass(); return _this50; } _createClass(oimo_collision_geometry_ConvexHullGeometry, [{ key: "getVertices", value: function getVertices() { return this._vertices; } }, { key: "_updateMass", value: function _updateMass() { this._volume = 1; this._inertiaCoeff00 = 1; this._inertiaCoeff01 = 0; this._inertiaCoeff02 = 0; this._inertiaCoeff10 = 0; this._inertiaCoeff11 = 1; this._inertiaCoeff12 = 0; this._inertiaCoeff20 = 0; this._inertiaCoeff21 = 0; this._inertiaCoeff22 = 1; var minx = this._vertices[0].x; var miny = this._vertices[0].y; var minz = this._vertices[0].z; var maxx = this._vertices[0].x; var maxy = this._vertices[0].y; var maxz = this._vertices[0].z; var _g = 1; var _g1 = this._numVertices; while (_g < _g1) { var i = _g++; var vx = this._vertices[i].x; var vy = this._vertices[i].y; var vz = this._vertices[i].z; if (vx < minx) { minx = vx; } else if (vx > maxx) { maxx = vx; } if (vy < miny) { miny = vy; } else if (vy > maxy) { maxy = vy; } if (vz < minz) { minz = vz; } else if (vz > maxz) { maxz = vz; } } var sizex = maxx - minx; var sizey = maxy - miny; var sizez = maxz - minz; this._volume = sizex * sizey * sizez; var diffCog = ((minx + maxx) * (minx + maxx) + (miny + maxy) * (miny + maxy) + (minz + maxz) * (minz + maxz)) * 0.25; sizex = sizex * sizex * 0.25; sizey = sizey * sizey * 0.25; sizez = sizez * sizez * 0.25; this._inertiaCoeff00 = 0.33333333333333331 * (sizey + sizez) + diffCog; this._inertiaCoeff01 = 0; this._inertiaCoeff02 = 0; this._inertiaCoeff10 = 0; this._inertiaCoeff11 = 0.33333333333333331 * (sizez + sizex) + diffCog; this._inertiaCoeff12 = 0; this._inertiaCoeff20 = 0; this._inertiaCoeff21 = 0; this._inertiaCoeff22 = 0.33333333333333331 * (sizex + sizey) + diffCog; } }, { key: "_computeAabb", value: function _computeAabb(aabb, tf) { var minX; var minY; var minZ; var maxX; var maxY; var maxZ; var marginX; var marginY; var marginZ; marginX = this._gjkMargin; marginY = this._gjkMargin; marginZ = this._gjkMargin; var localVX; var localVY; var localVZ; var v = this._vertices[0]; localVX = v.x; localVY = v.y; localVZ = v.z; var worldVX; var worldVY; var worldVZ; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = tf._rotation00 * localVX + tf._rotation01 * localVY + tf._rotation02 * localVZ; __tmp__Y = tf._rotation10 * localVX + tf._rotation11 * localVY + tf._rotation12 * localVZ; __tmp__Z = tf._rotation20 * localVX + tf._rotation21 * localVY + tf._rotation22 * localVZ; worldVX = __tmp__X; worldVY = __tmp__Y; worldVZ = __tmp__Z; worldVX += tf._positionX; worldVY += tf._positionY; worldVZ += tf._positionZ; minX = worldVX; minY = worldVY; minZ = worldVZ; maxX = worldVX; maxY = worldVY; maxZ = worldVZ; var _g = 1; var _g1 = this._numVertices; while (_g < _g1) { var _v2 = this._vertices[_g++]; localVX = _v2.x; localVY = _v2.y; localVZ = _v2.z; var _tmp__X3 = void 0; var _tmp__Y3 = void 0; var _tmp__Z3 = void 0; _tmp__X3 = tf._rotation00 * localVX + tf._rotation01 * localVY + tf._rotation02 * localVZ; _tmp__Y3 = tf._rotation10 * localVX + tf._rotation11 * localVY + tf._rotation12 * localVZ; _tmp__Z3 = tf._rotation20 * localVX + tf._rotation21 * localVY + tf._rotation22 * localVZ; worldVX = _tmp__X3; worldVY = _tmp__Y3; worldVZ = _tmp__Z3; worldVX += tf._positionX; worldVY += tf._positionY; worldVZ += tf._positionZ; if (!(minX < worldVX)) { minX = worldVX; } if (!(minY < worldVY)) { minY = worldVY; } if (!(minZ < worldVZ)) { minZ = worldVZ; } if (!(maxX > worldVX)) { maxX = worldVX; } if (!(maxY > worldVY)) { maxY = worldVY; } if (!(maxZ > worldVZ)) { maxZ = worldVZ; } } aabb._minX = minX - marginX; aabb._minY = minY - marginY; aabb._minZ = minZ - marginZ; aabb._maxX = maxX + marginX; aabb._maxY = maxY + marginY; aabb._maxZ = maxZ + marginZ; } }, { key: "computeLocalSupportingVertex", value: function computeLocalSupportingVertex(dir, out) { var _this = this._vertices[0]; var maxDot = _this.x * dir.x + _this.y * dir.y + _this.z * dir.z; var maxIndex = 0; var _g = 1; var _g1 = this._numVertices; while (_g < _g1) { var i = _g++; var _this51 = this._vertices[i]; var dot = _this51.x * dir.x + _this51.y * dir.y + _this51.z * dir.z; if (dot > maxDot) { maxDot = dot; maxIndex = i; } } var v = this._vertices[maxIndex]; out.x = v.x; out.y = v.y; out.z = v.z; } }]); return oimo_collision_geometry_ConvexHullGeometry; }(oimo.collision.geometry.ConvexGeometry); oimo.collision.geometry.CylinderGeometry = /*#__PURE__*/function (_oimo$collision$geome8) { _inherits(oimo_collision_geometry_CylinderGeometry, _oimo$collision$geome8); var _super11 = _createSuper(oimo_collision_geometry_CylinderGeometry); function oimo_collision_geometry_CylinderGeometry(radius, halfHeight) { var _this52; _classCallCheck(this, oimo_collision_geometry_CylinderGeometry); _this52 = _super11.call(this, 2); _this52._radius = radius; _this52._halfHeight = halfHeight; _this52._updateMass(); return _this52; } _createClass(oimo_collision_geometry_CylinderGeometry, [{ key: "getRadius", value: function getRadius() { return this._radius; } }, { key: "getHalfHeight", value: function getHalfHeight() { return this._halfHeight; } }, { key: "_updateMass", value: function _updateMass() { var r2 = this._radius * this._radius; var h2 = this._halfHeight * this._halfHeight * 4; this._volume = 3.14159265358979 * r2 * this._halfHeight * 2; this._inertiaCoeff00 = 0.083333333333333329 * (3 * r2 + h2); this._inertiaCoeff01 = 0; this._inertiaCoeff02 = 0; this._inertiaCoeff10 = 0; this._inertiaCoeff11 = 0.5 * r2; this._inertiaCoeff12 = 0; this._inertiaCoeff20 = 0; this._inertiaCoeff21 = 0; this._inertiaCoeff22 = 0.083333333333333329 * (3 * r2 + h2); } }, { key: "_computeAabb", value: function _computeAabb(aabb, tf) { var axisX; var axisY; var axisZ; var axis2X; var axis2Y; var axis2Z; var ehX; var ehY; var ehZ; var erX; var erY; var erZ; axisX = tf._rotation01; axisY = tf._rotation11; axisZ = tf._rotation21; if (axisX < 0) { axisX = -axisX; } if (axisY < 0) { axisY = -axisY; } if (axisZ < 0) { axisZ = -axisZ; } axis2X = axisX * axisX; axis2Y = axisY * axisY; axis2Z = axisZ * axisZ; erX = Math.sqrt(1 - axis2X); erY = Math.sqrt(1 - axis2Y); erZ = Math.sqrt(1 - axis2Z); erX *= this._radius; erY *= this._radius; erZ *= this._radius; ehX = axisX * this._halfHeight; ehY = axisY * this._halfHeight; ehZ = axisZ * this._halfHeight; var maxX; var maxY; var maxZ; maxX = erX + ehX; maxY = erY + ehY; maxZ = erZ + ehZ; aabb._minX = tf._positionX - maxX; aabb._minY = tf._positionY - maxY; aabb._minZ = tf._positionZ - maxZ; aabb._maxX = tf._positionX + maxX; aabb._maxY = tf._positionY + maxY; aabb._maxZ = tf._positionZ + maxZ; } }, { key: "computeLocalSupportingVertex", value: function computeLocalSupportingVertex(dir, out) { var rx = dir.x; var rz = dir.z; var len = rx * rx + rz * rz; var coreRadius = this._radius - this._gjkMargin; if (coreRadius < 0) { coreRadius = 0; } var invLen = len > 0 ? coreRadius / Math.sqrt(len) : 0; var coreHeight = this._halfHeight - this._gjkMargin; if (coreHeight < 0) { coreHeight = 0; } out.x = rx * invLen; out.y = dir.y > 0 ? coreHeight : -coreHeight; out.z = rz * invLen; } }, { key: "_rayCastLocal", value: function _rayCastLocal(beginX, beginY, beginZ, endX, endY, endZ, hit) { var halfH = this._halfHeight; var dx = endX - beginX; var dy = endY - beginY; var dz = endZ - beginZ; var tminy = 0; var tmaxy = 1; if (dy > -1e-6 && dy < 1e-6) { if (beginY <= -halfH || beginY >= halfH) { return false; } } else { var invDy = 1 / dy; var t1 = (-halfH - beginY) * invDy; var t2 = (halfH - beginY) * invDy; if (t1 > t2) { var tmp = t1; t1 = t2; t2 = tmp; } if (t1 > 0) { tminy = t1; } if (t2 < 1) { tmaxy = t2; } } if (tminy >= 1 || tmaxy <= 0) { return false; } var tminxz = 0; var tmaxxz; var a = dx * dx + dz * dz; var b = beginX * dx + beginZ * dz; var c = beginX * beginX + beginZ * beginZ - this._radius * this._radius; var D = b * b - a * c; if (D < 0) { return false; } if (a > 0) { var sqrtD = Math.sqrt(D); tminxz = (-b - sqrtD) / a; tmaxxz = (-b + sqrtD) / a; if (tminxz >= 1 || tmaxxz <= 0) { return false; } } else { if (c >= 0) { return false; } tminxz = 0; tmaxxz = 1; } var min; if (tmaxxz <= tminy || tmaxy <= tminxz) { return false; } if (tminxz < tminy) { min = tminy; if (min == 0) { return false; } hit.normal.init(0, dy > 0 ? -1 : 1, 0); } else { min = tminxz; if (min == 0) { return false; } var _this = hit.normal.init(beginX + dx * min, 0, beginZ + dz * min); var invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z); if (invLen > 0) { invLen = 1 / invLen; } _this.x *= invLen; _this.y *= invLen; _this.z *= invLen; } hit.position.init(beginX + min * dx, beginY + min * dy, beginZ + min * dz); hit.fraction = min; return true; } }]); return oimo_collision_geometry_CylinderGeometry; }(oimo.collision.geometry.ConvexGeometry); oimo.collision.geometry.GeometryType = /*#__PURE__*/_createClass(function oimo_collision_geometry_GeometryType() { _classCallCheck(this, oimo_collision_geometry_GeometryType); }); oimo.collision.geometry.RayCastHit = /*#__PURE__*/_createClass(function oimo_collision_geometry_RayCastHit() { _classCallCheck(this, oimo_collision_geometry_RayCastHit); this.position = new oimo.common.Vec3(); this.normal = new oimo.common.Vec3(); this.fraction = 0; }); oimo.collision.geometry.SphereGeometry = /*#__PURE__*/function (_oimo$collision$geome9) { _inherits(oimo_collision_geometry_SphereGeometry, _oimo$collision$geome9); var _super12 = _createSuper(oimo_collision_geometry_SphereGeometry); function oimo_collision_geometry_SphereGeometry(radius) { var _this53; _classCallCheck(this, oimo_collision_geometry_SphereGeometry); _this53 = _super12.call(this, 0); _this53._radius = radius; _this53._gjkMargin = _this53._radius; _this53._updateMass(); return _this53; } _createClass(oimo_collision_geometry_SphereGeometry, [{ key: "getRadius", value: function getRadius() { return this._radius; } }, { key: "_updateMass", value: function _updateMass() { this._volume = 4.1887902047863861 * this._radius * this._radius * this._radius; this._inertiaCoeff00 = 0.4 * this._radius * this._radius; this._inertiaCoeff01 = 0; this._inertiaCoeff02 = 0; this._inertiaCoeff10 = 0; this._inertiaCoeff11 = 0.4 * this._radius * this._radius; this._inertiaCoeff12 = 0; this._inertiaCoeff20 = 0; this._inertiaCoeff21 = 0; this._inertiaCoeff22 = 0.4 * this._radius * this._radius; } }, { key: "_computeAabb", value: function _computeAabb(aabb, tf) { var radVecX; var radVecY; var radVecZ; radVecX = this._radius; radVecY = this._radius; radVecZ = this._radius; aabb._minX = tf._positionX - radVecX; aabb._minY = tf._positionY - radVecY; aabb._minZ = tf._positionZ - radVecZ; aabb._maxX = tf._positionX + radVecX; aabb._maxY = tf._positionY + radVecY; aabb._maxZ = tf._positionZ + radVecZ; } }, { key: "computeLocalSupportingVertex", value: function computeLocalSupportingVertex(dir, out) { out.zero(); } }, { key: "_rayCastLocal", value: function _rayCastLocal(beginX, beginY, beginZ, endX, endY, endZ, hit) { var dX; var dY; var dZ; dX = endX - beginX; dY = endY - beginY; dZ = endZ - beginZ; var a = dX * dX + dY * dY + dZ * dZ; var b = beginX * dX + beginY * dY + beginZ * dZ; var D = b * b - a * (beginX * beginX + beginY * beginY + beginZ * beginZ - this._radius * this._radius); if (D < 0) { return false; } var t = (-b - Math.sqrt(D)) / a; if (t < 0 || t > 1) { return false; } var hitPosX; var hitPosY; var hitPosZ; var hitNormalX; var hitNormalY; var hitNormalZ; hitPosX = beginX + dX * t; hitPosY = beginY + dY * t; hitPosZ = beginZ + dZ * t; var l = hitPosX * hitPosX + hitPosY * hitPosY + hitPosZ * hitPosZ; if (l > 0) { l = 1 / Math.sqrt(l); } hitNormalX = hitPosX * l; hitNormalY = hitPosY * l; hitNormalZ = hitPosZ * l; var v = hit.position; v.x = hitPosX; v.y = hitPosY; v.z = hitPosZ; var v1 = hit.normal; v1.x = hitNormalX; v1.y = hitNormalY; v1.z = hitNormalZ; hit.fraction = t; return true; } }]); return oimo_collision_geometry_SphereGeometry; }(oimo.collision.geometry.ConvexGeometry); if (!oimo.collision.narrowphase) oimo.collision.narrowphase = {}; oimo.collision.narrowphase.CollisionMatrix = /*#__PURE__*/function () { function oimo_collision_narrowphase_CollisionMatrix() { _classCallCheck(this, oimo_collision_narrowphase_CollisionMatrix); this.detectors = new Array(8); this.detectors[0] = new Array(8); this.detectors[1] = new Array(8); this.detectors[2] = new Array(8); this.detectors[3] = new Array(8); this.detectors[4] = new Array(8); this.detectors[5] = new Array(8); var gjkEpaDetector = new oimo.collision.narrowphase.detector.GjkEpaDetector(); this.detectors[0][0] = new oimo.collision.narrowphase.detector.SphereSphereDetector(); this.detectors[0][1] = new oimo.collision.narrowphase.detector.SphereBoxDetector(false); this.detectors[0][2] = gjkEpaDetector; this.detectors[0][3] = gjkEpaDetector; this.detectors[0][4] = new oimo.collision.narrowphase.detector.SphereCapsuleDetector(false); this.detectors[0][5] = gjkEpaDetector; this.detectors[1][0] = new oimo.collision.narrowphase.detector.SphereBoxDetector(true); this.detectors[1][1] = new oimo.collision.narrowphase.detector.BoxBoxDetector(); this.detectors[1][2] = gjkEpaDetector; this.detectors[1][3] = gjkEpaDetector; this.detectors[1][4] = gjkEpaDetector; this.detectors[1][5] = gjkEpaDetector; this.detectors[2][0] = gjkEpaDetector; this.detectors[2][1] = gjkEpaDetector; this.detectors[2][2] = gjkEpaDetector; this.detectors[2][3] = gjkEpaDetector; this.detectors[2][4] = gjkEpaDetector; this.detectors[2][5] = gjkEpaDetector; this.detectors[3][0] = gjkEpaDetector; this.detectors[3][1] = gjkEpaDetector; this.detectors[3][2] = gjkEpaDetector; this.detectors[3][3] = gjkEpaDetector; this.detectors[3][4] = gjkEpaDetector; this.detectors[3][5] = gjkEpaDetector; this.detectors[4][0] = new oimo.collision.narrowphase.detector.SphereCapsuleDetector(true); this.detectors[4][1] = gjkEpaDetector; this.detectors[4][2] = gjkEpaDetector; this.detectors[4][3] = gjkEpaDetector; this.detectors[4][4] = new oimo.collision.narrowphase.detector.CapsuleCapsuleDetector(); this.detectors[4][5] = gjkEpaDetector; this.detectors[5][0] = gjkEpaDetector; this.detectors[5][1] = gjkEpaDetector; this.detectors[5][2] = gjkEpaDetector; this.detectors[5][3] = gjkEpaDetector; this.detectors[5][4] = gjkEpaDetector; this.detectors[5][5] = gjkEpaDetector; } _createClass(oimo_collision_narrowphase_CollisionMatrix, [{ key: "getDetector", value: function getDetector(geomType1, geomType2) { return this.detectors[geomType1][geomType2]; } }]); return oimo_collision_narrowphase_CollisionMatrix; }(); oimo.collision.narrowphase.DetectorResult = /*#__PURE__*/function () { function oimo_collision_narrowphase_DetectorResult() { _classCallCheck(this, oimo_collision_narrowphase_DetectorResult); this.numPoints = 0; this.normal = new oimo.common.Vec3(); this.points = new Array(oimo.common.Setting.maxManifoldPoints); this.incremental = false; var _g = 0; var _g1 = oimo.common.Setting.maxManifoldPoints; while (_g < _g1) { this.points[_g++] = new oimo.collision.narrowphase.DetectorResultPoint(); } } _createClass(oimo_collision_narrowphase_DetectorResult, [{ key: "getMaxDepth", value: function getMaxDepth() { var max = 0; var _g = 0; var _g1 = this.numPoints; while (_g < _g1) { var i = _g++; if (this.points[i].depth > max) { max = this.points[i].depth; } } return max; } }, { key: "clear", value: function clear() { this.numPoints = 0; var _g = 0; var _g1 = this.points; while (_g < _g1.length) { var p = _g1[_g]; ++_g; p.position1.zero(); p.position2.zero(); p.depth = 0; p.id = 0; } this.normal.zero(); } }]); return oimo_collision_narrowphase_DetectorResult; }(); oimo.collision.narrowphase.DetectorResultPoint = /*#__PURE__*/_createClass(function oimo_collision_narrowphase_DetectorResultPoint() { _classCallCheck(this, oimo_collision_narrowphase_DetectorResultPoint); this.position1 = new oimo.common.Vec3(); this.position2 = new oimo.common.Vec3(); this.depth = 0; this.id = 0; }); if (!oimo.collision.narrowphase.detector) oimo.collision.narrowphase.detector = {}; oimo.collision.narrowphase.detector.Detector = /*#__PURE__*/function () { function oimo_collision_narrowphase_detector_Detector(swapped) { _classCallCheck(this, oimo_collision_narrowphase_detector_Detector); this.swapped = swapped; } _createClass(oimo_collision_narrowphase_detector_Detector, [{ key: "setNormal", value: function setNormal(result, nX, nY, nZ) { var v = result.normal; v.x = nX; v.y = nY; v.z = nZ; if (this.swapped) { var _this = result.normal; _this.x = -_this.x; _this.y = -_this.y; _this.z = -_this.z; } } }, { key: "addPoint", value: function addPoint(result, pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, depth, id) { var p = result.points[result.numPoints++]; p.depth = depth; p.id = id; if (this.swapped) { var v = p.position1; v.x = pos2X; v.y = pos2Y; v.z = pos2Z; var v1 = p.position2; v1.x = pos1X; v1.y = pos1Y; v1.z = pos1Z; } else { var _v3 = p.position1; _v3.x = pos1X; _v3.y = pos1Y; _v3.z = pos1Z; var _v4 = p.position2; _v4.x = pos2X; _v4.y = pos2Y; _v4.z = pos2Z; } } }, { key: "detectImpl", value: function detectImpl(result, geom1, geom2, tf1, tf2, cachedData) {} }, { key: "detect", value: function detect(result, geom1, geom2, transform1, transform2, cachedData) { result.numPoints = 0; var _g = 0; var _g1 = result.points; while (_g < _g1.length) { var p = _g1[_g]; ++_g; p.position1.zero(); p.position2.zero(); p.depth = 0; p.id = 0; } result.normal.zero(); if (this.swapped) { this.detectImpl(result, geom2, geom1, transform2, transform1, cachedData); } else { this.detectImpl(result, geom1, geom2, transform1, transform2, cachedData); } } }]); return oimo_collision_narrowphase_detector_Detector; }(); oimo.collision.narrowphase.detector.BoxBoxDetector = /*#__PURE__*/function (_oimo$collision$narro) { _inherits(oimo_collision_narrowphase_detector_BoxBoxDetector, _oimo$collision$narro); var _super13 = _createSuper(oimo_collision_narrowphase_detector_BoxBoxDetector); function oimo_collision_narrowphase_detector_BoxBoxDetector() { var _this54; _classCallCheck(this, oimo_collision_narrowphase_detector_BoxBoxDetector); _this54 = _super13.call(this, false); _this54.clipper = new oimo.collision.narrowphase.detector._BoxBoxDetector.FaceClipper(); return _this54; } _createClass(oimo_collision_narrowphase_detector_BoxBoxDetector, [{ key: "detectImpl", value: function detectImpl(result, geom1, geom2, tf1, tf2, cachedData) { var b1 = geom1; var b2 = geom2; result.incremental = false; var c1X; var c1Y; var c1Z; var c2X; var c2Y; var c2Z; var c12X; var c12Y; var c12Z; c1X = tf1._positionX; c1Y = tf1._positionY; c1Z = tf1._positionZ; c2X = tf2._positionX; c2Y = tf2._positionY; c2Z = tf2._positionZ; c12X = c2X - c1X; c12Y = c2Y - c1Y; c12Z = c2Z - c1Z; var x1X; var x1Y; var x1Z; var y1X; var y1Y; var y1Z; var z1X; var z1Y; var z1Z; var x2X; var x2Y; var x2Z; var y2X; var y2Y; var y2Z; var z2X; var z2Y; var z2Z; x1X = tf1._rotation00; x1Y = tf1._rotation10; x1Z = tf1._rotation20; y1X = tf1._rotation01; y1Y = tf1._rotation11; y1Z = tf1._rotation21; z1X = tf1._rotation02; z1Y = tf1._rotation12; z1Z = tf1._rotation22; x2X = tf2._rotation00; x2Y = tf2._rotation10; x2Z = tf2._rotation20; y2X = tf2._rotation01; y2Y = tf2._rotation11; y2Z = tf2._rotation21; z2X = tf2._rotation02; z2Y = tf2._rotation12; z2Z = tf2._rotation22; var w1 = b1._halfExtentsX; var h1 = b1._halfExtentsY; var d1 = b1._halfExtentsZ; var w2 = b2._halfExtentsX; var h2 = b2._halfExtentsY; var d2 = b2._halfExtentsZ; var sx1X; var sx1Y; var sx1Z; var sy1X; var sy1Y; var sy1Z; var sz1X; var sz1Y; var sz1Z; var sx2X; var sx2Y; var sx2Z; var sy2X; var sy2Y; var sy2Z; var sz2X; var sz2Y; var sz2Z; sx1X = x1X * w1; sx1Y = x1Y * w1; sx1Z = x1Z * w1; sy1X = y1X * h1; sy1Y = y1Y * h1; sy1Z = y1Z * h1; sz1X = z1X * d1; sz1Y = z1Y * d1; sz1Z = z1Z * d1; sx2X = x2X * w2; sx2Y = x2Y * w2; sx2Z = x2Z * w2; sy2X = y2X * h2; sy2Y = y2Y * h2; sy2Z = y2Z * h2; sz2X = z2X * d2; sz2Y = z2Y * d2; sz2Z = z2Z * d2; var mDepth = 1e65536; var mId = -1; var mSign = 0; var mAxisX; var mAxisY; var mAxisZ; mAxisX = 0; mAxisY = 0; mAxisZ = 0; var proj1 = w1; var dx = x1X * sx2X + x1Y * sx2Y + x1Z * sx2Z; var dy = x1X * sy2X + x1Y * sy2Y + x1Z * sy2Z; var dz = x1X * sz2X + x1Y * sz2Y + x1Z * sz2Z; if (dx < 0) { dx = -dx; } if (dy < 0) { dy = -dy; } if (dz < 0) { dz = -dz; } var proj2 = dx + dy + dz; var projC12 = x1X * c12X + x1Y * c12Y + x1Z * c12Z; var sum = proj1 + proj2; var neg = projC12 < 0; var abs = neg ? -projC12 : projC12; if (abs < sum) { var depth = sum - abs; if (depth < 1e65536) { mDepth = depth; mId = 0; mAxisX = x1X; mAxisY = x1Y; mAxisZ = x1Z; mSign = neg ? -1 : 1; } } else { return; } proj1 = h1; var dx1 = y1X * sx2X + y1Y * sx2Y + y1Z * sx2Z; var dy1 = y1X * sy2X + y1Y * sy2Y + y1Z * sy2Z; var dz1 = y1X * sz2X + y1Y * sz2Y + y1Z * sz2Z; if (dx1 < 0) { dx1 = -dx1; } if (dy1 < 0) { dy1 = -dy1; } if (dz1 < 0) { dz1 = -dz1; } proj2 = dx1 + dy1 + dz1; projC12 = y1X * c12X + y1Y * c12Y + y1Z * c12Z; var sum1 = proj1 + proj2; var neg1 = projC12 < 0; var abs1 = neg1 ? -projC12 : projC12; if (abs1 < sum1) { var _depth = sum1 - abs1; if (_depth < mDepth) { mDepth = _depth; mId = 1; mAxisX = y1X; mAxisY = y1Y; mAxisZ = y1Z; mSign = neg1 ? -1 : 1; } } else { return; } proj1 = d1; var dx2 = z1X * sx2X + z1Y * sx2Y + z1Z * sx2Z; var dy2 = z1X * sy2X + z1Y * sy2Y + z1Z * sy2Z; var dz2 = z1X * sz2X + z1Y * sz2Y + z1Z * sz2Z; if (dx2 < 0) { dx2 = -dx2; } if (dy2 < 0) { dy2 = -dy2; } if (dz2 < 0) { dz2 = -dz2; } proj2 = dx2 + dy2 + dz2; projC12 = z1X * c12X + z1Y * c12Y + z1Z * c12Z; var sum2 = proj1 + proj2; var neg2 = projC12 < 0; var abs2 = neg2 ? -projC12 : projC12; if (abs2 < sum2) { var _depth2 = sum2 - abs2; if (_depth2 < mDepth) { mDepth = _depth2; mId = 2; mAxisX = z1X; mAxisY = z1Y; mAxisZ = z1Z; mSign = neg2 ? -1 : 1; } } else { return; } if (mDepth > oimo.common.Setting.linearSlop) { mDepth -= oimo.common.Setting.linearSlop; } else { mDepth = 0; } var dx3 = x2X * sx1X + x2Y * sx1Y + x2Z * sx1Z; var dy3 = x2X * sy1X + x2Y * sy1Y + x2Z * sy1Z; var dz3 = x2X * sz1X + x2Y * sz1Y + x2Z * sz1Z; if (dx3 < 0) { dx3 = -dx3; } if (dy3 < 0) { dy3 = -dy3; } if (dz3 < 0) { dz3 = -dz3; } proj1 = dx3 + dy3 + dz3; proj2 = w2; projC12 = x2X * c12X + x2Y * c12Y + x2Z * c12Z; var sum3 = proj1 + proj2; var neg3 = projC12 < 0; var abs3 = neg3 ? -projC12 : projC12; if (abs3 < sum3) { var _depth3 = sum3 - abs3; if (_depth3 < mDepth) { mDepth = _depth3; mId = 3; mAxisX = x2X; mAxisY = x2Y; mAxisZ = x2Z; mSign = neg3 ? -1 : 1; } } else { return; } var dx4 = y2X * sx1X + y2Y * sx1Y + y2Z * sx1Z; var dy4 = y2X * sy1X + y2Y * sy1Y + y2Z * sy1Z; var dz4 = y2X * sz1X + y2Y * sz1Y + y2Z * sz1Z; if (dx4 < 0) { dx4 = -dx4; } if (dy4 < 0) { dy4 = -dy4; } if (dz4 < 0) { dz4 = -dz4; } proj1 = dx4 + dy4 + dz4; proj2 = h2; projC12 = y2X * c12X + y2Y * c12Y + y2Z * c12Z; var sum4 = proj1 + proj2; var neg4 = projC12 < 0; var abs4 = neg4 ? -projC12 : projC12; if (abs4 < sum4) { var _depth4 = sum4 - abs4; if (_depth4 < mDepth) { mDepth = _depth4; mId = 4; mAxisX = y2X; mAxisY = y2Y; mAxisZ = y2Z; mSign = neg4 ? -1 : 1; } } else { return; } var dx5 = z2X * sx1X + z2Y * sx1Y + z2Z * sx1Z; var dy5 = z2X * sy1X + z2Y * sy1Y + z2Z * sy1Z; var dz5 = z2X * sz1X + z2Y * sz1Y + z2Z * sz1Z; if (dx5 < 0) { dx5 = -dx5; } if (dy5 < 0) { dy5 = -dy5; } if (dz5 < 0) { dz5 = -dz5; } proj1 = dx5 + dy5 + dz5; proj2 = d2; projC12 = z2X * c12X + z2Y * c12Y + z2Z * c12Z; var sum5 = proj1 + proj2; var neg5 = projC12 < 0; var abs5 = neg5 ? -projC12 : projC12; if (abs5 < sum5) { var _depth5 = sum5 - abs5; if (_depth5 < mDepth) { mDepth = _depth5; mId = 5; mAxisX = z2X; mAxisY = z2Y; mAxisZ = z2Z; mSign = neg5 ? -1 : 1; } } else { return; } if (mDepth > oimo.common.Setting.linearSlop) { mDepth -= oimo.common.Setting.linearSlop; } else { mDepth = 0; } var edgeAxisX; var edgeAxisY; var edgeAxisZ; edgeAxisX = x1Y * x2Z - x1Z * x2Y; edgeAxisY = x1Z * x2X - x1X * x2Z; edgeAxisZ = x1X * x2Y - x1Y * x2X; if (!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) { var l = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ; if (l > 0) { l = 1 / Math.sqrt(l); } edgeAxisX *= l; edgeAxisY *= l; edgeAxisZ *= l; var _dx = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z; var _dy = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z; if (_dx < 0) { _dx = -_dx; } if (_dy < 0) { _dy = -_dy; } proj1 = _dx + _dy; var _dx2 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z; var _dy2 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z; if (_dx2 < 0) { _dx2 = -_dx2; } if (_dy2 < 0) { _dy2 = -_dy2; } proj2 = _dx2 + _dy2; projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z; var _sum = proj1 + proj2; var _neg = projC12 < 0; var _abs = _neg ? -projC12 : projC12; if (_abs < _sum) { var _depth6 = _sum - _abs; if (_depth6 < mDepth) { mDepth = _depth6; mId = 6; mAxisX = edgeAxisX; mAxisY = edgeAxisY; mAxisZ = edgeAxisZ; mSign = _neg ? -1 : 1; } } else { return; } } edgeAxisX = x1Y * y2Z - x1Z * y2Y; edgeAxisY = x1Z * y2X - x1X * y2Z; edgeAxisZ = x1X * y2Y - x1Y * y2X; if (!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) { var _l2 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ; if (_l2 > 0) { _l2 = 1 / Math.sqrt(_l2); } edgeAxisX *= _l2; edgeAxisY *= _l2; edgeAxisZ *= _l2; var _dx3 = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z; var _dy3 = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z; if (_dx3 < 0) { _dx3 = -_dx3; } if (_dy3 < 0) { _dy3 = -_dy3; } proj1 = _dx3 + _dy3; var _dx4 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z; var _dy4 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z; if (_dx4 < 0) { _dx4 = -_dx4; } if (_dy4 < 0) { _dy4 = -_dy4; } proj2 = _dx4 + _dy4; projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z; var _sum2 = proj1 + proj2; var _neg2 = projC12 < 0; var _abs2 = _neg2 ? -projC12 : projC12; if (_abs2 < _sum2) { var _depth7 = _sum2 - _abs2; if (_depth7 < mDepth) { mDepth = _depth7; mId = 7; mAxisX = edgeAxisX; mAxisY = edgeAxisY; mAxisZ = edgeAxisZ; mSign = _neg2 ? -1 : 1; } } else { return; } } edgeAxisX = x1Y * z2Z - x1Z * z2Y; edgeAxisY = x1Z * z2X - x1X * z2Z; edgeAxisZ = x1X * z2Y - x1Y * z2X; if (!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) { var _l3 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ; if (_l3 > 0) { _l3 = 1 / Math.sqrt(_l3); } edgeAxisX *= _l3; edgeAxisY *= _l3; edgeAxisZ *= _l3; var _dx5 = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z; var _dy5 = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z; if (_dx5 < 0) { _dx5 = -_dx5; } if (_dy5 < 0) { _dy5 = -_dy5; } proj1 = _dx5 + _dy5; var _dx6 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z; var _dy6 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z; if (_dx6 < 0) { _dx6 = -_dx6; } if (_dy6 < 0) { _dy6 = -_dy6; } proj2 = _dx6 + _dy6; projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z; var _sum3 = proj1 + proj2; var _neg3 = projC12 < 0; var _abs3 = _neg3 ? -projC12 : projC12; if (_abs3 < _sum3) { var _depth8 = _sum3 - _abs3; if (_depth8 < mDepth) { mDepth = _depth8; mId = 8; mAxisX = edgeAxisX; mAxisY = edgeAxisY; mAxisZ = edgeAxisZ; mSign = _neg3 ? -1 : 1; } } else { return; } } edgeAxisX = y1Y * x2Z - y1Z * x2Y; edgeAxisY = y1Z * x2X - y1X * x2Z; edgeAxisZ = y1X * x2Y - y1Y * x2X; if (!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) { var _l4 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ; if (_l4 > 0) { _l4 = 1 / Math.sqrt(_l4); } edgeAxisX *= _l4; edgeAxisY *= _l4; edgeAxisZ *= _l4; var _dx7 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z; var _dy7 = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z; if (_dx7 < 0) { _dx7 = -_dx7; } if (_dy7 < 0) { _dy7 = -_dy7; } proj1 = _dx7 + _dy7; var _dx8 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z; var _dy8 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z; if (_dx8 < 0) { _dx8 = -_dx8; } if (_dy8 < 0) { _dy8 = -_dy8; } proj2 = _dx8 + _dy8; projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z; var _sum4 = proj1 + proj2; var _neg4 = projC12 < 0; var _abs4 = _neg4 ? -projC12 : projC12; if (_abs4 < _sum4) { var _depth9 = _sum4 - _abs4; if (_depth9 < mDepth) { mDepth = _depth9; mId = 9; mAxisX = edgeAxisX; mAxisY = edgeAxisY; mAxisZ = edgeAxisZ; mSign = _neg4 ? -1 : 1; } } else { return; } } edgeAxisX = y1Y * y2Z - y1Z * y2Y; edgeAxisY = y1Z * y2X - y1X * y2Z; edgeAxisZ = y1X * y2Y - y1Y * y2X; if (!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) { var _l5 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ; if (_l5 > 0) { _l5 = 1 / Math.sqrt(_l5); } edgeAxisX *= _l5; edgeAxisY *= _l5; edgeAxisZ *= _l5; var _dx9 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z; var _dy9 = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z; if (_dx9 < 0) { _dx9 = -_dx9; } if (_dy9 < 0) { _dy9 = -_dy9; } proj1 = _dx9 + _dy9; var _dx10 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z; var _dy10 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z; if (_dx10 < 0) { _dx10 = -_dx10; } if (_dy10 < 0) { _dy10 = -_dy10; } proj2 = _dx10 + _dy10; projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z; var _sum5 = proj1 + proj2; var _neg5 = projC12 < 0; var _abs5 = _neg5 ? -projC12 : projC12; if (_abs5 < _sum5) { var _depth10 = _sum5 - _abs5; if (_depth10 < mDepth) { mDepth = _depth10; mId = 10; mAxisX = edgeAxisX; mAxisY = edgeAxisY; mAxisZ = edgeAxisZ; mSign = _neg5 ? -1 : 1; } } else { return; } } edgeAxisX = y1Y * z2Z - y1Z * z2Y; edgeAxisY = y1Z * z2X - y1X * z2Z; edgeAxisZ = y1X * z2Y - y1Y * z2X; if (!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) { var _l6 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ; if (_l6 > 0) { _l6 = 1 / Math.sqrt(_l6); } edgeAxisX *= _l6; edgeAxisY *= _l6; edgeAxisZ *= _l6; var _dx11 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z; var _dy11 = edgeAxisX * sz1X + edgeAxisY * sz1Y + edgeAxisZ * sz1Z; if (_dx11 < 0) { _dx11 = -_dx11; } if (_dy11 < 0) { _dy11 = -_dy11; } proj1 = _dx11 + _dy11; var _dx12 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z; var _dy12 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z; if (_dx12 < 0) { _dx12 = -_dx12; } if (_dy12 < 0) { _dy12 = -_dy12; } proj2 = _dx12 + _dy12; projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z; var _sum6 = proj1 + proj2; var _neg6 = projC12 < 0; var _abs6 = _neg6 ? -projC12 : projC12; if (_abs6 < _sum6) { var _depth11 = _sum6 - _abs6; if (_depth11 < mDepth) { mDepth = _depth11; mId = 11; mAxisX = edgeAxisX; mAxisY = edgeAxisY; mAxisZ = edgeAxisZ; mSign = _neg6 ? -1 : 1; } } else { return; } } edgeAxisX = z1Y * x2Z - z1Z * x2Y; edgeAxisY = z1Z * x2X - z1X * x2Z; edgeAxisZ = z1X * x2Y - z1Y * x2X; if (!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) { var _l7 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ; if (_l7 > 0) { _l7 = 1 / Math.sqrt(_l7); } edgeAxisX *= _l7; edgeAxisY *= _l7; edgeAxisZ *= _l7; var _dx13 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z; var _dy13 = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z; if (_dx13 < 0) { _dx13 = -_dx13; } if (_dy13 < 0) { _dy13 = -_dy13; } proj1 = _dx13 + _dy13; var _dx14 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z; var _dy14 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z; if (_dx14 < 0) { _dx14 = -_dx14; } if (_dy14 < 0) { _dy14 = -_dy14; } proj2 = _dx14 + _dy14; projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z; var _sum7 = proj1 + proj2; var _neg7 = projC12 < 0; var _abs7 = _neg7 ? -projC12 : projC12; if (_abs7 < _sum7) { var _depth12 = _sum7 - _abs7; if (_depth12 < mDepth) { mDepth = _depth12; mId = 12; mAxisX = edgeAxisX; mAxisY = edgeAxisY; mAxisZ = edgeAxisZ; mSign = _neg7 ? -1 : 1; } } else { return; } } edgeAxisX = z1Y * y2Z - z1Z * y2Y; edgeAxisY = z1Z * y2X - z1X * y2Z; edgeAxisZ = z1X * y2Y - z1Y * y2X; if (!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) { var _l8 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ; if (_l8 > 0) { _l8 = 1 / Math.sqrt(_l8); } edgeAxisX *= _l8; edgeAxisY *= _l8; edgeAxisZ *= _l8; var _dx15 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z; var _dy15 = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z; if (_dx15 < 0) { _dx15 = -_dx15; } if (_dy15 < 0) { _dy15 = -_dy15; } proj1 = _dx15 + _dy15; var _dx16 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z; var _dy16 = edgeAxisX * sz2X + edgeAxisY * sz2Y + edgeAxisZ * sz2Z; if (_dx16 < 0) { _dx16 = -_dx16; } if (_dy16 < 0) { _dy16 = -_dy16; } proj2 = _dx16 + _dy16; projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z; var _sum8 = proj1 + proj2; var _neg8 = projC12 < 0; var _abs8 = _neg8 ? -projC12 : projC12; if (_abs8 < _sum8) { var _depth13 = _sum8 - _abs8; if (_depth13 < mDepth) { mDepth = _depth13; mId = 13; mAxisX = edgeAxisX; mAxisY = edgeAxisY; mAxisZ = edgeAxisZ; mSign = _neg8 ? -1 : 1; } } else { return; } } edgeAxisX = z1Y * z2Z - z1Z * z2Y; edgeAxisY = z1Z * z2X - z1X * z2Z; edgeAxisZ = z1X * z2Y - z1Y * z2X; if (!(edgeAxisX == 0 && edgeAxisY == 0 && edgeAxisZ == 0)) { var _l9 = edgeAxisX * edgeAxisX + edgeAxisY * edgeAxisY + edgeAxisZ * edgeAxisZ; if (_l9 > 0) { _l9 = 1 / Math.sqrt(_l9); } edgeAxisX *= _l9; edgeAxisY *= _l9; edgeAxisZ *= _l9; var _dx17 = edgeAxisX * sx1X + edgeAxisY * sx1Y + edgeAxisZ * sx1Z; var _dy17 = edgeAxisX * sy1X + edgeAxisY * sy1Y + edgeAxisZ * sy1Z; if (_dx17 < 0) { _dx17 = -_dx17; } if (_dy17 < 0) { _dy17 = -_dy17; } proj1 = _dx17 + _dy17; var _dx18 = edgeAxisX * sx2X + edgeAxisY * sx2Y + edgeAxisZ * sx2Z; var _dy18 = edgeAxisX * sy2X + edgeAxisY * sy2Y + edgeAxisZ * sy2Z; if (_dx18 < 0) { _dx18 = -_dx18; } if (_dy18 < 0) { _dy18 = -_dy18; } proj2 = _dx18 + _dy18; projC12 = edgeAxisX * c12X + edgeAxisY * c12Y + edgeAxisZ * c12Z; var _sum9 = proj1 + proj2; var _neg9 = projC12 < 0; var _abs9 = _neg9 ? -projC12 : projC12; if (_abs9 < _sum9) { var _depth14 = _sum9 - _abs9; if (_depth14 < mDepth) { mDepth = _depth14; mId = 14; mAxisX = edgeAxisX; mAxisY = edgeAxisY; mAxisZ = edgeAxisZ; mSign = _neg9 ? -1 : 1; } } else { return; } } if (mId >= 6) { mAxisX *= mSign; mAxisY *= mSign; mAxisZ *= mSign; var id1 = (mId - 6) / 3 | 0; var id2 = mId - 6 - id1 * 3; var p1X; var p1Y; var p1Z; var p2X; var p2Y; var p2Z; var d1X; var d1Y; var d1Z; var d2X; var d2Y; var d2Z; switch (id1) { case 0: d1X = x1X; d1Y = x1Y; d1Z = x1Z; var signY = sz1X * mAxisX + sz1Y * mAxisY + sz1Z * mAxisZ > 0; if (sy1X * mAxisX + sy1Y * mAxisY + sy1Z * mAxisZ > 0) { if (signY) { p1X = sy1X + sz1X; p1Y = sy1Y + sz1Y; p1Z = sy1Z + sz1Z; } else { p1X = sy1X - sz1X; p1Y = sy1Y - sz1Y; p1Z = sy1Z - sz1Z; } } else if (signY) { p1X = sz1X - sy1X; p1Y = sz1Y - sy1Y; p1Z = sz1Z - sy1Z; } else { p1X = sy1X + sz1X; p1Y = sy1Y + sz1Y; p1Z = sy1Z + sz1Z; p1X = -p1X; p1Y = -p1Y; p1Z = -p1Z; } break; case 1: d1X = y1X; d1Y = y1Y; d1Z = y1Z; var signY1 = sz1X * mAxisX + sz1Y * mAxisY + sz1Z * mAxisZ > 0; if (sx1X * mAxisX + sx1Y * mAxisY + sx1Z * mAxisZ > 0) { if (signY1) { p1X = sx1X + sz1X; p1Y = sx1Y + sz1Y; p1Z = sx1Z + sz1Z; } else { p1X = sx1X - sz1X; p1Y = sx1Y - sz1Y; p1Z = sx1Z - sz1Z; } } else if (signY1) { p1X = sz1X - sx1X; p1Y = sz1Y - sx1Y; p1Z = sz1Z - sx1Z; } else { p1X = sx1X + sz1X; p1Y = sx1Y + sz1Y; p1Z = sx1Z + sz1Z; p1X = -p1X; p1Y = -p1Y; p1Z = -p1Z; } break; default: d1X = z1X; d1Y = z1Y; d1Z = z1Z; var signY2 = sy1X * mAxisX + sy1Y * mAxisY + sy1Z * mAxisZ > 0; if (sx1X * mAxisX + sx1Y * mAxisY + sx1Z * mAxisZ > 0) { if (signY2) { p1X = sx1X + sy1X; p1Y = sx1Y + sy1Y; p1Z = sx1Z + sy1Z; } else { p1X = sx1X - sy1X; p1Y = sx1Y - sy1Y; p1Z = sx1Z - sy1Z; } } else if (signY2) { p1X = sy1X - sx1X; p1Y = sy1Y - sx1Y; p1Z = sy1Z - sx1Z; } else { p1X = sx1X + sy1X; p1Y = sx1Y + sy1Y; p1Z = sx1Z + sy1Z; p1X = -p1X; p1Y = -p1Y; p1Z = -p1Z; } } p1X = c1X + p1X; p1Y = c1Y + p1Y; p1Z = c1Z + p1Z; switch (id2) { case 0: d2X = x2X; d2Y = x2Y; d2Z = x2Z; var signY3 = sz2X * mAxisX + sz2Y * mAxisY + sz2Z * mAxisZ > 0; if (sy2X * mAxisX + sy2Y * mAxisY + sy2Z * mAxisZ > 0) { if (signY3) { p2X = sy2X + sz2X; p2Y = sy2Y + sz2Y; p2Z = sy2Z + sz2Z; } else { p2X = sy2X - sz2X; p2Y = sy2Y - sz2Y; p2Z = sy2Z - sz2Z; } } else if (signY3) { p2X = sz2X - sy2X; p2Y = sz2Y - sy2Y; p2Z = sz2Z - sy2Z; } else { p2X = sy2X + sz2X; p2Y = sy2Y + sz2Y; p2Z = sy2Z + sz2Z; p2X = -p2X; p2Y = -p2Y; p2Z = -p2Z; } break; case 1: d2X = y2X; d2Y = y2Y; d2Z = y2Z; var signY4 = sz2X * mAxisX + sz2Y * mAxisY + sz2Z * mAxisZ > 0; if (sx2X * mAxisX + sx2Y * mAxisY + sx2Z * mAxisZ > 0) { if (signY4) { p2X = sx2X + sz2X; p2Y = sx2Y + sz2Y; p2Z = sx2Z + sz2Z; } else { p2X = sx2X - sz2X; p2Y = sx2Y - sz2Y; p2Z = sx2Z - sz2Z; } } else if (signY4) { p2X = sz2X - sx2X; p2Y = sz2Y - sx2Y; p2Z = sz2Z - sx2Z; } else { p2X = sx2X + sz2X; p2Y = sx2Y + sz2Y; p2Z = sx2Z + sz2Z; p2X = -p2X; p2Y = -p2Y; p2Z = -p2Z; } break; default: d2X = z2X; d2Y = z2Y; d2Z = z2Z; var signY5 = sy2X * mAxisX + sy2Y * mAxisY + sy2Z * mAxisZ > 0; if (sx2X * mAxisX + sx2Y * mAxisY + sx2Z * mAxisZ > 0) { if (signY5) { p2X = sx2X + sy2X; p2Y = sx2Y + sy2Y; p2Z = sx2Z + sy2Z; } else { p2X = sx2X - sy2X; p2Y = sx2Y - sy2Y; p2Z = sx2Z - sy2Z; } } else if (signY5) { p2X = sy2X - sx2X; p2Y = sy2Y - sx2Y; p2Z = sy2Z - sx2Z; } else { p2X = sx2X + sy2X; p2Y = sx2Y + sy2Y; p2Z = sx2Z + sy2Z; p2X = -p2X; p2Y = -p2Y; p2Z = -p2Z; } } p2X = c2X - p2X; p2Y = c2Y - p2Y; p2Z = c2Z - p2Z; var rX; var rY; var rZ; rX = p1X - p2X; rY = p1Y - p2Y; rZ = p1Z - p2Z; var dot12 = d1X * d2X + d1Y * d2Y + d1Z * d2Z; var dot1r = d1X * rX + d1Y * rY + d1Z * rZ; var dot2r = d2X * rX + d2Y * rY + d2Z * rZ; var invDet = 1 / (1 - dot12 * dot12); var t1 = (dot12 * dot2r - dot1r) * invDet; var t2 = (dot2r - dot12 * dot1r) * invDet; var cp1X; var cp1Y; var cp1Z; var cp2X; var cp2Y; var cp2Z; cp1X = p1X + d1X * t1; cp1Y = p1Y + d1Y * t1; cp1Z = p1Z + d1Z * t1; cp2X = p2X + d2X * t2; cp2Y = p2Y + d2Y * t2; cp2Z = p2Z + d2Z * t2; var _normalX; var _normalY; var _normalZ; _normalX = -mAxisX; _normalY = -mAxisY; _normalZ = -mAxisZ; this.setNormal(result, _normalX, _normalY, _normalZ); this.addPoint(result, cp1X, cp1Y, cp1Z, cp2X, cp2Y, cp2Z, mDepth, 4); return; } var tmpX; var tmpY; var tmpZ; var swapped; if (mId >= 3) { mSign = -mSign; c12X = -c12X; c12Y = -c12Y; c12Z = -c12Z; w1 = w2; h1 = h2; d1 = d2; c1X = c2X; c1Y = c2Y; c1Z = c2Z; tmpX = x1X; tmpY = x1Y; tmpZ = x1Z; x1X = x2X; x1Y = x2Y; x1Z = x2Z; x2X = tmpX; x2Y = tmpY; x2Z = tmpZ; tmpX = y1X; tmpY = y1Y; tmpZ = y1Z; y1X = y2X; y1Y = y2Y; y1Z = y2Z; y2X = tmpX; y2Y = tmpY; y2Z = tmpZ; tmpX = z1X; tmpY = z1Y; tmpZ = z1Z; z1X = z2X; z1Y = z2Y; z1Z = z2Z; z2X = tmpX; z2Y = tmpY; z2Z = tmpZ; tmpX = sx1X; tmpY = sx1Y; tmpZ = sx1Z; sx1X = sx2X; sx1Y = sx2Y; sx1Z = sx2Z; sx2X = tmpX; sx2Y = tmpY; sx2Z = tmpZ; tmpX = sy1X; tmpY = sy1Y; tmpZ = sy1Z; sy1X = sy2X; sy1Y = sy2Y; sy1Z = sy2Z; sy2X = tmpX; sy2Y = tmpY; sy2Z = tmpZ; tmpX = sz1X; tmpY = sz1Y; tmpZ = sz1Z; sz1X = sz2X; sz1Y = sz2Y; sz1Z = sz2Z; sz2X = tmpX; sz2Y = tmpY; sz2Z = tmpZ; mId -= 3; swapped = true; } else { swapped = false; } var refCenterX; var refCenterY; var refCenterZ; var refNormalX; var refNormalY; var refNormalZ; var refXX; var refXY; var refXZ; var refYX; var refYY; var refYZ; var refW; var refH; switch (mId) { case 0: refCenterX = sx1X; refCenterY = sx1Y; refCenterZ = sx1Z; refNormalX = x1X; refNormalY = x1Y; refNormalZ = x1Z; refXX = y1X; refXY = y1Y; refXZ = y1Z; refYX = z1X; refYY = z1Y; refYZ = z1Z; refW = h1; refH = d1; break; case 1: refCenterX = sy1X; refCenterY = sy1Y; refCenterZ = sy1Z; refNormalX = y1X; refNormalY = y1Y; refNormalZ = y1Z; refXX = z1X; refXY = z1Y; refXZ = z1Z; refYX = x1X; refYY = x1Y; refYZ = x1Z; refW = d1; refH = w1; break; default: refCenterX = sz1X; refCenterY = sz1Y; refCenterZ = sz1Z; refNormalX = z1X; refNormalY = z1Y; refNormalZ = z1Z; refXX = x1X; refXY = x1Y; refXZ = x1Z; refYX = y1X; refYY = y1Y; refYZ = y1Z; refW = w1; refH = h1; } if (mSign < 0) { refCenterX = -refCenterX; refCenterY = -refCenterY; refCenterZ = -refCenterZ; refNormalX = -refNormalX; refNormalY = -refNormalY; refNormalZ = -refNormalZ; tmpX = refXX; tmpY = refXY; tmpZ = refXZ; refXX = refYX; refXY = refYY; refXZ = refYZ; refYX = tmpX; refYY = tmpY; refYZ = tmpZ; var tmp = refW; refW = refH; refH = tmp; } refCenterX += c1X; refCenterY += c1Y; refCenterZ += c1Z; var minIncDot = 1; var incId = 0; var incDot = refNormalX * x2X + refNormalY * x2Y + refNormalZ * x2Z; if (incDot < minIncDot) { minIncDot = incDot; incId = 0; } if (-incDot < minIncDot) { minIncDot = -incDot; incId = 1; } incDot = refNormalX * y2X + refNormalY * y2Y + refNormalZ * y2Z; if (incDot < minIncDot) { minIncDot = incDot; incId = 2; } if (-incDot < minIncDot) { minIncDot = -incDot; incId = 3; } incDot = refNormalX * z2X + refNormalY * z2Y + refNormalZ * z2Z; if (incDot < minIncDot) { minIncDot = incDot; incId = 4; } if (-incDot < minIncDot) { incId = 5; } var incV1X; var incV1Y; var incV1Z; var incV2X; var incV2Y; var incV2Z; var incV3X; var incV3Y; var incV3Z; var incV4X; var incV4Y; var incV4Z; switch (incId) { case 0: incV1X = sx2X + sy2X; incV1Y = sx2Y + sy2Y; incV1Z = sx2Z + sy2Z; incV1X += sz2X; incV1Y += sz2Y; incV1Z += sz2Z; incV2X = sx2X - sy2X; incV2Y = sx2Y - sy2Y; incV2Z = sx2Z - sy2Z; incV2X += sz2X; incV2Y += sz2Y; incV2Z += sz2Z; incV3X = sx2X - sy2X; incV3Y = sx2Y - sy2Y; incV3Z = sx2Z - sy2Z; incV3X -= sz2X; incV3Y -= sz2Y; incV3Z -= sz2Z; incV4X = sx2X + sy2X; incV4Y = sx2Y + sy2Y; incV4Z = sx2Z + sy2Z; incV4X -= sz2X; incV4Y -= sz2Y; incV4Z -= sz2Z; break; case 1: incV1X = sy2X - sx2X; incV1Y = sy2Y - sx2Y; incV1Z = sy2Z - sx2Z; incV1X += sz2X; incV1Y += sz2Y; incV1Z += sz2Z; incV2X = sy2X - sx2X; incV2Y = sy2Y - sx2Y; incV2Z = sy2Z - sx2Z; incV2X -= sz2X; incV2Y -= sz2Y; incV2Z -= sz2Z; incV3X = sx2X + sy2X; incV3Y = sx2Y + sy2Y; incV3Z = sx2Z + sy2Z; incV3X = -incV3X; incV3Y = -incV3Y; incV3Z = -incV3Z; incV3X -= sz2X; incV3Y -= sz2Y; incV3Z -= sz2Z; incV4X = sx2X + sy2X; incV4Y = sx2Y + sy2Y; incV4Z = sx2Z + sy2Z; incV4X = -incV4X; incV4Y = -incV4Y; incV4Z = -incV4Z; incV4X += sz2X; incV4Y += sz2Y; incV4Z += sz2Z; break; case 2: incV1X = sx2X + sy2X; incV1Y = sx2Y + sy2Y; incV1Z = sx2Z + sy2Z; incV1X += sz2X; incV1Y += sz2Y; incV1Z += sz2Z; incV2X = sx2X + sy2X; incV2Y = sx2Y + sy2Y; incV2Z = sx2Z + sy2Z; incV2X -= sz2X; incV2Y -= sz2Y; incV2Z -= sz2Z; incV3X = sy2X - sx2X; incV3Y = sy2Y - sx2Y; incV3Z = sy2Z - sx2Z; incV3X -= sz2X; incV3Y -= sz2Y; incV3Z -= sz2Z; incV4X = sy2X - sx2X; incV4Y = sy2Y - sx2Y; incV4Z = sy2Z - sx2Z; incV4X += sz2X; incV4Y += sz2Y; incV4Z += sz2Z; break; case 3: incV1X = sx2X - sy2X; incV1Y = sx2Y - sy2Y; incV1Z = sx2Z - sy2Z; incV1X += sz2X; incV1Y += sz2Y; incV1Z += sz2Z; incV2X = sx2X + sy2X; incV2Y = sx2Y + sy2Y; incV2Z = sx2Z + sy2Z; incV2X = -incV2X; incV2Y = -incV2Y; incV2Z = -incV2Z; incV2X += sz2X; incV2Y += sz2Y; incV2Z += sz2Z; incV3X = sx2X + sy2X; incV3Y = sx2Y + sy2Y; incV3Z = sx2Z + sy2Z; incV3X = -incV3X; incV3Y = -incV3Y; incV3Z = -incV3Z; incV3X -= sz2X; incV3Y -= sz2Y; incV3Z -= sz2Z; incV4X = sx2X - sy2X; incV4Y = sx2Y - sy2Y; incV4Z = sx2Z - sy2Z; incV4X -= sz2X; incV4Y -= sz2Y; incV4Z -= sz2Z; break; case 4: incV1X = sx2X + sy2X; incV1Y = sx2Y + sy2Y; incV1Z = sx2Z + sy2Z; incV1X += sz2X; incV1Y += sz2Y; incV1Z += sz2Z; incV2X = sy2X - sx2X; incV2Y = sy2Y - sx2Y; incV2Z = sy2Z - sx2Z; incV2X += sz2X; incV2Y += sz2Y; incV2Z += sz2Z; incV3X = sx2X + sy2X; incV3Y = sx2Y + sy2Y; incV3Z = sx2Z + sy2Z; incV3X = -incV3X; incV3Y = -incV3Y; incV3Z = -incV3Z; incV3X += sz2X; incV3Y += sz2Y; incV3Z += sz2Z; incV4X = sx2X - sy2X; incV4Y = sx2Y - sy2Y; incV4Z = sx2Z - sy2Z; incV4X += sz2X; incV4Y += sz2Y; incV4Z += sz2Z; break; default: incV1X = sx2X + sy2X; incV1Y = sx2Y + sy2Y; incV1Z = sx2Z + sy2Z; incV1X -= sz2X; incV1Y -= sz2Y; incV1Z -= sz2Z; incV2X = sx2X - sy2X; incV2Y = sx2Y - sy2Y; incV2Z = sx2Z - sy2Z; incV2X -= sz2X; incV2Y -= sz2Y; incV2Z -= sz2Z; incV3X = sx2X + sy2X; incV3Y = sx2Y + sy2Y; incV3Z = sx2Z + sy2Z; incV3X = -incV3X; incV3Y = -incV3Y; incV3Z = -incV3Z; incV3X -= sz2X; incV3Y -= sz2Y; incV3Z -= sz2Z; incV4X = sy2X - sx2X; incV4Y = sy2Y - sx2Y; incV4Z = sy2Z - sx2Z; incV4X -= sz2X; incV4Y -= sz2Y; incV4Z -= sz2Z; } incV1X += c12X; incV1Y += c12Y; incV1Z += c12Z; incV2X += c12X; incV2Y += c12Y; incV2Z += c12Z; incV3X += c12X; incV3Y += c12Y; incV3Z += c12Z; incV4X += c12X; incV4Y += c12Y; incV4Z += c12Z; var _this = this.clipper; _this.w = refW; _this.h = refH; _this.numVertices = 0; _this.numTmpVertices = 0; var _this1 = this.clipper; var _this2 = _this1.vertices[_this1.numVertices++]; _this2.x = incV1X * refXX + incV1Y * refXY + incV1Z * refXZ; _this2.y = incV1X * refYX + incV1Y * refYY + incV1Z * refYZ; _this2.wx = incV1X; _this2.wy = incV1Y; _this2.wz = incV1Z; var _this3 = this.clipper; var _this4 = _this3.vertices[_this3.numVertices++]; _this4.x = incV2X * refXX + incV2Y * refXY + incV2Z * refXZ; _this4.y = incV2X * refYX + incV2Y * refYY + incV2Z * refYZ; _this4.wx = incV2X; _this4.wy = incV2Y; _this4.wz = incV2Z; var _this5 = this.clipper; var _this6 = _this5.vertices[_this5.numVertices++]; _this6.x = incV3X * refXX + incV3Y * refXY + incV3Z * refXZ; _this6.y = incV3X * refYX + incV3Y * refYY + incV3Z * refYZ; _this6.wx = incV3X; _this6.wy = incV3Y; _this6.wz = incV3Z; var _this7 = this.clipper; var _this8 = _this7.vertices[_this7.numVertices++]; _this8.x = incV4X * refXX + incV4Y * refXY + incV4Z * refXZ; _this8.y = incV4X * refYX + incV4Y * refYY + incV4Z * refYZ; _this8.wx = incV4X; _this8.wy = incV4Y; _this8.wz = incV4Z; this.clipper.clip(); this.clipper.reduce(); var normalX; var normalY; var normalZ; if (swapped) { normalX = refNormalX; normalY = refNormalY; normalZ = refNormalZ; } else { normalX = -refNormalX; normalY = -refNormalY; normalZ = -refNormalZ; } this.setNormal(result, normalX, normalY, normalZ); var _g = 0; var _g1 = this.clipper.numVertices; while (_g < _g1) { var i = _g++; var v = this.clipper.vertices[i]; var clippedVertexX = void 0; var clippedVertexY = void 0; var clippedVertexZ = void 0; clippedVertexX = v.wx; clippedVertexY = v.wy; clippedVertexZ = v.wz; clippedVertexX += c1X; clippedVertexY += c1Y; clippedVertexZ += c1Z; var clippedVertexToRefCenterX = void 0; var clippedVertexToRefCenterY = void 0; var clippedVertexToRefCenterZ = void 0; clippedVertexToRefCenterX = refCenterX - clippedVertexX; clippedVertexToRefCenterY = refCenterY - clippedVertexY; clippedVertexToRefCenterZ = refCenterZ - clippedVertexZ; var _depth15 = clippedVertexToRefCenterX * refNormalX + clippedVertexToRefCenterY * refNormalY + clippedVertexToRefCenterZ * refNormalZ; var clippedVertexOnRefFaceX = void 0; var clippedVertexOnRefFaceY = void 0; var clippedVertexOnRefFaceZ = void 0; clippedVertexOnRefFaceX = clippedVertexX + refNormalX * _depth15; clippedVertexOnRefFaceY = clippedVertexY + refNormalY * _depth15; clippedVertexOnRefFaceZ = clippedVertexZ + refNormalZ * _depth15; if (_depth15 > -oimo.common.Setting.contactPersistenceThreshold) { if (swapped) { this.addPoint(result, clippedVertexX, clippedVertexY, clippedVertexZ, clippedVertexOnRefFaceX, clippedVertexOnRefFaceY, clippedVertexOnRefFaceZ, _depth15, i); } else { this.addPoint(result, clippedVertexOnRefFaceX, clippedVertexOnRefFaceY, clippedVertexOnRefFaceZ, clippedVertexX, clippedVertexY, clippedVertexZ, _depth15, i); } } } } }]); return oimo_collision_narrowphase_detector_BoxBoxDetector; }(oimo.collision.narrowphase.detector.Detector); if (!oimo.collision.narrowphase.detector._BoxBoxDetector) oimo.collision.narrowphase.detector._BoxBoxDetector = {}; oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex = /*#__PURE__*/_createClass(function oimo_collision_narrowphase_detector__$BoxBoxDetector_IncidentVertex() { _classCallCheck(this, oimo_collision_narrowphase_detector__$BoxBoxDetector_IncidentVertex); this.x = 0; this.y = 0; this.wx = 0; this.wy = 0; this.wz = 0; }); oimo.collision.narrowphase.detector._BoxBoxDetector.FaceClipper = /*#__PURE__*/function () { function oimo_collision_narrowphase_detector__$BoxBoxDetector_FaceClipper() { _classCallCheck(this, oimo_collision_narrowphase_detector__$BoxBoxDetector_FaceClipper); this.w = 0; this.h = 0; this.numVertices = 0; this.numTmpVertices = 0; this.vertices = new Array(8); this.tmpVertices = new Array(8); this.vertices[0] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.tmpVertices[0] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.vertices[1] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.tmpVertices[1] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.vertices[2] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.tmpVertices[2] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.vertices[3] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.tmpVertices[3] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.vertices[4] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.tmpVertices[4] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.vertices[5] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.tmpVertices[5] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.vertices[6] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.tmpVertices[6] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.vertices[7] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); this.tmpVertices[7] = new oimo.collision.narrowphase.detector._BoxBoxDetector.IncidentVertex(); } _createClass(oimo_collision_narrowphase_detector__$BoxBoxDetector_FaceClipper, [{ key: "clip", value: function clip() { var _g = 0; var _g1 = this.numVertices; while (_g < _g1) { var i = _g++; var v1 = this.vertices[i]; var v2 = this.vertices[(i + 1) % this.numVertices]; var s1 = this.w + v1.x; var s2 = this.w + v2.x; if (s1 > 0 && s2 > 0) { var _this = this.tmpVertices[this.numTmpVertices++]; _this.x = v1.x; _this.y = v1.y; _this.wx = v1.wx; _this.wy = v1.wy; _this.wz = v1.wz; } else if (s1 > 0 && s2 <= 0) { var _this55 = this.tmpVertices[this.numTmpVertices++]; _this55.x = v1.x; _this55.y = v1.y; _this55.wx = v1.wx; _this55.wy = v1.wy; _this55.wz = v1.wz; var t = s1 / (s1 - s2); var _this1 = this.tmpVertices[this.numTmpVertices++]; _this1.x = v1.x + (v2.x - v1.x) * t; _this1.y = v1.y + (v2.y - v1.y) * t; _this1.wx = v1.wx + (v2.wx - v1.wx) * t; _this1.wy = v1.wy + (v2.wy - v1.wy) * t; _this1.wz = v1.wz + (v2.wz - v1.wz) * t; } else if (s1 <= 0 && s2 > 0) { var _t5 = s1 / (s1 - s2); var _this56 = this.tmpVertices[this.numTmpVertices++]; _this56.x = v1.x + (v2.x - v1.x) * _t5; _this56.y = v1.y + (v2.y - v1.y) * _t5; _this56.wx = v1.wx + (v2.wx - v1.wx) * _t5; _this56.wy = v1.wy + (v2.wy - v1.wy) * _t5; _this56.wz = v1.wz + (v2.wz - v1.wz) * _t5; } } var tmp = this.vertices; this.vertices = this.tmpVertices; this.tmpVertices = tmp; this.numVertices = this.numTmpVertices; this.numTmpVertices = 0; var _g2 = 0; var _g3 = this.numVertices; while (_g2 < _g3) { var _i = _g2++; var _v5 = this.vertices[_i]; var _v6 = this.vertices[(_i + 1) % this.numVertices]; var _s = this.w - _v5.x; var _s2 = this.w - _v6.x; if (_s > 0 && _s2 > 0) { var _this57 = this.tmpVertices[this.numTmpVertices++]; _this57.x = _v5.x; _this57.y = _v5.y; _this57.wx = _v5.wx; _this57.wy = _v5.wy; _this57.wz = _v5.wz; } else if (_s > 0 && _s2 <= 0) { var _this58 = this.tmpVertices[this.numTmpVertices++]; _this58.x = _v5.x; _this58.y = _v5.y; _this58.wx = _v5.wx; _this58.wy = _v5.wy; _this58.wz = _v5.wz; var _t6 = _s / (_s - _s2); var _this59 = this.tmpVertices[this.numTmpVertices++]; _this59.x = _v5.x + (_v6.x - _v5.x) * _t6; _this59.y = _v5.y + (_v6.y - _v5.y) * _t6; _this59.wx = _v5.wx + (_v6.wx - _v5.wx) * _t6; _this59.wy = _v5.wy + (_v6.wy - _v5.wy) * _t6; _this59.wz = _v5.wz + (_v6.wz - _v5.wz) * _t6; } else if (_s <= 0 && _s2 > 0) { var _t7 = _s / (_s - _s2); var _this60 = this.tmpVertices[this.numTmpVertices++]; _this60.x = _v5.x + (_v6.x - _v5.x) * _t7; _this60.y = _v5.y + (_v6.y - _v5.y) * _t7; _this60.wx = _v5.wx + (_v6.wx - _v5.wx) * _t7; _this60.wy = _v5.wy + (_v6.wy - _v5.wy) * _t7; _this60.wz = _v5.wz + (_v6.wz - _v5.wz) * _t7; } } var tmp1 = this.vertices; this.vertices = this.tmpVertices; this.tmpVertices = tmp1; this.numVertices = this.numTmpVertices; this.numTmpVertices = 0; var _g4 = 0; var _g5 = this.numVertices; while (_g4 < _g5) { var _i2 = _g4++; var _v7 = this.vertices[_i2]; var _v8 = this.vertices[(_i2 + 1) % this.numVertices]; var _s3 = this.h + _v7.y; var _s4 = this.h + _v8.y; if (_s3 > 0 && _s4 > 0) { var _this61 = this.tmpVertices[this.numTmpVertices++]; _this61.x = _v7.x; _this61.y = _v7.y; _this61.wx = _v7.wx; _this61.wy = _v7.wy; _this61.wz = _v7.wz; } else if (_s3 > 0 && _s4 <= 0) { var _this62 = this.tmpVertices[this.numTmpVertices++]; _this62.x = _v7.x; _this62.y = _v7.y; _this62.wx = _v7.wx; _this62.wy = _v7.wy; _this62.wz = _v7.wz; var _t8 = _s3 / (_s3 - _s4); var _this63 = this.tmpVertices[this.numTmpVertices++]; _this63.x = _v7.x + (_v8.x - _v7.x) * _t8; _this63.y = _v7.y + (_v8.y - _v7.y) * _t8; _this63.wx = _v7.wx + (_v8.wx - _v7.wx) * _t8; _this63.wy = _v7.wy + (_v8.wy - _v7.wy) * _t8; _this63.wz = _v7.wz + (_v8.wz - _v7.wz) * _t8; } else if (_s3 <= 0 && _s4 > 0) { var _t9 = _s3 / (_s3 - _s4); var _this64 = this.tmpVertices[this.numTmpVertices++]; _this64.x = _v7.x + (_v8.x - _v7.x) * _t9; _this64.y = _v7.y + (_v8.y - _v7.y) * _t9; _this64.wx = _v7.wx + (_v8.wx - _v7.wx) * _t9; _this64.wy = _v7.wy + (_v8.wy - _v7.wy) * _t9; _this64.wz = _v7.wz + (_v8.wz - _v7.wz) * _t9; } } var tmp2 = this.vertices; this.vertices = this.tmpVertices; this.tmpVertices = tmp2; this.numVertices = this.numTmpVertices; this.numTmpVertices = 0; var _g6 = 0; var _g7 = this.numVertices; while (_g6 < _g7) { var _i3 = _g6++; var _v9 = this.vertices[_i3]; var _v10 = this.vertices[(_i3 + 1) % this.numVertices]; var _s5 = this.h - _v9.y; var _s6 = this.h - _v10.y; if (_s5 > 0 && _s6 > 0) { var _this65 = this.tmpVertices[this.numTmpVertices++]; _this65.x = _v9.x; _this65.y = _v9.y; _this65.wx = _v9.wx; _this65.wy = _v9.wy; _this65.wz = _v9.wz; } else if (_s5 > 0 && _s6 <= 0) { var _this66 = this.tmpVertices[this.numTmpVertices++]; _this66.x = _v9.x; _this66.y = _v9.y; _this66.wx = _v9.wx; _this66.wy = _v9.wy; _this66.wz = _v9.wz; var _t10 = _s5 / (_s5 - _s6); var _this67 = this.tmpVertices[this.numTmpVertices++]; _this67.x = _v9.x + (_v10.x - _v9.x) * _t10; _this67.y = _v9.y + (_v10.y - _v9.y) * _t10; _this67.wx = _v9.wx + (_v10.wx - _v9.wx) * _t10; _this67.wy = _v9.wy + (_v10.wy - _v9.wy) * _t10; _this67.wz = _v9.wz + (_v10.wz - _v9.wz) * _t10; } else if (_s5 <= 0 && _s6 > 0) { var _t11 = _s5 / (_s5 - _s6); var _this68 = this.tmpVertices[this.numTmpVertices++]; _this68.x = _v9.x + (_v10.x - _v9.x) * _t11; _this68.y = _v9.y + (_v10.y - _v9.y) * _t11; _this68.wx = _v9.wx + (_v10.wx - _v9.wx) * _t11; _this68.wy = _v9.wy + (_v10.wy - _v9.wy) * _t11; _this68.wz = _v9.wz + (_v10.wz - _v9.wz) * _t11; } } var tmp3 = this.vertices; this.vertices = this.tmpVertices; this.tmpVertices = tmp3; this.numVertices = this.numTmpVertices; this.numTmpVertices = 0; } }, { key: "reduce", value: function reduce() { if (this.numVertices < 4) { return; } var max1 = -1e65536; var min1 = 1e65536; var max2 = -1e65536; var min2 = 1e65536; var max1V = null; var min1V = null; var max2V = null; var min2V = null; var e1x = 1; var e1y = 1; var e2x = -1; var e2y = 1; var _g = 0; var _g1 = this.numVertices; while (_g < _g1) { var v = this.vertices[_g++]; var dot1 = v.x * e1x + v.y * e1y; var dot2 = v.x * e2x + v.y * e2y; if (dot1 > max1) { max1 = dot1; max1V = v; } if (dot1 < min1) { min1 = dot1; min1V = v; } if (dot2 > max2) { max2 = dot2; max2V = v; } if (dot2 < min2) { min2 = dot2; min2V = v; } } var _this = this.tmpVertices[this.numTmpVertices++]; _this.x = max1V.x; _this.y = max1V.y; _this.wx = max1V.wx; _this.wy = max1V.wy; _this.wz = max1V.wz; var _this1 = this.tmpVertices[this.numTmpVertices++]; _this1.x = max2V.x; _this1.y = max2V.y; _this1.wx = max2V.wx; _this1.wy = max2V.wy; _this1.wz = max2V.wz; var _this2 = this.tmpVertices[this.numTmpVertices++]; _this2.x = min1V.x; _this2.y = min1V.y; _this2.wx = min1V.wx; _this2.wy = min1V.wy; _this2.wz = min1V.wz; var _this3 = this.tmpVertices[this.numTmpVertices++]; _this3.x = min2V.x; _this3.y = min2V.y; _this3.wx = min2V.wx; _this3.wy = min2V.wy; _this3.wz = min2V.wz; var tmp = this.vertices; this.vertices = this.tmpVertices; this.tmpVertices = tmp; this.numVertices = this.numTmpVertices; this.numTmpVertices = 0; } }]); return oimo_collision_narrowphase_detector__$BoxBoxDetector_FaceClipper; }(); oimo.collision.narrowphase.detector.BoxBoxDetectorMacro = /*#__PURE__*/_createClass(function oimo_collision_narrowphase_detector_BoxBoxDetectorMacro() { _classCallCheck(this, oimo_collision_narrowphase_detector_BoxBoxDetectorMacro); }); oimo.collision.narrowphase.detector.CachedDetectorData = /*#__PURE__*/function () { function oimo_collision_narrowphase_detector_CachedDetectorData() { _classCallCheck(this, oimo_collision_narrowphase_detector_CachedDetectorData); } _createClass(oimo_collision_narrowphase_detector_CachedDetectorData, [{ key: "_clear", value: function _clear() { if (this._gjkCache != null) { this._gjkCache.clear(); } } }]); return oimo_collision_narrowphase_detector_CachedDetectorData; }(); oimo.collision.narrowphase.detector.CapsuleCapsuleDetector = /*#__PURE__*/function (_oimo$collision$narro2) { _inherits(oimo_collision_narrowphase_detector_CapsuleCapsuleDetector, _oimo$collision$narro2); var _super14 = _createSuper(oimo_collision_narrowphase_detector_CapsuleCapsuleDetector); function oimo_collision_narrowphase_detector_CapsuleCapsuleDetector() { _classCallCheck(this, oimo_collision_narrowphase_detector_CapsuleCapsuleDetector); return _super14.call(this, false); } _createClass(oimo_collision_narrowphase_detector_CapsuleCapsuleDetector, [{ key: "detectImpl", value: function detectImpl(result, geom1, geom2, tf1, tf2, cachedData) { var c1 = geom1; var c2 = geom2; result.incremental = false; var axis1X; var axis1Y; var axis1Z; var axis2X; var axis2Y; var axis2Z; axis1X = tf1._rotation01; axis1Y = tf1._rotation11; axis1Z = tf1._rotation21; axis2X = tf2._rotation01; axis2Y = tf2._rotation11; axis2Z = tf2._rotation21; var hh1 = c1._halfHeight; var hh2 = c2._halfHeight; var r1 = c1._radius; var r2 = c2._radius; var p1X; var p1Y; var p1Z; var q1X; var q1Y; var q1Z; var p2X; var p2Y; var p2Z; var q2X; var q2Y; var q2Z; p1X = tf1._positionX + axis1X * -hh1; p1Y = tf1._positionY + axis1Y * -hh1; p1Z = tf1._positionZ + axis1Z * -hh1; q1X = tf1._positionX + axis1X * hh1; q1Y = tf1._positionY + axis1Y * hh1; q1Z = tf1._positionZ + axis1Z * hh1; p2X = tf2._positionX + axis2X * -hh2; p2Y = tf2._positionY + axis2Y * -hh2; p2Z = tf2._positionZ + axis2Z * -hh2; q2X = tf2._positionX + axis2X * hh2; q2Y = tf2._positionY + axis2Y * hh2; q2Z = tf2._positionZ + axis2Z * hh2; var p12X; var p12Y; var p12Z; p12X = p1X - p2X; p12Y = p1Y - p2Y; p12Z = p1Z - p2Z; var d1X; var d1Y; var d1Z; var d2X; var d2Y; var d2Z; d1X = q1X - p1X; d1Y = q1Y - p1Y; d1Z = q1Z - p1Z; d2X = q2X - p2X; d2Y = q2Y - p2Y; d2Z = q2Z - p2Z; var p21d1 = -(p12X * d1X + p12Y * d1Y + p12Z * d1Z); var p12d2 = p12X * d2X + p12Y * d2Y + p12Z * d2Z; var d11 = hh1 * hh1 * 4; var d12 = d1X * d2X + d1Y * d2Y + d1Z * d2Z; var d22 = hh2 * hh2 * 4; var t1; var t2; if (d11 == 0 && d22 == 0) { t1 = 0; t2 = 0; } else if (d11 == 0) { t1 = 0; if (p12d2 < 0) { t2 = 0; } else if (p12d2 > d22) { t2 = 1; } else { t2 = p12d2 / d22; } } else if (d22 == 0) { t2 = 0; if (p21d1 < 0) { t1 = 0; } else if (p21d1 > d11) { t1 = 1; } else { t1 = p21d1 / d11; } } else { var det = d11 * d22 - d12 * d12; if (det == 0) { t1 = 0; } else { t1 = d12 * p12d2 + d22 * p21d1; if (t1 < 0) { t1 = 0; } else if (t1 > det) { t1 = 1; } else { t1 /= det; } } t2 = t1 * d12 + p12d2; if (t2 < 0) { t2 = 0; if (p21d1 < 0) { t1 = 0; } else if (p21d1 > d11) { t1 = 1; } else { t1 = p21d1 / d11; } } else if (t2 > d22) { t2 = 1; t1 = d12 + p21d1; if (t1 < 0) { t1 = 0; } else if (t1 > d11) { t1 = 1; } else { t1 /= d11; } } else { t2 /= d22; } } var cp1X; var cp1Y; var cp1Z; var cp2X; var cp2Y; var cp2Z; cp1X = p1X + d1X * t1; cp1Y = p1Y + d1Y * t1; cp1Z = p1Z + d1Z * t1; cp2X = p2X + d2X * t2; cp2Y = p2Y + d2Y * t2; cp2Z = p2Z + d2Z * t2; var dX; var dY; var dZ; dX = cp1X - cp2X; dY = cp1Y - cp2Y; dZ = cp1Z - cp2Z; var len2 = dX * dX + dY * dY + dZ * dZ; if (len2 >= (r1 + r2) * (r1 + r2)) { return; } var len = Math.sqrt(len2); var nX; var nY; var nZ; if (len > 0) { nX = dX * (1 / len); nY = dY * (1 / len); nZ = dZ * (1 / len); } else { nX = 1; nY = 0; nZ = 0; } this.setNormal(result, nX, nY, nZ); var pos1X; var pos1Y; var pos1Z; var pos2X; var pos2Y; var pos2Z; pos1X = cp1X + nX * -r1; pos1Y = cp1Y + nY * -r1; pos1Z = cp1Z + nZ * -r1; pos2X = cp2X + nX * r2; pos2Y = cp2Y + nY * r2; pos2Z = cp2Z + nZ * r2; this.addPoint(result, pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, r1 + r2 - len, 0); } }]); return oimo_collision_narrowphase_detector_CapsuleCapsuleDetector; }(oimo.collision.narrowphase.detector.Detector); oimo.collision.narrowphase.detector.GjkEpaDetector = /*#__PURE__*/function (_oimo$collision$narro3) { _inherits(oimo_collision_narrowphase_detector_GjkEpaDetector, _oimo$collision$narro3); var _super15 = _createSuper(oimo_collision_narrowphase_detector_GjkEpaDetector); function oimo_collision_narrowphase_detector_GjkEpaDetector() { _classCallCheck(this, oimo_collision_narrowphase_detector_GjkEpaDetector); return _super15.call(this, false); } _createClass(oimo_collision_narrowphase_detector_GjkEpaDetector, [{ key: "detectImpl", value: function detectImpl(result, geom1, geom2, tf1, tf2, cachedData) { var gjkEpa = oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance; var g1 = geom1; var g2 = geom2; var status = gjkEpa.computeClosestPointsImpl(g1, g2, tf1, tf2, oimo.common.Setting.enableGJKCaching ? cachedData : null, true); result.incremental = true; if (status != oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.SUCCEEDED) { console.log("src/oimo/collision/narrowphase/detector/GjkEpaDetector.hx:28:", "GJK/EPA failed: status=" + status); return; } if (gjkEpa.distance > g1._gjkMargin + g2._gjkMargin) { return; } var pos1X; var pos1Y; var pos1Z; var pos2X; var pos2Y; var pos2Z; var v = gjkEpa.closestPoint1; pos1X = v.x; pos1Y = v.y; pos1Z = v.z; var v1 = gjkEpa.closestPoint2; pos2X = v1.x; pos2Y = v1.y; pos2Z = v1.z; var normalX; var normalY; var normalZ; normalX = pos1X - pos2X; normalY = pos1Y - pos2Y; normalZ = pos1Z - pos2Z; if (normalX * normalX + normalY * normalY + normalZ * normalZ == 0) { return; } if (gjkEpa.distance < 0) { normalX = -normalX; normalY = -normalY; normalZ = -normalZ; } var l = normalX * normalX + normalY * normalY + normalZ * normalZ; if (l > 0) { l = 1 / Math.sqrt(l); } normalX *= l; normalY *= l; normalZ *= l; this.setNormal(result, normalX, normalY, normalZ); pos1X += normalX * -g1._gjkMargin; pos1Y += normalY * -g1._gjkMargin; pos1Z += normalZ * -g1._gjkMargin; pos2X += normalX * g2._gjkMargin; pos2Y += normalY * g2._gjkMargin; pos2Z += normalZ * g2._gjkMargin; this.addPoint(result, pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, g1._gjkMargin + g2._gjkMargin - gjkEpa.distance, 0); } }]); return oimo_collision_narrowphase_detector_GjkEpaDetector; }(oimo.collision.narrowphase.detector.Detector); oimo.collision.narrowphase.detector.SphereBoxDetector = /*#__PURE__*/function (_oimo$collision$narro4) { _inherits(oimo_collision_narrowphase_detector_SphereBoxDetector, _oimo$collision$narro4); var _super16 = _createSuper(oimo_collision_narrowphase_detector_SphereBoxDetector); function oimo_collision_narrowphase_detector_SphereBoxDetector(swapped) { _classCallCheck(this, oimo_collision_narrowphase_detector_SphereBoxDetector); return _super16.call(this, swapped); } _createClass(oimo_collision_narrowphase_detector_SphereBoxDetector, [{ key: "detectImpl", value: function detectImpl(result, geom1, geom2, tf1, tf2, cachedData) { var b = geom2; result.incremental = false; var halfExtX; var halfExtY; var halfExtZ; var negHalfExtX; var negHalfExtY; var negHalfExtZ; halfExtX = b._halfExtentsX; halfExtY = b._halfExtentsY; halfExtZ = b._halfExtentsZ; negHalfExtX = -halfExtX; negHalfExtY = -halfExtY; negHalfExtZ = -halfExtZ; var r = geom1._radius; var boxToSphereX; var boxToSphereY; var boxToSphereZ; boxToSphereX = tf1._positionX - tf2._positionX; boxToSphereY = tf1._positionY - tf2._positionY; boxToSphereZ = tf1._positionZ - tf2._positionZ; var boxToSphereInBoxX; var boxToSphereInBoxY; var boxToSphereInBoxZ; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = tf2._rotation00 * boxToSphereX + tf2._rotation10 * boxToSphereY + tf2._rotation20 * boxToSphereZ; __tmp__Y = tf2._rotation01 * boxToSphereX + tf2._rotation11 * boxToSphereY + tf2._rotation21 * boxToSphereZ; __tmp__Z = tf2._rotation02 * boxToSphereX + tf2._rotation12 * boxToSphereY + tf2._rotation22 * boxToSphereZ; boxToSphereInBoxX = __tmp__X; boxToSphereInBoxY = __tmp__Y; boxToSphereInBoxZ = __tmp__Z; if (negHalfExtX < boxToSphereInBoxX && halfExtX > boxToSphereInBoxX && negHalfExtY < boxToSphereInBoxY && halfExtY > boxToSphereInBoxY && negHalfExtZ < boxToSphereInBoxZ && halfExtZ > boxToSphereInBoxZ) { var sphereToBoxSurfaceX; var sphereToBoxSurfaceY; var sphereToBoxSurfaceZ; sphereToBoxSurfaceX = boxToSphereInBoxX < 0 ? -boxToSphereInBoxX : boxToSphereInBoxX; sphereToBoxSurfaceY = boxToSphereInBoxY < 0 ? -boxToSphereInBoxY : boxToSphereInBoxY; sphereToBoxSurfaceZ = boxToSphereInBoxZ < 0 ? -boxToSphereInBoxZ : boxToSphereInBoxZ; sphereToBoxSurfaceX = halfExtX - sphereToBoxSurfaceX; sphereToBoxSurfaceY = halfExtY - sphereToBoxSurfaceY; sphereToBoxSurfaceZ = halfExtZ - sphereToBoxSurfaceZ; var normalInBoxX; var normalInBoxY; var normalInBoxZ; var distX = sphereToBoxSurfaceX; var distY = sphereToBoxSurfaceY; var distZ = sphereToBoxSurfaceZ; var depth; var projectionMaskX; var projectionMaskY; var projectionMaskZ; if (distX < distY) { if (distX < distZ) { if (boxToSphereInBoxX > 0) { normalInBoxX = 1; normalInBoxY = 0; normalInBoxZ = 0; } else { normalInBoxX = -1; normalInBoxY = 0; normalInBoxZ = 0; } projectionMaskX = 0; projectionMaskY = 1; projectionMaskZ = 1; depth = distX; } else { if (boxToSphereInBoxZ > 0) { normalInBoxX = 0; normalInBoxY = 0; normalInBoxZ = 1; } else { normalInBoxX = 0; normalInBoxY = 0; normalInBoxZ = -1; } projectionMaskX = 1; projectionMaskY = 1; projectionMaskZ = 0; depth = distZ; } } else if (distY < distZ) { if (boxToSphereInBoxY > 0) { normalInBoxX = 0; normalInBoxY = 1; normalInBoxZ = 0; } else { normalInBoxX = 0; normalInBoxY = -1; normalInBoxZ = 0; } projectionMaskX = 1; projectionMaskY = 0; projectionMaskZ = 1; depth = distY; } else { if (boxToSphereInBoxZ > 0) { normalInBoxX = 0; normalInBoxY = 0; normalInBoxZ = 1; } else { normalInBoxX = 0; normalInBoxY = 0; normalInBoxZ = -1; } projectionMaskX = 1; projectionMaskY = 1; projectionMaskZ = 0; depth = distZ; } var baseX; var baseY; var baseZ; baseX = projectionMaskX * boxToSphereInBoxX; baseY = projectionMaskY * boxToSphereInBoxY; baseZ = projectionMaskZ * boxToSphereInBoxZ; var _boxToClosestPointInBoxX; var _boxToClosestPointInBoxY; var _boxToClosestPointInBoxZ; _boxToClosestPointInBoxX = normalInBoxX * halfExtX; _boxToClosestPointInBoxY = normalInBoxY * halfExtY; _boxToClosestPointInBoxZ = normalInBoxZ * halfExtZ; _boxToClosestPointInBoxX += baseX; _boxToClosestPointInBoxY += baseY; _boxToClosestPointInBoxZ += baseZ; var _boxToClosestPointX; var _boxToClosestPointY; var _boxToClosestPointZ; var _normalX2; var _normalY2; var _normalZ2; var _tmp__X4; var _tmp__Y4; var _tmp__Z4; _tmp__X4 = tf2._rotation00 * _boxToClosestPointInBoxX + tf2._rotation01 * _boxToClosestPointInBoxY + tf2._rotation02 * _boxToClosestPointInBoxZ; _tmp__Y4 = tf2._rotation10 * _boxToClosestPointInBoxX + tf2._rotation11 * _boxToClosestPointInBoxY + tf2._rotation12 * _boxToClosestPointInBoxZ; _tmp__Z4 = tf2._rotation20 * _boxToClosestPointInBoxX + tf2._rotation21 * _boxToClosestPointInBoxY + tf2._rotation22 * _boxToClosestPointInBoxZ; _boxToClosestPointX = _tmp__X4; _boxToClosestPointY = _tmp__Y4; _boxToClosestPointZ = _tmp__Z4; var _tmp__X5; var _tmp__Y5; var _tmp__Z5; _tmp__X5 = tf2._rotation00 * normalInBoxX + tf2._rotation01 * normalInBoxY + tf2._rotation02 * normalInBoxZ; _tmp__Y5 = tf2._rotation10 * normalInBoxX + tf2._rotation11 * normalInBoxY + tf2._rotation12 * normalInBoxZ; _tmp__Z5 = tf2._rotation20 * normalInBoxX + tf2._rotation21 * normalInBoxY + tf2._rotation22 * normalInBoxZ; _normalX2 = _tmp__X5; _normalY2 = _tmp__Y5; _normalZ2 = _tmp__Z5; this.setNormal(result, _normalX2, _normalY2, _normalZ2); var _pos1X; var _pos1Y; var _pos1Z; var _pos2X; var _pos2Y; var _pos2Z; _pos1X = tf1._positionX + _normalX2 * -r; _pos1Y = tf1._positionY + _normalY2 * -r; _pos1Z = tf1._positionZ + _normalZ2 * -r; _pos2X = tf2._positionX + _boxToClosestPointX; _pos2Y = tf2._positionY + _boxToClosestPointY; _pos2Z = tf2._positionZ + _boxToClosestPointZ; this.addPoint(result, _pos1X, _pos1Y, _pos1Z, _pos2X, _pos2Y, _pos2Z, depth, 0); return; } var boxToClosestPointInBoxX; var boxToClosestPointInBoxY; var boxToClosestPointInBoxZ; halfExtX -= 1e-9; halfExtY -= 1e-9; halfExtZ -= 1e-9; negHalfExtX += 1e-9; negHalfExtY += 1e-9; negHalfExtZ += 1e-9; boxToClosestPointInBoxX = boxToSphereInBoxX < halfExtX ? boxToSphereInBoxX : halfExtX; boxToClosestPointInBoxY = boxToSphereInBoxY < halfExtY ? boxToSphereInBoxY : halfExtY; boxToClosestPointInBoxZ = boxToSphereInBoxZ < halfExtZ ? boxToSphereInBoxZ : halfExtZ; if (!(boxToClosestPointInBoxX > negHalfExtX)) { boxToClosestPointInBoxX = negHalfExtX; } if (!(boxToClosestPointInBoxY > negHalfExtY)) { boxToClosestPointInBoxY = negHalfExtY; } if (!(boxToClosestPointInBoxZ > negHalfExtZ)) { boxToClosestPointInBoxZ = negHalfExtZ; } var closestPointToSphereInBoxX; var closestPointToSphereInBoxY; var closestPointToSphereInBoxZ; closestPointToSphereInBoxX = boxToSphereInBoxX - boxToClosestPointInBoxX; closestPointToSphereInBoxY = boxToSphereInBoxY - boxToClosestPointInBoxY; closestPointToSphereInBoxZ = boxToSphereInBoxZ - boxToClosestPointInBoxZ; var dist = closestPointToSphereInBoxX * closestPointToSphereInBoxX + closestPointToSphereInBoxY * closestPointToSphereInBoxY + closestPointToSphereInBoxZ * closestPointToSphereInBoxZ; if (dist >= r * r) { return; } dist = Math.sqrt(dist); var boxToClosestPointX; var boxToClosestPointY; var boxToClosestPointZ; var closestPointToSphereX; var closestPointToSphereY; var closestPointToSphereZ; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = tf2._rotation00 * boxToClosestPointInBoxX + tf2._rotation01 * boxToClosestPointInBoxY + tf2._rotation02 * boxToClosestPointInBoxZ; __tmp__Y1 = tf2._rotation10 * boxToClosestPointInBoxX + tf2._rotation11 * boxToClosestPointInBoxY + tf2._rotation12 * boxToClosestPointInBoxZ; __tmp__Z1 = tf2._rotation20 * boxToClosestPointInBoxX + tf2._rotation21 * boxToClosestPointInBoxY + tf2._rotation22 * boxToClosestPointInBoxZ; boxToClosestPointX = __tmp__X1; boxToClosestPointY = __tmp__Y1; boxToClosestPointZ = __tmp__Z1; var __tmp__X2; var __tmp__Y2; var __tmp__Z2; __tmp__X2 = tf2._rotation00 * closestPointToSphereInBoxX + tf2._rotation01 * closestPointToSphereInBoxY + tf2._rotation02 * closestPointToSphereInBoxZ; __tmp__Y2 = tf2._rotation10 * closestPointToSphereInBoxX + tf2._rotation11 * closestPointToSphereInBoxY + tf2._rotation12 * closestPointToSphereInBoxZ; __tmp__Z2 = tf2._rotation20 * closestPointToSphereInBoxX + tf2._rotation21 * closestPointToSphereInBoxY + tf2._rotation22 * closestPointToSphereInBoxZ; closestPointToSphereX = __tmp__X2; closestPointToSphereY = __tmp__Y2; closestPointToSphereZ = __tmp__Z2; var normalX; var normalY; var normalZ; var l = closestPointToSphereX * closestPointToSphereX + closestPointToSphereY * closestPointToSphereY + closestPointToSphereZ * closestPointToSphereZ; if (l > 0) { l = 1 / Math.sqrt(l); } normalX = closestPointToSphereX * l; normalY = closestPointToSphereY * l; normalZ = closestPointToSphereZ * l; this.setNormal(result, normalX, normalY, normalZ); var pos1X; var pos1Y; var pos1Z; var pos2X; var pos2Y; var pos2Z; pos1X = tf1._positionX + normalX * -r; pos1Y = tf1._positionY + normalY * -r; pos1Z = tf1._positionZ + normalZ * -r; pos2X = tf2._positionX + boxToClosestPointX; pos2Y = tf2._positionY + boxToClosestPointY; pos2Z = tf2._positionZ + boxToClosestPointZ; this.addPoint(result, pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, r - dist, 0); } }]); return oimo_collision_narrowphase_detector_SphereBoxDetector; }(oimo.collision.narrowphase.detector.Detector); oimo.collision.narrowphase.detector.SphereCapsuleDetector = /*#__PURE__*/function (_oimo$collision$narro5) { _inherits(oimo_collision_narrowphase_detector_SphereCapsuleDetector, _oimo$collision$narro5); var _super17 = _createSuper(oimo_collision_narrowphase_detector_SphereCapsuleDetector); function oimo_collision_narrowphase_detector_SphereCapsuleDetector(swapped) { _classCallCheck(this, oimo_collision_narrowphase_detector_SphereCapsuleDetector); return _super17.call(this, swapped); } _createClass(oimo_collision_narrowphase_detector_SphereCapsuleDetector, [{ key: "detectImpl", value: function detectImpl(result, geom1, geom2, tf1, tf2, cachedData) { var c2 = geom2; result.incremental = false; var hh2 = c2._halfHeight; var r1 = geom1._radius; var r2 = c2._radius; var axis2X; var axis2Y; var axis2Z; axis2X = tf2._rotation01; axis2Y = tf2._rotation11; axis2Z = tf2._rotation21; var cp1X; var cp1Y; var cp1Z; cp1X = tf1._positionX; cp1Y = tf1._positionY; cp1Z = tf1._positionZ; var p2X; var p2Y; var p2Z; var q2X; var q2Y; var q2Z; p2X = tf2._positionX + axis2X * -hh2; p2Y = tf2._positionY + axis2Y * -hh2; p2Z = tf2._positionZ + axis2Z * -hh2; q2X = tf2._positionX + axis2X * hh2; q2Y = tf2._positionY + axis2Y * hh2; q2Z = tf2._positionZ + axis2Z * hh2; var p12X; var p12Y; var p12Z; p12X = cp1X - p2X; p12Y = cp1Y - p2Y; p12Z = cp1Z - p2Z; var d2X; var d2Y; var d2Z; d2X = q2X - p2X; d2Y = q2Y - p2Y; d2Z = q2Z - p2Z; var d22 = hh2 * hh2 * 4; var t = p12X * d2X + p12Y * d2Y + p12Z * d2Z; if (t < 0) { t = 0; } else if (t > d22) { t = 1; } else { t /= d22; } var cp2X; var cp2Y; var cp2Z; cp2X = p2X + d2X * t; cp2Y = p2Y + d2Y * t; cp2Z = p2Z + d2Z * t; var dX; var dY; var dZ; dX = cp1X - cp2X; dY = cp1Y - cp2Y; dZ = cp1Z - cp2Z; var len2 = dX * dX + dY * dY + dZ * dZ; if (len2 >= (r1 + r2) * (r1 + r2)) { return; } var len = Math.sqrt(len2); var nX; var nY; var nZ; if (len > 0) { nX = dX * (1 / len); nY = dY * (1 / len); nZ = dZ * (1 / len); } else { nX = 1; nY = 0; nZ = 0; } this.setNormal(result, nX, nY, nZ); var pos1X; var pos1Y; var pos1Z; var pos2X; var pos2Y; var pos2Z; pos1X = cp1X + nX * -r1; pos1Y = cp1Y + nY * -r1; pos1Z = cp1Z + nZ * -r1; pos2X = cp2X + nX * r2; pos2Y = cp2Y + nY * r2; pos2Z = cp2Z + nZ * r2; this.addPoint(result, pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, r1 + r2 - len, 0); } }]); return oimo_collision_narrowphase_detector_SphereCapsuleDetector; }(oimo.collision.narrowphase.detector.Detector); oimo.collision.narrowphase.detector.SphereSphereDetector = /*#__PURE__*/function (_oimo$collision$narro6) { _inherits(oimo_collision_narrowphase_detector_SphereSphereDetector, _oimo$collision$narro6); var _super18 = _createSuper(oimo_collision_narrowphase_detector_SphereSphereDetector); function oimo_collision_narrowphase_detector_SphereSphereDetector() { _classCallCheck(this, oimo_collision_narrowphase_detector_SphereSphereDetector); return _super18.call(this, false); } _createClass(oimo_collision_narrowphase_detector_SphereSphereDetector, [{ key: "detectImpl", value: function detectImpl(result, geom1, geom2, tf1, tf2, cachedData) { result.incremental = false; var dX; var dY; var dZ; dX = tf1._positionX - tf2._positionX; dY = tf1._positionY - tf2._positionY; dZ = tf1._positionZ - tf2._positionZ; var r1 = geom1._radius; var r2 = geom2._radius; var len2 = dX * dX + dY * dY + dZ * dZ; if (len2 >= (r1 + r2) * (r1 + r2)) { return; } var len = Math.sqrt(len2); var nX; var nY; var nZ; if (len > 0) { nX = dX * (1 / len); nY = dY * (1 / len); nZ = dZ * (1 / len); } else { nX = 1; nY = 0; nZ = 0; } this.setNormal(result, nX, nY, nZ); var pos1X; var pos1Y; var pos1Z; var pos2X; var pos2Y; var pos2Z; pos1X = tf1._positionX + nX * -r1; pos1Y = tf1._positionY + nY * -r1; pos1Z = tf1._positionZ + nZ * -r1; pos2X = tf2._positionX + nX * r2; pos2Y = tf2._positionY + nY * r2; pos2Z = tf2._positionZ + nZ * r2; this.addPoint(result, pos1X, pos1Y, pos1Z, pos2X, pos2Y, pos2Z, r1 + r2 - len, 0); } }]); return oimo_collision_narrowphase_detector_SphereSphereDetector; }(oimo.collision.narrowphase.detector.Detector); if (!oimo.collision.narrowphase.detector.gjkepa) oimo.collision.narrowphase.detector.gjkepa = {}; oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedron = /*#__PURE__*/function () { function oimo_collision_narrowphase_detector_gjkepa_EpaPolyhedron() { _classCallCheck(this, oimo_collision_narrowphase_detector_gjkepa_EpaPolyhedron); this._vertices = new Array(oimo.common.Setting.maxEPAVertices); this._center = new oimo.common.Vec3(); this._numVertices = 0; this._triangleList = null; this._triangleListLast = null; this._numTriangles = 0; this._trianglePool = null; this._vertexPool = null; } _createClass(oimo_collision_narrowphase_detector_gjkepa_EpaPolyhedron, [{ key: "dumpHoleEdge", value: function dumpHoleEdge(first) {} }, { key: "validate", value: function validate() { var t = this._triangleList; while (t != null) { t._vertices[0]._tmpEdgeLoopOuterTriangle = null; t._vertices[0]._tmpEdgeLoopNext = null; if (t._adjacentPairIndex[0] == -1) { this._status = 2; return false; } if (t._adjacentTriangles[0] == null) { this._status = 3; return false; } t._vertices[1]._tmpEdgeLoopOuterTriangle = null; t._vertices[1]._tmpEdgeLoopNext = null; if (t._adjacentPairIndex[1] == -1) { this._status = 2; return false; } if (t._adjacentTriangles[1] == null) { this._status = 3; return false; } t._vertices[2]._tmpEdgeLoopOuterTriangle = null; t._vertices[2]._tmpEdgeLoopNext = null; if (t._adjacentPairIndex[2] == -1) { this._status = 2; return false; } if (t._adjacentTriangles[2] == null) { this._status = 3; return false; } t = t._next; } return true; } }, { key: "findEdgeLoop", value: function findEdgeLoop(id, base, from) { if (base._tmpDfsId == id) { return; } base._tmpDfsId = id; var _this = base.tmp; _this.x = from.x; _this.y = from.y; _this.z = from.z; var v = base._vertices[0].v; _this.x -= v.x; _this.y -= v.y; _this.z -= v.z; var _this1 = base.tmp; var v1 = base._normal; base._tmpDfsVisible = _this1.x * v1.x + _this1.y * v1.y + _this1.z * v1.z > 0; if (!base._tmpDfsVisible) { this._status = 6; return; } var _g = 0; while (_g < 3) { var i = _g++; var t = base._adjacentTriangles[i]; if (t == null) { continue; } var _this69 = t.tmp; _this69.x = from.x; _this69.y = from.y; _this69.z = from.z; var _v11 = t._vertices[0].v; _this69.x -= _v11.x; _this69.y -= _v11.y; _this69.z -= _v11.z; var _this70 = t.tmp; var _v12 = t._normal; t._tmpDfsVisible = _this70.x * _v12.x + _this70.y * _v12.y + _this70.z * _v12.z > 0; if (t._tmpDfsVisible) { this.findEdgeLoop(id, t, from); } else { var _v13 = base._vertices[i]; _v13._tmpEdgeLoopNext = base._vertices[base._nextIndex[i]]; _v13._tmpEdgeLoopOuterTriangle = t; } } var triangle = base._adjacentTriangles[0]; if (triangle != null) { var pairIndex = base._adjacentPairIndex[0]; triangle._adjacentTriangles[pairIndex] = null; triangle._adjacentPairIndex[pairIndex] = -1; base._adjacentTriangles[0] = null; base._adjacentPairIndex[0] = -1; } var triangle1 = base._adjacentTriangles[1]; if (triangle1 != null) { var _pairIndex = base._adjacentPairIndex[1]; triangle1._adjacentTriangles[_pairIndex] = null; triangle1._adjacentPairIndex[_pairIndex] = -1; base._adjacentTriangles[1] = null; base._adjacentPairIndex[1] = -1; } var triangle2 = base._adjacentTriangles[2]; if (triangle2 != null) { var _pairIndex2 = base._adjacentPairIndex[2]; triangle2._adjacentTriangles[_pairIndex2] = null; triangle2._adjacentPairIndex[_pairIndex2] = -1; base._adjacentTriangles[2] = null; base._adjacentPairIndex[2] = -1; } this._numTriangles--; var prev = base._prev; var next = base._next; if (prev != null) { prev._next = next; } if (next != null) { next._prev = prev; } if (base == this._triangleList) { this._triangleList = this._triangleList._next; } if (base == this._triangleListLast) { this._triangleListLast = this._triangleListLast._prev; } base._next = null; base._prev = null; base.removeReferences(); base._next = this._trianglePool; this._trianglePool = base; } }, { key: "_init", value: function _init(v1, v2, v3, v4) { this._status = 0; this._numVertices = 4; this._vertices[0] = v1; this._vertices[1] = v2; this._vertices[2] = v3; this._vertices[3] = v4; var _this = this._center; var v = v1.v; _this.x = v.x; _this.y = v.y; _this.z = v.z; var v5 = v2.v; _this.x += v5.x; _this.y += v5.y; _this.z += v5.z; var v6 = v3.v; _this.x += v6.x; _this.y += v6.y; _this.z += v6.z; var v7 = v4.v; _this.x += v7.x; _this.y += v7.y; _this.z += v7.z; _this.x *= 0.25; _this.y *= 0.25; _this.z *= 0.25; var first = this._trianglePool; if (first != null) { this._trianglePool = first._next; first._next = null; } else { first = new oimo.collision.narrowphase.detector.gjkepa.EpaTriangle(); } var t1 = first; var first1 = this._trianglePool; if (first1 != null) { this._trianglePool = first1._next; first1._next = null; } else { first1 = new oimo.collision.narrowphase.detector.gjkepa.EpaTriangle(); } var t2 = first1; var first2 = this._trianglePool; if (first2 != null) { this._trianglePool = first2._next; first2._next = null; } else { first2 = new oimo.collision.narrowphase.detector.gjkepa.EpaTriangle(); } var t3 = first2; var first3 = this._trianglePool; if (first3 != null) { this._trianglePool = first3._next; first3._next = null; } else { first3 = new oimo.collision.narrowphase.detector.gjkepa.EpaTriangle(); } var t4 = first3; if (!t1.init(v1, v2, v3, this._center, true)) { this._status = 1; } if (!t2.init(v1, v2, v4, this._center, true)) { this._status = 1; } if (!t3.init(v1, v3, v4, this._center, true)) { this._status = 1; } if (!t4.init(v2, v3, v4, this._center, true)) { this._status = 1; } if (!t1.setAdjacentTriangle(t2)) { this._status = 1; } if (!t1.setAdjacentTriangle(t3)) { this._status = 1; } if (!t1.setAdjacentTriangle(t4)) { this._status = 1; } if (!t2.setAdjacentTriangle(t3)) { this._status = 1; } if (!t2.setAdjacentTriangle(t4)) { this._status = 1; } if (!t3.setAdjacentTriangle(t4)) { this._status = 1; } this._numTriangles++; if (this._triangleList == null) { this._triangleList = t1; this._triangleListLast = t1; } else { this._triangleListLast._next = t1; t1._prev = this._triangleListLast; this._triangleListLast = t1; } this._numTriangles++; if (this._triangleList == null) { this._triangleList = t2; this._triangleListLast = t2; } else { this._triangleListLast._next = t2; t2._prev = this._triangleListLast; this._triangleListLast = t2; } this._numTriangles++; if (this._triangleList == null) { this._triangleList = t3; this._triangleListLast = t3; } else { this._triangleListLast._next = t3; t3._prev = this._triangleListLast; this._triangleListLast = t3; } this._numTriangles++; if (this._triangleList == null) { this._triangleList = t4; this._triangleListLast = t4; } else { this._triangleListLast._next = t4; t4._prev = this._triangleListLast; this._triangleListLast = t4; } return this._status == 0; } }, { key: "_addVertex", value: function _addVertex(vertex, base) { this._vertices[this._numVertices++] = vertex; var v1 = base._vertices[0]; this.findEdgeLoop(this._numVertices, base, vertex.v); if (this._status != 0) { return false; } var v = v1; var prevT = null; var firstT = null; while (true) { if (v._tmpEdgeLoopNext == null) { this._dumpAsObjModel(); this._status = 4; return false; } if (v._tmpEdgeLoopOuterTriangle == null) { this._status = 5; return false; } var first = this._trianglePool; if (first != null) { this._trianglePool = first._next; first._next = null; } else { first = new oimo.collision.narrowphase.detector.gjkepa.EpaTriangle(); } var t = first; if (firstT == null) { firstT = t; } if (!t.init(v, v._tmpEdgeLoopNext, vertex, this._center, false)) { this._status = 1; } if (this._status != 0) { return false; } this._numTriangles++; if (this._triangleList == null) { this._triangleList = t; this._triangleListLast = t; } else { this._triangleListLast._next = t; t._prev = this._triangleListLast; this._triangleListLast = t; } if (!t.setAdjacentTriangle(v._tmpEdgeLoopOuterTriangle)) { this._status = 1; } if (prevT != null) { if (!t.setAdjacentTriangle(prevT)) { this._status = 1; } } prevT = t; v = v._tmpEdgeLoopNext; if (!(v != v1)) { break; } } if (!prevT.setAdjacentTriangle(firstT)) { this._status = 1; } if (this._status == 0) { return this.validate(); } else { return false; } } }, { key: "_dumpAsObjModel", value: function _dumpAsObjModel() {} }]); return oimo_collision_narrowphase_detector_gjkepa_EpaPolyhedron; }(); oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState = /*#__PURE__*/_createClass(function oimo_collision_narrowphase_detector_gjkepa_EpaPolyhedronState() { _classCallCheck(this, oimo_collision_narrowphase_detector_gjkepa_EpaPolyhedronState); }); oimo.collision.narrowphase.detector.gjkepa.EpaTriangle = /*#__PURE__*/function () { function oimo_collision_narrowphase_detector_gjkepa_EpaTriangle() { _classCallCheck(this, oimo_collision_narrowphase_detector_gjkepa_EpaTriangle); this.id = ++oimo.collision.narrowphase.detector.gjkepa.EpaTriangle.count; this._next = null; this._prev = null; this._normal = new oimo.common.Vec3(); this._distanceSq = 0; this._tmpDfsId = 0; this._tmpDfsVisible = false; this._vertices = new Array(3); this._adjacentTriangles = new Array(3); this._adjacentPairIndex = new Array(3); this.tmp = new oimo.common.Vec3(); this._nextIndex = new Array(3); this._nextIndex[0] = 1; this._nextIndex[1] = 2; this._nextIndex[2] = 0; } _createClass(oimo_collision_narrowphase_detector_gjkepa_EpaTriangle, [{ key: "init", value: function init(vertex1, vertex2, vertex3, center, autoCheck) { if (autoCheck == null) { autoCheck = false; } var v1X; var v1Y; var v1Z; var v2X; var v2Y; var v2Z; var v3X; var v3Y; var v3Z; var vcX; var vcY; var vcZ; var v = vertex1.v; v1X = v.x; v1Y = v.y; v1Z = v.z; var v1 = vertex2.v; v2X = v1.x; v2Y = v1.y; v2Z = v1.z; var v2 = vertex3.v; v3X = v2.x; v3Y = v2.y; v3Z = v2.z; vcX = center.x; vcY = center.y; vcZ = center.z; var v12X; var v12Y; var v12Z; var v13X; var v13Y; var v13Z; var vc1X; var vc1Y; var vc1Z; v12X = v2X - v1X; v12Y = v2Y - v1Y; v12Z = v2Z - v1Z; v13X = v3X - v1X; v13Y = v3Y - v1Y; v13Z = v3Z - v1Z; vc1X = v1X - vcX; vc1Y = v1Y - vcY; vc1Z = v1Z - vcZ; var inorX; var inorY; var inorZ; inorX = v12Y * v13Z - v12Z * v13Y; inorY = v12Z * v13X - v12X * v13Z; inorZ = v12X * v13Y - v12Y * v13X; var inverted = false; if (vc1X * inorX + vc1Y * inorY + vc1Z * inorZ < 0) { if (autoCheck) { var tmp = vertex2; vertex2 = vertex3; vertex3 = tmp; inorX *= -1; inorY *= -1; inorZ *= -1; } else { inverted = true; } } this._vertices[0] = vertex1; this._vertices[1] = vertex2; this._vertices[2] = vertex3; var v3 = this._normal; v3.x = inorX; v3.y = inorY; v3.z = inorZ; var vec1 = vertex1.v; var vec2 = vertex2.v; var vec3 = vertex3.v; var out = this.tmp; var v1X1; var v1Y1; var v1Z1; var v2X1; var v2Y1; var v2Z1; var v3X1; var v3Y1; var v3Z1; var v12X1; var v12Y1; var v12Z1; var v23X; var v23Y; var v23Z; var v31X; var v31Y; var v31Z; v1X1 = vec1.x; v1Y1 = vec1.y; v1Z1 = vec1.z; v2X1 = vec2.x; v2Y1 = vec2.y; v2Z1 = vec2.z; v3X1 = vec3.x; v3Y1 = vec3.y; v3Z1 = vec3.z; v12X1 = v2X1 - v1X1; v12Y1 = v2Y1 - v1Y1; v12Z1 = v2Z1 - v1Z1; v23X = v3X1 - v2X1; v23Y = v3Y1 - v2Y1; v23Z = v3Z1 - v2Z1; v31X = v1X1 - v3X1; v31Y = v1Y1 - v3Y1; v31Z = v1Z1 - v3Z1; var nX; var nY; var nZ; nX = v12Y1 * v23Z - v12Z1 * v23Y; nY = v12Z1 * v23X - v12X1 * v23Z; nZ = v12X1 * v23Y - v12Y1 * v23X; var n12X; var n12Y; var n12Z; var n23X; var n23Y; var n23Z; var n31X; var n31Y; var n31Z; n12X = v12Y1 * nZ - v12Z1 * nY; n12Y = v12Z1 * nX - v12X1 * nZ; n12Z = v12X1 * nY - v12Y1 * nX; n23X = v23Y * nZ - v23Z * nY; n23Y = v23Z * nX - v23X * nZ; n23Z = v23X * nY - v23Y * nX; n31X = v31Y * nZ - v31Z * nY; n31Y = v31Z * nX - v31X * nZ; n31Z = v31X * nY - v31Y * nX; var mind = -1; var minvX; var minvY; var minvZ; minvX = 0; minvY = 0; minvZ = 0; if (v1X1 * n12X + v1Y1 * n12Y + v1Z1 * n12Z < 0) { var _v1X; var _v1Y; var _v1Z; var _v2X; var _v2Y; var _v2Z; _v1X = vec1.x; _v1Y = vec1.y; _v1Z = vec1.z; _v2X = vec2.x; _v2Y = vec2.y; _v2Z = vec2.z; var _v12X; var _v12Y; var _v12Z; _v12X = _v2X - _v1X; _v12Y = _v2Y - _v1Y; _v12Z = _v2Z - _v1Z; var t = _v12X * _v1X + _v12Y * _v1Y + _v12Z * _v1Z; t = -t / (_v12X * _v12X + _v12Y * _v12Y + _v12Z * _v12Z); if (t < 0) { out.x = _v1X; out.y = _v1Y; out.z = _v1Z; } else if (t > 1) { out.x = _v2X; out.y = _v2Y; out.z = _v2Z; } else { var pX; var pY; var pZ; pX = _v1X + _v12X * t; pY = _v1Y + _v12Y * t; pZ = _v1Z + _v12Z * t; out.x = pX; out.y = pY; out.z = pZ; } mind = out.x * out.x + out.y * out.y + out.z * out.z; minvX = out.x; minvY = out.y; minvZ = out.z; } if (v2X1 * n23X + v2Y1 * n23Y + v2Z1 * n23Z < 0) { var _v1X2; var _v1Y2; var _v1Z2; var _v2X2; var _v2Y2; var _v2Z2; _v1X2 = vec2.x; _v1Y2 = vec2.y; _v1Z2 = vec2.z; _v2X2 = vec3.x; _v2Y2 = vec3.y; _v2Z2 = vec3.z; var _v12X2; var _v12Y2; var _v12Z2; _v12X2 = _v2X2 - _v1X2; _v12Y2 = _v2Y2 - _v1Y2; _v12Z2 = _v2Z2 - _v1Z2; var _t12 = _v12X2 * _v1X2 + _v12Y2 * _v1Y2 + _v12Z2 * _v1Z2; _t12 = -_t12 / (_v12X2 * _v12X2 + _v12Y2 * _v12Y2 + _v12Z2 * _v12Z2); if (_t12 < 0) { out.x = _v1X2; out.y = _v1Y2; out.z = _v1Z2; } else if (_t12 > 1) { out.x = _v2X2; out.y = _v2Y2; out.z = _v2Z2; } else { var _pX; var _pY; var _pZ; _pX = _v1X2 + _v12X2 * _t12; _pY = _v1Y2 + _v12Y2 * _t12; _pZ = _v1Z2 + _v12Z2 * _t12; out.x = _pX; out.y = _pY; out.z = _pZ; } var d = out.x * out.x + out.y * out.y + out.z * out.z; if (mind < 0 || d < mind) { mind = d; minvX = out.x; minvY = out.y; minvZ = out.z; } } if (v3X1 * n31X + v3Y1 * n31Y + v3Z1 * n31Z < 0) { var _v1X3; var _v1Y3; var _v1Z3; var _v2X3; var _v2Y3; var _v2Z3; _v1X3 = vec1.x; _v1Y3 = vec1.y; _v1Z3 = vec1.z; _v2X3 = vec3.x; _v2Y3 = vec3.y; _v2Z3 = vec3.z; var _v12X3; var _v12Y3; var _v12Z3; _v12X3 = _v2X3 - _v1X3; _v12Y3 = _v2Y3 - _v1Y3; _v12Z3 = _v2Z3 - _v1Z3; var _t13 = _v12X3 * _v1X3 + _v12Y3 * _v1Y3 + _v12Z3 * _v1Z3; _t13 = -_t13 / (_v12X3 * _v12X3 + _v12Y3 * _v12Y3 + _v12Z3 * _v12Z3); if (_t13 < 0) { out.x = _v1X3; out.y = _v1Y3; out.z = _v1Z3; } else if (_t13 > 1) { out.x = _v2X3; out.y = _v2Y3; out.z = _v2Z3; } else { var _pX2; var _pY2; var _pZ2; _pX2 = _v1X3 + _v12X3 * _t13; _pY2 = _v1Y3 + _v12Y3 * _t13; _pZ2 = _v1Z3 + _v12Z3 * _t13; out.x = _pX2; out.y = _pY2; out.z = _pZ2; } var _d = out.x * out.x + out.y * out.y + out.z * out.z; if (mind < 0 || _d < mind) { mind = _d; minvX = out.x; minvY = out.y; minvZ = out.z; } } if (mind > 0) { out.x = minvX; out.y = minvY; out.z = minvZ; } else { var l = nX * nX + nY * nY + nZ * nZ; if (l > 0) { l = 1 / Math.sqrt(l); } nX *= l; nY *= l; nZ *= l; var l2 = nX * nX + nY * nY + nZ * nZ; l2 = (v1X1 * nX + v1Y1 * nY + v1Z1 * nZ) / l2; minvX = nX * l2; minvY = nY * l2; minvZ = nZ * l2; out.x = minvX; out.y = minvY; out.z = minvZ; } var _this = this.tmp; this._distanceSq = _this.x * _this.x + _this.y * _this.y + _this.z * _this.z; this._adjacentTriangles[0] = null; this._adjacentTriangles[1] = null; this._adjacentTriangles[2] = null; this._adjacentPairIndex[0] = -1; this._adjacentPairIndex[1] = -1; this._adjacentPairIndex[2] = -1; return !inverted; } }, { key: "setAdjacentTriangle", value: function setAdjacentTriangle(triangle) { var count = 0; if (this._vertices[0] == triangle._vertices[this._nextIndex[0]] && this._vertices[this._nextIndex[0]] == triangle._vertices[0]) { this._adjacentTriangles[0] = triangle; this._adjacentPairIndex[0] = 0; triangle._adjacentTriangles[0] = this; triangle._adjacentPairIndex[0] = 0; count = 1; } if (this._vertices[0] == triangle._vertices[this._nextIndex[1]] && this._vertices[this._nextIndex[0]] == triangle._vertices[1]) { this._adjacentTriangles[0] = triangle; this._adjacentPairIndex[0] = 1; triangle._adjacentTriangles[1] = this; triangle._adjacentPairIndex[1] = 0; ++count; } if (this._vertices[0] == triangle._vertices[this._nextIndex[2]] && this._vertices[this._nextIndex[0]] == triangle._vertices[2]) { this._adjacentTriangles[0] = triangle; this._adjacentPairIndex[0] = 2; triangle._adjacentTriangles[2] = this; triangle._adjacentPairIndex[2] = 0; ++count; } if (this._vertices[1] == triangle._vertices[this._nextIndex[0]] && this._vertices[this._nextIndex[1]] == triangle._vertices[0]) { this._adjacentTriangles[1] = triangle; this._adjacentPairIndex[1] = 0; triangle._adjacentTriangles[0] = this; triangle._adjacentPairIndex[0] = 1; ++count; } if (this._vertices[1] == triangle._vertices[this._nextIndex[1]] && this._vertices[this._nextIndex[1]] == triangle._vertices[1]) { this._adjacentTriangles[1] = triangle; this._adjacentPairIndex[1] = 1; triangle._adjacentTriangles[1] = this; triangle._adjacentPairIndex[1] = 1; ++count; } if (this._vertices[1] == triangle._vertices[this._nextIndex[2]] && this._vertices[this._nextIndex[1]] == triangle._vertices[2]) { this._adjacentTriangles[1] = triangle; this._adjacentPairIndex[1] = 2; triangle._adjacentTriangles[2] = this; triangle._adjacentPairIndex[2] = 1; ++count; } if (this._vertices[2] == triangle._vertices[this._nextIndex[0]] && this._vertices[this._nextIndex[2]] == triangle._vertices[0]) { this._adjacentTriangles[2] = triangle; this._adjacentPairIndex[2] = 0; triangle._adjacentTriangles[0] = this; triangle._adjacentPairIndex[0] = 2; ++count; } if (this._vertices[2] == triangle._vertices[this._nextIndex[1]] && this._vertices[this._nextIndex[2]] == triangle._vertices[1]) { this._adjacentTriangles[2] = triangle; this._adjacentPairIndex[2] = 1; triangle._adjacentTriangles[1] = this; triangle._adjacentPairIndex[1] = 2; ++count; } if (this._vertices[2] == triangle._vertices[this._nextIndex[2]] && this._vertices[this._nextIndex[2]] == triangle._vertices[2]) { this._adjacentTriangles[2] = triangle; this._adjacentPairIndex[2] = 2; triangle._adjacentTriangles[2] = this; triangle._adjacentPairIndex[2] = 2; ++count; } if (count != 1) { return false; } return true; } }, { key: "removeAdjacentTriangles", value: function removeAdjacentTriangles() { var triangle = this._adjacentTriangles[0]; if (triangle != null) { var pairIndex = this._adjacentPairIndex[0]; triangle._adjacentTriangles[pairIndex] = null; triangle._adjacentPairIndex[pairIndex] = -1; this._adjacentTriangles[0] = null; this._adjacentPairIndex[0] = -1; } var triangle1 = this._adjacentTriangles[1]; if (triangle1 != null) { var _pairIndex3 = this._adjacentPairIndex[1]; triangle1._adjacentTriangles[_pairIndex3] = null; triangle1._adjacentPairIndex[_pairIndex3] = -1; this._adjacentTriangles[1] = null; this._adjacentPairIndex[1] = -1; } var triangle2 = this._adjacentTriangles[2]; if (triangle2 != null) { var _pairIndex4 = this._adjacentPairIndex[2]; triangle2._adjacentTriangles[_pairIndex4] = null; triangle2._adjacentPairIndex[_pairIndex4] = -1; this._adjacentTriangles[2] = null; this._adjacentPairIndex[2] = -1; } } }, { key: "removeReferences", value: function removeReferences() { this._next = null; this._prev = null; this._tmpDfsId = 0; this._tmpDfsVisible = false; this._distanceSq = 0; this._vertices[0] = null; this._vertices[1] = null; this._vertices[2] = null; this._adjacentTriangles[0] = null; this._adjacentTriangles[1] = null; this._adjacentTriangles[2] = null; this._adjacentPairIndex[0] = 0; this._adjacentPairIndex[1] = 0; this._adjacentPairIndex[2] = 0; } }, { key: "dump", value: function dump() {} }]); return oimo_collision_narrowphase_detector_gjkepa_EpaTriangle; }(); oimo.collision.narrowphase.detector.gjkepa.EpaVertex = /*#__PURE__*/function () { function oimo_collision_narrowphase_detector_gjkepa_EpaVertex() { _classCallCheck(this, oimo_collision_narrowphase_detector_gjkepa_EpaVertex); this.randId = Math.random() * 100000 | 0; this.v = new oimo.common.Vec3(); this.w1 = new oimo.common.Vec3(); this.w2 = new oimo.common.Vec3(); } _createClass(oimo_collision_narrowphase_detector_gjkepa_EpaVertex, [{ key: "init", value: function init(v, w1, w2) { var _this = this.v; _this.x = v.x; _this.y = v.y; _this.z = v.z; var _this1 = this.w1; _this1.x = w1.x; _this1.y = w1.y; _this1.z = w1.z; var _this2 = this.w2; _this2.x = w2.x; _this2.y = w2.y; _this2.z = w2.z; this._next = null; this._tmpEdgeLoopNext = null; this._tmpEdgeLoopOuterTriangle = null; return this; } }, { key: "removeReferences", value: function removeReferences() { this._next = null; this._tmpEdgeLoopNext = null; this._tmpEdgeLoopOuterTriangle = null; } }]); return oimo_collision_narrowphase_detector_gjkepa_EpaVertex; }(); oimo.collision.narrowphase.detector.gjkepa.GjkCache = /*#__PURE__*/function () { function oimo_collision_narrowphase_detector_gjkepa_GjkCache() { _classCallCheck(this, oimo_collision_narrowphase_detector_gjkepa_GjkCache); this.prevClosestDir = new oimo.common.Vec3(); } _createClass(oimo_collision_narrowphase_detector_gjkepa_GjkCache, [{ key: "clear", value: function clear() { this.prevClosestDir.zero(); } }]); return oimo_collision_narrowphase_detector_gjkepa_GjkCache; }(); if (!oimo.common) oimo.common = {}; oimo.common.Vec3 = /*#__PURE__*/function () { function oimo_common_Vec3(x, y, z) { _classCallCheck(this, oimo_common_Vec3); if (z == null) { z = 0; } if (y == null) { y = 0; } if (x == null) { x = 0; } this.x = x; this.y = y; this.z = z; oimo.common.Vec3.numCreations++; } _createClass(oimo_common_Vec3, [{ key: "init", value: function init(x, y, z) { this.x = x; this.y = y; this.z = z; return this; } }, { key: "zero", value: function zero() { this.x = 0; this.y = 0; this.z = 0; return this; } }, { key: "add", value: function add(v) { return new oimo.common.Vec3(this.x + v.x, this.y + v.y, this.z + v.z); } }, { key: "add3", value: function add3(vx, vy, vz) { return new oimo.common.Vec3(this.x + vx, this.y + vy, this.z + vz); } }, { key: "addScaled", value: function addScaled(v, s) { return new oimo.common.Vec3(this.x + v.x * s, this.y + v.y * s, this.z + v.z * s); } }, { key: "sub", value: function sub(v) { return new oimo.common.Vec3(this.x - v.x, this.y - v.y, this.z - v.z); } }, { key: "sub3", value: function sub3(vx, vy, vz) { return new oimo.common.Vec3(this.x - vx, this.y - vy, this.z - vz); } }, { key: "scale", value: function scale(s) { return new oimo.common.Vec3(this.x * s, this.y * s, this.z * s); } }, { key: "scale3", value: function scale3(sx, sy, sz) { return new oimo.common.Vec3(this.x * sx, this.y * sy, this.z * sz); } }, { key: "dot", value: function dot(v) { return this.x * v.x + this.y * v.y + this.z * v.z; } }, { key: "cross", value: function cross(v) { return new oimo.common.Vec3(this.y * v.z - this.z * v.y, this.z * v.x - this.x * v.z, this.x * v.y - this.y * v.x); } }, { key: "addEq", value: function addEq(v) { this.x += v.x; this.y += v.y; this.z += v.z; return this; } }, { key: "add3Eq", value: function add3Eq(vx, vy, vz) { this.x += vx; this.y += vy; this.z += vz; return this; } }, { key: "addScaledEq", value: function addScaledEq(v, s) { this.x += v.x * s; this.y += v.y * s; this.z += v.z * s; return this; } }, { key: "subEq", value: function subEq(v) { this.x -= v.x; this.y -= v.y; this.z -= v.z; return this; } }, { key: "sub3Eq", value: function sub3Eq(vx, vy, vz) { this.x -= vx; this.y -= vy; this.z -= vz; return this; } }, { key: "scaleEq", value: function scaleEq(s) { this.x *= s; this.y *= s; this.z *= s; return this; } }, { key: "scale3Eq", value: function scale3Eq(sx, sy, sz) { this.x *= sx; this.y *= sy; this.z *= sz; return this; } }, { key: "crossEq", value: function crossEq(v) { var y = this.z * v.x - this.x * v.z; var z = this.x * v.y - this.y * v.x; this.x = this.y * v.z - this.z * v.y; this.y = y; this.z = z; return this; } }, { key: "mulMat3", value: function mulMat3(m) { return new oimo.common.Vec3(this.x * m.e00 + this.y * m.e01 + this.z * m.e02, this.x * m.e10 + this.y * m.e11 + this.z * m.e12, this.x * m.e20 + this.y * m.e21 + this.z * m.e22); } }, { key: "mulMat4", value: function mulMat4(m) { return new oimo.common.Vec3(this.x * m.e00 + this.y * m.e01 + this.z * m.e02 + m.e03, this.x * m.e10 + this.y * m.e11 + this.z * m.e12 + m.e13, this.x * m.e20 + this.y * m.e21 + this.z * m.e22 + m.e23); } }, { key: "mulTransform", value: function mulTransform(tf) { var vX; var vY; var vZ; vX = this.x; vY = this.y; vZ = this.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = tf._rotation00 * vX + tf._rotation01 * vY + tf._rotation02 * vZ; __tmp__Y = tf._rotation10 * vX + tf._rotation11 * vY + tf._rotation12 * vZ; __tmp__Z = tf._rotation20 * vX + tf._rotation21 * vY + tf._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; vX += tf._positionX; vY += tf._positionY; vZ += tf._positionZ; var res = new oimo.common.Vec3(); res.x = vX; res.y = vY; res.z = vZ; return res; } }, { key: "mulMat3Eq", value: function mulMat3Eq(m) { var y = this.x * m.e10 + this.y * m.e11 + this.z * m.e12; var z = this.x * m.e20 + this.y * m.e21 + this.z * m.e22; this.x = this.x * m.e00 + this.y * m.e01 + this.z * m.e02; this.y = y; this.z = z; return this; } }, { key: "mulMat4Eq", value: function mulMat4Eq(m) { var y = this.x * m.e10 + this.y * m.e11 + this.z * m.e12 + m.e13; var z = this.x * m.e20 + this.y * m.e21 + this.z * m.e22 + m.e23; this.x = this.x * m.e00 + this.y * m.e01 + this.z * m.e02 + m.e03; this.y = y; this.z = z; return this; } }, { key: "mulTransformEq", value: function mulTransformEq(tf) { var vX; var vY; var vZ; vX = this.x; vY = this.y; vZ = this.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = tf._rotation00 * vX + tf._rotation01 * vY + tf._rotation02 * vZ; __tmp__Y = tf._rotation10 * vX + tf._rotation11 * vY + tf._rotation12 * vZ; __tmp__Z = tf._rotation20 * vX + tf._rotation21 * vY + tf._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; vX += tf._positionX; vY += tf._positionY; vZ += tf._positionZ; this.x = vX; this.y = vY; this.z = vZ; return this; } }, { key: "length", value: function length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } }, { key: "lengthSq", value: function lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z; } }, { key: "normalized", value: function normalized() { var invLen = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); if (invLen > 0) { invLen = 1 / invLen; } return new oimo.common.Vec3(this.x * invLen, this.y * invLen, this.z * invLen); } }, { key: "normalize", value: function normalize() { var invLen = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); if (invLen > 0) { invLen = 1 / invLen; } this.x *= invLen; this.y *= invLen; this.z *= invLen; return this; } }, { key: "negate", value: function negate() { return new oimo.common.Vec3(-this.x, -this.y, -this.z); } }, { key: "negateEq", value: function negateEq() { this.x = -this.x; this.y = -this.y; this.z = -this.z; return this; } }, { key: "copyFrom", value: function copyFrom(v) { this.x = v.x; this.y = v.y; this.z = v.z; return this; } }, { key: "clone", value: function clone() { return new oimo.common.Vec3(this.x, this.y, this.z); } }, { key: "toString", value: function toString() { return "Vec3[" + (this.x > 0 ? (this.x * 10000000 + 0.5 | 0) / 10000000 : (this.x * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.y > 0 ? (this.y * 10000000 + 0.5 | 0) / 10000000 : (this.y * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.z > 0 ? (this.z * 10000000 + 0.5 | 0) / 10000000 : (this.z * 10000000 - 0.5 | 0) / 10000000) + "]"; } }]); return oimo_common_Vec3; }(); oimo.common.Transform = /*#__PURE__*/function () { function oimo_common_Transform() { _classCallCheck(this, oimo_common_Transform); this._positionX = 0; this._positionY = 0; this._positionZ = 0; this._rotation00 = 1; this._rotation01 = 0; this._rotation02 = 0; this._rotation10 = 0; this._rotation11 = 1; this._rotation12 = 0; this._rotation20 = 0; this._rotation21 = 0; this._rotation22 = 1; } _createClass(oimo_common_Transform, [{ key: "identity", value: function identity() { this._positionX = 0; this._positionY = 0; this._positionZ = 0; this._rotation00 = 1; this._rotation01 = 0; this._rotation02 = 0; this._rotation10 = 0; this._rotation11 = 1; this._rotation12 = 0; this._rotation20 = 0; this._rotation21 = 0; this._rotation22 = 1; return this; } }, { key: "getPosition", value: function getPosition() { var position = new oimo.common.Vec3(); position.x = this._positionX; position.y = this._positionY; position.z = this._positionZ; return position; } }, { key: "getPositionTo", value: function getPositionTo(position) { position.x = this._positionX; position.y = this._positionY; position.z = this._positionZ; } }, { key: "setPosition", value: function setPosition(position) { this._positionX = position.x; this._positionY = position.y; this._positionZ = position.z; return this; } }, { key: "translate", value: function translate(translation) { var diffX; var diffY; var diffZ; diffX = translation.x; diffY = translation.y; diffZ = translation.z; this._positionX += diffX; this._positionY += diffY; this._positionZ += diffZ; } }, { key: "getRotation", value: function getRotation() { var rotation = new oimo.common.Mat3(); rotation.e00 = this._rotation00; rotation.e01 = this._rotation01; rotation.e02 = this._rotation02; rotation.e10 = this._rotation10; rotation.e11 = this._rotation11; rotation.e12 = this._rotation12; rotation.e20 = this._rotation20; rotation.e21 = this._rotation21; rotation.e22 = this._rotation22; return rotation; } }, { key: "getRotationTo", value: function getRotationTo(out) { out.e00 = this._rotation00; out.e01 = this._rotation01; out.e02 = this._rotation02; out.e10 = this._rotation10; out.e11 = this._rotation11; out.e12 = this._rotation12; out.e20 = this._rotation20; out.e21 = this._rotation21; out.e22 = this._rotation22; } }, { key: "setRotation", value: function setRotation(rotation) { this._rotation00 = rotation.e00; this._rotation01 = rotation.e01; this._rotation02 = rotation.e02; this._rotation10 = rotation.e10; this._rotation11 = rotation.e11; this._rotation12 = rotation.e12; this._rotation20 = rotation.e20; this._rotation21 = rotation.e21; this._rotation22 = rotation.e22; return this; } }, { key: "setRotationXyz", value: function setRotationXyz(eulerAngles) { var xyzX; var xyzY; var xyzZ; xyzX = eulerAngles.x; xyzY = eulerAngles.y; xyzZ = eulerAngles.z; var sx = Math.sin(xyzX); var sy = Math.sin(xyzY); var sz = Math.sin(xyzZ); var cx = Math.cos(xyzX); var cy = Math.cos(xyzY); var cz = Math.cos(xyzZ); this._rotation00 = cy * cz; this._rotation01 = -cy * sz; this._rotation02 = sy; this._rotation10 = cx * sz + cz * sx * sy; this._rotation11 = cx * cz - sx * sy * sz; this._rotation12 = -cy * sx; this._rotation20 = sx * sz - cx * cz * sy; this._rotation21 = cz * sx + cx * sy * sz; this._rotation22 = cx * cy; } }, { key: "rotate", value: function rotate(rotation) { var rot00; var rot01; var rot02; var rot10; var rot11; var rot12; var rot20; var rot21; var rot22; rot00 = rotation.e00; rot01 = rotation.e01; rot02 = rotation.e02; rot10 = rotation.e10; rot11 = rotation.e11; rot12 = rotation.e12; rot20 = rotation.e20; rot21 = rotation.e21; rot22 = rotation.e22; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = rot00 * this._rotation00 + rot01 * this._rotation10 + rot02 * this._rotation20; __tmp__01 = rot00 * this._rotation01 + rot01 * this._rotation11 + rot02 * this._rotation21; __tmp__02 = rot00 * this._rotation02 + rot01 * this._rotation12 + rot02 * this._rotation22; __tmp__10 = rot10 * this._rotation00 + rot11 * this._rotation10 + rot12 * this._rotation20; __tmp__11 = rot10 * this._rotation01 + rot11 * this._rotation11 + rot12 * this._rotation21; __tmp__12 = rot10 * this._rotation02 + rot11 * this._rotation12 + rot12 * this._rotation22; __tmp__20 = rot20 * this._rotation00 + rot21 * this._rotation10 + rot22 * this._rotation20; __tmp__21 = rot20 * this._rotation01 + rot21 * this._rotation11 + rot22 * this._rotation21; __tmp__22 = rot20 * this._rotation02 + rot21 * this._rotation12 + rot22 * this._rotation22; this._rotation00 = __tmp__00; this._rotation01 = __tmp__01; this._rotation02 = __tmp__02; this._rotation10 = __tmp__10; this._rotation11 = __tmp__11; this._rotation12 = __tmp__12; this._rotation20 = __tmp__20; this._rotation21 = __tmp__21; this._rotation22 = __tmp__22; } }, { key: "rotateXyz", value: function rotateXyz(eulerAngles) { var xyzX; var xyzY; var xyzZ; var rot00; var rot01; var rot02; var rot10; var rot11; var rot12; var rot20; var rot21; var rot22; xyzX = eulerAngles.x; xyzY = eulerAngles.y; xyzZ = eulerAngles.z; var sx = Math.sin(xyzX); var sy = Math.sin(xyzY); var sz = Math.sin(xyzZ); var cx = Math.cos(xyzX); var cy = Math.cos(xyzY); var cz = Math.cos(xyzZ); rot00 = cy * cz; rot01 = -cy * sz; rot02 = sy; rot10 = cx * sz + cz * sx * sy; rot11 = cx * cz - sx * sy * sz; rot12 = -cy * sx; rot20 = sx * sz - cx * cz * sy; rot21 = cz * sx + cx * sy * sz; rot22 = cx * cy; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = rot00 * this._rotation00 + rot01 * this._rotation10 + rot02 * this._rotation20; __tmp__01 = rot00 * this._rotation01 + rot01 * this._rotation11 + rot02 * this._rotation21; __tmp__02 = rot00 * this._rotation02 + rot01 * this._rotation12 + rot02 * this._rotation22; __tmp__10 = rot10 * this._rotation00 + rot11 * this._rotation10 + rot12 * this._rotation20; __tmp__11 = rot10 * this._rotation01 + rot11 * this._rotation11 + rot12 * this._rotation21; __tmp__12 = rot10 * this._rotation02 + rot11 * this._rotation12 + rot12 * this._rotation22; __tmp__20 = rot20 * this._rotation00 + rot21 * this._rotation10 + rot22 * this._rotation20; __tmp__21 = rot20 * this._rotation01 + rot21 * this._rotation11 + rot22 * this._rotation21; __tmp__22 = rot20 * this._rotation02 + rot21 * this._rotation12 + rot22 * this._rotation22; this._rotation00 = __tmp__00; this._rotation01 = __tmp__01; this._rotation02 = __tmp__02; this._rotation10 = __tmp__10; this._rotation11 = __tmp__11; this._rotation12 = __tmp__12; this._rotation20 = __tmp__20; this._rotation21 = __tmp__21; this._rotation22 = __tmp__22; } }, { key: "getOrientation", value: function getOrientation() { var q = new oimo.common.Quat(); var iqX; var iqY; var iqZ; var iqW; var e00 = this._rotation00; var e11 = this._rotation11; var e22 = this._rotation22; var t = e00 + e11 + e22; var s; if (t > 0) { s = Math.sqrt(t + 1); iqW = 0.5 * s; s = 0.5 / s; iqX = (this._rotation21 - this._rotation12) * s; iqY = (this._rotation02 - this._rotation20) * s; iqZ = (this._rotation10 - this._rotation01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); iqX = 0.5 * s; s = 0.5 / s; iqY = (this._rotation01 + this._rotation10) * s; iqZ = (this._rotation02 + this._rotation20) * s; iqW = (this._rotation21 - this._rotation12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); iqZ = 0.5 * s; s = 0.5 / s; iqX = (this._rotation02 + this._rotation20) * s; iqY = (this._rotation12 + this._rotation21) * s; iqW = (this._rotation10 - this._rotation01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); iqY = 0.5 * s; s = 0.5 / s; iqX = (this._rotation01 + this._rotation10) * s; iqZ = (this._rotation12 + this._rotation21) * s; iqW = (this._rotation02 - this._rotation20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); iqZ = 0.5 * s; s = 0.5 / s; iqX = (this._rotation02 + this._rotation20) * s; iqY = (this._rotation12 + this._rotation21) * s; iqW = (this._rotation10 - this._rotation01) * s; } q.x = iqX; q.y = iqY; q.z = iqZ; q.w = iqW; return q; } }, { key: "getOrientationTo", value: function getOrientationTo(orientation) { var iqX; var iqY; var iqZ; var iqW; var e00 = this._rotation00; var e11 = this._rotation11; var e22 = this._rotation22; var t = e00 + e11 + e22; var s; if (t > 0) { s = Math.sqrt(t + 1); iqW = 0.5 * s; s = 0.5 / s; iqX = (this._rotation21 - this._rotation12) * s; iqY = (this._rotation02 - this._rotation20) * s; iqZ = (this._rotation10 - this._rotation01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); iqX = 0.5 * s; s = 0.5 / s; iqY = (this._rotation01 + this._rotation10) * s; iqZ = (this._rotation02 + this._rotation20) * s; iqW = (this._rotation21 - this._rotation12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); iqZ = 0.5 * s; s = 0.5 / s; iqX = (this._rotation02 + this._rotation20) * s; iqY = (this._rotation12 + this._rotation21) * s; iqW = (this._rotation10 - this._rotation01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); iqY = 0.5 * s; s = 0.5 / s; iqX = (this._rotation01 + this._rotation10) * s; iqZ = (this._rotation12 + this._rotation21) * s; iqW = (this._rotation02 - this._rotation20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); iqZ = 0.5 * s; s = 0.5 / s; iqX = (this._rotation02 + this._rotation20) * s; iqY = (this._rotation12 + this._rotation21) * s; iqW = (this._rotation10 - this._rotation01) * s; } orientation.x = iqX; orientation.y = iqY; orientation.z = iqZ; orientation.w = iqW; } }, { key: "setOrientation", value: function setOrientation(quaternion) { var qX; var qY; var qZ; var qW; qX = quaternion.x; qY = quaternion.y; qZ = quaternion.z; qW = quaternion.w; var x = qX; var y = qY; var z = qZ; var w = qW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; this._rotation00 = 1 - yy - zz; this._rotation01 = xy - wz; this._rotation02 = xz + wy; this._rotation10 = xy + wz; this._rotation11 = 1 - xx - zz; this._rotation12 = yz - wx; this._rotation20 = xz - wy; this._rotation21 = yz + wx; this._rotation22 = 1 - xx - yy; return this; } }, { key: "clone", value: function clone() { var tf = new oimo.common.Transform(); tf._positionX = this._positionX; tf._positionY = this._positionY; tf._positionZ = this._positionZ; tf._rotation00 = this._rotation00; tf._rotation01 = this._rotation01; tf._rotation02 = this._rotation02; tf._rotation10 = this._rotation10; tf._rotation11 = this._rotation11; tf._rotation12 = this._rotation12; tf._rotation20 = this._rotation20; tf._rotation21 = this._rotation21; tf._rotation22 = this._rotation22; return tf; } }, { key: "copyFrom", value: function copyFrom(transform) { this._positionX = transform._positionX; this._positionY = transform._positionY; this._positionZ = transform._positionZ; this._rotation00 = transform._rotation00; this._rotation01 = transform._rotation01; this._rotation02 = transform._rotation02; this._rotation10 = transform._rotation10; this._rotation11 = transform._rotation11; this._rotation12 = transform._rotation12; this._rotation20 = transform._rotation20; this._rotation21 = transform._rotation21; this._rotation22 = transform._rotation22; return this; } }]); return oimo_common_Transform; }(); oimo.common.Setting = /*#__PURE__*/_createClass(function oimo_common_Setting() { _classCallCheck(this, oimo_common_Setting); }); oimo.collision.narrowphase.detector.gjkepa.GjkEpa = /*#__PURE__*/function () { function oimo_collision_narrowphase_detector_gjkepa_GjkEpa() { _classCallCheck(this, oimo_collision_narrowphase_detector_gjkepa_GjkEpa); this.s = new Array(4); this.w1 = new Array(4); this.w2 = new Array(4); this.baseDirs = new Array(3); this.baseDirs[0] = new oimo.common.Vec3(1, 0, 0); this.baseDirs[1] = new oimo.common.Vec3(0, 1, 0); this.baseDirs[2] = new oimo.common.Vec3(0, 0, 1); this.tl1 = new oimo.common.Vec3(); this.tl2 = new oimo.common.Vec3(); this.rayX = new oimo.common.Vec3(); this.rayR = new oimo.common.Vec3(); this.tempTransform = new oimo.common.Transform(); this.s[0] = new oimo.common.Vec3(); this.w1[0] = new oimo.common.Vec3(); this.w2[0] = new oimo.common.Vec3(); this.s[1] = new oimo.common.Vec3(); this.w1[1] = new oimo.common.Vec3(); this.w2[1] = new oimo.common.Vec3(); this.s[2] = new oimo.common.Vec3(); this.w1[2] = new oimo.common.Vec3(); this.w2[2] = new oimo.common.Vec3(); this.s[3] = new oimo.common.Vec3(); this.w1[3] = new oimo.common.Vec3(); this.w2[3] = new oimo.common.Vec3(); this.dir = new oimo.common.Vec3(); this.closest = new oimo.common.Vec3(); this.closestPoint1 = new oimo.common.Vec3(); this.closestPoint2 = new oimo.common.Vec3(); this.polyhedron = new oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedron(); } _createClass(oimo_collision_narrowphase_detector_gjkepa_GjkEpa, [{ key: "computeClosestPointsImpl", value: function computeClosestPointsImpl(c1, c2, tf1, tf2, cache, useEpa) { this.c1 = c1; this.c2 = c2; this.tf1 = tf1; this.tf2 = tf2; var s = this.s; var w1 = this.w1; var w2 = this.w2; var closest = this.closest; var dir = this.dir; if (cache != null) { if (cache._gjkCache == null) { cache._gjkCache = new oimo.collision.narrowphase.detector.gjkepa.GjkCache(); } this.loadCache(cache._gjkCache); } else { dir.zero(); } if (dir.x * dir.x + dir.y * dir.y + dir.z * dir.z == 0) { var firstDirX; var firstDirY; var firstDirZ; firstDirX = tf2._positionX - tf1._positionX; firstDirY = tf2._positionY - tf1._positionY; firstDirZ = tf2._positionZ - tf1._positionZ; dir.x = firstDirX; dir.y = firstDirY; dir.z = firstDirZ; if (dir.x * dir.x + dir.y * dir.y + dir.z * dir.z < 1e-6) { dir.init(1, 0, 0); } } this.simplexSize = 0; this.computeWitnessPoint1(false); this.computeWitnessPoint2(false); var _this = this.s[this.simplexSize]; var v = this.w1[this.simplexSize]; _this.x = v.x; _this.y = v.y; _this.z = v.z; var v1 = this.w2[this.simplexSize]; _this.x -= v1.x; _this.y -= v1.y; _this.z -= v1.z; this.simplexSize = 1; var count = 0; while (count < 40) { var _v14 = 0; switch (this.simplexSize) { case 1: var _v15 = s[0]; closest.x = _v15.x; closest.y = _v15.y; closest.z = _v15.z; _v14 = 1; break; case 2: var v1X = void 0; var v1Y = void 0; var v1Z = void 0; var v2X = void 0; var v2Y = void 0; var v2Z = void 0; var v2 = s[0]; v1X = v2.x; v1Y = v2.y; v1Z = v2.z; var v3 = s[1]; v2X = v3.x; v2Y = v3.y; v2Z = v3.z; var v12X = void 0; var v12Y = void 0; var v12Z = void 0; v12X = v2X - v1X; v12Y = v2Y - v1Y; v12Z = v2Z - v1Z; var t = v12X * v1X + v12Y * v1Y + v12Z * v1Z; t = -t / (v12X * v12X + v12Y * v12Y + v12Z * v12Z); if (t < 0) { closest.x = v1X; closest.y = v1Y; closest.z = v1Z; _v14 = 1; } else if (t > 1) { closest.x = v2X; closest.y = v2Y; closest.z = v2Z; _v14 = 2; } else { var pX = void 0; var pY = void 0; var pZ = void 0; pX = v1X + v12X * t; pY = v1Y + v12Y * t; pZ = v1Z + v12Z * t; closest.x = pX; closest.y = pY; closest.z = pZ; _v14 = 3; } break; case 3: var vec1 = s[0]; var vec2 = s[1]; var vec3 = s[2]; var v1X1 = void 0; var v1Y1 = void 0; var v1Z1 = void 0; var v2X1 = void 0; var v2Y1 = void 0; var v2Z1 = void 0; var v3X = void 0; var v3Y = void 0; var v3Z = void 0; var v12X1 = void 0; var v12Y1 = void 0; var v12Z1 = void 0; var v23X = void 0; var v23Y = void 0; var v23Z = void 0; var v31X = void 0; var v31Y = void 0; var v31Z = void 0; v1X1 = vec1.x; v1Y1 = vec1.y; v1Z1 = vec1.z; v2X1 = vec2.x; v2Y1 = vec2.y; v2Z1 = vec2.z; v3X = vec3.x; v3Y = vec3.y; v3Z = vec3.z; v12X1 = v2X1 - v1X1; v12Y1 = v2Y1 - v1Y1; v12Z1 = v2Z1 - v1Z1; v23X = v3X - v2X1; v23Y = v3Y - v2Y1; v23Z = v3Z - v2Z1; v31X = v1X1 - v3X; v31Y = v1Y1 - v3Y; v31Z = v1Z1 - v3Z; var nX = void 0; var nY = void 0; var nZ = void 0; nX = v12Y1 * v23Z - v12Z1 * v23Y; nY = v12Z1 * v23X - v12X1 * v23Z; nZ = v12X1 * v23Y - v12Y1 * v23X; var n12X = void 0; var n12Y = void 0; var n12Z = void 0; var n23X = void 0; var n23Y = void 0; var n23Z = void 0; var n31X = void 0; var n31Y = void 0; var n31Z = void 0; n12X = v12Y1 * nZ - v12Z1 * nY; n12Y = v12Z1 * nX - v12X1 * nZ; n12Z = v12X1 * nY - v12Y1 * nX; n23X = v23Y * nZ - v23Z * nY; n23Y = v23Z * nX - v23X * nZ; n23Z = v23X * nY - v23Y * nX; n31X = v31Y * nZ - v31Z * nY; n31Y = v31Z * nX - v31X * nZ; n31Z = v31X * nY - v31Y * nX; var mind = -1; var minvX = void 0; var minvY = void 0; var minvZ = void 0; var mini = 0; minvX = 0; minvY = 0; minvZ = 0; if (v1X1 * n12X + v1Y1 * n12Y + v1Z1 * n12Z < 0) { var _v1X4 = void 0; var _v1Y4 = void 0; var _v1Z4 = void 0; var _v2X4 = void 0; var _v2Y4 = void 0; var _v2Z4 = void 0; _v1X4 = vec1.x; _v1Y4 = vec1.y; _v1Z4 = vec1.z; _v2X4 = vec2.x; _v2Y4 = vec2.y; _v2Z4 = vec2.z; var _v12X4 = void 0; var _v12Y4 = void 0; var _v12Z4 = void 0; _v12X4 = _v2X4 - _v1X4; _v12Y4 = _v2Y4 - _v1Y4; _v12Z4 = _v2Z4 - _v1Z4; var _t14 = _v12X4 * _v1X4 + _v12Y4 * _v1Y4 + _v12Z4 * _v1Z4; _t14 = -_t14 / (_v12X4 * _v12X4 + _v12Y4 * _v12Y4 + _v12Z4 * _v12Z4); var b = void 0; if (_t14 < 0) { closest.x = _v1X4; closest.y = _v1Y4; closest.z = _v1Z4; b = 1; } else if (_t14 > 1) { closest.x = _v2X4; closest.y = _v2Y4; closest.z = _v2Z4; b = 2; } else { var _pX3 = void 0; var _pY3 = void 0; var _pZ3 = void 0; _pX3 = _v1X4 + _v12X4 * _t14; _pY3 = _v1Y4 + _v12Y4 * _t14; _pZ3 = _v1Z4 + _v12Z4 * _t14; closest.x = _pX3; closest.y = _pY3; closest.z = _pZ3; b = 3; } mini = b; mind = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; minvX = closest.x; minvY = closest.y; minvZ = closest.z; } if (v2X1 * n23X + v2Y1 * n23Y + v2Z1 * n23Z < 0) { var _v1X5 = void 0; var _v1Y5 = void 0; var _v1Z5 = void 0; var _v2X5 = void 0; var _v2Y5 = void 0; var _v2Z5 = void 0; _v1X5 = vec2.x; _v1Y5 = vec2.y; _v1Z5 = vec2.z; _v2X5 = vec3.x; _v2Y5 = vec3.y; _v2Z5 = vec3.z; var _v12X5 = void 0; var _v12Y5 = void 0; var _v12Z5 = void 0; _v12X5 = _v2X5 - _v1X5; _v12Y5 = _v2Y5 - _v1Y5; _v12Z5 = _v2Z5 - _v1Z5; var _t15 = _v12X5 * _v1X5 + _v12Y5 * _v1Y5 + _v12Z5 * _v1Z5; _t15 = -_t15 / (_v12X5 * _v12X5 + _v12Y5 * _v12Y5 + _v12Z5 * _v12Z5); var _b = void 0; if (_t15 < 0) { closest.x = _v1X5; closest.y = _v1Y5; closest.z = _v1Z5; _b = 1; } else if (_t15 > 1) { closest.x = _v2X5; closest.y = _v2Y5; closest.z = _v2Z5; _b = 2; } else { var _pX4 = void 0; var _pY4 = void 0; var _pZ4 = void 0; _pX4 = _v1X5 + _v12X5 * _t15; _pY4 = _v1Y5 + _v12Y5 * _t15; _pZ4 = _v1Z5 + _v12Z5 * _t15; closest.x = _pX4; closest.y = _pY4; closest.z = _pZ4; _b = 3; } var d = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (mind < 0 || d < mind) { mini = _b << 1; mind = d; minvX = closest.x; minvY = closest.y; minvZ = closest.z; } } if (v3X * n31X + v3Y * n31Y + v3Z * n31Z < 0) { var _v1X6 = void 0; var _v1Y6 = void 0; var _v1Z6 = void 0; var _v2X6 = void 0; var _v2Y6 = void 0; var _v2Z6 = void 0; _v1X6 = vec1.x; _v1Y6 = vec1.y; _v1Z6 = vec1.z; _v2X6 = vec3.x; _v2Y6 = vec3.y; _v2Z6 = vec3.z; var _v12X6 = void 0; var _v12Y6 = void 0; var _v12Z6 = void 0; _v12X6 = _v2X6 - _v1X6; _v12Y6 = _v2Y6 - _v1Y6; _v12Z6 = _v2Z6 - _v1Z6; var _t16 = _v12X6 * _v1X6 + _v12Y6 * _v1Y6 + _v12Z6 * _v1Z6; _t16 = -_t16 / (_v12X6 * _v12X6 + _v12Y6 * _v12Y6 + _v12Z6 * _v12Z6); var _b2 = void 0; if (_t16 < 0) { closest.x = _v1X6; closest.y = _v1Y6; closest.z = _v1Z6; _b2 = 1; } else if (_t16 > 1) { closest.x = _v2X6; closest.y = _v2Y6; closest.z = _v2Z6; _b2 = 2; } else { var _pX5 = void 0; var _pY5 = void 0; var _pZ5 = void 0; _pX5 = _v1X6 + _v12X6 * _t16; _pY5 = _v1Y6 + _v12Y6 * _t16; _pZ5 = _v1Z6 + _v12Z6 * _t16; closest.x = _pX5; closest.y = _pY5; closest.z = _pZ5; _b2 = 3; } var _d2 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (mind < 0 || _d2 < mind) { mini = _b2 & 1 | (_b2 & 2) << 1; mind = _d2; minvX = closest.x; minvY = closest.y; minvZ = closest.z; } } if (mind > 0) { closest.x = minvX; closest.y = minvY; closest.z = minvZ; _v14 = mini; } else { var l = nX * nX + nY * nY + nZ * nZ; if (l > 0) { l = 1 / Math.sqrt(l); } nX *= l; nY *= l; nZ *= l; var l2 = nX * nX + nY * nY + nZ * nZ; l2 = (v1X1 * nX + v1Y1 * nY + v1Z1 * nZ) / l2; minvX = nX * l2; minvY = nY * l2; minvZ = nZ * l2; closest.x = minvX; closest.y = minvY; closest.z = minvZ; _v14 = 7; } break; case 4: var vec11 = s[0]; var vec21 = s[1]; var vec31 = s[2]; var vec4 = s[3]; var v1X2 = void 0; var v1Y2 = void 0; var v1Z2 = void 0; var v2X2 = void 0; var v2Y2 = void 0; var v2Z2 = void 0; var v3X1 = void 0; var v3Y1 = void 0; var v3Z1 = void 0; var v4X = void 0; var v4Y = void 0; var v4Z = void 0; var v12X2 = void 0; var v12Y2 = void 0; var v12Z2 = void 0; var v13X = void 0; var v13Y = void 0; var v13Z = void 0; var v14X = void 0; var v14Y = void 0; var v14Z = void 0; var v23X1 = void 0; var v23Y1 = void 0; var v23Z1 = void 0; var v24X = void 0; var v24Y = void 0; var v24Z = void 0; v1X2 = vec11.x; v1Y2 = vec11.y; v1Z2 = vec11.z; v2X2 = vec21.x; v2Y2 = vec21.y; v2Z2 = vec21.z; v3X1 = vec31.x; v3Y1 = vec31.y; v3Z1 = vec31.z; v4X = vec4.x; v4Y = vec4.y; v4Z = vec4.z; v12X2 = v2X2 - v1X2; v12Y2 = v2Y2 - v1Y2; v12Z2 = v2Z2 - v1Z2; v13X = v3X1 - v1X2; v13Y = v3Y1 - v1Y2; v13Z = v3Z1 - v1Z2; v14X = v4X - v1X2; v14Y = v4Y - v1Y2; v14Z = v4Z - v1Z2; v23X1 = v3X1 - v2X2; v23Y1 = v3Y1 - v2Y2; v23Z1 = v3Z1 - v2Z2; v24X = v4X - v2X2; v24Y = v4Y - v2Y2; v24Z = v4Z - v2Z2; var n123X = void 0; var n123Y = void 0; var n123Z = void 0; var n134X = void 0; var n134Y = void 0; var n134Z = void 0; var n142X = void 0; var n142Y = void 0; var n142Z = void 0; var n243X = void 0; var n243Y = void 0; var n243Z = void 0; n123X = v12Y2 * v13Z - v12Z2 * v13Y; n123Y = v12Z2 * v13X - v12X2 * v13Z; n123Z = v12X2 * v13Y - v12Y2 * v13X; n134X = v13Y * v14Z - v13Z * v14Y; n134Y = v13Z * v14X - v13X * v14Z; n134Z = v13X * v14Y - v13Y * v14X; n142X = v14Y * v12Z2 - v14Z * v12Y2; n142Y = v14Z * v12X2 - v14X * v12Z2; n142Z = v14X * v12Y2 - v14Y * v12X2; n243X = v24Y * v23Z1 - v24Z * v23Y1; n243Y = v24Z * v23X1 - v24X * v23Z1; n243Z = v24X * v23Y1 - v24Y * v23X1; var sign = v12X2 * n243X + v12Y2 * n243Y + v12Z2 * n243Z > 0 ? 1 : -1; var mind1 = -1; var minvX1 = void 0; var minvY1 = void 0; var minvZ1 = void 0; var mini1 = 0; minvX1 = 0; minvY1 = 0; minvZ1 = 0; if ((v1X2 * n123X + v1Y2 * n123Y + v1Z2 * n123Z) * sign < 0) { var _v1X7 = void 0; var _v1Y7 = void 0; var _v1Z7 = void 0; var _v2X7 = void 0; var _v2Y7 = void 0; var _v2Z7 = void 0; var _v3X = void 0; var _v3Y = void 0; var _v3Z = void 0; var _v12X7 = void 0; var _v12Y7 = void 0; var _v12Z7 = void 0; var _v23X = void 0; var _v23Y = void 0; var _v23Z = void 0; var _v31X = void 0; var _v31Y = void 0; var _v31Z = void 0; _v1X7 = vec11.x; _v1Y7 = vec11.y; _v1Z7 = vec11.z; _v2X7 = vec21.x; _v2Y7 = vec21.y; _v2Z7 = vec21.z; _v3X = vec31.x; _v3Y = vec31.y; _v3Z = vec31.z; _v12X7 = _v2X7 - _v1X7; _v12Y7 = _v2Y7 - _v1Y7; _v12Z7 = _v2Z7 - _v1Z7; _v23X = _v3X - _v2X7; _v23Y = _v3Y - _v2Y7; _v23Z = _v3Z - _v2Z7; _v31X = _v1X7 - _v3X; _v31Y = _v1Y7 - _v3Y; _v31Z = _v1Z7 - _v3Z; var _nX = void 0; var _nY = void 0; var _nZ = void 0; _nX = _v12Y7 * _v23Z - _v12Z7 * _v23Y; _nY = _v12Z7 * _v23X - _v12X7 * _v23Z; _nZ = _v12X7 * _v23Y - _v12Y7 * _v23X; var _n12X = void 0; var _n12Y = void 0; var _n12Z = void 0; var _n23X = void 0; var _n23Y = void 0; var _n23Z = void 0; var _n31X = void 0; var _n31Y = void 0; var _n31Z = void 0; _n12X = _v12Y7 * _nZ - _v12Z7 * _nY; _n12Y = _v12Z7 * _nX - _v12X7 * _nZ; _n12Z = _v12X7 * _nY - _v12Y7 * _nX; _n23X = _v23Y * _nZ - _v23Z * _nY; _n23Y = _v23Z * _nX - _v23X * _nZ; _n23Z = _v23X * _nY - _v23Y * _nX; _n31X = _v31Y * _nZ - _v31Z * _nY; _n31Y = _v31Z * _nX - _v31X * _nZ; _n31Z = _v31X * _nY - _v31Y * _nX; var _mind = -1; var _minvX = void 0; var _minvY = void 0; var _minvZ = void 0; var _mini = 0; _minvX = 0; _minvY = 0; _minvZ = 0; if (_v1X7 * _n12X + _v1Y7 * _n12Y + _v1Z7 * _n12Z < 0) { var _v1X8 = void 0; var _v1Y8 = void 0; var _v1Z8 = void 0; var _v2X8 = void 0; var _v2Y8 = void 0; var _v2Z8 = void 0; _v1X8 = vec11.x; _v1Y8 = vec11.y; _v1Z8 = vec11.z; _v2X8 = vec21.x; _v2Y8 = vec21.y; _v2Z8 = vec21.z; var _v12X8 = void 0; var _v12Y8 = void 0; var _v12Z8 = void 0; _v12X8 = _v2X8 - _v1X8; _v12Y8 = _v2Y8 - _v1Y8; _v12Z8 = _v2Z8 - _v1Z8; var _t17 = _v12X8 * _v1X8 + _v12Y8 * _v1Y8 + _v12Z8 * _v1Z8; _t17 = -_t17 / (_v12X8 * _v12X8 + _v12Y8 * _v12Y8 + _v12Z8 * _v12Z8); var _b4 = void 0; if (_t17 < 0) { closest.x = _v1X8; closest.y = _v1Y8; closest.z = _v1Z8; _b4 = 1; } else if (_t17 > 1) { closest.x = _v2X8; closest.y = _v2Y8; closest.z = _v2Z8; _b4 = 2; } else { var _pX6 = void 0; var _pY6 = void 0; var _pZ6 = void 0; _pX6 = _v1X8 + _v12X8 * _t17; _pY6 = _v1Y8 + _v12Y8 * _t17; _pZ6 = _v1Z8 + _v12Z8 * _t17; closest.x = _pX6; closest.y = _pY6; closest.z = _pZ6; _b4 = 3; } _mini = _b4; _mind = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; _minvX = closest.x; _minvY = closest.y; _minvZ = closest.z; } if (_v2X7 * _n23X + _v2Y7 * _n23Y + _v2Z7 * _n23Z < 0) { var _v1X9 = void 0; var _v1Y9 = void 0; var _v1Z9 = void 0; var _v2X9 = void 0; var _v2Y9 = void 0; var _v2Z9 = void 0; _v1X9 = vec21.x; _v1Y9 = vec21.y; _v1Z9 = vec21.z; _v2X9 = vec31.x; _v2Y9 = vec31.y; _v2Z9 = vec31.z; var _v12X9 = void 0; var _v12Y9 = void 0; var _v12Z9 = void 0; _v12X9 = _v2X9 - _v1X9; _v12Y9 = _v2Y9 - _v1Y9; _v12Z9 = _v2Z9 - _v1Z9; var _t18 = _v12X9 * _v1X9 + _v12Y9 * _v1Y9 + _v12Z9 * _v1Z9; _t18 = -_t18 / (_v12X9 * _v12X9 + _v12Y9 * _v12Y9 + _v12Z9 * _v12Z9); var _b5 = void 0; if (_t18 < 0) { closest.x = _v1X9; closest.y = _v1Y9; closest.z = _v1Z9; _b5 = 1; } else if (_t18 > 1) { closest.x = _v2X9; closest.y = _v2Y9; closest.z = _v2Z9; _b5 = 2; } else { var _pX7 = void 0; var _pY7 = void 0; var _pZ7 = void 0; _pX7 = _v1X9 + _v12X9 * _t18; _pY7 = _v1Y9 + _v12Y9 * _t18; _pZ7 = _v1Z9 + _v12Z9 * _t18; closest.x = _pX7; closest.y = _pY7; closest.z = _pZ7; _b5 = 3; } var _d3 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind < 0 || _d3 < _mind) { _mini = _b5 << 1; _mind = _d3; _minvX = closest.x; _minvY = closest.y; _minvZ = closest.z; } } if (_v3X * _n31X + _v3Y * _n31Y + _v3Z * _n31Z < 0) { var _v1X10 = void 0; var _v1Y10 = void 0; var _v1Z10 = void 0; var _v2X10 = void 0; var _v2Y10 = void 0; var _v2Z10 = void 0; _v1X10 = vec11.x; _v1Y10 = vec11.y; _v1Z10 = vec11.z; _v2X10 = vec31.x; _v2Y10 = vec31.y; _v2Z10 = vec31.z; var _v12X10 = void 0; var _v12Y10 = void 0; var _v12Z10 = void 0; _v12X10 = _v2X10 - _v1X10; _v12Y10 = _v2Y10 - _v1Y10; _v12Z10 = _v2Z10 - _v1Z10; var _t19 = _v12X10 * _v1X10 + _v12Y10 * _v1Y10 + _v12Z10 * _v1Z10; _t19 = -_t19 / (_v12X10 * _v12X10 + _v12Y10 * _v12Y10 + _v12Z10 * _v12Z10); var _b6 = void 0; if (_t19 < 0) { closest.x = _v1X10; closest.y = _v1Y10; closest.z = _v1Z10; _b6 = 1; } else if (_t19 > 1) { closest.x = _v2X10; closest.y = _v2Y10; closest.z = _v2Z10; _b6 = 2; } else { var _pX8 = void 0; var _pY8 = void 0; var _pZ8 = void 0; _pX8 = _v1X10 + _v12X10 * _t19; _pY8 = _v1Y10 + _v12Y10 * _t19; _pZ8 = _v1Z10 + _v12Z10 * _t19; closest.x = _pX8; closest.y = _pY8; closest.z = _pZ8; _b6 = 3; } var _d4 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind < 0 || _d4 < _mind) { _mini = _b6 & 1 | (_b6 & 2) << 1; _mind = _d4; _minvX = closest.x; _minvY = closest.y; _minvZ = closest.z; } } var _b3 = void 0; if (_mind > 0) { closest.x = _minvX; closest.y = _minvY; closest.z = _minvZ; _b3 = _mini; } else { var _l10 = _nX * _nX + _nY * _nY + _nZ * _nZ; if (_l10 > 0) { _l10 = 1 / Math.sqrt(_l10); } _nX *= _l10; _nY *= _l10; _nZ *= _l10; var _l11 = _nX * _nX + _nY * _nY + _nZ * _nZ; _l11 = (_v1X7 * _nX + _v1Y7 * _nY + _v1Z7 * _nZ) / _l11; _minvX = _nX * _l11; _minvY = _nY * _l11; _minvZ = _nZ * _l11; closest.x = _minvX; closest.y = _minvY; closest.z = _minvZ; _b3 = 7; } mini1 = _b3; mind1 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; minvX1 = closest.x; minvY1 = closest.y; minvZ1 = closest.z; } if ((v1X2 * n134X + v1Y2 * n134Y + v1Z2 * n134Z) * sign < 0) { var _v1X11 = void 0; var _v1Y11 = void 0; var _v1Z11 = void 0; var _v2X11 = void 0; var _v2Y11 = void 0; var _v2Z11 = void 0; var _v3X2 = void 0; var _v3Y2 = void 0; var _v3Z2 = void 0; var _v12X11 = void 0; var _v12Y11 = void 0; var _v12Z11 = void 0; var _v23X2 = void 0; var _v23Y2 = void 0; var _v23Z2 = void 0; var _v31X2 = void 0; var _v31Y2 = void 0; var _v31Z2 = void 0; _v1X11 = vec11.x; _v1Y11 = vec11.y; _v1Z11 = vec11.z; _v2X11 = vec31.x; _v2Y11 = vec31.y; _v2Z11 = vec31.z; _v3X2 = vec4.x; _v3Y2 = vec4.y; _v3Z2 = vec4.z; _v12X11 = _v2X11 - _v1X11; _v12Y11 = _v2Y11 - _v1Y11; _v12Z11 = _v2Z11 - _v1Z11; _v23X2 = _v3X2 - _v2X11; _v23Y2 = _v3Y2 - _v2Y11; _v23Z2 = _v3Z2 - _v2Z11; _v31X2 = _v1X11 - _v3X2; _v31Y2 = _v1Y11 - _v3Y2; _v31Z2 = _v1Z11 - _v3Z2; var _nX2 = void 0; var _nY2 = void 0; var _nZ2 = void 0; _nX2 = _v12Y11 * _v23Z2 - _v12Z11 * _v23Y2; _nY2 = _v12Z11 * _v23X2 - _v12X11 * _v23Z2; _nZ2 = _v12X11 * _v23Y2 - _v12Y11 * _v23X2; var _n12X2 = void 0; var _n12Y2 = void 0; var _n12Z2 = void 0; var _n23X2 = void 0; var _n23Y2 = void 0; var _n23Z2 = void 0; var _n31X2 = void 0; var _n31Y2 = void 0; var _n31Z2 = void 0; _n12X2 = _v12Y11 * _nZ2 - _v12Z11 * _nY2; _n12Y2 = _v12Z11 * _nX2 - _v12X11 * _nZ2; _n12Z2 = _v12X11 * _nY2 - _v12Y11 * _nX2; _n23X2 = _v23Y2 * _nZ2 - _v23Z2 * _nY2; _n23Y2 = _v23Z2 * _nX2 - _v23X2 * _nZ2; _n23Z2 = _v23X2 * _nY2 - _v23Y2 * _nX2; _n31X2 = _v31Y2 * _nZ2 - _v31Z2 * _nY2; _n31Y2 = _v31Z2 * _nX2 - _v31X2 * _nZ2; _n31Z2 = _v31X2 * _nY2 - _v31Y2 * _nX2; var _mind2 = -1; var _minvX2 = void 0; var _minvY2 = void 0; var _minvZ2 = void 0; var _mini2 = 0; _minvX2 = 0; _minvY2 = 0; _minvZ2 = 0; if (_v1X11 * _n12X2 + _v1Y11 * _n12Y2 + _v1Z11 * _n12Z2 < 0) { var _v1X12 = void 0; var _v1Y12 = void 0; var _v1Z12 = void 0; var _v2X12 = void 0; var _v2Y12 = void 0; var _v2Z12 = void 0; _v1X12 = vec11.x; _v1Y12 = vec11.y; _v1Z12 = vec11.z; _v2X12 = vec31.x; _v2Y12 = vec31.y; _v2Z12 = vec31.z; var _v12X12 = void 0; var _v12Y12 = void 0; var _v12Z12 = void 0; _v12X12 = _v2X12 - _v1X12; _v12Y12 = _v2Y12 - _v1Y12; _v12Z12 = _v2Z12 - _v1Z12; var _t20 = _v12X12 * _v1X12 + _v12Y12 * _v1Y12 + _v12Z12 * _v1Z12; _t20 = -_t20 / (_v12X12 * _v12X12 + _v12Y12 * _v12Y12 + _v12Z12 * _v12Z12); var _b8 = void 0; if (_t20 < 0) { closest.x = _v1X12; closest.y = _v1Y12; closest.z = _v1Z12; _b8 = 1; } else if (_t20 > 1) { closest.x = _v2X12; closest.y = _v2Y12; closest.z = _v2Z12; _b8 = 2; } else { var _pX9 = void 0; var _pY9 = void 0; var _pZ9 = void 0; _pX9 = _v1X12 + _v12X12 * _t20; _pY9 = _v1Y12 + _v12Y12 * _t20; _pZ9 = _v1Z12 + _v12Z12 * _t20; closest.x = _pX9; closest.y = _pY9; closest.z = _pZ9; _b8 = 3; } _mini2 = _b8; _mind2 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; _minvX2 = closest.x; _minvY2 = closest.y; _minvZ2 = closest.z; } if (_v2X11 * _n23X2 + _v2Y11 * _n23Y2 + _v2Z11 * _n23Z2 < 0) { var _v1X13 = void 0; var _v1Y13 = void 0; var _v1Z13 = void 0; var _v2X13 = void 0; var _v2Y13 = void 0; var _v2Z13 = void 0; _v1X13 = vec31.x; _v1Y13 = vec31.y; _v1Z13 = vec31.z; _v2X13 = vec4.x; _v2Y13 = vec4.y; _v2Z13 = vec4.z; var _v12X13 = void 0; var _v12Y13 = void 0; var _v12Z13 = void 0; _v12X13 = _v2X13 - _v1X13; _v12Y13 = _v2Y13 - _v1Y13; _v12Z13 = _v2Z13 - _v1Z13; var _t21 = _v12X13 * _v1X13 + _v12Y13 * _v1Y13 + _v12Z13 * _v1Z13; _t21 = -_t21 / (_v12X13 * _v12X13 + _v12Y13 * _v12Y13 + _v12Z13 * _v12Z13); var _b9 = void 0; if (_t21 < 0) { closest.x = _v1X13; closest.y = _v1Y13; closest.z = _v1Z13; _b9 = 1; } else if (_t21 > 1) { closest.x = _v2X13; closest.y = _v2Y13; closest.z = _v2Z13; _b9 = 2; } else { var _pX10 = void 0; var _pY10 = void 0; var _pZ10 = void 0; _pX10 = _v1X13 + _v12X13 * _t21; _pY10 = _v1Y13 + _v12Y13 * _t21; _pZ10 = _v1Z13 + _v12Z13 * _t21; closest.x = _pX10; closest.y = _pY10; closest.z = _pZ10; _b9 = 3; } var _d6 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind2 < 0 || _d6 < _mind2) { _mini2 = _b9 << 1; _mind2 = _d6; _minvX2 = closest.x; _minvY2 = closest.y; _minvZ2 = closest.z; } } if (_v3X2 * _n31X2 + _v3Y2 * _n31Y2 + _v3Z2 * _n31Z2 < 0) { var _v1X14 = void 0; var _v1Y14 = void 0; var _v1Z14 = void 0; var _v2X14 = void 0; var _v2Y14 = void 0; var _v2Z14 = void 0; _v1X14 = vec11.x; _v1Y14 = vec11.y; _v1Z14 = vec11.z; _v2X14 = vec4.x; _v2Y14 = vec4.y; _v2Z14 = vec4.z; var _v12X14 = void 0; var _v12Y14 = void 0; var _v12Z14 = void 0; _v12X14 = _v2X14 - _v1X14; _v12Y14 = _v2Y14 - _v1Y14; _v12Z14 = _v2Z14 - _v1Z14; var _t22 = _v12X14 * _v1X14 + _v12Y14 * _v1Y14 + _v12Z14 * _v1Z14; _t22 = -_t22 / (_v12X14 * _v12X14 + _v12Y14 * _v12Y14 + _v12Z14 * _v12Z14); var _b10 = void 0; if (_t22 < 0) { closest.x = _v1X14; closest.y = _v1Y14; closest.z = _v1Z14; _b10 = 1; } else if (_t22 > 1) { closest.x = _v2X14; closest.y = _v2Y14; closest.z = _v2Z14; _b10 = 2; } else { var _pX11 = void 0; var _pY11 = void 0; var _pZ11 = void 0; _pX11 = _v1X14 + _v12X14 * _t22; _pY11 = _v1Y14 + _v12Y14 * _t22; _pZ11 = _v1Z14 + _v12Z14 * _t22; closest.x = _pX11; closest.y = _pY11; closest.z = _pZ11; _b10 = 3; } var _d7 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind2 < 0 || _d7 < _mind2) { _mini2 = _b10 & 1 | (_b10 & 2) << 1; _mind2 = _d7; _minvX2 = closest.x; _minvY2 = closest.y; _minvZ2 = closest.z; } } var _b7 = void 0; if (_mind2 > 0) { closest.x = _minvX2; closest.y = _minvY2; closest.z = _minvZ2; _b7 = _mini2; } else { var _l12 = _nX2 * _nX2 + _nY2 * _nY2 + _nZ2 * _nZ2; if (_l12 > 0) { _l12 = 1 / Math.sqrt(_l12); } _nX2 *= _l12; _nY2 *= _l12; _nZ2 *= _l12; var _l13 = _nX2 * _nX2 + _nY2 * _nY2 + _nZ2 * _nZ2; _l13 = (_v1X11 * _nX2 + _v1Y11 * _nY2 + _v1Z11 * _nZ2) / _l13; _minvX2 = _nX2 * _l13; _minvY2 = _nY2 * _l13; _minvZ2 = _nZ2 * _l13; closest.x = _minvX2; closest.y = _minvY2; closest.z = _minvZ2; _b7 = 7; } var _d5 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (mind1 < 0 || _d5 < mind1) { mini1 = _b7 & 1 | (_b7 & 6) << 1; mind1 = _d5; minvX1 = closest.x; minvY1 = closest.y; minvZ1 = closest.z; } } if ((v1X2 * n142X + v1Y2 * n142Y + v1Z2 * n142Z) * sign < 0) { var _v1X15 = void 0; var _v1Y15 = void 0; var _v1Z15 = void 0; var _v2X15 = void 0; var _v2Y15 = void 0; var _v2Z15 = void 0; var _v3X3 = void 0; var _v3Y3 = void 0; var _v3Z3 = void 0; var _v12X15 = void 0; var _v12Y15 = void 0; var _v12Z15 = void 0; var _v23X3 = void 0; var _v23Y3 = void 0; var _v23Z3 = void 0; var _v31X3 = void 0; var _v31Y3 = void 0; var _v31Z3 = void 0; _v1X15 = vec11.x; _v1Y15 = vec11.y; _v1Z15 = vec11.z; _v2X15 = vec21.x; _v2Y15 = vec21.y; _v2Z15 = vec21.z; _v3X3 = vec4.x; _v3Y3 = vec4.y; _v3Z3 = vec4.z; _v12X15 = _v2X15 - _v1X15; _v12Y15 = _v2Y15 - _v1Y15; _v12Z15 = _v2Z15 - _v1Z15; _v23X3 = _v3X3 - _v2X15; _v23Y3 = _v3Y3 - _v2Y15; _v23Z3 = _v3Z3 - _v2Z15; _v31X3 = _v1X15 - _v3X3; _v31Y3 = _v1Y15 - _v3Y3; _v31Z3 = _v1Z15 - _v3Z3; var _nX3 = void 0; var _nY3 = void 0; var _nZ3 = void 0; _nX3 = _v12Y15 * _v23Z3 - _v12Z15 * _v23Y3; _nY3 = _v12Z15 * _v23X3 - _v12X15 * _v23Z3; _nZ3 = _v12X15 * _v23Y3 - _v12Y15 * _v23X3; var _n12X3 = void 0; var _n12Y3 = void 0; var _n12Z3 = void 0; var _n23X3 = void 0; var _n23Y3 = void 0; var _n23Z3 = void 0; var _n31X3 = void 0; var _n31Y3 = void 0; var _n31Z3 = void 0; _n12X3 = _v12Y15 * _nZ3 - _v12Z15 * _nY3; _n12Y3 = _v12Z15 * _nX3 - _v12X15 * _nZ3; _n12Z3 = _v12X15 * _nY3 - _v12Y15 * _nX3; _n23X3 = _v23Y3 * _nZ3 - _v23Z3 * _nY3; _n23Y3 = _v23Z3 * _nX3 - _v23X3 * _nZ3; _n23Z3 = _v23X3 * _nY3 - _v23Y3 * _nX3; _n31X3 = _v31Y3 * _nZ3 - _v31Z3 * _nY3; _n31Y3 = _v31Z3 * _nX3 - _v31X3 * _nZ3; _n31Z3 = _v31X3 * _nY3 - _v31Y3 * _nX3; var _mind3 = -1; var _minvX3 = void 0; var _minvY3 = void 0; var _minvZ3 = void 0; var _mini3 = 0; _minvX3 = 0; _minvY3 = 0; _minvZ3 = 0; if (_v1X15 * _n12X3 + _v1Y15 * _n12Y3 + _v1Z15 * _n12Z3 < 0) { var _v1X16 = void 0; var _v1Y16 = void 0; var _v1Z16 = void 0; var _v2X16 = void 0; var _v2Y16 = void 0; var _v2Z16 = void 0; _v1X16 = vec11.x; _v1Y16 = vec11.y; _v1Z16 = vec11.z; _v2X16 = vec21.x; _v2Y16 = vec21.y; _v2Z16 = vec21.z; var _v12X16 = void 0; var _v12Y16 = void 0; var _v12Z16 = void 0; _v12X16 = _v2X16 - _v1X16; _v12Y16 = _v2Y16 - _v1Y16; _v12Z16 = _v2Z16 - _v1Z16; var _t23 = _v12X16 * _v1X16 + _v12Y16 * _v1Y16 + _v12Z16 * _v1Z16; _t23 = -_t23 / (_v12X16 * _v12X16 + _v12Y16 * _v12Y16 + _v12Z16 * _v12Z16); var _b12 = void 0; if (_t23 < 0) { closest.x = _v1X16; closest.y = _v1Y16; closest.z = _v1Z16; _b12 = 1; } else if (_t23 > 1) { closest.x = _v2X16; closest.y = _v2Y16; closest.z = _v2Z16; _b12 = 2; } else { var _pX12 = void 0; var _pY12 = void 0; var _pZ12 = void 0; _pX12 = _v1X16 + _v12X16 * _t23; _pY12 = _v1Y16 + _v12Y16 * _t23; _pZ12 = _v1Z16 + _v12Z16 * _t23; closest.x = _pX12; closest.y = _pY12; closest.z = _pZ12; _b12 = 3; } _mini3 = _b12; _mind3 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; _minvX3 = closest.x; _minvY3 = closest.y; _minvZ3 = closest.z; } if (_v2X15 * _n23X3 + _v2Y15 * _n23Y3 + _v2Z15 * _n23Z3 < 0) { var _v1X17 = void 0; var _v1Y17 = void 0; var _v1Z17 = void 0; var _v2X17 = void 0; var _v2Y17 = void 0; var _v2Z17 = void 0; _v1X17 = vec21.x; _v1Y17 = vec21.y; _v1Z17 = vec21.z; _v2X17 = vec4.x; _v2Y17 = vec4.y; _v2Z17 = vec4.z; var _v12X17 = void 0; var _v12Y17 = void 0; var _v12Z17 = void 0; _v12X17 = _v2X17 - _v1X17; _v12Y17 = _v2Y17 - _v1Y17; _v12Z17 = _v2Z17 - _v1Z17; var _t24 = _v12X17 * _v1X17 + _v12Y17 * _v1Y17 + _v12Z17 * _v1Z17; _t24 = -_t24 / (_v12X17 * _v12X17 + _v12Y17 * _v12Y17 + _v12Z17 * _v12Z17); var _b13 = void 0; if (_t24 < 0) { closest.x = _v1X17; closest.y = _v1Y17; closest.z = _v1Z17; _b13 = 1; } else if (_t24 > 1) { closest.x = _v2X17; closest.y = _v2Y17; closest.z = _v2Z17; _b13 = 2; } else { var _pX13 = void 0; var _pY13 = void 0; var _pZ13 = void 0; _pX13 = _v1X17 + _v12X17 * _t24; _pY13 = _v1Y17 + _v12Y17 * _t24; _pZ13 = _v1Z17 + _v12Z17 * _t24; closest.x = _pX13; closest.y = _pY13; closest.z = _pZ13; _b13 = 3; } var _d9 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind3 < 0 || _d9 < _mind3) { _mini3 = _b13 << 1; _mind3 = _d9; _minvX3 = closest.x; _minvY3 = closest.y; _minvZ3 = closest.z; } } if (_v3X3 * _n31X3 + _v3Y3 * _n31Y3 + _v3Z3 * _n31Z3 < 0) { var _v1X18 = void 0; var _v1Y18 = void 0; var _v1Z18 = void 0; var _v2X18 = void 0; var _v2Y18 = void 0; var _v2Z18 = void 0; _v1X18 = vec11.x; _v1Y18 = vec11.y; _v1Z18 = vec11.z; _v2X18 = vec4.x; _v2Y18 = vec4.y; _v2Z18 = vec4.z; var _v12X18 = void 0; var _v12Y18 = void 0; var _v12Z18 = void 0; _v12X18 = _v2X18 - _v1X18; _v12Y18 = _v2Y18 - _v1Y18; _v12Z18 = _v2Z18 - _v1Z18; var _t25 = _v12X18 * _v1X18 + _v12Y18 * _v1Y18 + _v12Z18 * _v1Z18; _t25 = -_t25 / (_v12X18 * _v12X18 + _v12Y18 * _v12Y18 + _v12Z18 * _v12Z18); var _b14 = void 0; if (_t25 < 0) { closest.x = _v1X18; closest.y = _v1Y18; closest.z = _v1Z18; _b14 = 1; } else if (_t25 > 1) { closest.x = _v2X18; closest.y = _v2Y18; closest.z = _v2Z18; _b14 = 2; } else { var _pX14 = void 0; var _pY14 = void 0; var _pZ14 = void 0; _pX14 = _v1X18 + _v12X18 * _t25; _pY14 = _v1Y18 + _v12Y18 * _t25; _pZ14 = _v1Z18 + _v12Z18 * _t25; closest.x = _pX14; closest.y = _pY14; closest.z = _pZ14; _b14 = 3; } var _d10 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind3 < 0 || _d10 < _mind3) { _mini3 = _b14 & 1 | (_b14 & 2) << 1; _mind3 = _d10; _minvX3 = closest.x; _minvY3 = closest.y; _minvZ3 = closest.z; } } var _b11 = void 0; if (_mind3 > 0) { closest.x = _minvX3; closest.y = _minvY3; closest.z = _minvZ3; _b11 = _mini3; } else { var _l14 = _nX3 * _nX3 + _nY3 * _nY3 + _nZ3 * _nZ3; if (_l14 > 0) { _l14 = 1 / Math.sqrt(_l14); } _nX3 *= _l14; _nY3 *= _l14; _nZ3 *= _l14; var _l15 = _nX3 * _nX3 + _nY3 * _nY3 + _nZ3 * _nZ3; _l15 = (_v1X15 * _nX3 + _v1Y15 * _nY3 + _v1Z15 * _nZ3) / _l15; _minvX3 = _nX3 * _l15; _minvY3 = _nY3 * _l15; _minvZ3 = _nZ3 * _l15; closest.x = _minvX3; closest.y = _minvY3; closest.z = _minvZ3; _b11 = 7; } var _d8 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (mind1 < 0 || _d8 < mind1) { mini1 = _b11 & 3 | (_b11 & 4) << 1; mind1 = _d8; minvX1 = closest.x; minvY1 = closest.y; minvZ1 = closest.z; } } if ((v2X2 * n243X + v2Y2 * n243Y + v2Z2 * n243Z) * sign < 0) { var _v1X19 = void 0; var _v1Y19 = void 0; var _v1Z19 = void 0; var _v2X19 = void 0; var _v2Y19 = void 0; var _v2Z19 = void 0; var _v3X4 = void 0; var _v3Y4 = void 0; var _v3Z4 = void 0; var _v12X19 = void 0; var _v12Y19 = void 0; var _v12Z19 = void 0; var _v23X4 = void 0; var _v23Y4 = void 0; var _v23Z4 = void 0; var _v31X4 = void 0; var _v31Y4 = void 0; var _v31Z4 = void 0; _v1X19 = vec21.x; _v1Y19 = vec21.y; _v1Z19 = vec21.z; _v2X19 = vec31.x; _v2Y19 = vec31.y; _v2Z19 = vec31.z; _v3X4 = vec4.x; _v3Y4 = vec4.y; _v3Z4 = vec4.z; _v12X19 = _v2X19 - _v1X19; _v12Y19 = _v2Y19 - _v1Y19; _v12Z19 = _v2Z19 - _v1Z19; _v23X4 = _v3X4 - _v2X19; _v23Y4 = _v3Y4 - _v2Y19; _v23Z4 = _v3Z4 - _v2Z19; _v31X4 = _v1X19 - _v3X4; _v31Y4 = _v1Y19 - _v3Y4; _v31Z4 = _v1Z19 - _v3Z4; var _nX4 = void 0; var _nY4 = void 0; var _nZ4 = void 0; _nX4 = _v12Y19 * _v23Z4 - _v12Z19 * _v23Y4; _nY4 = _v12Z19 * _v23X4 - _v12X19 * _v23Z4; _nZ4 = _v12X19 * _v23Y4 - _v12Y19 * _v23X4; var _n12X4 = void 0; var _n12Y4 = void 0; var _n12Z4 = void 0; var _n23X4 = void 0; var _n23Y4 = void 0; var _n23Z4 = void 0; var _n31X4 = void 0; var _n31Y4 = void 0; var _n31Z4 = void 0; _n12X4 = _v12Y19 * _nZ4 - _v12Z19 * _nY4; _n12Y4 = _v12Z19 * _nX4 - _v12X19 * _nZ4; _n12Z4 = _v12X19 * _nY4 - _v12Y19 * _nX4; _n23X4 = _v23Y4 * _nZ4 - _v23Z4 * _nY4; _n23Y4 = _v23Z4 * _nX4 - _v23X4 * _nZ4; _n23Z4 = _v23X4 * _nY4 - _v23Y4 * _nX4; _n31X4 = _v31Y4 * _nZ4 - _v31Z4 * _nY4; _n31Y4 = _v31Z4 * _nX4 - _v31X4 * _nZ4; _n31Z4 = _v31X4 * _nY4 - _v31Y4 * _nX4; var _mind4 = -1; var _minvX4 = void 0; var _minvY4 = void 0; var _minvZ4 = void 0; var _mini4 = 0; _minvX4 = 0; _minvY4 = 0; _minvZ4 = 0; if (_v1X19 * _n12X4 + _v1Y19 * _n12Y4 + _v1Z19 * _n12Z4 < 0) { var _v1X20 = void 0; var _v1Y20 = void 0; var _v1Z20 = void 0; var _v2X20 = void 0; var _v2Y20 = void 0; var _v2Z20 = void 0; _v1X20 = vec21.x; _v1Y20 = vec21.y; _v1Z20 = vec21.z; _v2X20 = vec31.x; _v2Y20 = vec31.y; _v2Z20 = vec31.z; var _v12X20 = void 0; var _v12Y20 = void 0; var _v12Z20 = void 0; _v12X20 = _v2X20 - _v1X20; _v12Y20 = _v2Y20 - _v1Y20; _v12Z20 = _v2Z20 - _v1Z20; var _t26 = _v12X20 * _v1X20 + _v12Y20 * _v1Y20 + _v12Z20 * _v1Z20; _t26 = -_t26 / (_v12X20 * _v12X20 + _v12Y20 * _v12Y20 + _v12Z20 * _v12Z20); var _b16 = void 0; if (_t26 < 0) { closest.x = _v1X20; closest.y = _v1Y20; closest.z = _v1Z20; _b16 = 1; } else if (_t26 > 1) { closest.x = _v2X20; closest.y = _v2Y20; closest.z = _v2Z20; _b16 = 2; } else { var _pX15 = void 0; var _pY15 = void 0; var _pZ15 = void 0; _pX15 = _v1X20 + _v12X20 * _t26; _pY15 = _v1Y20 + _v12Y20 * _t26; _pZ15 = _v1Z20 + _v12Z20 * _t26; closest.x = _pX15; closest.y = _pY15; closest.z = _pZ15; _b16 = 3; } _mini4 = _b16; _mind4 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; _minvX4 = closest.x; _minvY4 = closest.y; _minvZ4 = closest.z; } if (_v2X19 * _n23X4 + _v2Y19 * _n23Y4 + _v2Z19 * _n23Z4 < 0) { var _v1X21 = void 0; var _v1Y21 = void 0; var _v1Z21 = void 0; var _v2X21 = void 0; var _v2Y21 = void 0; var _v2Z21 = void 0; _v1X21 = vec31.x; _v1Y21 = vec31.y; _v1Z21 = vec31.z; _v2X21 = vec4.x; _v2Y21 = vec4.y; _v2Z21 = vec4.z; var _v12X21 = void 0; var _v12Y21 = void 0; var _v12Z21 = void 0; _v12X21 = _v2X21 - _v1X21; _v12Y21 = _v2Y21 - _v1Y21; _v12Z21 = _v2Z21 - _v1Z21; var _t27 = _v12X21 * _v1X21 + _v12Y21 * _v1Y21 + _v12Z21 * _v1Z21; _t27 = -_t27 / (_v12X21 * _v12X21 + _v12Y21 * _v12Y21 + _v12Z21 * _v12Z21); var _b17 = void 0; if (_t27 < 0) { closest.x = _v1X21; closest.y = _v1Y21; closest.z = _v1Z21; _b17 = 1; } else if (_t27 > 1) { closest.x = _v2X21; closest.y = _v2Y21; closest.z = _v2Z21; _b17 = 2; } else { var _pX16 = void 0; var _pY16 = void 0; var _pZ16 = void 0; _pX16 = _v1X21 + _v12X21 * _t27; _pY16 = _v1Y21 + _v12Y21 * _t27; _pZ16 = _v1Z21 + _v12Z21 * _t27; closest.x = _pX16; closest.y = _pY16; closest.z = _pZ16; _b17 = 3; } var _d12 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind4 < 0 || _d12 < _mind4) { _mini4 = _b17 << 1; _mind4 = _d12; _minvX4 = closest.x; _minvY4 = closest.y; _minvZ4 = closest.z; } } if (_v3X4 * _n31X4 + _v3Y4 * _n31Y4 + _v3Z4 * _n31Z4 < 0) { var _v1X22 = void 0; var _v1Y22 = void 0; var _v1Z22 = void 0; var _v2X22 = void 0; var _v2Y22 = void 0; var _v2Z22 = void 0; _v1X22 = vec21.x; _v1Y22 = vec21.y; _v1Z22 = vec21.z; _v2X22 = vec4.x; _v2Y22 = vec4.y; _v2Z22 = vec4.z; var _v12X22 = void 0; var _v12Y22 = void 0; var _v12Z22 = void 0; _v12X22 = _v2X22 - _v1X22; _v12Y22 = _v2Y22 - _v1Y22; _v12Z22 = _v2Z22 - _v1Z22; var _t28 = _v12X22 * _v1X22 + _v12Y22 * _v1Y22 + _v12Z22 * _v1Z22; _t28 = -_t28 / (_v12X22 * _v12X22 + _v12Y22 * _v12Y22 + _v12Z22 * _v12Z22); var _b18 = void 0; if (_t28 < 0) { closest.x = _v1X22; closest.y = _v1Y22; closest.z = _v1Z22; _b18 = 1; } else if (_t28 > 1) { closest.x = _v2X22; closest.y = _v2Y22; closest.z = _v2Z22; _b18 = 2; } else { var _pX17 = void 0; var _pY17 = void 0; var _pZ17 = void 0; _pX17 = _v1X22 + _v12X22 * _t28; _pY17 = _v1Y22 + _v12Y22 * _t28; _pZ17 = _v1Z22 + _v12Z22 * _t28; closest.x = _pX17; closest.y = _pY17; closest.z = _pZ17; _b18 = 3; } var _d13 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind4 < 0 || _d13 < _mind4) { _mini4 = _b18 & 1 | (_b18 & 2) << 1; _mind4 = _d13; _minvX4 = closest.x; _minvY4 = closest.y; _minvZ4 = closest.z; } } var _b15 = void 0; if (_mind4 > 0) { closest.x = _minvX4; closest.y = _minvY4; closest.z = _minvZ4; _b15 = _mini4; } else { var _l16 = _nX4 * _nX4 + _nY4 * _nY4 + _nZ4 * _nZ4; if (_l16 > 0) { _l16 = 1 / Math.sqrt(_l16); } _nX4 *= _l16; _nY4 *= _l16; _nZ4 *= _l16; var _l17 = _nX4 * _nX4 + _nY4 * _nY4 + _nZ4 * _nZ4; _l17 = (_v1X19 * _nX4 + _v1Y19 * _nY4 + _v1Z19 * _nZ4) / _l17; _minvX4 = _nX4 * _l17; _minvY4 = _nY4 * _l17; _minvZ4 = _nZ4 * _l17; closest.x = _minvX4; closest.y = _minvY4; closest.z = _minvZ4; _b15 = 7; } var _d11 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (mind1 < 0 || _d11 < mind1) { mini1 = _b15 << 1; mind1 = _d11; minvX1 = closest.x; minvY1 = closest.y; minvZ1 = closest.z; } } if (mind1 > 0) { closest.x = minvX1; closest.y = minvY1; closest.z = minvZ1; _v14 = mini1; } else { closest.zero(); _v14 = 15; } break; } if (closest.x * closest.x + closest.y * closest.y + closest.z * closest.z < 1e-008) { if (!useEpa) { this.distance = 0; return 0; } switch (this.simplexSize) { case 1: this.pointToTetrahedron(); break; case 2: this.lineToTetrahedron(); break; case 3: this.triangleToTetrahedron(); break; } if (this.simplexSize == 4) { var epaState = this.computeDepth(c1, c2, tf1, tf2, s, w1, w2); if (epaState != 0) { this.distance = 0; return epaState; } this.distance = -this.depth; return 0; } this.distance = 0; return 1; } this.shrinkSimplex(_v14); dir.x = closest.x; dir.y = closest.y; dir.z = closest.z; dir.x = -dir.x; dir.y = -dir.y; dir.z = -dir.z; this.computeWitnessPoint1(false); this.computeWitnessPoint2(false); var _this71 = this.s[this.simplexSize]; var v4 = this.w1[this.simplexSize]; _this71.x = v4.x; _this71.y = v4.y; _this71.z = v4.z; var v5 = this.w2[this.simplexSize]; _this71.x -= v5.x; _this71.y -= v5.y; _this71.z -= v5.z; if (dir.x * dir.x + dir.y * dir.y + dir.z * dir.z < 1e-008) { throw new Error("!?"); } var _this1 = s[this.simplexSize]; if (_this1.x * dir.x + _this1.y * dir.y + _this1.z * dir.z - (closest.x * dir.x + closest.y * dir.y + closest.z * dir.z) < 1e-008) { this.interpolateClosestPoints(); this.distance = Math.sqrt(closest.x * closest.x + closest.y * closest.y + closest.z * closest.z); if (cache != null && cache._gjkCache != null) { this.saveCache(cache._gjkCache); } return 0; } this.simplexSize++; ++count; } return 2; } }, { key: "convexCastImpl", value: function convexCastImpl(c1, c2, tf1, tf2, tl1, tl2, hit) { this.c1 = c1; this.c2 = c2; this.tf1 = tf1; this.tf2 = tf2; var s = this.s; var closest = this.closest; var dir = this.dir; var firstDirX; var firstDirY; var firstDirZ; firstDirX = tf2._positionX - tf1._positionX; firstDirY = tf2._positionY - tf1._positionY; firstDirZ = tf2._positionZ - tf1._positionZ; dir.x = firstDirX; dir.y = firstDirY; dir.z = firstDirZ; if (dir.x * dir.x + dir.y * dir.y + dir.z * dir.z < 1e-6) { dir.init(1, 0, 0); } this.simplexSize = 0; if (this.c1 != null) { this.computeWitnessPoint1(true); } else { var _v16 = this.w1[this.simplexSize]; _v16.x = this.tf1._positionX; _v16.y = this.tf1._positionY; _v16.z = this.tf1._positionZ; } this.computeWitnessPoint2(true); var _this = this.s[this.simplexSize]; var v = this.w1[this.simplexSize]; _this.x = v.x; _this.y = v.y; _this.z = v.z; var v1 = this.w2[this.simplexSize]; _this.x -= v1.x; _this.y -= v1.y; _this.z -= v1.z; this.simplexSize = 1; var count = 0; var lambda = 0.0; var rayX = this.rayX; var rayR = this.rayR; rayX.zero(); rayR.x = tl2.x; rayR.y = tl2.y; rayR.z = tl2.z; rayR.x -= tl1.x; rayR.y -= tl1.y; rayR.z -= tl1.z; while (count < 40) { var _v17 = 0; switch (this.simplexSize) { case 1: var _v18 = s[0]; closest.x = _v18.x; closest.y = _v18.y; closest.z = _v18.z; _v17 = 1; break; case 2: var v1X = void 0; var v1Y = void 0; var v1Z = void 0; var v2X = void 0; var v2Y = void 0; var v2Z = void 0; var v2 = s[0]; v1X = v2.x; v1Y = v2.y; v1Z = v2.z; var v3 = s[1]; v2X = v3.x; v2Y = v3.y; v2Z = v3.z; var v12X = void 0; var v12Y = void 0; var v12Z = void 0; v12X = v2X - v1X; v12Y = v2Y - v1Y; v12Z = v2Z - v1Z; var t = v12X * v1X + v12Y * v1Y + v12Z * v1Z; t = -t / (v12X * v12X + v12Y * v12Y + v12Z * v12Z); if (t < 0) { closest.x = v1X; closest.y = v1Y; closest.z = v1Z; _v17 = 1; } else if (t > 1) { closest.x = v2X; closest.y = v2Y; closest.z = v2Z; _v17 = 2; } else { var pX = void 0; var pY = void 0; var pZ = void 0; pX = v1X + v12X * t; pY = v1Y + v12Y * t; pZ = v1Z + v12Z * t; closest.x = pX; closest.y = pY; closest.z = pZ; _v17 = 3; } break; case 3: var vec1 = s[0]; var vec2 = s[1]; var vec3 = s[2]; var v1X1 = void 0; var v1Y1 = void 0; var v1Z1 = void 0; var v2X1 = void 0; var v2Y1 = void 0; var v2Z1 = void 0; var v3X = void 0; var v3Y = void 0; var v3Z = void 0; var v12X1 = void 0; var v12Y1 = void 0; var v12Z1 = void 0; var v23X = void 0; var v23Y = void 0; var v23Z = void 0; var v31X = void 0; var v31Y = void 0; var v31Z = void 0; v1X1 = vec1.x; v1Y1 = vec1.y; v1Z1 = vec1.z; v2X1 = vec2.x; v2Y1 = vec2.y; v2Z1 = vec2.z; v3X = vec3.x; v3Y = vec3.y; v3Z = vec3.z; v12X1 = v2X1 - v1X1; v12Y1 = v2Y1 - v1Y1; v12Z1 = v2Z1 - v1Z1; v23X = v3X - v2X1; v23Y = v3Y - v2Y1; v23Z = v3Z - v2Z1; v31X = v1X1 - v3X; v31Y = v1Y1 - v3Y; v31Z = v1Z1 - v3Z; var nX = void 0; var nY = void 0; var nZ = void 0; nX = v12Y1 * v23Z - v12Z1 * v23Y; nY = v12Z1 * v23X - v12X1 * v23Z; nZ = v12X1 * v23Y - v12Y1 * v23X; var n12X = void 0; var n12Y = void 0; var n12Z = void 0; var n23X = void 0; var n23Y = void 0; var n23Z = void 0; var n31X = void 0; var n31Y = void 0; var n31Z = void 0; n12X = v12Y1 * nZ - v12Z1 * nY; n12Y = v12Z1 * nX - v12X1 * nZ; n12Z = v12X1 * nY - v12Y1 * nX; n23X = v23Y * nZ - v23Z * nY; n23Y = v23Z * nX - v23X * nZ; n23Z = v23X * nY - v23Y * nX; n31X = v31Y * nZ - v31Z * nY; n31Y = v31Z * nX - v31X * nZ; n31Z = v31X * nY - v31Y * nX; var mind = -1; var minvX = void 0; var minvY = void 0; var minvZ = void 0; var mini = 0; minvX = 0; minvY = 0; minvZ = 0; if (v1X1 * n12X + v1Y1 * n12Y + v1Z1 * n12Z < 0) { var _v1X23 = void 0; var _v1Y23 = void 0; var _v1Z23 = void 0; var _v2X23 = void 0; var _v2Y23 = void 0; var _v2Z23 = void 0; _v1X23 = vec1.x; _v1Y23 = vec1.y; _v1Z23 = vec1.z; _v2X23 = vec2.x; _v2Y23 = vec2.y; _v2Z23 = vec2.z; var _v12X23 = void 0; var _v12Y23 = void 0; var _v12Z23 = void 0; _v12X23 = _v2X23 - _v1X23; _v12Y23 = _v2Y23 - _v1Y23; _v12Z23 = _v2Z23 - _v1Z23; var _t29 = _v12X23 * _v1X23 + _v12Y23 * _v1Y23 + _v12Z23 * _v1Z23; _t29 = -_t29 / (_v12X23 * _v12X23 + _v12Y23 * _v12Y23 + _v12Z23 * _v12Z23); var b = void 0; if (_t29 < 0) { closest.x = _v1X23; closest.y = _v1Y23; closest.z = _v1Z23; b = 1; } else if (_t29 > 1) { closest.x = _v2X23; closest.y = _v2Y23; closest.z = _v2Z23; b = 2; } else { var _pX18 = void 0; var _pY18 = void 0; var _pZ18 = void 0; _pX18 = _v1X23 + _v12X23 * _t29; _pY18 = _v1Y23 + _v12Y23 * _t29; _pZ18 = _v1Z23 + _v12Z23 * _t29; closest.x = _pX18; closest.y = _pY18; closest.z = _pZ18; b = 3; } mini = b; mind = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; minvX = closest.x; minvY = closest.y; minvZ = closest.z; } if (v2X1 * n23X + v2Y1 * n23Y + v2Z1 * n23Z < 0) { var _v1X24 = void 0; var _v1Y24 = void 0; var _v1Z24 = void 0; var _v2X24 = void 0; var _v2Y24 = void 0; var _v2Z24 = void 0; _v1X24 = vec2.x; _v1Y24 = vec2.y; _v1Z24 = vec2.z; _v2X24 = vec3.x; _v2Y24 = vec3.y; _v2Z24 = vec3.z; var _v12X24 = void 0; var _v12Y24 = void 0; var _v12Z24 = void 0; _v12X24 = _v2X24 - _v1X24; _v12Y24 = _v2Y24 - _v1Y24; _v12Z24 = _v2Z24 - _v1Z24; var _t30 = _v12X24 * _v1X24 + _v12Y24 * _v1Y24 + _v12Z24 * _v1Z24; _t30 = -_t30 / (_v12X24 * _v12X24 + _v12Y24 * _v12Y24 + _v12Z24 * _v12Z24); var _b19 = void 0; if (_t30 < 0) { closest.x = _v1X24; closest.y = _v1Y24; closest.z = _v1Z24; _b19 = 1; } else if (_t30 > 1) { closest.x = _v2X24; closest.y = _v2Y24; closest.z = _v2Z24; _b19 = 2; } else { var _pX19 = void 0; var _pY19 = void 0; var _pZ19 = void 0; _pX19 = _v1X24 + _v12X24 * _t30; _pY19 = _v1Y24 + _v12Y24 * _t30; _pZ19 = _v1Z24 + _v12Z24 * _t30; closest.x = _pX19; closest.y = _pY19; closest.z = _pZ19; _b19 = 3; } var d = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (mind < 0 || d < mind) { mini = _b19 << 1; mind = d; minvX = closest.x; minvY = closest.y; minvZ = closest.z; } } if (v3X * n31X + v3Y * n31Y + v3Z * n31Z < 0) { var _v1X25 = void 0; var _v1Y25 = void 0; var _v1Z25 = void 0; var _v2X25 = void 0; var _v2Y25 = void 0; var _v2Z25 = void 0; _v1X25 = vec1.x; _v1Y25 = vec1.y; _v1Z25 = vec1.z; _v2X25 = vec3.x; _v2Y25 = vec3.y; _v2Z25 = vec3.z; var _v12X25 = void 0; var _v12Y25 = void 0; var _v12Z25 = void 0; _v12X25 = _v2X25 - _v1X25; _v12Y25 = _v2Y25 - _v1Y25; _v12Z25 = _v2Z25 - _v1Z25; var _t31 = _v12X25 * _v1X25 + _v12Y25 * _v1Y25 + _v12Z25 * _v1Z25; _t31 = -_t31 / (_v12X25 * _v12X25 + _v12Y25 * _v12Y25 + _v12Z25 * _v12Z25); var _b20 = void 0; if (_t31 < 0) { closest.x = _v1X25; closest.y = _v1Y25; closest.z = _v1Z25; _b20 = 1; } else if (_t31 > 1) { closest.x = _v2X25; closest.y = _v2Y25; closest.z = _v2Z25; _b20 = 2; } else { var _pX20 = void 0; var _pY20 = void 0; var _pZ20 = void 0; _pX20 = _v1X25 + _v12X25 * _t31; _pY20 = _v1Y25 + _v12Y25 * _t31; _pZ20 = _v1Z25 + _v12Z25 * _t31; closest.x = _pX20; closest.y = _pY20; closest.z = _pZ20; _b20 = 3; } var _d14 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (mind < 0 || _d14 < mind) { mini = _b20 & 1 | (_b20 & 2) << 1; mind = _d14; minvX = closest.x; minvY = closest.y; minvZ = closest.z; } } if (mind > 0) { closest.x = minvX; closest.y = minvY; closest.z = minvZ; _v17 = mini; } else { var l = nX * nX + nY * nY + nZ * nZ; if (l > 0) { l = 1 / Math.sqrt(l); } nX *= l; nY *= l; nZ *= l; var l2 = nX * nX + nY * nY + nZ * nZ; l2 = (v1X1 * nX + v1Y1 * nY + v1Z1 * nZ) / l2; minvX = nX * l2; minvY = nY * l2; minvZ = nZ * l2; closest.x = minvX; closest.y = minvY; closest.z = minvZ; _v17 = 7; } break; case 4: var vec11 = s[0]; var vec21 = s[1]; var vec31 = s[2]; var vec4 = s[3]; var v1X2 = void 0; var v1Y2 = void 0; var v1Z2 = void 0; var v2X2 = void 0; var v2Y2 = void 0; var v2Z2 = void 0; var v3X1 = void 0; var v3Y1 = void 0; var v3Z1 = void 0; var v4X = void 0; var v4Y = void 0; var v4Z = void 0; var v12X2 = void 0; var v12Y2 = void 0; var v12Z2 = void 0; var v13X = void 0; var v13Y = void 0; var v13Z = void 0; var v14X = void 0; var v14Y = void 0; var v14Z = void 0; var v23X1 = void 0; var v23Y1 = void 0; var v23Z1 = void 0; var v24X = void 0; var v24Y = void 0; var v24Z = void 0; v1X2 = vec11.x; v1Y2 = vec11.y; v1Z2 = vec11.z; v2X2 = vec21.x; v2Y2 = vec21.y; v2Z2 = vec21.z; v3X1 = vec31.x; v3Y1 = vec31.y; v3Z1 = vec31.z; v4X = vec4.x; v4Y = vec4.y; v4Z = vec4.z; v12X2 = v2X2 - v1X2; v12Y2 = v2Y2 - v1Y2; v12Z2 = v2Z2 - v1Z2; v13X = v3X1 - v1X2; v13Y = v3Y1 - v1Y2; v13Z = v3Z1 - v1Z2; v14X = v4X - v1X2; v14Y = v4Y - v1Y2; v14Z = v4Z - v1Z2; v23X1 = v3X1 - v2X2; v23Y1 = v3Y1 - v2Y2; v23Z1 = v3Z1 - v2Z2; v24X = v4X - v2X2; v24Y = v4Y - v2Y2; v24Z = v4Z - v2Z2; var n123X = void 0; var n123Y = void 0; var n123Z = void 0; var n134X = void 0; var n134Y = void 0; var n134Z = void 0; var n142X = void 0; var n142Y = void 0; var n142Z = void 0; var n243X = void 0; var n243Y = void 0; var n243Z = void 0; n123X = v12Y2 * v13Z - v12Z2 * v13Y; n123Y = v12Z2 * v13X - v12X2 * v13Z; n123Z = v12X2 * v13Y - v12Y2 * v13X; n134X = v13Y * v14Z - v13Z * v14Y; n134Y = v13Z * v14X - v13X * v14Z; n134Z = v13X * v14Y - v13Y * v14X; n142X = v14Y * v12Z2 - v14Z * v12Y2; n142Y = v14Z * v12X2 - v14X * v12Z2; n142Z = v14X * v12Y2 - v14Y * v12X2; n243X = v24Y * v23Z1 - v24Z * v23Y1; n243Y = v24Z * v23X1 - v24X * v23Z1; n243Z = v24X * v23Y1 - v24Y * v23X1; var sign = v12X2 * n243X + v12Y2 * n243Y + v12Z2 * n243Z > 0 ? 1 : -1; var mind1 = -1; var minvX1 = void 0; var minvY1 = void 0; var minvZ1 = void 0; var mini1 = 0; minvX1 = 0; minvY1 = 0; minvZ1 = 0; if ((v1X2 * n123X + v1Y2 * n123Y + v1Z2 * n123Z) * sign < 0) { var _v1X26 = void 0; var _v1Y26 = void 0; var _v1Z26 = void 0; var _v2X26 = void 0; var _v2Y26 = void 0; var _v2Z26 = void 0; var _v3X5 = void 0; var _v3Y5 = void 0; var _v3Z5 = void 0; var _v12X26 = void 0; var _v12Y26 = void 0; var _v12Z26 = void 0; var _v23X5 = void 0; var _v23Y5 = void 0; var _v23Z5 = void 0; var _v31X5 = void 0; var _v31Y5 = void 0; var _v31Z5 = void 0; _v1X26 = vec11.x; _v1Y26 = vec11.y; _v1Z26 = vec11.z; _v2X26 = vec21.x; _v2Y26 = vec21.y; _v2Z26 = vec21.z; _v3X5 = vec31.x; _v3Y5 = vec31.y; _v3Z5 = vec31.z; _v12X26 = _v2X26 - _v1X26; _v12Y26 = _v2Y26 - _v1Y26; _v12Z26 = _v2Z26 - _v1Z26; _v23X5 = _v3X5 - _v2X26; _v23Y5 = _v3Y5 - _v2Y26; _v23Z5 = _v3Z5 - _v2Z26; _v31X5 = _v1X26 - _v3X5; _v31Y5 = _v1Y26 - _v3Y5; _v31Z5 = _v1Z26 - _v3Z5; var _nX5 = void 0; var _nY5 = void 0; var _nZ5 = void 0; _nX5 = _v12Y26 * _v23Z5 - _v12Z26 * _v23Y5; _nY5 = _v12Z26 * _v23X5 - _v12X26 * _v23Z5; _nZ5 = _v12X26 * _v23Y5 - _v12Y26 * _v23X5; var _n12X5 = void 0; var _n12Y5 = void 0; var _n12Z5 = void 0; var _n23X5 = void 0; var _n23Y5 = void 0; var _n23Z5 = void 0; var _n31X5 = void 0; var _n31Y5 = void 0; var _n31Z5 = void 0; _n12X5 = _v12Y26 * _nZ5 - _v12Z26 * _nY5; _n12Y5 = _v12Z26 * _nX5 - _v12X26 * _nZ5; _n12Z5 = _v12X26 * _nY5 - _v12Y26 * _nX5; _n23X5 = _v23Y5 * _nZ5 - _v23Z5 * _nY5; _n23Y5 = _v23Z5 * _nX5 - _v23X5 * _nZ5; _n23Z5 = _v23X5 * _nY5 - _v23Y5 * _nX5; _n31X5 = _v31Y5 * _nZ5 - _v31Z5 * _nY5; _n31Y5 = _v31Z5 * _nX5 - _v31X5 * _nZ5; _n31Z5 = _v31X5 * _nY5 - _v31Y5 * _nX5; var _mind5 = -1; var _minvX5 = void 0; var _minvY5 = void 0; var _minvZ5 = void 0; var _mini5 = 0; _minvX5 = 0; _minvY5 = 0; _minvZ5 = 0; if (_v1X26 * _n12X5 + _v1Y26 * _n12Y5 + _v1Z26 * _n12Z5 < 0) { var _v1X27 = void 0; var _v1Y27 = void 0; var _v1Z27 = void 0; var _v2X27 = void 0; var _v2Y27 = void 0; var _v2Z27 = void 0; _v1X27 = vec11.x; _v1Y27 = vec11.y; _v1Z27 = vec11.z; _v2X27 = vec21.x; _v2Y27 = vec21.y; _v2Z27 = vec21.z; var _v12X27 = void 0; var _v12Y27 = void 0; var _v12Z27 = void 0; _v12X27 = _v2X27 - _v1X27; _v12Y27 = _v2Y27 - _v1Y27; _v12Z27 = _v2Z27 - _v1Z27; var _t32 = _v12X27 * _v1X27 + _v12Y27 * _v1Y27 + _v12Z27 * _v1Z27; _t32 = -_t32 / (_v12X27 * _v12X27 + _v12Y27 * _v12Y27 + _v12Z27 * _v12Z27); var _b22 = void 0; if (_t32 < 0) { closest.x = _v1X27; closest.y = _v1Y27; closest.z = _v1Z27; _b22 = 1; } else if (_t32 > 1) { closest.x = _v2X27; closest.y = _v2Y27; closest.z = _v2Z27; _b22 = 2; } else { var _pX21 = void 0; var _pY21 = void 0; var _pZ21 = void 0; _pX21 = _v1X27 + _v12X27 * _t32; _pY21 = _v1Y27 + _v12Y27 * _t32; _pZ21 = _v1Z27 + _v12Z27 * _t32; closest.x = _pX21; closest.y = _pY21; closest.z = _pZ21; _b22 = 3; } _mini5 = _b22; _mind5 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; _minvX5 = closest.x; _minvY5 = closest.y; _minvZ5 = closest.z; } if (_v2X26 * _n23X5 + _v2Y26 * _n23Y5 + _v2Z26 * _n23Z5 < 0) { var _v1X28 = void 0; var _v1Y28 = void 0; var _v1Z28 = void 0; var _v2X28 = void 0; var _v2Y28 = void 0; var _v2Z28 = void 0; _v1X28 = vec21.x; _v1Y28 = vec21.y; _v1Z28 = vec21.z; _v2X28 = vec31.x; _v2Y28 = vec31.y; _v2Z28 = vec31.z; var _v12X28 = void 0; var _v12Y28 = void 0; var _v12Z28 = void 0; _v12X28 = _v2X28 - _v1X28; _v12Y28 = _v2Y28 - _v1Y28; _v12Z28 = _v2Z28 - _v1Z28; var _t33 = _v12X28 * _v1X28 + _v12Y28 * _v1Y28 + _v12Z28 * _v1Z28; _t33 = -_t33 / (_v12X28 * _v12X28 + _v12Y28 * _v12Y28 + _v12Z28 * _v12Z28); var _b23 = void 0; if (_t33 < 0) { closest.x = _v1X28; closest.y = _v1Y28; closest.z = _v1Z28; _b23 = 1; } else if (_t33 > 1) { closest.x = _v2X28; closest.y = _v2Y28; closest.z = _v2Z28; _b23 = 2; } else { var _pX22 = void 0; var _pY22 = void 0; var _pZ22 = void 0; _pX22 = _v1X28 + _v12X28 * _t33; _pY22 = _v1Y28 + _v12Y28 * _t33; _pZ22 = _v1Z28 + _v12Z28 * _t33; closest.x = _pX22; closest.y = _pY22; closest.z = _pZ22; _b23 = 3; } var _d15 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind5 < 0 || _d15 < _mind5) { _mini5 = _b23 << 1; _mind5 = _d15; _minvX5 = closest.x; _minvY5 = closest.y; _minvZ5 = closest.z; } } if (_v3X5 * _n31X5 + _v3Y5 * _n31Y5 + _v3Z5 * _n31Z5 < 0) { var _v1X29 = void 0; var _v1Y29 = void 0; var _v1Z29 = void 0; var _v2X29 = void 0; var _v2Y29 = void 0; var _v2Z29 = void 0; _v1X29 = vec11.x; _v1Y29 = vec11.y; _v1Z29 = vec11.z; _v2X29 = vec31.x; _v2Y29 = vec31.y; _v2Z29 = vec31.z; var _v12X29 = void 0; var _v12Y29 = void 0; var _v12Z29 = void 0; _v12X29 = _v2X29 - _v1X29; _v12Y29 = _v2Y29 - _v1Y29; _v12Z29 = _v2Z29 - _v1Z29; var _t34 = _v12X29 * _v1X29 + _v12Y29 * _v1Y29 + _v12Z29 * _v1Z29; _t34 = -_t34 / (_v12X29 * _v12X29 + _v12Y29 * _v12Y29 + _v12Z29 * _v12Z29); var _b24 = void 0; if (_t34 < 0) { closest.x = _v1X29; closest.y = _v1Y29; closest.z = _v1Z29; _b24 = 1; } else if (_t34 > 1) { closest.x = _v2X29; closest.y = _v2Y29; closest.z = _v2Z29; _b24 = 2; } else { var _pX23 = void 0; var _pY23 = void 0; var _pZ23 = void 0; _pX23 = _v1X29 + _v12X29 * _t34; _pY23 = _v1Y29 + _v12Y29 * _t34; _pZ23 = _v1Z29 + _v12Z29 * _t34; closest.x = _pX23; closest.y = _pY23; closest.z = _pZ23; _b24 = 3; } var _d16 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind5 < 0 || _d16 < _mind5) { _mini5 = _b24 & 1 | (_b24 & 2) << 1; _mind5 = _d16; _minvX5 = closest.x; _minvY5 = closest.y; _minvZ5 = closest.z; } } var _b21 = void 0; if (_mind5 > 0) { closest.x = _minvX5; closest.y = _minvY5; closest.z = _minvZ5; _b21 = _mini5; } else { var _l18 = _nX5 * _nX5 + _nY5 * _nY5 + _nZ5 * _nZ5; if (_l18 > 0) { _l18 = 1 / Math.sqrt(_l18); } _nX5 *= _l18; _nY5 *= _l18; _nZ5 *= _l18; var _l19 = _nX5 * _nX5 + _nY5 * _nY5 + _nZ5 * _nZ5; _l19 = (_v1X26 * _nX5 + _v1Y26 * _nY5 + _v1Z26 * _nZ5) / _l19; _minvX5 = _nX5 * _l19; _minvY5 = _nY5 * _l19; _minvZ5 = _nZ5 * _l19; closest.x = _minvX5; closest.y = _minvY5; closest.z = _minvZ5; _b21 = 7; } mini1 = _b21; mind1 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; minvX1 = closest.x; minvY1 = closest.y; minvZ1 = closest.z; } if ((v1X2 * n134X + v1Y2 * n134Y + v1Z2 * n134Z) * sign < 0) { var _v1X30 = void 0; var _v1Y30 = void 0; var _v1Z30 = void 0; var _v2X30 = void 0; var _v2Y30 = void 0; var _v2Z30 = void 0; var _v3X6 = void 0; var _v3Y6 = void 0; var _v3Z6 = void 0; var _v12X30 = void 0; var _v12Y30 = void 0; var _v12Z30 = void 0; var _v23X6 = void 0; var _v23Y6 = void 0; var _v23Z6 = void 0; var _v31X6 = void 0; var _v31Y6 = void 0; var _v31Z6 = void 0; _v1X30 = vec11.x; _v1Y30 = vec11.y; _v1Z30 = vec11.z; _v2X30 = vec31.x; _v2Y30 = vec31.y; _v2Z30 = vec31.z; _v3X6 = vec4.x; _v3Y6 = vec4.y; _v3Z6 = vec4.z; _v12X30 = _v2X30 - _v1X30; _v12Y30 = _v2Y30 - _v1Y30; _v12Z30 = _v2Z30 - _v1Z30; _v23X6 = _v3X6 - _v2X30; _v23Y6 = _v3Y6 - _v2Y30; _v23Z6 = _v3Z6 - _v2Z30; _v31X6 = _v1X30 - _v3X6; _v31Y6 = _v1Y30 - _v3Y6; _v31Z6 = _v1Z30 - _v3Z6; var _nX6 = void 0; var _nY6 = void 0; var _nZ6 = void 0; _nX6 = _v12Y30 * _v23Z6 - _v12Z30 * _v23Y6; _nY6 = _v12Z30 * _v23X6 - _v12X30 * _v23Z6; _nZ6 = _v12X30 * _v23Y6 - _v12Y30 * _v23X6; var _n12X6 = void 0; var _n12Y6 = void 0; var _n12Z6 = void 0; var _n23X6 = void 0; var _n23Y6 = void 0; var _n23Z6 = void 0; var _n31X6 = void 0; var _n31Y6 = void 0; var _n31Z6 = void 0; _n12X6 = _v12Y30 * _nZ6 - _v12Z30 * _nY6; _n12Y6 = _v12Z30 * _nX6 - _v12X30 * _nZ6; _n12Z6 = _v12X30 * _nY6 - _v12Y30 * _nX6; _n23X6 = _v23Y6 * _nZ6 - _v23Z6 * _nY6; _n23Y6 = _v23Z6 * _nX6 - _v23X6 * _nZ6; _n23Z6 = _v23X6 * _nY6 - _v23Y6 * _nX6; _n31X6 = _v31Y6 * _nZ6 - _v31Z6 * _nY6; _n31Y6 = _v31Z6 * _nX6 - _v31X6 * _nZ6; _n31Z6 = _v31X6 * _nY6 - _v31Y6 * _nX6; var _mind6 = -1; var _minvX6 = void 0; var _minvY6 = void 0; var _minvZ6 = void 0; var _mini6 = 0; _minvX6 = 0; _minvY6 = 0; _minvZ6 = 0; if (_v1X30 * _n12X6 + _v1Y30 * _n12Y6 + _v1Z30 * _n12Z6 < 0) { var _v1X31 = void 0; var _v1Y31 = void 0; var _v1Z31 = void 0; var _v2X31 = void 0; var _v2Y31 = void 0; var _v2Z31 = void 0; _v1X31 = vec11.x; _v1Y31 = vec11.y; _v1Z31 = vec11.z; _v2X31 = vec31.x; _v2Y31 = vec31.y; _v2Z31 = vec31.z; var _v12X31 = void 0; var _v12Y31 = void 0; var _v12Z31 = void 0; _v12X31 = _v2X31 - _v1X31; _v12Y31 = _v2Y31 - _v1Y31; _v12Z31 = _v2Z31 - _v1Z31; var _t35 = _v12X31 * _v1X31 + _v12Y31 * _v1Y31 + _v12Z31 * _v1Z31; _t35 = -_t35 / (_v12X31 * _v12X31 + _v12Y31 * _v12Y31 + _v12Z31 * _v12Z31); var _b26 = void 0; if (_t35 < 0) { closest.x = _v1X31; closest.y = _v1Y31; closest.z = _v1Z31; _b26 = 1; } else if (_t35 > 1) { closest.x = _v2X31; closest.y = _v2Y31; closest.z = _v2Z31; _b26 = 2; } else { var _pX24 = void 0; var _pY24 = void 0; var _pZ24 = void 0; _pX24 = _v1X31 + _v12X31 * _t35; _pY24 = _v1Y31 + _v12Y31 * _t35; _pZ24 = _v1Z31 + _v12Z31 * _t35; closest.x = _pX24; closest.y = _pY24; closest.z = _pZ24; _b26 = 3; } _mini6 = _b26; _mind6 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; _minvX6 = closest.x; _minvY6 = closest.y; _minvZ6 = closest.z; } if (_v2X30 * _n23X6 + _v2Y30 * _n23Y6 + _v2Z30 * _n23Z6 < 0) { var _v1X32 = void 0; var _v1Y32 = void 0; var _v1Z32 = void 0; var _v2X32 = void 0; var _v2Y32 = void 0; var _v2Z32 = void 0; _v1X32 = vec31.x; _v1Y32 = vec31.y; _v1Z32 = vec31.z; _v2X32 = vec4.x; _v2Y32 = vec4.y; _v2Z32 = vec4.z; var _v12X32 = void 0; var _v12Y32 = void 0; var _v12Z32 = void 0; _v12X32 = _v2X32 - _v1X32; _v12Y32 = _v2Y32 - _v1Y32; _v12Z32 = _v2Z32 - _v1Z32; var _t36 = _v12X32 * _v1X32 + _v12Y32 * _v1Y32 + _v12Z32 * _v1Z32; _t36 = -_t36 / (_v12X32 * _v12X32 + _v12Y32 * _v12Y32 + _v12Z32 * _v12Z32); var _b27 = void 0; if (_t36 < 0) { closest.x = _v1X32; closest.y = _v1Y32; closest.z = _v1Z32; _b27 = 1; } else if (_t36 > 1) { closest.x = _v2X32; closest.y = _v2Y32; closest.z = _v2Z32; _b27 = 2; } else { var _pX25 = void 0; var _pY25 = void 0; var _pZ25 = void 0; _pX25 = _v1X32 + _v12X32 * _t36; _pY25 = _v1Y32 + _v12Y32 * _t36; _pZ25 = _v1Z32 + _v12Z32 * _t36; closest.x = _pX25; closest.y = _pY25; closest.z = _pZ25; _b27 = 3; } var _d18 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind6 < 0 || _d18 < _mind6) { _mini6 = _b27 << 1; _mind6 = _d18; _minvX6 = closest.x; _minvY6 = closest.y; _minvZ6 = closest.z; } } if (_v3X6 * _n31X6 + _v3Y6 * _n31Y6 + _v3Z6 * _n31Z6 < 0) { var _v1X33 = void 0; var _v1Y33 = void 0; var _v1Z33 = void 0; var _v2X33 = void 0; var _v2Y33 = void 0; var _v2Z33 = void 0; _v1X33 = vec11.x; _v1Y33 = vec11.y; _v1Z33 = vec11.z; _v2X33 = vec4.x; _v2Y33 = vec4.y; _v2Z33 = vec4.z; var _v12X33 = void 0; var _v12Y33 = void 0; var _v12Z33 = void 0; _v12X33 = _v2X33 - _v1X33; _v12Y33 = _v2Y33 - _v1Y33; _v12Z33 = _v2Z33 - _v1Z33; var _t37 = _v12X33 * _v1X33 + _v12Y33 * _v1Y33 + _v12Z33 * _v1Z33; _t37 = -_t37 / (_v12X33 * _v12X33 + _v12Y33 * _v12Y33 + _v12Z33 * _v12Z33); var _b28 = void 0; if (_t37 < 0) { closest.x = _v1X33; closest.y = _v1Y33; closest.z = _v1Z33; _b28 = 1; } else if (_t37 > 1) { closest.x = _v2X33; closest.y = _v2Y33; closest.z = _v2Z33; _b28 = 2; } else { var _pX26 = void 0; var _pY26 = void 0; var _pZ26 = void 0; _pX26 = _v1X33 + _v12X33 * _t37; _pY26 = _v1Y33 + _v12Y33 * _t37; _pZ26 = _v1Z33 + _v12Z33 * _t37; closest.x = _pX26; closest.y = _pY26; closest.z = _pZ26; _b28 = 3; } var _d19 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind6 < 0 || _d19 < _mind6) { _mini6 = _b28 & 1 | (_b28 & 2) << 1; _mind6 = _d19; _minvX6 = closest.x; _minvY6 = closest.y; _minvZ6 = closest.z; } } var _b25 = void 0; if (_mind6 > 0) { closest.x = _minvX6; closest.y = _minvY6; closest.z = _minvZ6; _b25 = _mini6; } else { var _l20 = _nX6 * _nX6 + _nY6 * _nY6 + _nZ6 * _nZ6; if (_l20 > 0) { _l20 = 1 / Math.sqrt(_l20); } _nX6 *= _l20; _nY6 *= _l20; _nZ6 *= _l20; var _l21 = _nX6 * _nX6 + _nY6 * _nY6 + _nZ6 * _nZ6; _l21 = (_v1X30 * _nX6 + _v1Y30 * _nY6 + _v1Z30 * _nZ6) / _l21; _minvX6 = _nX6 * _l21; _minvY6 = _nY6 * _l21; _minvZ6 = _nZ6 * _l21; closest.x = _minvX6; closest.y = _minvY6; closest.z = _minvZ6; _b25 = 7; } var _d17 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (mind1 < 0 || _d17 < mind1) { mini1 = _b25 & 1 | (_b25 & 6) << 1; mind1 = _d17; minvX1 = closest.x; minvY1 = closest.y; minvZ1 = closest.z; } } if ((v1X2 * n142X + v1Y2 * n142Y + v1Z2 * n142Z) * sign < 0) { var _v1X34 = void 0; var _v1Y34 = void 0; var _v1Z34 = void 0; var _v2X34 = void 0; var _v2Y34 = void 0; var _v2Z34 = void 0; var _v3X7 = void 0; var _v3Y7 = void 0; var _v3Z7 = void 0; var _v12X34 = void 0; var _v12Y34 = void 0; var _v12Z34 = void 0; var _v23X7 = void 0; var _v23Y7 = void 0; var _v23Z7 = void 0; var _v31X7 = void 0; var _v31Y7 = void 0; var _v31Z7 = void 0; _v1X34 = vec11.x; _v1Y34 = vec11.y; _v1Z34 = vec11.z; _v2X34 = vec21.x; _v2Y34 = vec21.y; _v2Z34 = vec21.z; _v3X7 = vec4.x; _v3Y7 = vec4.y; _v3Z7 = vec4.z; _v12X34 = _v2X34 - _v1X34; _v12Y34 = _v2Y34 - _v1Y34; _v12Z34 = _v2Z34 - _v1Z34; _v23X7 = _v3X7 - _v2X34; _v23Y7 = _v3Y7 - _v2Y34; _v23Z7 = _v3Z7 - _v2Z34; _v31X7 = _v1X34 - _v3X7; _v31Y7 = _v1Y34 - _v3Y7; _v31Z7 = _v1Z34 - _v3Z7; var _nX7 = void 0; var _nY7 = void 0; var _nZ7 = void 0; _nX7 = _v12Y34 * _v23Z7 - _v12Z34 * _v23Y7; _nY7 = _v12Z34 * _v23X7 - _v12X34 * _v23Z7; _nZ7 = _v12X34 * _v23Y7 - _v12Y34 * _v23X7; var _n12X7 = void 0; var _n12Y7 = void 0; var _n12Z7 = void 0; var _n23X7 = void 0; var _n23Y7 = void 0; var _n23Z7 = void 0; var _n31X7 = void 0; var _n31Y7 = void 0; var _n31Z7 = void 0; _n12X7 = _v12Y34 * _nZ7 - _v12Z34 * _nY7; _n12Y7 = _v12Z34 * _nX7 - _v12X34 * _nZ7; _n12Z7 = _v12X34 * _nY7 - _v12Y34 * _nX7; _n23X7 = _v23Y7 * _nZ7 - _v23Z7 * _nY7; _n23Y7 = _v23Z7 * _nX7 - _v23X7 * _nZ7; _n23Z7 = _v23X7 * _nY7 - _v23Y7 * _nX7; _n31X7 = _v31Y7 * _nZ7 - _v31Z7 * _nY7; _n31Y7 = _v31Z7 * _nX7 - _v31X7 * _nZ7; _n31Z7 = _v31X7 * _nY7 - _v31Y7 * _nX7; var _mind7 = -1; var _minvX7 = void 0; var _minvY7 = void 0; var _minvZ7 = void 0; var _mini7 = 0; _minvX7 = 0; _minvY7 = 0; _minvZ7 = 0; if (_v1X34 * _n12X7 + _v1Y34 * _n12Y7 + _v1Z34 * _n12Z7 < 0) { var _v1X35 = void 0; var _v1Y35 = void 0; var _v1Z35 = void 0; var _v2X35 = void 0; var _v2Y35 = void 0; var _v2Z35 = void 0; _v1X35 = vec11.x; _v1Y35 = vec11.y; _v1Z35 = vec11.z; _v2X35 = vec21.x; _v2Y35 = vec21.y; _v2Z35 = vec21.z; var _v12X35 = void 0; var _v12Y35 = void 0; var _v12Z35 = void 0; _v12X35 = _v2X35 - _v1X35; _v12Y35 = _v2Y35 - _v1Y35; _v12Z35 = _v2Z35 - _v1Z35; var _t38 = _v12X35 * _v1X35 + _v12Y35 * _v1Y35 + _v12Z35 * _v1Z35; _t38 = -_t38 / (_v12X35 * _v12X35 + _v12Y35 * _v12Y35 + _v12Z35 * _v12Z35); var _b30 = void 0; if (_t38 < 0) { closest.x = _v1X35; closest.y = _v1Y35; closest.z = _v1Z35; _b30 = 1; } else if (_t38 > 1) { closest.x = _v2X35; closest.y = _v2Y35; closest.z = _v2Z35; _b30 = 2; } else { var _pX27 = void 0; var _pY27 = void 0; var _pZ27 = void 0; _pX27 = _v1X35 + _v12X35 * _t38; _pY27 = _v1Y35 + _v12Y35 * _t38; _pZ27 = _v1Z35 + _v12Z35 * _t38; closest.x = _pX27; closest.y = _pY27; closest.z = _pZ27; _b30 = 3; } _mini7 = _b30; _mind7 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; _minvX7 = closest.x; _minvY7 = closest.y; _minvZ7 = closest.z; } if (_v2X34 * _n23X7 + _v2Y34 * _n23Y7 + _v2Z34 * _n23Z7 < 0) { var _v1X36 = void 0; var _v1Y36 = void 0; var _v1Z36 = void 0; var _v2X36 = void 0; var _v2Y36 = void 0; var _v2Z36 = void 0; _v1X36 = vec21.x; _v1Y36 = vec21.y; _v1Z36 = vec21.z; _v2X36 = vec4.x; _v2Y36 = vec4.y; _v2Z36 = vec4.z; var _v12X36 = void 0; var _v12Y36 = void 0; var _v12Z36 = void 0; _v12X36 = _v2X36 - _v1X36; _v12Y36 = _v2Y36 - _v1Y36; _v12Z36 = _v2Z36 - _v1Z36; var _t39 = _v12X36 * _v1X36 + _v12Y36 * _v1Y36 + _v12Z36 * _v1Z36; _t39 = -_t39 / (_v12X36 * _v12X36 + _v12Y36 * _v12Y36 + _v12Z36 * _v12Z36); var _b31 = void 0; if (_t39 < 0) { closest.x = _v1X36; closest.y = _v1Y36; closest.z = _v1Z36; _b31 = 1; } else if (_t39 > 1) { closest.x = _v2X36; closest.y = _v2Y36; closest.z = _v2Z36; _b31 = 2; } else { var _pX28 = void 0; var _pY28 = void 0; var _pZ28 = void 0; _pX28 = _v1X36 + _v12X36 * _t39; _pY28 = _v1Y36 + _v12Y36 * _t39; _pZ28 = _v1Z36 + _v12Z36 * _t39; closest.x = _pX28; closest.y = _pY28; closest.z = _pZ28; _b31 = 3; } var _d21 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind7 < 0 || _d21 < _mind7) { _mini7 = _b31 << 1; _mind7 = _d21; _minvX7 = closest.x; _minvY7 = closest.y; _minvZ7 = closest.z; } } if (_v3X7 * _n31X7 + _v3Y7 * _n31Y7 + _v3Z7 * _n31Z7 < 0) { var _v1X37 = void 0; var _v1Y37 = void 0; var _v1Z37 = void 0; var _v2X37 = void 0; var _v2Y37 = void 0; var _v2Z37 = void 0; _v1X37 = vec11.x; _v1Y37 = vec11.y; _v1Z37 = vec11.z; _v2X37 = vec4.x; _v2Y37 = vec4.y; _v2Z37 = vec4.z; var _v12X37 = void 0; var _v12Y37 = void 0; var _v12Z37 = void 0; _v12X37 = _v2X37 - _v1X37; _v12Y37 = _v2Y37 - _v1Y37; _v12Z37 = _v2Z37 - _v1Z37; var _t40 = _v12X37 * _v1X37 + _v12Y37 * _v1Y37 + _v12Z37 * _v1Z37; _t40 = -_t40 / (_v12X37 * _v12X37 + _v12Y37 * _v12Y37 + _v12Z37 * _v12Z37); var _b32 = void 0; if (_t40 < 0) { closest.x = _v1X37; closest.y = _v1Y37; closest.z = _v1Z37; _b32 = 1; } else if (_t40 > 1) { closest.x = _v2X37; closest.y = _v2Y37; closest.z = _v2Z37; _b32 = 2; } else { var _pX29 = void 0; var _pY29 = void 0; var _pZ29 = void 0; _pX29 = _v1X37 + _v12X37 * _t40; _pY29 = _v1Y37 + _v12Y37 * _t40; _pZ29 = _v1Z37 + _v12Z37 * _t40; closest.x = _pX29; closest.y = _pY29; closest.z = _pZ29; _b32 = 3; } var _d22 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind7 < 0 || _d22 < _mind7) { _mini7 = _b32 & 1 | (_b32 & 2) << 1; _mind7 = _d22; _minvX7 = closest.x; _minvY7 = closest.y; _minvZ7 = closest.z; } } var _b29 = void 0; if (_mind7 > 0) { closest.x = _minvX7; closest.y = _minvY7; closest.z = _minvZ7; _b29 = _mini7; } else { var _l22 = _nX7 * _nX7 + _nY7 * _nY7 + _nZ7 * _nZ7; if (_l22 > 0) { _l22 = 1 / Math.sqrt(_l22); } _nX7 *= _l22; _nY7 *= _l22; _nZ7 *= _l22; var _l23 = _nX7 * _nX7 + _nY7 * _nY7 + _nZ7 * _nZ7; _l23 = (_v1X34 * _nX7 + _v1Y34 * _nY7 + _v1Z34 * _nZ7) / _l23; _minvX7 = _nX7 * _l23; _minvY7 = _nY7 * _l23; _minvZ7 = _nZ7 * _l23; closest.x = _minvX7; closest.y = _minvY7; closest.z = _minvZ7; _b29 = 7; } var _d20 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (mind1 < 0 || _d20 < mind1) { mini1 = _b29 & 3 | (_b29 & 4) << 1; mind1 = _d20; minvX1 = closest.x; minvY1 = closest.y; minvZ1 = closest.z; } } if ((v2X2 * n243X + v2Y2 * n243Y + v2Z2 * n243Z) * sign < 0) { var _v1X38 = void 0; var _v1Y38 = void 0; var _v1Z38 = void 0; var _v2X38 = void 0; var _v2Y38 = void 0; var _v2Z38 = void 0; var _v3X8 = void 0; var _v3Y8 = void 0; var _v3Z8 = void 0; var _v12X38 = void 0; var _v12Y38 = void 0; var _v12Z38 = void 0; var _v23X8 = void 0; var _v23Y8 = void 0; var _v23Z8 = void 0; var _v31X8 = void 0; var _v31Y8 = void 0; var _v31Z8 = void 0; _v1X38 = vec21.x; _v1Y38 = vec21.y; _v1Z38 = vec21.z; _v2X38 = vec31.x; _v2Y38 = vec31.y; _v2Z38 = vec31.z; _v3X8 = vec4.x; _v3Y8 = vec4.y; _v3Z8 = vec4.z; _v12X38 = _v2X38 - _v1X38; _v12Y38 = _v2Y38 - _v1Y38; _v12Z38 = _v2Z38 - _v1Z38; _v23X8 = _v3X8 - _v2X38; _v23Y8 = _v3Y8 - _v2Y38; _v23Z8 = _v3Z8 - _v2Z38; _v31X8 = _v1X38 - _v3X8; _v31Y8 = _v1Y38 - _v3Y8; _v31Z8 = _v1Z38 - _v3Z8; var _nX8 = void 0; var _nY8 = void 0; var _nZ8 = void 0; _nX8 = _v12Y38 * _v23Z8 - _v12Z38 * _v23Y8; _nY8 = _v12Z38 * _v23X8 - _v12X38 * _v23Z8; _nZ8 = _v12X38 * _v23Y8 - _v12Y38 * _v23X8; var _n12X8 = void 0; var _n12Y8 = void 0; var _n12Z8 = void 0; var _n23X8 = void 0; var _n23Y8 = void 0; var _n23Z8 = void 0; var _n31X8 = void 0; var _n31Y8 = void 0; var _n31Z8 = void 0; _n12X8 = _v12Y38 * _nZ8 - _v12Z38 * _nY8; _n12Y8 = _v12Z38 * _nX8 - _v12X38 * _nZ8; _n12Z8 = _v12X38 * _nY8 - _v12Y38 * _nX8; _n23X8 = _v23Y8 * _nZ8 - _v23Z8 * _nY8; _n23Y8 = _v23Z8 * _nX8 - _v23X8 * _nZ8; _n23Z8 = _v23X8 * _nY8 - _v23Y8 * _nX8; _n31X8 = _v31Y8 * _nZ8 - _v31Z8 * _nY8; _n31Y8 = _v31Z8 * _nX8 - _v31X8 * _nZ8; _n31Z8 = _v31X8 * _nY8 - _v31Y8 * _nX8; var _mind8 = -1; var _minvX8 = void 0; var _minvY8 = void 0; var _minvZ8 = void 0; var _mini8 = 0; _minvX8 = 0; _minvY8 = 0; _minvZ8 = 0; if (_v1X38 * _n12X8 + _v1Y38 * _n12Y8 + _v1Z38 * _n12Z8 < 0) { var _v1X39 = void 0; var _v1Y39 = void 0; var _v1Z39 = void 0; var _v2X39 = void 0; var _v2Y39 = void 0; var _v2Z39 = void 0; _v1X39 = vec21.x; _v1Y39 = vec21.y; _v1Z39 = vec21.z; _v2X39 = vec31.x; _v2Y39 = vec31.y; _v2Z39 = vec31.z; var _v12X39 = void 0; var _v12Y39 = void 0; var _v12Z39 = void 0; _v12X39 = _v2X39 - _v1X39; _v12Y39 = _v2Y39 - _v1Y39; _v12Z39 = _v2Z39 - _v1Z39; var _t41 = _v12X39 * _v1X39 + _v12Y39 * _v1Y39 + _v12Z39 * _v1Z39; _t41 = -_t41 / (_v12X39 * _v12X39 + _v12Y39 * _v12Y39 + _v12Z39 * _v12Z39); var _b34 = void 0; if (_t41 < 0) { closest.x = _v1X39; closest.y = _v1Y39; closest.z = _v1Z39; _b34 = 1; } else if (_t41 > 1) { closest.x = _v2X39; closest.y = _v2Y39; closest.z = _v2Z39; _b34 = 2; } else { var _pX30 = void 0; var _pY30 = void 0; var _pZ30 = void 0; _pX30 = _v1X39 + _v12X39 * _t41; _pY30 = _v1Y39 + _v12Y39 * _t41; _pZ30 = _v1Z39 + _v12Z39 * _t41; closest.x = _pX30; closest.y = _pY30; closest.z = _pZ30; _b34 = 3; } _mini8 = _b34; _mind8 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; _minvX8 = closest.x; _minvY8 = closest.y; _minvZ8 = closest.z; } if (_v2X38 * _n23X8 + _v2Y38 * _n23Y8 + _v2Z38 * _n23Z8 < 0) { var _v1X40 = void 0; var _v1Y40 = void 0; var _v1Z40 = void 0; var _v2X40 = void 0; var _v2Y40 = void 0; var _v2Z40 = void 0; _v1X40 = vec31.x; _v1Y40 = vec31.y; _v1Z40 = vec31.z; _v2X40 = vec4.x; _v2Y40 = vec4.y; _v2Z40 = vec4.z; var _v12X40 = void 0; var _v12Y40 = void 0; var _v12Z40 = void 0; _v12X40 = _v2X40 - _v1X40; _v12Y40 = _v2Y40 - _v1Y40; _v12Z40 = _v2Z40 - _v1Z40; var _t42 = _v12X40 * _v1X40 + _v12Y40 * _v1Y40 + _v12Z40 * _v1Z40; _t42 = -_t42 / (_v12X40 * _v12X40 + _v12Y40 * _v12Y40 + _v12Z40 * _v12Z40); var _b35 = void 0; if (_t42 < 0) { closest.x = _v1X40; closest.y = _v1Y40; closest.z = _v1Z40; _b35 = 1; } else if (_t42 > 1) { closest.x = _v2X40; closest.y = _v2Y40; closest.z = _v2Z40; _b35 = 2; } else { var _pX31 = void 0; var _pY31 = void 0; var _pZ31 = void 0; _pX31 = _v1X40 + _v12X40 * _t42; _pY31 = _v1Y40 + _v12Y40 * _t42; _pZ31 = _v1Z40 + _v12Z40 * _t42; closest.x = _pX31; closest.y = _pY31; closest.z = _pZ31; _b35 = 3; } var _d24 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind8 < 0 || _d24 < _mind8) { _mini8 = _b35 << 1; _mind8 = _d24; _minvX8 = closest.x; _minvY8 = closest.y; _minvZ8 = closest.z; } } if (_v3X8 * _n31X8 + _v3Y8 * _n31Y8 + _v3Z8 * _n31Z8 < 0) { var _v1X41 = void 0; var _v1Y41 = void 0; var _v1Z41 = void 0; var _v2X41 = void 0; var _v2Y41 = void 0; var _v2Z41 = void 0; _v1X41 = vec21.x; _v1Y41 = vec21.y; _v1Z41 = vec21.z; _v2X41 = vec4.x; _v2Y41 = vec4.y; _v2Z41 = vec4.z; var _v12X41 = void 0; var _v12Y41 = void 0; var _v12Z41 = void 0; _v12X41 = _v2X41 - _v1X41; _v12Y41 = _v2Y41 - _v1Y41; _v12Z41 = _v2Z41 - _v1Z41; var _t43 = _v12X41 * _v1X41 + _v12Y41 * _v1Y41 + _v12Z41 * _v1Z41; _t43 = -_t43 / (_v12X41 * _v12X41 + _v12Y41 * _v12Y41 + _v12Z41 * _v12Z41); var _b36 = void 0; if (_t43 < 0) { closest.x = _v1X41; closest.y = _v1Y41; closest.z = _v1Z41; _b36 = 1; } else if (_t43 > 1) { closest.x = _v2X41; closest.y = _v2Y41; closest.z = _v2Z41; _b36 = 2; } else { var _pX32 = void 0; var _pY32 = void 0; var _pZ32 = void 0; _pX32 = _v1X41 + _v12X41 * _t43; _pY32 = _v1Y41 + _v12Y41 * _t43; _pZ32 = _v1Z41 + _v12Z41 * _t43; closest.x = _pX32; closest.y = _pY32; closest.z = _pZ32; _b36 = 3; } var _d25 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (_mind8 < 0 || _d25 < _mind8) { _mini8 = _b36 & 1 | (_b36 & 2) << 1; _mind8 = _d25; _minvX8 = closest.x; _minvY8 = closest.y; _minvZ8 = closest.z; } } var _b33 = void 0; if (_mind8 > 0) { closest.x = _minvX8; closest.y = _minvY8; closest.z = _minvZ8; _b33 = _mini8; } else { var _l24 = _nX8 * _nX8 + _nY8 * _nY8 + _nZ8 * _nZ8; if (_l24 > 0) { _l24 = 1 / Math.sqrt(_l24); } _nX8 *= _l24; _nY8 *= _l24; _nZ8 *= _l24; var _l25 = _nX8 * _nX8 + _nY8 * _nY8 + _nZ8 * _nZ8; _l25 = (_v1X38 * _nX8 + _v1Y38 * _nY8 + _v1Z38 * _nZ8) / _l25; _minvX8 = _nX8 * _l25; _minvY8 = _nY8 * _l25; _minvZ8 = _nZ8 * _l25; closest.x = _minvX8; closest.y = _minvY8; closest.z = _minvZ8; _b33 = 7; } var _d23 = closest.x * closest.x + closest.y * closest.y + closest.z * closest.z; if (mind1 < 0 || _d23 < mind1) { mini1 = _b33 << 1; mind1 = _d23; minvX1 = closest.x; minvY1 = closest.y; minvZ1 = closest.z; } } if (mind1 > 0) { closest.x = minvX1; closest.y = minvY1; closest.z = minvZ1; _v17 = mini1; } else { closest.zero(); _v17 = 15; } break; } this.shrinkSimplex(_v17); if (closest.x * closest.x + closest.y * closest.y + closest.z * closest.z < 1e-008) { if (lambda == 0 || this.simplexSize == 4) { hit.fraction = lambda; return false; } this.interpolateClosestPoints(); hit.fraction = lambda; var _this73 = hit.normal; _this73.x = dir.x; _this73.y = dir.y; _this73.z = dir.z; var invLen = Math.sqrt(_this73.x * _this73.x + _this73.y * _this73.y + _this73.z * _this73.z); if (invLen > 0) { invLen = 1 / invLen; } _this73.x *= invLen; _this73.y *= invLen; _this73.z *= invLen; var _this74 = hit.position; var _v19 = this.closestPoint1; _this74.x = _v19.x; _this74.y = _v19.y; _this74.z = _v19.z; _this74.x += tl1.x * lambda; _this74.y += tl1.y * lambda; _this74.z += tl1.z * lambda; return true; } dir.x = closest.x; dir.y = closest.y; dir.z = closest.z; dir.x = -dir.x; dir.y = -dir.y; dir.z = -dir.z; if (this.c1 != null) { this.computeWitnessPoint1(true); } else { var _v20 = this.w1[this.simplexSize]; _v20.x = this.tf1._positionX; _v20.y = this.tf1._positionY; _v20.z = this.tf1._positionZ; } this.computeWitnessPoint2(true); var _this72 = this.s[this.simplexSize]; var v4 = this.w1[this.simplexSize]; _this72.x = v4.x; _this72.y = v4.y; _this72.z = v4.z; var v5 = this.w2[this.simplexSize]; _this72.x -= v5.x; _this72.y -= v5.y; _this72.z -= v5.z; var _this1 = s[this.simplexSize]; _this1.x -= rayX.x; _this1.y -= rayX.y; _this1.z -= rayX.z; if (dir.x * dir.x + dir.y * dir.y + dir.z * dir.z < 1e-008) { throw new Error("!?"); } var p = s[this.simplexSize]; var pn = p.x * dir.x + p.y * dir.y + p.z * dir.z; if (pn < 0) { if (rayR.x * dir.x + rayR.y * dir.y + rayR.z * dir.z >= 0) { return false; } var dLambda = pn / (rayR.x * dir.x + rayR.y * dir.y + rayR.z * dir.z); lambda += dLambda; if (lambda >= 1) { return false; } rayX.x += rayR.x * dLambda; rayX.y += rayR.y * dLambda; rayX.z += rayR.z * dLambda; var _g23 = 0; var _g24 = this.simplexSize + 1; while (_g23 < _g24) { var _this75 = s[_g23++]; var s1 = -dLambda; _this75.x += rayR.x * s1; _this75.y += rayR.y * s1; _this75.z += rayR.z * s1; } } var duplicate = false; var _g = 0; var _g1 = this.simplexSize; while (_g < _g1) { var i = _g++; var dx = s[i].x - s[this.simplexSize].x; var dy = s[i].y - s[this.simplexSize].y; var dz = s[i].z - s[this.simplexSize].z; if (dx * dx + dy * dy + dz * dz < 1e-008) { duplicate = true; break; } } if (!duplicate) { this.simplexSize++; } ++count; } return false; } }, { key: "interpolateClosestPoints", value: function interpolateClosestPoints() { switch (this.simplexSize) { case 1: var _this = this.closestPoint1; var v = this.w1[0]; _this.x = v.x; _this.y = v.y; _this.z = v.z; var _this1 = this.closestPoint2; var v1 = this.w2[0]; _this1.x = v1.x; _this1.y = v1.y; _this1.z = v1.z; break; case 2: var cX; var cY; var cZ; var v2 = this.closest; cX = v2.x; cY = v2.y; cZ = v2.z; var s0X; var s0Y; var s0Z; var w10X; var w10Y; var w10Z; var w20X; var w20Y; var w20Z; var s1X; var s1Y; var s1Z; var w11X; var w11Y; var w11Z; var w21X; var w21Y; var w21Z; var v3 = this.s[0]; s0X = v3.x; s0Y = v3.y; s0Z = v3.z; var v4 = this.w1[0]; w10X = v4.x; w10Y = v4.y; w10Z = v4.z; var v5 = this.w2[0]; w20X = v5.x; w20Y = v5.y; w20Z = v5.z; var v6 = this.s[1]; s1X = v6.x; s1Y = v6.y; s1Z = v6.z; var v7 = this.w1[1]; w11X = v7.x; w11Y = v7.y; w11Z = v7.z; var v8 = this.w2[1]; w21X = v8.x; w21Y = v8.y; w21Z = v8.z; var s01X; var s01Y; var s01Z; s01X = s1X - s0X; s01Y = s1Y - s0Y; s01Z = s1Z - s0Z; var invDet = s01X * s01X + s01Y * s01Y + s01Z * s01Z; if (invDet != 0) { invDet = 1 / invDet; } var s0cX; var s0cY; var s0cZ; s0cX = cX - s0X; s0cY = cY - s0Y; s0cZ = cZ - s0Z; var t = (s0cX * s01X + s0cY * s01Y + s0cZ * s01Z) * invDet; var diffX; var diffY; var diffZ; var cp1X; var cp1Y; var cp1Z; var cp2X; var cp2Y; var cp2Z; diffX = w11X - w10X; diffY = w11Y - w10Y; diffZ = w11Z - w10Z; cp1X = w10X + diffX * t; cp1Y = w10Y + diffY * t; cp1Z = w10Z + diffZ * t; diffX = w21X - w20X; diffY = w21Y - w20Y; diffZ = w21Z - w20Z; cp2X = w20X + diffX * t; cp2Y = w20Y + diffY * t; cp2Z = w20Z + diffZ * t; var v9 = this.closestPoint1; v9.x = cp1X; v9.y = cp1Y; v9.z = cp1Z; var v10 = this.closestPoint2; v10.x = cp2X; v10.y = cp2Y; v10.z = cp2Z; break; case 3: var cX1; var cY1; var cZ1; var v11 = this.closest; cX1 = v11.x; cY1 = v11.y; cZ1 = v11.z; var s0X1; var s0Y1; var s0Z1; var w10X1; var w10Y1; var w10Z1; var w20X1; var w20Y1; var w20Z1; var s1X1; var s1Y1; var s1Z1; var w11X1; var w11Y1; var w11Z1; var w21X1; var w21Y1; var w21Z1; var s2X; var s2Y; var s2Z; var w12X; var w12Y; var w12Z; var w22X; var w22Y; var w22Z; var v12 = this.s[0]; s0X1 = v12.x; s0Y1 = v12.y; s0Z1 = v12.z; var v13 = this.w1[0]; w10X1 = v13.x; w10Y1 = v13.y; w10Z1 = v13.z; var v14 = this.w2[0]; w20X1 = v14.x; w20Y1 = v14.y; w20Z1 = v14.z; var v15 = this.s[1]; s1X1 = v15.x; s1Y1 = v15.y; s1Z1 = v15.z; var v16 = this.w1[1]; w11X1 = v16.x; w11Y1 = v16.y; w11Z1 = v16.z; var v17 = this.w2[1]; w21X1 = v17.x; w21Y1 = v17.y; w21Z1 = v17.z; var v18 = this.s[2]; s2X = v18.x; s2Y = v18.y; s2Z = v18.z; var v19 = this.w1[2]; w12X = v19.x; w12Y = v19.y; w12Z = v19.z; var v20 = this.w2[2]; w22X = v20.x; w22Y = v20.y; w22Z = v20.z; var s01X1; var s01Y1; var s01Z1; var s02X; var s02Y; var s02Z; var s0cX1; var s0cY1; var s0cZ1; s01X1 = s1X1 - s0X1; s01Y1 = s1Y1 - s0Y1; s01Z1 = s1Z1 - s0Z1; s02X = s2X - s0X1; s02Y = s2Y - s0Y1; s02Z = s2Z - s0Z1; s0cX1 = cX1 - s0X1; s0cY1 = cY1 - s0Y1; s0cZ1 = cZ1 - s0Z1; var d11 = s01X1 * s01X1 + s01Y1 * s01Y1 + s01Z1 * s01Z1; var d12 = s01X1 * s02X + s01Y1 * s02Y + s01Z1 * s02Z; var d22 = s02X * s02X + s02Y * s02Y + s02Z * s02Z; var d1c = s01X1 * s0cX1 + s01Y1 * s0cY1 + s01Z1 * s0cZ1; var d2c = s02X * s0cX1 + s02Y * s0cY1 + s02Z * s0cZ1; var invDet1 = d11 * d22 - d12 * d12; if (invDet1 != 0) { invDet1 = 1 / invDet1; } var s = (d1c * d22 - d2c * d12) * invDet1; var t1 = (-d1c * d12 + d2c * d11) * invDet1; var diffX1; var diffY1; var diffZ1; var cp1X1; var cp1Y1; var cp1Z1; var cp2X1; var cp2Y1; var cp2Z1; diffX1 = w11X1 - w10X1; diffY1 = w11Y1 - w10Y1; diffZ1 = w11Z1 - w10Z1; cp1X1 = w10X1 + diffX1 * s; cp1Y1 = w10Y1 + diffY1 * s; cp1Z1 = w10Z1 + diffZ1 * s; diffX1 = w12X - w10X1; diffY1 = w12Y - w10Y1; diffZ1 = w12Z - w10Z1; cp1X1 += diffX1 * t1; cp1Y1 += diffY1 * t1; cp1Z1 += diffZ1 * t1; diffX1 = w21X1 - w20X1; diffY1 = w21Y1 - w20Y1; diffZ1 = w21Z1 - w20Z1; cp2X1 = w20X1 + diffX1 * s; cp2Y1 = w20Y1 + diffY1 * s; cp2Z1 = w20Z1 + diffZ1 * s; diffX1 = w22X - w20X1; diffY1 = w22Y - w20Y1; diffZ1 = w22Z - w20Z1; cp2X1 += diffX1 * t1; cp2Y1 += diffY1 * t1; cp2Z1 += diffZ1 * t1; var v21 = this.closestPoint1; v21.x = cp1X1; v21.y = cp1Y1; v21.z = cp1Z1; var v22 = this.closestPoint2; v22.x = cp2X1; v22.y = cp2Y1; v22.z = cp2Z1; break; default: throw new Error("!?"); } } }, { key: "loadCache", value: function loadCache(gjkCache) { var _this = this.dir; var v = gjkCache.prevClosestDir; _this.x = v.x; _this.y = v.y; _this.z = v.z; } }, { key: "saveCache", value: function saveCache(gjkCache) { var _this = gjkCache.prevClosestDir; var v = this.closest; _this.x = v.x; _this.y = v.y; _this.z = v.z; _this.x = -_this.x; _this.y = -_this.y; _this.z = -_this.z; } }, { key: "shrinkSimplex", value: function shrinkSimplex(vertexBits) { this.simplexSize = vertexBits; this.simplexSize = (this.simplexSize & 5) + (this.simplexSize >> 1 & 5); this.simplexSize = (this.simplexSize & 3) + (this.simplexSize >> 2 & 3); switch (vertexBits) { case 2: var _this = this.s[0]; var v = this.s[1]; _this.x = v.x; _this.y = v.y; _this.z = v.z; var _this1 = this.w1[0]; var v1 = this.w1[1]; _this1.x = v1.x; _this1.y = v1.y; _this1.z = v1.z; var _this2 = this.w2[0]; var v2 = this.w2[1]; _this2.x = v2.x; _this2.y = v2.y; _this2.z = v2.z; break; case 4: var _this3 = this.s[0]; var v3 = this.s[2]; _this3.x = v3.x; _this3.y = v3.y; _this3.z = v3.z; var _this4 = this.w1[0]; var v4 = this.w1[2]; _this4.x = v4.x; _this4.y = v4.y; _this4.z = v4.z; var _this5 = this.w2[0]; var v5 = this.w2[2]; _this5.x = v5.x; _this5.y = v5.y; _this5.z = v5.z; break; case 5: var _this6 = this.s[1]; var v6 = this.s[2]; _this6.x = v6.x; _this6.y = v6.y; _this6.z = v6.z; var _this7 = this.w1[1]; var v7 = this.w1[2]; _this7.x = v7.x; _this7.y = v7.y; _this7.z = v7.z; var _this8 = this.w2[1]; var v8 = this.w2[2]; _this8.x = v8.x; _this8.y = v8.y; _this8.z = v8.z; break; case 6: var _this9 = this.s[0]; var v9 = this.s[2]; _this9.x = v9.x; _this9.y = v9.y; _this9.z = v9.z; var _this10 = this.w1[0]; var v10 = this.w1[2]; _this10.x = v10.x; _this10.y = v10.y; _this10.z = v10.z; var _this11 = this.w2[0]; var v11 = this.w2[2]; _this11.x = v11.x; _this11.y = v11.y; _this11.z = v11.z; break; case 8: var _this12 = this.s[0]; var v12 = this.s[3]; _this12.x = v12.x; _this12.y = v12.y; _this12.z = v12.z; var _this13 = this.w1[0]; var v13 = this.w1[3]; _this13.x = v13.x; _this13.y = v13.y; _this13.z = v13.z; var _this14 = this.w2[0]; var v14 = this.w2[3]; _this14.x = v14.x; _this14.y = v14.y; _this14.z = v14.z; break; case 9: var _this15 = this.s[1]; var v15 = this.s[3]; _this15.x = v15.x; _this15.y = v15.y; _this15.z = v15.z; var _this16 = this.w1[1]; var v16 = this.w1[3]; _this16.x = v16.x; _this16.y = v16.y; _this16.z = v16.z; var _this17 = this.w2[1]; var v17 = this.w2[3]; _this17.x = v17.x; _this17.y = v17.y; _this17.z = v17.z; break; case 10: var _this18 = this.s[0]; var v18 = this.s[3]; _this18.x = v18.x; _this18.y = v18.y; _this18.z = v18.z; var _this19 = this.w1[0]; var v19 = this.w1[3]; _this19.x = v19.x; _this19.y = v19.y; _this19.z = v19.z; var _this20 = this.w2[0]; var v20 = this.w2[3]; _this20.x = v20.x; _this20.y = v20.y; _this20.z = v20.z; break; case 11: var _this21 = this.s[2]; var v21 = this.s[3]; _this21.x = v21.x; _this21.y = v21.y; _this21.z = v21.z; var _this22 = this.w1[2]; var v22 = this.w1[3]; _this22.x = v22.x; _this22.y = v22.y; _this22.z = v22.z; var _this23 = this.w2[2]; var v23 = this.w2[3]; _this23.x = v23.x; _this23.y = v23.y; _this23.z = v23.z; break; case 12: var _this24 = this.s[0]; var v24 = this.s[2]; _this24.x = v24.x; _this24.y = v24.y; _this24.z = v24.z; var _this25 = this.w1[0]; var v25 = this.w1[2]; _this25.x = v25.x; _this25.y = v25.y; _this25.z = v25.z; var _this26 = this.w2[0]; var v26 = this.w2[2]; _this26.x = v26.x; _this26.y = v26.y; _this26.z = v26.z; var _this27 = this.s[1]; var v27 = this.s[3]; _this27.x = v27.x; _this27.y = v27.y; _this27.z = v27.z; var _this28 = this.w1[1]; var v28 = this.w1[3]; _this28.x = v28.x; _this28.y = v28.y; _this28.z = v28.z; var _this29 = this.w2[1]; var v29 = this.w2[3]; _this29.x = v29.x; _this29.y = v29.y; _this29.z = v29.z; break; case 13: var _this30 = this.s[1]; var v30 = this.s[3]; _this30.x = v30.x; _this30.y = v30.y; _this30.z = v30.z; var _this31 = this.w1[1]; var v31 = this.w1[3]; _this31.x = v31.x; _this31.y = v31.y; _this31.z = v31.z; var _this32 = this.w2[1]; var v32 = this.w2[3]; _this32.x = v32.x; _this32.y = v32.y; _this32.z = v32.z; break; case 14: var _this33 = this.s[0]; var v33 = this.s[3]; _this33.x = v33.x; _this33.y = v33.y; _this33.z = v33.z; var _this34 = this.w1[0]; var v34 = this.w1[3]; _this34.x = v34.x; _this34.y = v34.y; _this34.z = v34.z; var _this35 = this.w2[0]; var v35 = this.w2[3]; _this35.x = v35.x; _this35.y = v35.y; _this35.z = v35.z; break; } } }, { key: "computeWitnessPoint1", value: function computeWitnessPoint1(addMargin) { var tmpX; var tmpY; var tmpZ; var idirX; var idirY; var idirZ; var v = this.dir; idirX = v.x; idirY = v.y; idirZ = v.z; var ldir1X; var ldir1Y; var ldir1Z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this.tf1._rotation00 * idirX + this.tf1._rotation10 * idirY + this.tf1._rotation20 * idirZ; __tmp__Y = this.tf1._rotation01 * idirX + this.tf1._rotation11 * idirY + this.tf1._rotation21 * idirZ; __tmp__Z = this.tf1._rotation02 * idirX + this.tf1._rotation12 * idirY + this.tf1._rotation22 * idirZ; ldir1X = __tmp__X; ldir1Y = __tmp__Y; ldir1Z = __tmp__Z; var iw1X; var iw1Y; var iw1Z; var v1 = this.dir; v1.x = ldir1X; v1.y = ldir1Y; v1.z = ldir1Z; this.c1.computeLocalSupportingVertex(this.dir, this.w1[this.simplexSize]); if (addMargin) { var _this = this.dir; var invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z); if (invLen > 0) { invLen = 1 / invLen; } _this.x *= invLen; _this.y *= invLen; _this.z *= invLen; var _this1 = this.w1[this.simplexSize]; var _v21 = this.dir; var s = this.c1._gjkMargin; _this1.x += _v21.x * s; _this1.y += _v21.y * s; _this1.z += _v21.z * s; } var v2 = this.w1[this.simplexSize]; tmpX = v2.x; tmpY = v2.y; tmpZ = v2.z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = this.tf1._rotation00 * tmpX + this.tf1._rotation01 * tmpY + this.tf1._rotation02 * tmpZ; __tmp__Y1 = this.tf1._rotation10 * tmpX + this.tf1._rotation11 * tmpY + this.tf1._rotation12 * tmpZ; __tmp__Z1 = this.tf1._rotation20 * tmpX + this.tf1._rotation21 * tmpY + this.tf1._rotation22 * tmpZ; iw1X = __tmp__X1; iw1Y = __tmp__Y1; iw1Z = __tmp__Z1; iw1X += this.tf1._positionX; iw1Y += this.tf1._positionY; iw1Z += this.tf1._positionZ; var v3 = this.w1[this.simplexSize]; v3.x = iw1X; v3.y = iw1Y; v3.z = iw1Z; var v4 = this.dir; v4.x = idirX; v4.y = idirY; v4.z = idirZ; } }, { key: "computeWitnessPoint2", value: function computeWitnessPoint2(addMargin) { var tmpX; var tmpY; var tmpZ; var idirX; var idirY; var idirZ; var v = this.dir; idirX = v.x; idirY = v.y; idirZ = v.z; var ldir2X; var ldir2Y; var ldir2Z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this.tf2._rotation00 * idirX + this.tf2._rotation10 * idirY + this.tf2._rotation20 * idirZ; __tmp__Y = this.tf2._rotation01 * idirX + this.tf2._rotation11 * idirY + this.tf2._rotation21 * idirZ; __tmp__Z = this.tf2._rotation02 * idirX + this.tf2._rotation12 * idirY + this.tf2._rotation22 * idirZ; ldir2X = __tmp__X; ldir2Y = __tmp__Y; ldir2Z = __tmp__Z; ldir2X = -ldir2X; ldir2Y = -ldir2Y; ldir2Z = -ldir2Z; var iw2X; var iw2Y; var iw2Z; var v1 = this.dir; v1.x = ldir2X; v1.y = ldir2Y; v1.z = ldir2Z; this.c2.computeLocalSupportingVertex(this.dir, this.w2[this.simplexSize]); if (addMargin) { var _this = this.dir; var invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z); if (invLen > 0) { invLen = 1 / invLen; } _this.x *= invLen; _this.y *= invLen; _this.z *= invLen; var _this1 = this.w2[this.simplexSize]; var _v22 = this.dir; var s = this.c2._gjkMargin; _this1.x += _v22.x * s; _this1.y += _v22.y * s; _this1.z += _v22.z * s; } var v2 = this.w2[this.simplexSize]; tmpX = v2.x; tmpY = v2.y; tmpZ = v2.z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = this.tf2._rotation00 * tmpX + this.tf2._rotation01 * tmpY + this.tf2._rotation02 * tmpZ; __tmp__Y1 = this.tf2._rotation10 * tmpX + this.tf2._rotation11 * tmpY + this.tf2._rotation12 * tmpZ; __tmp__Z1 = this.tf2._rotation20 * tmpX + this.tf2._rotation21 * tmpY + this.tf2._rotation22 * tmpZ; iw2X = __tmp__X1; iw2Y = __tmp__Y1; iw2Z = __tmp__Z1; iw2X += this.tf2._positionX; iw2Y += this.tf2._positionY; iw2Z += this.tf2._positionZ; var v3 = this.w2[this.simplexSize]; v3.x = iw2X; v3.y = iw2Y; v3.z = iw2Z; var v4 = this.dir; v4.x = idirX; v4.y = idirY; v4.z = idirZ; } }, { key: "pointToTetrahedron", value: function pointToTetrahedron() { var _g = 0; while (_g < 3) { var _this = this.dir; var v = this.baseDirs[_g++]; _this.x = v.x; _this.y = v.y; _this.z = v.z; this.computeWitnessPoint1(false); this.computeWitnessPoint2(false); var _this1 = this.s[this.simplexSize]; var v1 = this.w1[this.simplexSize]; _this1.x = v1.x; _this1.y = v1.y; _this1.z = v1.z; var v2 = this.w2[this.simplexSize]; _this1.x -= v2.x; _this1.y -= v2.y; _this1.z -= v2.z; this.simplexSize++; this.lineToTetrahedron(); if (this.simplexSize == 4) { break; } this.simplexSize--; var _this2 = this.dir; _this2.x = -_this2.x; _this2.y = -_this2.y; _this2.z = -_this2.z; this.computeWitnessPoint1(false); this.computeWitnessPoint2(false); var _this3 = this.s[this.simplexSize]; var v3 = this.w1[this.simplexSize]; _this3.x = v3.x; _this3.y = v3.y; _this3.z = v3.z; var v4 = this.w2[this.simplexSize]; _this3.x -= v4.x; _this3.y -= v4.y; _this3.z -= v4.z; this.simplexSize++; this.lineToTetrahedron(); if (this.simplexSize == 4) { break; } this.simplexSize--; } } }, { key: "lineToTetrahedron", value: function lineToTetrahedron() { var oldDirX; var oldDirY; var oldDirZ; var v = this.dir; oldDirX = v.x; oldDirY = v.y; oldDirZ = v.z; var s0X; var s0Y; var s0Z; var s1X; var s1Y; var s1Z; var lineDirX; var lineDirY; var lineDirZ; var v1 = this.s[0]; s0X = v1.x; s0Y = v1.y; s0Z = v1.z; var v2 = this.s[1]; s1X = v2.x; s1Y = v2.y; s1Z = v2.z; lineDirX = s0X - s1X; lineDirY = s0Y - s1Y; lineDirZ = s0Z - s1Z; var _g = 0; while (_g < 3) { var baseDirX = void 0; var baseDirY = void 0; var baseDirZ = void 0; var _v23 = this.baseDirs[_g++]; baseDirX = _v23.x; baseDirY = _v23.y; baseDirZ = _v23.z; var newDirX = void 0; var newDirY = void 0; var newDirZ = void 0; newDirX = lineDirY * baseDirZ - lineDirZ * baseDirY; newDirY = lineDirZ * baseDirX - lineDirX * baseDirZ; newDirZ = lineDirX * baseDirY - lineDirY * baseDirX; var _v24 = this.dir; _v24.x = newDirX; _v24.y = newDirY; _v24.z = newDirZ; this.computeWitnessPoint1(false); this.computeWitnessPoint2(false); var _this = this.s[this.simplexSize]; var _v25 = this.w1[this.simplexSize]; _this.x = _v25.x; _this.y = _v25.y; _this.z = _v25.z; var _v26 = this.w2[this.simplexSize]; _this.x -= _v26.x; _this.y -= _v26.y; _this.z -= _v26.z; this.simplexSize++; this.triangleToTetrahedron(); if (this.simplexSize == 4) { break; } this.simplexSize--; var _this1 = this.dir; _this1.x = -_this1.x; _this1.y = -_this1.y; _this1.z = -_this1.z; this.computeWitnessPoint1(false); this.computeWitnessPoint2(false); var _this2 = this.s[this.simplexSize]; var v4 = this.w1[this.simplexSize]; _this2.x = v4.x; _this2.y = v4.y; _this2.z = v4.z; var v5 = this.w2[this.simplexSize]; _this2.x -= v5.x; _this2.y -= v5.y; _this2.z -= v5.z; this.simplexSize++; this.triangleToTetrahedron(); if (this.simplexSize == 4) { break; } this.simplexSize--; } var v3 = this.dir; v3.x = oldDirX; v3.y = oldDirY; v3.z = oldDirZ; } }, { key: "triangleToTetrahedron", value: function triangleToTetrahedron() { var oldDirX; var oldDirY; var oldDirZ; var v = this.dir; oldDirX = v.x; oldDirY = v.y; oldDirZ = v.z; while (true) { var s0X = void 0; var s0Y = void 0; var s0Z = void 0; var s1X = void 0; var s1Y = void 0; var s1Z = void 0; var s2X = void 0; var s2Y = void 0; var s2Z = void 0; var s01X = void 0; var s01Y = void 0; var s01Z = void 0; var s02X = void 0; var s02Y = void 0; var s02Z = void 0; var _v27 = this.s[0]; s0X = _v27.x; s0Y = _v27.y; s0Z = _v27.z; var _v28 = this.s[1]; s1X = _v28.x; s1Y = _v28.y; s1Z = _v28.z; var v2 = this.s[2]; s2X = v2.x; s2Y = v2.y; s2Z = v2.z; s01X = s1X - s0X; s01Y = s1Y - s0Y; s01Z = s1Z - s0Z; s02X = s2X - s0X; s02Y = s2Y - s0Y; s02Z = s2Z - s0Z; var nX = void 0; var nY = void 0; var nZ = void 0; nX = s01Y * s02Z - s01Z * s02Y; nY = s01Z * s02X - s01X * s02Z; nZ = s01X * s02Y - s01Y * s02X; var v3 = this.dir; v3.x = nX; v3.y = nY; v3.z = nZ; this.computeWitnessPoint1(false); this.computeWitnessPoint2(false); var _this = this.s[this.simplexSize]; var v4 = this.w1[this.simplexSize]; _this.x = v4.x; _this.y = v4.y; _this.z = v4.z; var v5 = this.w2[this.simplexSize]; _this.x -= v5.x; _this.y -= v5.y; _this.z -= v5.z; this.simplexSize++; if (this.isValidTetrahedron()) { break; } this.simplexSize--; var _this1 = this.dir; _this1.x = -_this1.x; _this1.y = -_this1.y; _this1.z = -_this1.z; this.computeWitnessPoint1(false); this.computeWitnessPoint2(false); var _this2 = this.s[this.simplexSize]; var v6 = this.w1[this.simplexSize]; _this2.x = v6.x; _this2.y = v6.y; _this2.z = v6.z; var v7 = this.w2[this.simplexSize]; _this2.x -= v7.x; _this2.y -= v7.y; _this2.z -= v7.z; this.simplexSize++; if (this.isValidTetrahedron()) { break; } this.simplexSize--; break; } var v1 = this.dir; v1.x = oldDirX; v1.y = oldDirY; v1.z = oldDirZ; } }, { key: "isValidTetrahedron", value: function isValidTetrahedron() { var e10 = this.s[2].x - this.s[0].x; var e11 = this.s[2].y - this.s[0].y; var e12 = this.s[2].z - this.s[0].z; var e20 = this.s[3].x - this.s[0].x; var e21 = this.s[3].y - this.s[0].y; var e22 = this.s[3].z - this.s[0].z; var det = (this.s[1].x - this.s[0].x) * (e11 * e22 - e12 * e21) - (this.s[1].y - this.s[0].y) * (e10 * e22 - e12 * e20) + (this.s[1].z - this.s[0].z) * (e10 * e21 - e11 * e20); if (!(det > 1e-12)) { return det < -1e-12; } else { return true; } } }, { key: "computeDepth", value: function computeDepth(convex1, convex2, tf1, tf2, initialPolyhedron, initialPolyhedron1, initialPolyhedron2) { var _this = this.polyhedron; while (_this._numTriangles > 0) { var t = _this._triangleList; _this._numTriangles--; var prev = t._prev; var next = t._next; if (prev != null) { prev._next = next; } if (next != null) { next._prev = prev; } if (t == _this._triangleList) { _this._triangleList = _this._triangleList._next; } if (t == _this._triangleListLast) { _this._triangleListLast = _this._triangleListLast._prev; } t._next = null; t._prev = null; t.removeReferences(); t._next = _this._trianglePool; _this._trianglePool = t; } while (_this._numVertices > 0) { var v = _this._vertices[--_this._numVertices]; v.removeReferences(); v._next = _this._vertexPool; _this._vertexPool = v; } var tmp = this.polyhedron; var _this1 = this.polyhedron; var first = _this1._vertexPool; if (first != null) { _this1._vertexPool = first._next; first._next = null; } else { first = new oimo.collision.narrowphase.detector.gjkepa.EpaVertex(); } var tmp1 = first.init(initialPolyhedron[0], initialPolyhedron1[0], initialPolyhedron2[0]); var _this2 = this.polyhedron; var first1 = _this2._vertexPool; if (first1 != null) { _this2._vertexPool = first1._next; first1._next = null; } else { first1 = new oimo.collision.narrowphase.detector.gjkepa.EpaVertex(); } var tmp2 = first1.init(initialPolyhedron[1], initialPolyhedron1[1], initialPolyhedron2[1]); var _this3 = this.polyhedron; var first2 = _this3._vertexPool; if (first2 != null) { _this3._vertexPool = first2._next; first2._next = null; } else { first2 = new oimo.collision.narrowphase.detector.gjkepa.EpaVertex(); } var tmp3 = first2.init(initialPolyhedron[2], initialPolyhedron1[2], initialPolyhedron2[2]); var _this4 = this.polyhedron; var first3 = _this4._vertexPool; if (first3 != null) { _this4._vertexPool = first3._next; first3._next = null; } else { first3 = new oimo.collision.narrowphase.detector.gjkepa.EpaVertex(); } if (!tmp._init(tmp1, tmp2, tmp3, first3.init(initialPolyhedron[3], initialPolyhedron1[3], initialPolyhedron2[3]))) { return oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_FAILED_TO_INIT; } this.simplexSize = 0; var supportingVertex = this.s[0]; var witness1 = this.w1[0]; var witness2 = this.w2[0]; var count = 0; while (count < 40) { var f = this.polyhedron._triangleList; var mind = 1e65536; var minf = null; while (f != null) { if (f._distanceSq < mind) { mind = f._distanceSq; minf = f; } f = f._next; } var face = minf; var _this76 = this.dir; var _v29 = face._normal; _this76.x = _v29.x; _this76.y = _v29.y; _this76.z = _v29.z; var invLen = Math.sqrt(_this76.x * _this76.x + _this76.y * _this76.y + _this76.z * _this76.z); if (invLen > 0) { invLen = 1 / invLen; } _this76.x *= invLen; _this76.y *= invLen; _this76.z *= invLen; this.computeWitnessPoint1(false); this.computeWitnessPoint2(false); var _this77 = this.s[this.simplexSize]; var v1 = this.w1[this.simplexSize]; _this77.x = v1.x; _this77.y = v1.y; _this77.z = v1.z; var v2 = this.w2[this.simplexSize]; _this77.x -= v2.x; _this77.y -= v2.y; _this77.z -= v2.z; var v0 = face._vertices[0]; var v11 = face._vertices[1]; var v21 = face._vertices[2]; var _this78 = v0.v; var v3 = this.dir; var v4 = this.dir; if (supportingVertex.x * v4.x + supportingVertex.y * v4.y + supportingVertex.z * v4.z - (_this78.x * v3.x + _this78.y * v3.y + _this78.z * v3.z) < 1e-6 || count == 39) { var _this80 = this.closest; var _v30 = this.dir; _this80.x = _v30.x; _this80.y = _v30.y; _this80.z = _v30.z; var _this81 = this.dir; var _v31 = v0.v; var _this82 = this.dir; var s = (_this81.x * _v31.x + _this81.y * _v31.y + _this81.z * _v31.z) / (_this82.x * _this82.x + _this82.y * _this82.y + _this82.z * _this82.z); _this80.x *= s; _this80.y *= s; _this80.z *= s; var cX = void 0; var cY = void 0; var cZ = void 0; var _v32 = this.closest; cX = _v32.x; cY = _v32.y; cZ = _v32.z; var s0X = void 0; var s0Y = void 0; var s0Z = void 0; var w10X = void 0; var w10Y = void 0; var w10Z = void 0; var w20X = void 0; var w20Y = void 0; var w20Z = void 0; var s1X = void 0; var s1Y = void 0; var s1Z = void 0; var w11X = void 0; var w11Y = void 0; var w11Z = void 0; var w21X = void 0; var w21Y = void 0; var w21Z = void 0; var s2X = void 0; var s2Y = void 0; var s2Z = void 0; var w12X = void 0; var w12Y = void 0; var w12Z = void 0; var w22X = void 0; var w22Y = void 0; var w22Z = void 0; var _v33 = v0.v; s0X = _v33.x; s0Y = _v33.y; s0Z = _v33.z; var _v34 = v0.w1; w10X = _v34.x; w10Y = _v34.y; w10Z = _v34.z; var v5 = v0.w2; w20X = v5.x; w20Y = v5.y; w20Z = v5.z; var v6 = v11.v; s1X = v6.x; s1Y = v6.y; s1Z = v6.z; var v7 = v11.w1; w11X = v7.x; w11Y = v7.y; w11Z = v7.z; var v8 = v11.w2; w21X = v8.x; w21Y = v8.y; w21Z = v8.z; var v9 = v21.v; s2X = v9.x; s2Y = v9.y; s2Z = v9.z; var v10 = v21.w1; w12X = v10.x; w12Y = v10.y; w12Z = v10.z; var v12 = v21.w2; w22X = v12.x; w22Y = v12.y; w22Z = v12.z; var s01X = void 0; var s01Y = void 0; var s01Z = void 0; var s02X = void 0; var s02Y = void 0; var s02Z = void 0; var s0cX = void 0; var s0cY = void 0; var s0cZ = void 0; s01X = s1X - s0X; s01Y = s1Y - s0Y; s01Z = s1Z - s0Z; s02X = s2X - s0X; s02Y = s2Y - s0Y; s02Z = s2Z - s0Z; s0cX = cX - s0X; s0cY = cY - s0Y; s0cZ = cZ - s0Z; var d11 = s01X * s01X + s01Y * s01Y + s01Z * s01Z; var d12 = s01X * s02X + s01Y * s02Y + s01Z * s02Z; var d22 = s02X * s02X + s02Y * s02Y + s02Z * s02Z; var d1c = s01X * s0cX + s01Y * s0cY + s01Z * s0cZ; var d2c = s02X * s0cX + s02Y * s0cY + s02Z * s0cZ; var invDet = d11 * d22 - d12 * d12; if (invDet != 0) { invDet = 1 / invDet; } var s1 = (d1c * d22 - d2c * d12) * invDet; var _t44 = (-d1c * d12 + d2c * d11) * invDet; var diffX = void 0; var diffY = void 0; var diffZ = void 0; var cp1X = void 0; var cp1Y = void 0; var cp1Z = void 0; var cp2X = void 0; var cp2Y = void 0; var cp2Z = void 0; diffX = w11X - w10X; diffY = w11Y - w10Y; diffZ = w11Z - w10Z; cp1X = w10X + diffX * s1; cp1Y = w10Y + diffY * s1; cp1Z = w10Z + diffZ * s1; diffX = w12X - w10X; diffY = w12Y - w10Y; diffZ = w12Z - w10Z; cp1X += diffX * _t44; cp1Y += diffY * _t44; cp1Z += diffZ * _t44; diffX = w21X - w20X; diffY = w21Y - w20Y; diffZ = w21Z - w20Z; cp2X = w20X + diffX * s1; cp2Y = w20Y + diffY * s1; cp2Z = w20Z + diffZ * s1; diffX = w22X - w20X; diffY = w22Y - w20Y; diffZ = w22Z - w20Z; cp2X += diffX * _t44; cp2Y += diffY * _t44; cp2Z += diffZ * _t44; var v13 = this.closestPoint1; v13.x = cp1X; v13.y = cp1Y; v13.z = cp1Z; var v14 = this.closestPoint2; v14.x = cp2X; v14.y = cp2Y; v14.z = cp2Z; var _this83 = this.closest; this.depth = Math.sqrt(_this83.x * _this83.x + _this83.y * _this83.y + _this83.z * _this83.z); return oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.SUCCEEDED; } var _this79 = this.polyhedron; var _first3 = _this79._vertexPool; if (_first3 != null) { _this79._vertexPool = _first3._next; _first3._next = null; } else { _first3 = new oimo.collision.narrowphase.detector.gjkepa.EpaVertex(); } var epaVertex = _first3.init(supportingVertex, witness1, witness2); if (!this.polyhedron._addVertex(epaVertex, face)) { return oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_FAILED_TO_ADD_VERTEX; } ++count; } return oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_DID_NOT_CONVERGE; } }, { key: "computeClosestPoints", value: function computeClosestPoints(c1, c2, tf1, tf2, cache) { return this.computeClosestPointsImpl(c1, c2, tf1, tf2, cache, true); } }, { key: "computeDistance", value: function computeDistance(c1, c2, tf1, tf2, cache) { return this.computeClosestPointsImpl(c1, c2, tf1, tf2, cache, false); } }, { key: "convexCast", value: function convexCast(c1, c2, tf1, tf2, tl1, tl2, hit) { return this.convexCastImpl(c1, c2, tf1, tf2, tl1, tl2, hit); } }, { key: "rayCast", value: function rayCast(c, tf, begin, end, hit) { var tf1 = this.tempTransform; tf1._positionX = begin.x; tf1._positionY = begin.y; tf1._positionZ = begin.z; var tl1 = this.tl1; var tl2 = this.tl2; tl1.x = end.x; tl1.y = end.y; tl1.z = end.z; tl1.x -= begin.x; tl1.y -= begin.y; tl1.z -= begin.z; tl2.zero(); return this.convexCastImpl(null, c, tf1, tf, tl1, tl2, hit); } }], [{ key: "getInstance", value: function getInstance() { return oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance; } }]); return oimo_collision_narrowphase_detector_gjkepa_GjkEpa; }(); oimo.collision.narrowphase.detector.gjkepa.GjkEpaLog = /*#__PURE__*/_createClass(function oimo_collision_narrowphase_detector_gjkepa_GjkEpaLog() { _classCallCheck(this, oimo_collision_narrowphase_detector_gjkepa_GjkEpaLog); }); oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState = /*#__PURE__*/_createClass(function oimo_collision_narrowphase_detector_gjkepa_GjkEpaResultState() { _classCallCheck(this, oimo_collision_narrowphase_detector_gjkepa_GjkEpaResultState); }); oimo.collision.narrowphase.detector.gjkepa.SimplexUtil = /*#__PURE__*/function () { function oimo_collision_narrowphase_detector_gjkepa_SimplexUtil() { _classCallCheck(this, oimo_collision_narrowphase_detector_gjkepa_SimplexUtil); } _createClass(oimo_collision_narrowphase_detector_gjkepa_SimplexUtil, null, [{ key: "projectOrigin2", value: function projectOrigin2(vec1, vec2, out) { var v1X; var v1Y; var v1Z; var v2X; var v2Y; var v2Z; v1X = vec1.x; v1Y = vec1.y; v1Z = vec1.z; v2X = vec2.x; v2Y = vec2.y; v2Z = vec2.z; var v12X; var v12Y; var v12Z; v12X = v2X - v1X; v12Y = v2Y - v1Y; v12Z = v2Z - v1Z; var t = v12X * v1X + v12Y * v1Y + v12Z * v1Z; t = -t / (v12X * v12X + v12Y * v12Y + v12Z * v12Z); if (t < 0) { out.x = v1X; out.y = v1Y; out.z = v1Z; return 1; } if (t > 1) { out.x = v2X; out.y = v2Y; out.z = v2Z; return 2; } var pX; var pY; var pZ; pX = v1X + v12X * t; pY = v1Y + v12Y * t; pZ = v1Z + v12Z * t; out.x = pX; out.y = pY; out.z = pZ; return 3; } }, { key: "projectOrigin3", value: function projectOrigin3(vec1, vec2, vec3, out) { var v1X; var v1Y; var v1Z; var v2X; var v2Y; var v2Z; var v3X; var v3Y; var v3Z; var v12X; var v12Y; var v12Z; var v23X; var v23Y; var v23Z; var v31X; var v31Y; var v31Z; v1X = vec1.x; v1Y = vec1.y; v1Z = vec1.z; v2X = vec2.x; v2Y = vec2.y; v2Z = vec2.z; v3X = vec3.x; v3Y = vec3.y; v3Z = vec3.z; v12X = v2X - v1X; v12Y = v2Y - v1Y; v12Z = v2Z - v1Z; v23X = v3X - v2X; v23Y = v3Y - v2Y; v23Z = v3Z - v2Z; v31X = v1X - v3X; v31Y = v1Y - v3Y; v31Z = v1Z - v3Z; var nX; var nY; var nZ; nX = v12Y * v23Z - v12Z * v23Y; nY = v12Z * v23X - v12X * v23Z; nZ = v12X * v23Y - v12Y * v23X; var n12X; var n12Y; var n12Z; var n23X; var n23Y; var n23Z; var n31X; var n31Y; var n31Z; n12X = v12Y * nZ - v12Z * nY; n12Y = v12Z * nX - v12X * nZ; n12Z = v12X * nY - v12Y * nX; n23X = v23Y * nZ - v23Z * nY; n23Y = v23Z * nX - v23X * nZ; n23Z = v23X * nY - v23Y * nX; n31X = v31Y * nZ - v31Z * nY; n31Y = v31Z * nX - v31X * nZ; n31Z = v31X * nY - v31Y * nX; var mind = -1; var minvX; var minvY; var minvZ; var mini = 0; minvX = 0; minvY = 0; minvZ = 0; if (v1X * n12X + v1Y * n12Y + v1Z * n12Z < 0) { var _v1X42; var _v1Y42; var _v1Z42; var _v2X42; var _v2Y42; var _v2Z42; _v1X42 = vec1.x; _v1Y42 = vec1.y; _v1Z42 = vec1.z; _v2X42 = vec2.x; _v2Y42 = vec2.y; _v2Z42 = vec2.z; var _v12X42; var _v12Y42; var _v12Z42; _v12X42 = _v2X42 - _v1X42; _v12Y42 = _v2Y42 - _v1Y42; _v12Z42 = _v2Z42 - _v1Z42; var t = _v12X42 * _v1X42 + _v12Y42 * _v1Y42 + _v12Z42 * _v1Z42; t = -t / (_v12X42 * _v12X42 + _v12Y42 * _v12Y42 + _v12Z42 * _v12Z42); var b; if (t < 0) { out.x = _v1X42; out.y = _v1Y42; out.z = _v1Z42; b = 1; } else if (t > 1) { out.x = _v2X42; out.y = _v2Y42; out.z = _v2Z42; b = 2; } else { var pX; var pY; var pZ; pX = _v1X42 + _v12X42 * t; pY = _v1Y42 + _v12Y42 * t; pZ = _v1Z42 + _v12Z42 * t; out.x = pX; out.y = pY; out.z = pZ; b = 3; } mini = b; mind = out.x * out.x + out.y * out.y + out.z * out.z; minvX = out.x; minvY = out.y; minvZ = out.z; } if (v2X * n23X + v2Y * n23Y + v2Z * n23Z < 0) { var _v1X43; var _v1Y43; var _v1Z43; var _v2X43; var _v2Y43; var _v2Z43; _v1X43 = vec2.x; _v1Y43 = vec2.y; _v1Z43 = vec2.z; _v2X43 = vec3.x; _v2Y43 = vec3.y; _v2Z43 = vec3.z; var _v12X43; var _v12Y43; var _v12Z43; _v12X43 = _v2X43 - _v1X43; _v12Y43 = _v2Y43 - _v1Y43; _v12Z43 = _v2Z43 - _v1Z43; var _t45 = _v12X43 * _v1X43 + _v12Y43 * _v1Y43 + _v12Z43 * _v1Z43; _t45 = -_t45 / (_v12X43 * _v12X43 + _v12Y43 * _v12Y43 + _v12Z43 * _v12Z43); var _b37; if (_t45 < 0) { out.x = _v1X43; out.y = _v1Y43; out.z = _v1Z43; _b37 = 1; } else if (_t45 > 1) { out.x = _v2X43; out.y = _v2Y43; out.z = _v2Z43; _b37 = 2; } else { var _pX33; var _pY33; var _pZ33; _pX33 = _v1X43 + _v12X43 * _t45; _pY33 = _v1Y43 + _v12Y43 * _t45; _pZ33 = _v1Z43 + _v12Z43 * _t45; out.x = _pX33; out.y = _pY33; out.z = _pZ33; _b37 = 3; } var d = out.x * out.x + out.y * out.y + out.z * out.z; if (mind < 0 || d < mind) { mini = _b37 << 1; mind = d; minvX = out.x; minvY = out.y; minvZ = out.z; } } if (v3X * n31X + v3Y * n31Y + v3Z * n31Z < 0) { var _v1X44; var _v1Y44; var _v1Z44; var _v2X44; var _v2Y44; var _v2Z44; _v1X44 = vec1.x; _v1Y44 = vec1.y; _v1Z44 = vec1.z; _v2X44 = vec3.x; _v2Y44 = vec3.y; _v2Z44 = vec3.z; var _v12X44; var _v12Y44; var _v12Z44; _v12X44 = _v2X44 - _v1X44; _v12Y44 = _v2Y44 - _v1Y44; _v12Z44 = _v2Z44 - _v1Z44; var _t46 = _v12X44 * _v1X44 + _v12Y44 * _v1Y44 + _v12Z44 * _v1Z44; _t46 = -_t46 / (_v12X44 * _v12X44 + _v12Y44 * _v12Y44 + _v12Z44 * _v12Z44); var _b38; if (_t46 < 0) { out.x = _v1X44; out.y = _v1Y44; out.z = _v1Z44; _b38 = 1; } else if (_t46 > 1) { out.x = _v2X44; out.y = _v2Y44; out.z = _v2Z44; _b38 = 2; } else { var _pX34; var _pY34; var _pZ34; _pX34 = _v1X44 + _v12X44 * _t46; _pY34 = _v1Y44 + _v12Y44 * _t46; _pZ34 = _v1Z44 + _v12Z44 * _t46; out.x = _pX34; out.y = _pY34; out.z = _pZ34; _b38 = 3; } var _d26 = out.x * out.x + out.y * out.y + out.z * out.z; if (mind < 0 || _d26 < mind) { mini = _b38 & 1 | (_b38 & 2) << 1; mind = _d26; minvX = out.x; minvY = out.y; minvZ = out.z; } } if (mind > 0) { out.x = minvX; out.y = minvY; out.z = minvZ; return mini; } var l = nX * nX + nY * nY + nZ * nZ; if (l > 0) { l = 1 / Math.sqrt(l); } nX *= l; nY *= l; nZ *= l; var l2 = nX * nX + nY * nY + nZ * nZ; l2 = (v1X * nX + v1Y * nY + v1Z * nZ) / l2; minvX = nX * l2; minvY = nY * l2; minvZ = nZ * l2; out.x = minvX; out.y = minvY; out.z = minvZ; return 7; } }, { key: "projectOrigin4", value: function projectOrigin4(vec1, vec2, vec3, vec4, out) { var v1X; var v1Y; var v1Z; var v2X; var v2Y; var v2Z; var v3X; var v3Y; var v3Z; var v4X; var v4Y; var v4Z; var v12X; var v12Y; var v12Z; var v13X; var v13Y; var v13Z; var v14X; var v14Y; var v14Z; var v23X; var v23Y; var v23Z; var v24X; var v24Y; var v24Z; v1X = vec1.x; v1Y = vec1.y; v1Z = vec1.z; v2X = vec2.x; v2Y = vec2.y; v2Z = vec2.z; v3X = vec3.x; v3Y = vec3.y; v3Z = vec3.z; v4X = vec4.x; v4Y = vec4.y; v4Z = vec4.z; v12X = v2X - v1X; v12Y = v2Y - v1Y; v12Z = v2Z - v1Z; v13X = v3X - v1X; v13Y = v3Y - v1Y; v13Z = v3Z - v1Z; v14X = v4X - v1X; v14Y = v4Y - v1Y; v14Z = v4Z - v1Z; v23X = v3X - v2X; v23Y = v3Y - v2Y; v23Z = v3Z - v2Z; v24X = v4X - v2X; v24Y = v4Y - v2Y; v24Z = v4Z - v2Z; var n123X; var n123Y; var n123Z; var n134X; var n134Y; var n134Z; var n142X; var n142Y; var n142Z; var n243X; var n243Y; var n243Z; n123X = v12Y * v13Z - v12Z * v13Y; n123Y = v12Z * v13X - v12X * v13Z; n123Z = v12X * v13Y - v12Y * v13X; n134X = v13Y * v14Z - v13Z * v14Y; n134Y = v13Z * v14X - v13X * v14Z; n134Z = v13X * v14Y - v13Y * v14X; n142X = v14Y * v12Z - v14Z * v12Y; n142Y = v14Z * v12X - v14X * v12Z; n142Z = v14X * v12Y - v14Y * v12X; n243X = v24Y * v23Z - v24Z * v23Y; n243Y = v24Z * v23X - v24X * v23Z; n243Z = v24X * v23Y - v24Y * v23X; var sign = v12X * n243X + v12Y * n243Y + v12Z * n243Z > 0 ? 1 : -1; var mind = -1; var minvX; var minvY; var minvZ; var mini = 0; minvX = 0; minvY = 0; minvZ = 0; if ((v1X * n123X + v1Y * n123Y + v1Z * n123Z) * sign < 0) { var _v1X45; var _v1Y45; var _v1Z45; var _v2X45; var _v2Y45; var _v2Z45; var _v3X9; var _v3Y9; var _v3Z9; var _v12X45; var _v12Y45; var _v12Z45; var _v23X9; var _v23Y9; var _v23Z9; var v31X; var v31Y; var v31Z; _v1X45 = vec1.x; _v1Y45 = vec1.y; _v1Z45 = vec1.z; _v2X45 = vec2.x; _v2Y45 = vec2.y; _v2Z45 = vec2.z; _v3X9 = vec3.x; _v3Y9 = vec3.y; _v3Z9 = vec3.z; _v12X45 = _v2X45 - _v1X45; _v12Y45 = _v2Y45 - _v1Y45; _v12Z45 = _v2Z45 - _v1Z45; _v23X9 = _v3X9 - _v2X45; _v23Y9 = _v3Y9 - _v2Y45; _v23Z9 = _v3Z9 - _v2Z45; v31X = _v1X45 - _v3X9; v31Y = _v1Y45 - _v3Y9; v31Z = _v1Z45 - _v3Z9; var nX; var nY; var nZ; nX = _v12Y45 * _v23Z9 - _v12Z45 * _v23Y9; nY = _v12Z45 * _v23X9 - _v12X45 * _v23Z9; nZ = _v12X45 * _v23Y9 - _v12Y45 * _v23X9; var n12X; var n12Y; var n12Z; var n23X; var n23Y; var n23Z; var n31X; var n31Y; var n31Z; n12X = _v12Y45 * nZ - _v12Z45 * nY; n12Y = _v12Z45 * nX - _v12X45 * nZ; n12Z = _v12X45 * nY - _v12Y45 * nX; n23X = _v23Y9 * nZ - _v23Z9 * nY; n23Y = _v23Z9 * nX - _v23X9 * nZ; n23Z = _v23X9 * nY - _v23Y9 * nX; n31X = v31Y * nZ - v31Z * nY; n31Y = v31Z * nX - v31X * nZ; n31Z = v31X * nY - v31Y * nX; var mind1 = -1; var minvX1; var minvY1; var minvZ1; var mini1 = 0; minvX1 = 0; minvY1 = 0; minvZ1 = 0; if (_v1X45 * n12X + _v1Y45 * n12Y + _v1Z45 * n12Z < 0) { var _v1X46; var _v1Y46; var _v1Z46; var _v2X46; var _v2Y46; var _v2Z46; _v1X46 = vec1.x; _v1Y46 = vec1.y; _v1Z46 = vec1.z; _v2X46 = vec2.x; _v2Y46 = vec2.y; _v2Z46 = vec2.z; var _v12X46; var _v12Y46; var _v12Z46; _v12X46 = _v2X46 - _v1X46; _v12Y46 = _v2Y46 - _v1Y46; _v12Z46 = _v2Z46 - _v1Z46; var t = _v12X46 * _v1X46 + _v12Y46 * _v1Y46 + _v12Z46 * _v1Z46; t = -t / (_v12X46 * _v12X46 + _v12Y46 * _v12Y46 + _v12Z46 * _v12Z46); var _b39; if (t < 0) { out.x = _v1X46; out.y = _v1Y46; out.z = _v1Z46; _b39 = 1; } else if (t > 1) { out.x = _v2X46; out.y = _v2Y46; out.z = _v2Z46; _b39 = 2; } else { var pX; var pY; var pZ; pX = _v1X46 + _v12X46 * t; pY = _v1Y46 + _v12Y46 * t; pZ = _v1Z46 + _v12Z46 * t; out.x = pX; out.y = pY; out.z = pZ; _b39 = 3; } mini1 = _b39; mind1 = out.x * out.x + out.y * out.y + out.z * out.z; minvX1 = out.x; minvY1 = out.y; minvZ1 = out.z; } if (_v2X45 * n23X + _v2Y45 * n23Y + _v2Z45 * n23Z < 0) { var _v1X47; var _v1Y47; var _v1Z47; var _v2X47; var _v2Y47; var _v2Z47; _v1X47 = vec2.x; _v1Y47 = vec2.y; _v1Z47 = vec2.z; _v2X47 = vec3.x; _v2Y47 = vec3.y; _v2Z47 = vec3.z; var _v12X47; var _v12Y47; var _v12Z47; _v12X47 = _v2X47 - _v1X47; _v12Y47 = _v2Y47 - _v1Y47; _v12Z47 = _v2Z47 - _v1Z47; var _t47 = _v12X47 * _v1X47 + _v12Y47 * _v1Y47 + _v12Z47 * _v1Z47; _t47 = -_t47 / (_v12X47 * _v12X47 + _v12Y47 * _v12Y47 + _v12Z47 * _v12Z47); var _b40; if (_t47 < 0) { out.x = _v1X47; out.y = _v1Y47; out.z = _v1Z47; _b40 = 1; } else if (_t47 > 1) { out.x = _v2X47; out.y = _v2Y47; out.z = _v2Z47; _b40 = 2; } else { var _pX35; var _pY35; var _pZ35; _pX35 = _v1X47 + _v12X47 * _t47; _pY35 = _v1Y47 + _v12Y47 * _t47; _pZ35 = _v1Z47 + _v12Z47 * _t47; out.x = _pX35; out.y = _pY35; out.z = _pZ35; _b40 = 3; } var d = out.x * out.x + out.y * out.y + out.z * out.z; if (mind1 < 0 || d < mind1) { mini1 = _b40 << 1; mind1 = d; minvX1 = out.x; minvY1 = out.y; minvZ1 = out.z; } } if (_v3X9 * n31X + _v3Y9 * n31Y + _v3Z9 * n31Z < 0) { var _v1X48; var _v1Y48; var _v1Z48; var _v2X48; var _v2Y48; var _v2Z48; _v1X48 = vec1.x; _v1Y48 = vec1.y; _v1Z48 = vec1.z; _v2X48 = vec3.x; _v2Y48 = vec3.y; _v2Z48 = vec3.z; var _v12X48; var _v12Y48; var _v12Z48; _v12X48 = _v2X48 - _v1X48; _v12Y48 = _v2Y48 - _v1Y48; _v12Z48 = _v2Z48 - _v1Z48; var _t48 = _v12X48 * _v1X48 + _v12Y48 * _v1Y48 + _v12Z48 * _v1Z48; _t48 = -_t48 / (_v12X48 * _v12X48 + _v12Y48 * _v12Y48 + _v12Z48 * _v12Z48); var _b41; if (_t48 < 0) { out.x = _v1X48; out.y = _v1Y48; out.z = _v1Z48; _b41 = 1; } else if (_t48 > 1) { out.x = _v2X48; out.y = _v2Y48; out.z = _v2Z48; _b41 = 2; } else { var _pX36; var _pY36; var _pZ36; _pX36 = _v1X48 + _v12X48 * _t48; _pY36 = _v1Y48 + _v12Y48 * _t48; _pZ36 = _v1Z48 + _v12Z48 * _t48; out.x = _pX36; out.y = _pY36; out.z = _pZ36; _b41 = 3; } var _d27 = out.x * out.x + out.y * out.y + out.z * out.z; if (mind1 < 0 || _d27 < mind1) { mini1 = _b41 & 1 | (_b41 & 2) << 1; mind1 = _d27; minvX1 = out.x; minvY1 = out.y; minvZ1 = out.z; } } var b; if (mind1 > 0) { out.x = minvX1; out.y = minvY1; out.z = minvZ1; b = mini1; } else { var l = nX * nX + nY * nY + nZ * nZ; if (l > 0) { l = 1 / Math.sqrt(l); } nX *= l; nY *= l; nZ *= l; var l2 = nX * nX + nY * nY + nZ * nZ; l2 = (_v1X45 * nX + _v1Y45 * nY + _v1Z45 * nZ) / l2; minvX1 = nX * l2; minvY1 = nY * l2; minvZ1 = nZ * l2; out.x = minvX1; out.y = minvY1; out.z = minvZ1; b = 7; } mini = b; mind = out.x * out.x + out.y * out.y + out.z * out.z; minvX = out.x; minvY = out.y; minvZ = out.z; } if ((v1X * n134X + v1Y * n134Y + v1Z * n134Z) * sign < 0) { var _v1X49; var _v1Y49; var _v1Z49; var _v2X49; var _v2Y49; var _v2Z49; var _v3X10; var _v3Y10; var _v3Z10; var _v12X49; var _v12Y49; var _v12Z49; var _v23X10; var _v23Y10; var _v23Z10; var _v31X9; var _v31Y9; var _v31Z9; _v1X49 = vec1.x; _v1Y49 = vec1.y; _v1Z49 = vec1.z; _v2X49 = vec3.x; _v2Y49 = vec3.y; _v2Z49 = vec3.z; _v3X10 = vec4.x; _v3Y10 = vec4.y; _v3Z10 = vec4.z; _v12X49 = _v2X49 - _v1X49; _v12Y49 = _v2Y49 - _v1Y49; _v12Z49 = _v2Z49 - _v1Z49; _v23X10 = _v3X10 - _v2X49; _v23Y10 = _v3Y10 - _v2Y49; _v23Z10 = _v3Z10 - _v2Z49; _v31X9 = _v1X49 - _v3X10; _v31Y9 = _v1Y49 - _v3Y10; _v31Z9 = _v1Z49 - _v3Z10; var _nX9; var _nY9; var _nZ9; _nX9 = _v12Y49 * _v23Z10 - _v12Z49 * _v23Y10; _nY9 = _v12Z49 * _v23X10 - _v12X49 * _v23Z10; _nZ9 = _v12X49 * _v23Y10 - _v12Y49 * _v23X10; var _n12X9; var _n12Y9; var _n12Z9; var _n23X9; var _n23Y9; var _n23Z9; var _n31X9; var _n31Y9; var _n31Z9; _n12X9 = _v12Y49 * _nZ9 - _v12Z49 * _nY9; _n12Y9 = _v12Z49 * _nX9 - _v12X49 * _nZ9; _n12Z9 = _v12X49 * _nY9 - _v12Y49 * _nX9; _n23X9 = _v23Y10 * _nZ9 - _v23Z10 * _nY9; _n23Y9 = _v23Z10 * _nX9 - _v23X10 * _nZ9; _n23Z9 = _v23X10 * _nY9 - _v23Y10 * _nX9; _n31X9 = _v31Y9 * _nZ9 - _v31Z9 * _nY9; _n31Y9 = _v31Z9 * _nX9 - _v31X9 * _nZ9; _n31Z9 = _v31X9 * _nY9 - _v31Y9 * _nX9; var _mind9 = -1; var _minvX9; var _minvY9; var _minvZ9; var _mini9 = 0; _minvX9 = 0; _minvY9 = 0; _minvZ9 = 0; if (_v1X49 * _n12X9 + _v1Y49 * _n12Y9 + _v1Z49 * _n12Z9 < 0) { var _v1X50; var _v1Y50; var _v1Z50; var _v2X50; var _v2Y50; var _v2Z50; _v1X50 = vec1.x; _v1Y50 = vec1.y; _v1Z50 = vec1.z; _v2X50 = vec3.x; _v2Y50 = vec3.y; _v2Z50 = vec3.z; var _v12X50; var _v12Y50; var _v12Z50; _v12X50 = _v2X50 - _v1X50; _v12Y50 = _v2Y50 - _v1Y50; _v12Z50 = _v2Z50 - _v1Z50; var _t49 = _v12X50 * _v1X50 + _v12Y50 * _v1Y50 + _v12Z50 * _v1Z50; _t49 = -_t49 / (_v12X50 * _v12X50 + _v12Y50 * _v12Y50 + _v12Z50 * _v12Z50); var _b43; if (_t49 < 0) { out.x = _v1X50; out.y = _v1Y50; out.z = _v1Z50; _b43 = 1; } else if (_t49 > 1) { out.x = _v2X50; out.y = _v2Y50; out.z = _v2Z50; _b43 = 2; } else { var _pX37; var _pY37; var _pZ37; _pX37 = _v1X50 + _v12X50 * _t49; _pY37 = _v1Y50 + _v12Y50 * _t49; _pZ37 = _v1Z50 + _v12Z50 * _t49; out.x = _pX37; out.y = _pY37; out.z = _pZ37; _b43 = 3; } _mini9 = _b43; _mind9 = out.x * out.x + out.y * out.y + out.z * out.z; _minvX9 = out.x; _minvY9 = out.y; _minvZ9 = out.z; } if (_v2X49 * _n23X9 + _v2Y49 * _n23Y9 + _v2Z49 * _n23Z9 < 0) { var _v1X51; var _v1Y51; var _v1Z51; var _v2X51; var _v2Y51; var _v2Z51; _v1X51 = vec3.x; _v1Y51 = vec3.y; _v1Z51 = vec3.z; _v2X51 = vec4.x; _v2Y51 = vec4.y; _v2Z51 = vec4.z; var _v12X51; var _v12Y51; var _v12Z51; _v12X51 = _v2X51 - _v1X51; _v12Y51 = _v2Y51 - _v1Y51; _v12Z51 = _v2Z51 - _v1Z51; var _t50 = _v12X51 * _v1X51 + _v12Y51 * _v1Y51 + _v12Z51 * _v1Z51; _t50 = -_t50 / (_v12X51 * _v12X51 + _v12Y51 * _v12Y51 + _v12Z51 * _v12Z51); var _b44; if (_t50 < 0) { out.x = _v1X51; out.y = _v1Y51; out.z = _v1Z51; _b44 = 1; } else if (_t50 > 1) { out.x = _v2X51; out.y = _v2Y51; out.z = _v2Z51; _b44 = 2; } else { var _pX38; var _pY38; var _pZ38; _pX38 = _v1X51 + _v12X51 * _t50; _pY38 = _v1Y51 + _v12Y51 * _t50; _pZ38 = _v1Z51 + _v12Z51 * _t50; out.x = _pX38; out.y = _pY38; out.z = _pZ38; _b44 = 3; } var _d29 = out.x * out.x + out.y * out.y + out.z * out.z; if (_mind9 < 0 || _d29 < _mind9) { _mini9 = _b44 << 1; _mind9 = _d29; _minvX9 = out.x; _minvY9 = out.y; _minvZ9 = out.z; } } if (_v3X10 * _n31X9 + _v3Y10 * _n31Y9 + _v3Z10 * _n31Z9 < 0) { var _v1X52; var _v1Y52; var _v1Z52; var _v2X52; var _v2Y52; var _v2Z52; _v1X52 = vec1.x; _v1Y52 = vec1.y; _v1Z52 = vec1.z; _v2X52 = vec4.x; _v2Y52 = vec4.y; _v2Z52 = vec4.z; var _v12X52; var _v12Y52; var _v12Z52; _v12X52 = _v2X52 - _v1X52; _v12Y52 = _v2Y52 - _v1Y52; _v12Z52 = _v2Z52 - _v1Z52; var _t51 = _v12X52 * _v1X52 + _v12Y52 * _v1Y52 + _v12Z52 * _v1Z52; _t51 = -_t51 / (_v12X52 * _v12X52 + _v12Y52 * _v12Y52 + _v12Z52 * _v12Z52); var _b45; if (_t51 < 0) { out.x = _v1X52; out.y = _v1Y52; out.z = _v1Z52; _b45 = 1; } else if (_t51 > 1) { out.x = _v2X52; out.y = _v2Y52; out.z = _v2Z52; _b45 = 2; } else { var _pX39; var _pY39; var _pZ39; _pX39 = _v1X52 + _v12X52 * _t51; _pY39 = _v1Y52 + _v12Y52 * _t51; _pZ39 = _v1Z52 + _v12Z52 * _t51; out.x = _pX39; out.y = _pY39; out.z = _pZ39; _b45 = 3; } var _d30 = out.x * out.x + out.y * out.y + out.z * out.z; if (_mind9 < 0 || _d30 < _mind9) { _mini9 = _b45 & 1 | (_b45 & 2) << 1; _mind9 = _d30; _minvX9 = out.x; _minvY9 = out.y; _minvZ9 = out.z; } } var _b42; if (_mind9 > 0) { out.x = _minvX9; out.y = _minvY9; out.z = _minvZ9; _b42 = _mini9; } else { var _l26 = _nX9 * _nX9 + _nY9 * _nY9 + _nZ9 * _nZ9; if (_l26 > 0) { _l26 = 1 / Math.sqrt(_l26); } _nX9 *= _l26; _nY9 *= _l26; _nZ9 *= _l26; var _l27 = _nX9 * _nX9 + _nY9 * _nY9 + _nZ9 * _nZ9; _l27 = (_v1X49 * _nX9 + _v1Y49 * _nY9 + _v1Z49 * _nZ9) / _l27; _minvX9 = _nX9 * _l27; _minvY9 = _nY9 * _l27; _minvZ9 = _nZ9 * _l27; out.x = _minvX9; out.y = _minvY9; out.z = _minvZ9; _b42 = 7; } var _d28 = out.x * out.x + out.y * out.y + out.z * out.z; if (mind < 0 || _d28 < mind) { mini = _b42 & 1 | (_b42 & 6) << 1; mind = _d28; minvX = out.x; minvY = out.y; minvZ = out.z; } } if ((v1X * n142X + v1Y * n142Y + v1Z * n142Z) * sign < 0) { var _v1X53; var _v1Y53; var _v1Z53; var _v2X53; var _v2Y53; var _v2Z53; var _v3X11; var _v3Y11; var _v3Z11; var _v12X53; var _v12Y53; var _v12Z53; var _v23X11; var _v23Y11; var _v23Z11; var _v31X10; var _v31Y10; var _v31Z10; _v1X53 = vec1.x; _v1Y53 = vec1.y; _v1Z53 = vec1.z; _v2X53 = vec2.x; _v2Y53 = vec2.y; _v2Z53 = vec2.z; _v3X11 = vec4.x; _v3Y11 = vec4.y; _v3Z11 = vec4.z; _v12X53 = _v2X53 - _v1X53; _v12Y53 = _v2Y53 - _v1Y53; _v12Z53 = _v2Z53 - _v1Z53; _v23X11 = _v3X11 - _v2X53; _v23Y11 = _v3Y11 - _v2Y53; _v23Z11 = _v3Z11 - _v2Z53; _v31X10 = _v1X53 - _v3X11; _v31Y10 = _v1Y53 - _v3Y11; _v31Z10 = _v1Z53 - _v3Z11; var _nX10; var _nY10; var _nZ10; _nX10 = _v12Y53 * _v23Z11 - _v12Z53 * _v23Y11; _nY10 = _v12Z53 * _v23X11 - _v12X53 * _v23Z11; _nZ10 = _v12X53 * _v23Y11 - _v12Y53 * _v23X11; var _n12X10; var _n12Y10; var _n12Z10; var _n23X10; var _n23Y10; var _n23Z10; var _n31X10; var _n31Y10; var _n31Z10; _n12X10 = _v12Y53 * _nZ10 - _v12Z53 * _nY10; _n12Y10 = _v12Z53 * _nX10 - _v12X53 * _nZ10; _n12Z10 = _v12X53 * _nY10 - _v12Y53 * _nX10; _n23X10 = _v23Y11 * _nZ10 - _v23Z11 * _nY10; _n23Y10 = _v23Z11 * _nX10 - _v23X11 * _nZ10; _n23Z10 = _v23X11 * _nY10 - _v23Y11 * _nX10; _n31X10 = _v31Y10 * _nZ10 - _v31Z10 * _nY10; _n31Y10 = _v31Z10 * _nX10 - _v31X10 * _nZ10; _n31Z10 = _v31X10 * _nY10 - _v31Y10 * _nX10; var _mind10 = -1; var _minvX10; var _minvY10; var _minvZ10; var _mini10 = 0; _minvX10 = 0; _minvY10 = 0; _minvZ10 = 0; if (_v1X53 * _n12X10 + _v1Y53 * _n12Y10 + _v1Z53 * _n12Z10 < 0) { var _v1X54; var _v1Y54; var _v1Z54; var _v2X54; var _v2Y54; var _v2Z54; _v1X54 = vec1.x; _v1Y54 = vec1.y; _v1Z54 = vec1.z; _v2X54 = vec2.x; _v2Y54 = vec2.y; _v2Z54 = vec2.z; var _v12X54; var _v12Y54; var _v12Z54; _v12X54 = _v2X54 - _v1X54; _v12Y54 = _v2Y54 - _v1Y54; _v12Z54 = _v2Z54 - _v1Z54; var _t52 = _v12X54 * _v1X54 + _v12Y54 * _v1Y54 + _v12Z54 * _v1Z54; _t52 = -_t52 / (_v12X54 * _v12X54 + _v12Y54 * _v12Y54 + _v12Z54 * _v12Z54); var _b47; if (_t52 < 0) { out.x = _v1X54; out.y = _v1Y54; out.z = _v1Z54; _b47 = 1; } else if (_t52 > 1) { out.x = _v2X54; out.y = _v2Y54; out.z = _v2Z54; _b47 = 2; } else { var _pX40; var _pY40; var _pZ40; _pX40 = _v1X54 + _v12X54 * _t52; _pY40 = _v1Y54 + _v12Y54 * _t52; _pZ40 = _v1Z54 + _v12Z54 * _t52; out.x = _pX40; out.y = _pY40; out.z = _pZ40; _b47 = 3; } _mini10 = _b47; _mind10 = out.x * out.x + out.y * out.y + out.z * out.z; _minvX10 = out.x; _minvY10 = out.y; _minvZ10 = out.z; } if (_v2X53 * _n23X10 + _v2Y53 * _n23Y10 + _v2Z53 * _n23Z10 < 0) { var _v1X55; var _v1Y55; var _v1Z55; var _v2X55; var _v2Y55; var _v2Z55; _v1X55 = vec2.x; _v1Y55 = vec2.y; _v1Z55 = vec2.z; _v2X55 = vec4.x; _v2Y55 = vec4.y; _v2Z55 = vec4.z; var _v12X55; var _v12Y55; var _v12Z55; _v12X55 = _v2X55 - _v1X55; _v12Y55 = _v2Y55 - _v1Y55; _v12Z55 = _v2Z55 - _v1Z55; var _t53 = _v12X55 * _v1X55 + _v12Y55 * _v1Y55 + _v12Z55 * _v1Z55; _t53 = -_t53 / (_v12X55 * _v12X55 + _v12Y55 * _v12Y55 + _v12Z55 * _v12Z55); var _b48; if (_t53 < 0) { out.x = _v1X55; out.y = _v1Y55; out.z = _v1Z55; _b48 = 1; } else if (_t53 > 1) { out.x = _v2X55; out.y = _v2Y55; out.z = _v2Z55; _b48 = 2; } else { var _pX41; var _pY41; var _pZ41; _pX41 = _v1X55 + _v12X55 * _t53; _pY41 = _v1Y55 + _v12Y55 * _t53; _pZ41 = _v1Z55 + _v12Z55 * _t53; out.x = _pX41; out.y = _pY41; out.z = _pZ41; _b48 = 3; } var _d32 = out.x * out.x + out.y * out.y + out.z * out.z; if (_mind10 < 0 || _d32 < _mind10) { _mini10 = _b48 << 1; _mind10 = _d32; _minvX10 = out.x; _minvY10 = out.y; _minvZ10 = out.z; } } if (_v3X11 * _n31X10 + _v3Y11 * _n31Y10 + _v3Z11 * _n31Z10 < 0) { var _v1X56; var _v1Y56; var _v1Z56; var _v2X56; var _v2Y56; var _v2Z56; _v1X56 = vec1.x; _v1Y56 = vec1.y; _v1Z56 = vec1.z; _v2X56 = vec4.x; _v2Y56 = vec4.y; _v2Z56 = vec4.z; var _v12X56; var _v12Y56; var _v12Z56; _v12X56 = _v2X56 - _v1X56; _v12Y56 = _v2Y56 - _v1Y56; _v12Z56 = _v2Z56 - _v1Z56; var _t54 = _v12X56 * _v1X56 + _v12Y56 * _v1Y56 + _v12Z56 * _v1Z56; _t54 = -_t54 / (_v12X56 * _v12X56 + _v12Y56 * _v12Y56 + _v12Z56 * _v12Z56); var _b49; if (_t54 < 0) { out.x = _v1X56; out.y = _v1Y56; out.z = _v1Z56; _b49 = 1; } else if (_t54 > 1) { out.x = _v2X56; out.y = _v2Y56; out.z = _v2Z56; _b49 = 2; } else { var _pX42; var _pY42; var _pZ42; _pX42 = _v1X56 + _v12X56 * _t54; _pY42 = _v1Y56 + _v12Y56 * _t54; _pZ42 = _v1Z56 + _v12Z56 * _t54; out.x = _pX42; out.y = _pY42; out.z = _pZ42; _b49 = 3; } var _d33 = out.x * out.x + out.y * out.y + out.z * out.z; if (_mind10 < 0 || _d33 < _mind10) { _mini10 = _b49 & 1 | (_b49 & 2) << 1; _mind10 = _d33; _minvX10 = out.x; _minvY10 = out.y; _minvZ10 = out.z; } } var _b46; if (_mind10 > 0) { out.x = _minvX10; out.y = _minvY10; out.z = _minvZ10; _b46 = _mini10; } else { var _l28 = _nX10 * _nX10 + _nY10 * _nY10 + _nZ10 * _nZ10; if (_l28 > 0) { _l28 = 1 / Math.sqrt(_l28); } _nX10 *= _l28; _nY10 *= _l28; _nZ10 *= _l28; var _l29 = _nX10 * _nX10 + _nY10 * _nY10 + _nZ10 * _nZ10; _l29 = (_v1X53 * _nX10 + _v1Y53 * _nY10 + _v1Z53 * _nZ10) / _l29; _minvX10 = _nX10 * _l29; _minvY10 = _nY10 * _l29; _minvZ10 = _nZ10 * _l29; out.x = _minvX10; out.y = _minvY10; out.z = _minvZ10; _b46 = 7; } var _d31 = out.x * out.x + out.y * out.y + out.z * out.z; if (mind < 0 || _d31 < mind) { mini = _b46 & 3 | (_b46 & 4) << 1; mind = _d31; minvX = out.x; minvY = out.y; minvZ = out.z; } } if ((v2X * n243X + v2Y * n243Y + v2Z * n243Z) * sign < 0) { var _v1X57; var _v1Y57; var _v1Z57; var _v2X57; var _v2Y57; var _v2Z57; var _v3X12; var _v3Y12; var _v3Z12; var _v12X57; var _v12Y57; var _v12Z57; var _v23X12; var _v23Y12; var _v23Z12; var _v31X11; var _v31Y11; var _v31Z11; _v1X57 = vec2.x; _v1Y57 = vec2.y; _v1Z57 = vec2.z; _v2X57 = vec3.x; _v2Y57 = vec3.y; _v2Z57 = vec3.z; _v3X12 = vec4.x; _v3Y12 = vec4.y; _v3Z12 = vec4.z; _v12X57 = _v2X57 - _v1X57; _v12Y57 = _v2Y57 - _v1Y57; _v12Z57 = _v2Z57 - _v1Z57; _v23X12 = _v3X12 - _v2X57; _v23Y12 = _v3Y12 - _v2Y57; _v23Z12 = _v3Z12 - _v2Z57; _v31X11 = _v1X57 - _v3X12; _v31Y11 = _v1Y57 - _v3Y12; _v31Z11 = _v1Z57 - _v3Z12; var _nX11; var _nY11; var _nZ11; _nX11 = _v12Y57 * _v23Z12 - _v12Z57 * _v23Y12; _nY11 = _v12Z57 * _v23X12 - _v12X57 * _v23Z12; _nZ11 = _v12X57 * _v23Y12 - _v12Y57 * _v23X12; var _n12X11; var _n12Y11; var _n12Z11; var _n23X11; var _n23Y11; var _n23Z11; var _n31X11; var _n31Y11; var _n31Z11; _n12X11 = _v12Y57 * _nZ11 - _v12Z57 * _nY11; _n12Y11 = _v12Z57 * _nX11 - _v12X57 * _nZ11; _n12Z11 = _v12X57 * _nY11 - _v12Y57 * _nX11; _n23X11 = _v23Y12 * _nZ11 - _v23Z12 * _nY11; _n23Y11 = _v23Z12 * _nX11 - _v23X12 * _nZ11; _n23Z11 = _v23X12 * _nY11 - _v23Y12 * _nX11; _n31X11 = _v31Y11 * _nZ11 - _v31Z11 * _nY11; _n31Y11 = _v31Z11 * _nX11 - _v31X11 * _nZ11; _n31Z11 = _v31X11 * _nY11 - _v31Y11 * _nX11; var _mind11 = -1; var _minvX11; var _minvY11; var _minvZ11; var _mini11 = 0; _minvX11 = 0; _minvY11 = 0; _minvZ11 = 0; if (_v1X57 * _n12X11 + _v1Y57 * _n12Y11 + _v1Z57 * _n12Z11 < 0) { var _v1X58; var _v1Y58; var _v1Z58; var _v2X58; var _v2Y58; var _v2Z58; _v1X58 = vec2.x; _v1Y58 = vec2.y; _v1Z58 = vec2.z; _v2X58 = vec3.x; _v2Y58 = vec3.y; _v2Z58 = vec3.z; var _v12X58; var _v12Y58; var _v12Z58; _v12X58 = _v2X58 - _v1X58; _v12Y58 = _v2Y58 - _v1Y58; _v12Z58 = _v2Z58 - _v1Z58; var _t55 = _v12X58 * _v1X58 + _v12Y58 * _v1Y58 + _v12Z58 * _v1Z58; _t55 = -_t55 / (_v12X58 * _v12X58 + _v12Y58 * _v12Y58 + _v12Z58 * _v12Z58); var _b51; if (_t55 < 0) { out.x = _v1X58; out.y = _v1Y58; out.z = _v1Z58; _b51 = 1; } else if (_t55 > 1) { out.x = _v2X58; out.y = _v2Y58; out.z = _v2Z58; _b51 = 2; } else { var _pX43; var _pY43; var _pZ43; _pX43 = _v1X58 + _v12X58 * _t55; _pY43 = _v1Y58 + _v12Y58 * _t55; _pZ43 = _v1Z58 + _v12Z58 * _t55; out.x = _pX43; out.y = _pY43; out.z = _pZ43; _b51 = 3; } _mini11 = _b51; _mind11 = out.x * out.x + out.y * out.y + out.z * out.z; _minvX11 = out.x; _minvY11 = out.y; _minvZ11 = out.z; } if (_v2X57 * _n23X11 + _v2Y57 * _n23Y11 + _v2Z57 * _n23Z11 < 0) { var _v1X59; var _v1Y59; var _v1Z59; var _v2X59; var _v2Y59; var _v2Z59; _v1X59 = vec3.x; _v1Y59 = vec3.y; _v1Z59 = vec3.z; _v2X59 = vec4.x; _v2Y59 = vec4.y; _v2Z59 = vec4.z; var _v12X59; var _v12Y59; var _v12Z59; _v12X59 = _v2X59 - _v1X59; _v12Y59 = _v2Y59 - _v1Y59; _v12Z59 = _v2Z59 - _v1Z59; var _t56 = _v12X59 * _v1X59 + _v12Y59 * _v1Y59 + _v12Z59 * _v1Z59; _t56 = -_t56 / (_v12X59 * _v12X59 + _v12Y59 * _v12Y59 + _v12Z59 * _v12Z59); var _b52; if (_t56 < 0) { out.x = _v1X59; out.y = _v1Y59; out.z = _v1Z59; _b52 = 1; } else if (_t56 > 1) { out.x = _v2X59; out.y = _v2Y59; out.z = _v2Z59; _b52 = 2; } else { var _pX44; var _pY44; var _pZ44; _pX44 = _v1X59 + _v12X59 * _t56; _pY44 = _v1Y59 + _v12Y59 * _t56; _pZ44 = _v1Z59 + _v12Z59 * _t56; out.x = _pX44; out.y = _pY44; out.z = _pZ44; _b52 = 3; } var _d35 = out.x * out.x + out.y * out.y + out.z * out.z; if (_mind11 < 0 || _d35 < _mind11) { _mini11 = _b52 << 1; _mind11 = _d35; _minvX11 = out.x; _minvY11 = out.y; _minvZ11 = out.z; } } if (_v3X12 * _n31X11 + _v3Y12 * _n31Y11 + _v3Z12 * _n31Z11 < 0) { var _v1X60; var _v1Y60; var _v1Z60; var _v2X60; var _v2Y60; var _v2Z60; _v1X60 = vec2.x; _v1Y60 = vec2.y; _v1Z60 = vec2.z; _v2X60 = vec4.x; _v2Y60 = vec4.y; _v2Z60 = vec4.z; var _v12X60; var _v12Y60; var _v12Z60; _v12X60 = _v2X60 - _v1X60; _v12Y60 = _v2Y60 - _v1Y60; _v12Z60 = _v2Z60 - _v1Z60; var _t57 = _v12X60 * _v1X60 + _v12Y60 * _v1Y60 + _v12Z60 * _v1Z60; _t57 = -_t57 / (_v12X60 * _v12X60 + _v12Y60 * _v12Y60 + _v12Z60 * _v12Z60); var _b53; if (_t57 < 0) { out.x = _v1X60; out.y = _v1Y60; out.z = _v1Z60; _b53 = 1; } else if (_t57 > 1) { out.x = _v2X60; out.y = _v2Y60; out.z = _v2Z60; _b53 = 2; } else { var _pX45; var _pY45; var _pZ45; _pX45 = _v1X60 + _v12X60 * _t57; _pY45 = _v1Y60 + _v12Y60 * _t57; _pZ45 = _v1Z60 + _v12Z60 * _t57; out.x = _pX45; out.y = _pY45; out.z = _pZ45; _b53 = 3; } var _d36 = out.x * out.x + out.y * out.y + out.z * out.z; if (_mind11 < 0 || _d36 < _mind11) { _mini11 = _b53 & 1 | (_b53 & 2) << 1; _mind11 = _d36; _minvX11 = out.x; _minvY11 = out.y; _minvZ11 = out.z; } } var _b50; if (_mind11 > 0) { out.x = _minvX11; out.y = _minvY11; out.z = _minvZ11; _b50 = _mini11; } else { var _l30 = _nX11 * _nX11 + _nY11 * _nY11 + _nZ11 * _nZ11; if (_l30 > 0) { _l30 = 1 / Math.sqrt(_l30); } _nX11 *= _l30; _nY11 *= _l30; _nZ11 *= _l30; var _l31 = _nX11 * _nX11 + _nY11 * _nY11 + _nZ11 * _nZ11; _l31 = (_v1X57 * _nX11 + _v1Y57 * _nY11 + _v1Z57 * _nZ11) / _l31; _minvX11 = _nX11 * _l31; _minvY11 = _nY11 * _l31; _minvZ11 = _nZ11 * _l31; out.x = _minvX11; out.y = _minvY11; out.z = _minvZ11; _b50 = 7; } var _d34 = out.x * out.x + out.y * out.y + out.z * out.z; if (mind < 0 || _d34 < mind) { mini = _b50 << 1; mind = _d34; minvX = out.x; minvY = out.y; minvZ = out.z; } } if (mind > 0) { out.x = minvX; out.y = minvY; out.z = minvZ; return mini; } out.zero(); return 15; } }]); return oimo_collision_narrowphase_detector_gjkepa_SimplexUtil; }(); oimo.common.Mat3 = /*#__PURE__*/function () { function oimo_common_Mat3(e00, e01, e02, e10, e11, e12, e20, e21, e22) { _classCallCheck(this, oimo_common_Mat3); if (e22 == null) { e22 = 1; } if (e21 == null) { e21 = 0; } if (e20 == null) { e20 = 0; } if (e12 == null) { e12 = 0; } if (e11 == null) { e11 = 1; } if (e10 == null) { e10 = 0; } if (e02 == null) { e02 = 0; } if (e01 == null) { e01 = 0; } if (e00 == null) { e00 = 1; } this.e00 = e00; this.e01 = e01; this.e02 = e02; this.e10 = e10; this.e11 = e11; this.e12 = e12; this.e20 = e20; this.e21 = e21; this.e22 = e22; oimo.common.Mat3.numCreations++; } _createClass(oimo_common_Mat3, [{ key: "init", value: function init(e00, e01, e02, e10, e11, e12, e20, e21, e22) { this.e00 = e00; this.e01 = e01; this.e02 = e02; this.e10 = e10; this.e11 = e11; this.e12 = e12; this.e20 = e20; this.e21 = e21; this.e22 = e22; return this; } }, { key: "identity", value: function identity() { this.e00 = 1; this.e01 = 0; this.e02 = 0; this.e10 = 0; this.e11 = 1; this.e12 = 0; this.e20 = 0; this.e21 = 0; this.e22 = 1; return this; } }, { key: "add", value: function add(m) { return new oimo.common.Mat3(this.e00 + m.e00, this.e01 + m.e01, this.e02 + m.e02, this.e10 + m.e10, this.e11 + m.e11, this.e12 + m.e12, this.e20 + m.e20, this.e21 + m.e21, this.e22 + m.e22); } }, { key: "sub", value: function sub(m) { return new oimo.common.Mat3(this.e00 - m.e00, this.e01 - m.e01, this.e02 - m.e02, this.e10 - m.e10, this.e11 - m.e11, this.e12 - m.e12, this.e20 - m.e20, this.e21 - m.e21, this.e22 - m.e22); } }, { key: "scale", value: function scale(s) { return new oimo.common.Mat3(this.e00 * s, this.e01 * s, this.e02 * s, this.e10 * s, this.e11 * s, this.e12 * s, this.e20 * s, this.e21 * s, this.e22 * s); } }, { key: "mul", value: function mul(m) { return new oimo.common.Mat3(this.e00 * m.e00 + this.e01 * m.e10 + this.e02 * m.e20, this.e00 * m.e01 + this.e01 * m.e11 + this.e02 * m.e21, this.e00 * m.e02 + this.e01 * m.e12 + this.e02 * m.e22, this.e10 * m.e00 + this.e11 * m.e10 + this.e12 * m.e20, this.e10 * m.e01 + this.e11 * m.e11 + this.e12 * m.e21, this.e10 * m.e02 + this.e11 * m.e12 + this.e12 * m.e22, this.e20 * m.e00 + this.e21 * m.e10 + this.e22 * m.e20, this.e20 * m.e01 + this.e21 * m.e11 + this.e22 * m.e21, this.e20 * m.e02 + this.e21 * m.e12 + this.e22 * m.e22); } }, { key: "addEq", value: function addEq(m) { this.e00 += m.e00; this.e01 += m.e01; this.e02 += m.e02; this.e10 += m.e10; this.e11 += m.e11; this.e12 += m.e12; this.e20 += m.e20; this.e21 += m.e21; this.e22 += m.e22; return this; } }, { key: "subEq", value: function subEq(m) { this.e00 -= m.e00; this.e01 -= m.e01; this.e02 -= m.e02; this.e10 -= m.e10; this.e11 -= m.e11; this.e12 -= m.e12; this.e20 -= m.e20; this.e21 -= m.e21; this.e22 -= m.e22; return this; } }, { key: "scaleEq", value: function scaleEq(s) { this.e00 *= s; this.e01 *= s; this.e02 *= s; this.e10 *= s; this.e11 *= s; this.e12 *= s; this.e20 *= s; this.e21 *= s; this.e22 *= s; return this; } }, { key: "mulEq", value: function mulEq(m) { var e01 = this.e00 * m.e01 + this.e01 * m.e11 + this.e02 * m.e21; var e02 = this.e00 * m.e02 + this.e01 * m.e12 + this.e02 * m.e22; var e10 = this.e10 * m.e00 + this.e11 * m.e10 + this.e12 * m.e20; var e11 = this.e10 * m.e01 + this.e11 * m.e11 + this.e12 * m.e21; var e12 = this.e10 * m.e02 + this.e11 * m.e12 + this.e12 * m.e22; var e20 = this.e20 * m.e00 + this.e21 * m.e10 + this.e22 * m.e20; var e21 = this.e20 * m.e01 + this.e21 * m.e11 + this.e22 * m.e21; var e22 = this.e20 * m.e02 + this.e21 * m.e12 + this.e22 * m.e22; this.e00 = this.e00 * m.e00 + this.e01 * m.e10 + this.e02 * m.e20; this.e01 = e01; this.e02 = e02; this.e10 = e10; this.e11 = e11; this.e12 = e12; this.e20 = e20; this.e21 = e21; this.e22 = e22; return this; } }, { key: "prependScale", value: function prependScale(sx, sy, sz) { return new oimo.common.Mat3(this.e00 * sx, this.e01 * sx, this.e02 * sx, this.e10 * sy, this.e11 * sy, this.e12 * sy, this.e20 * sz, this.e21 * sz, this.e22 * sz); } }, { key: "appendScale", value: function appendScale(sx, sy, sz) { return new oimo.common.Mat3(this.e00 * sx, this.e01 * sy, this.e02 * sz, this.e10 * sx, this.e11 * sy, this.e12 * sz, this.e20 * sx, this.e21 * sy, this.e22 * sz); } }, { key: "prependRotation", value: function prependRotation(rad, axisX, axisY, axisZ) { var s = Math.sin(rad); var c = Math.cos(rad); var c1 = 1 - c; var r00 = axisX * axisX * c1 + c; var r01 = axisX * axisY * c1 - axisZ * s; var r02 = axisX * axisZ * c1 + axisY * s; var r10 = axisY * axisX * c1 + axisZ * s; var r11 = axisY * axisY * c1 + c; var r12 = axisY * axisZ * c1 - axisX * s; var r20 = axisZ * axisX * c1 - axisY * s; var r21 = axisZ * axisY * c1 + axisX * s; var r22 = axisZ * axisZ * c1 + c; return new oimo.common.Mat3(r00 * this.e00 + r01 * this.e10 + r02 * this.e20, r00 * this.e01 + r01 * this.e11 + r02 * this.e21, r00 * this.e02 + r01 * this.e12 + r02 * this.e22, r10 * this.e00 + r11 * this.e10 + r12 * this.e20, r10 * this.e01 + r11 * this.e11 + r12 * this.e21, r10 * this.e02 + r11 * this.e12 + r12 * this.e22, r20 * this.e00 + r21 * this.e10 + r22 * this.e20, r20 * this.e01 + r21 * this.e11 + r22 * this.e21, r20 * this.e02 + r21 * this.e12 + r22 * this.e22); } }, { key: "appendRotation", value: function appendRotation(rad, axisX, axisY, axisZ) { var s = Math.sin(rad); var c = Math.cos(rad); var c1 = 1 - c; var r00 = axisX * axisX * c1 + c; var r01 = axisX * axisY * c1 - axisZ * s; var r02 = axisX * axisZ * c1 + axisY * s; var r10 = axisY * axisX * c1 + axisZ * s; var r11 = axisY * axisY * c1 + c; var r12 = axisY * axisZ * c1 - axisX * s; var r20 = axisZ * axisX * c1 - axisY * s; var r21 = axisZ * axisY * c1 + axisX * s; var r22 = axisZ * axisZ * c1 + c; return new oimo.common.Mat3(this.e00 * r00 + this.e01 * r10 + this.e02 * r20, this.e00 * r01 + this.e01 * r11 + this.e02 * r21, this.e00 * r02 + this.e01 * r12 + this.e02 * r22, this.e10 * r00 + this.e11 * r10 + this.e12 * r20, this.e10 * r01 + this.e11 * r11 + this.e12 * r21, this.e10 * r02 + this.e11 * r12 + this.e12 * r22, this.e20 * r00 + this.e21 * r10 + this.e22 * r20, this.e20 * r01 + this.e21 * r11 + this.e22 * r21, this.e20 * r02 + this.e21 * r12 + this.e22 * r22); } }, { key: "prependScaleEq", value: function prependScaleEq(sx, sy, sz) { this.e00 *= sx; this.e01 *= sx; this.e02 *= sx; this.e10 *= sy; this.e11 *= sy; this.e12 *= sy; this.e20 *= sz; this.e21 *= sz; this.e22 *= sz; return this; } }, { key: "appendScaleEq", value: function appendScaleEq(sx, sy, sz) { this.e00 *= sx; this.e01 *= sy; this.e02 *= sz; this.e10 *= sx; this.e11 *= sy; this.e12 *= sz; this.e20 *= sx; this.e21 *= sy; this.e22 *= sz; return this; } }, { key: "prependRotationEq", value: function prependRotationEq(rad, axisX, axisY, axisZ) { var s = Math.sin(rad); var c = Math.cos(rad); var c1 = 1 - c; var r00 = axisX * axisX * c1 + c; var r01 = axisX * axisY * c1 - axisZ * s; var r02 = axisX * axisZ * c1 + axisY * s; var r10 = axisY * axisX * c1 + axisZ * s; var r11 = axisY * axisY * c1 + c; var r12 = axisY * axisZ * c1 - axisX * s; var r20 = axisZ * axisX * c1 - axisY * s; var r21 = axisZ * axisY * c1 + axisX * s; var r22 = axisZ * axisZ * c1 + c; var e10 = r10 * this.e00 + r11 * this.e10 + r12 * this.e20; var e11 = r10 * this.e01 + r11 * this.e11 + r12 * this.e21; var e12 = r10 * this.e02 + r11 * this.e12 + r12 * this.e22; var e20 = r20 * this.e00 + r21 * this.e10 + r22 * this.e20; var e21 = r20 * this.e01 + r21 * this.e11 + r22 * this.e21; var e22 = r20 * this.e02 + r21 * this.e12 + r22 * this.e22; this.e00 = r00 * this.e00 + r01 * this.e10 + r02 * this.e20; this.e01 = r00 * this.e01 + r01 * this.e11 + r02 * this.e21; this.e02 = r00 * this.e02 + r01 * this.e12 + r02 * this.e22; this.e10 = e10; this.e11 = e11; this.e12 = e12; this.e20 = e20; this.e21 = e21; this.e22 = e22; return this; } }, { key: "appendRotationEq", value: function appendRotationEq(rad, axisX, axisY, axisZ) { var s = Math.sin(rad); var c = Math.cos(rad); var c1 = 1 - c; var r00 = axisX * axisX * c1 + c; var r01 = axisX * axisY * c1 - axisZ * s; var r02 = axisX * axisZ * c1 + axisY * s; var r10 = axisY * axisX * c1 + axisZ * s; var r11 = axisY * axisY * c1 + c; var r12 = axisY * axisZ * c1 - axisX * s; var r20 = axisZ * axisX * c1 - axisY * s; var r21 = axisZ * axisY * c1 + axisX * s; var r22 = axisZ * axisZ * c1 + c; var e01 = this.e00 * r01 + this.e01 * r11 + this.e02 * r21; var e02 = this.e00 * r02 + this.e01 * r12 + this.e02 * r22; var e11 = this.e10 * r01 + this.e11 * r11 + this.e12 * r21; var e12 = this.e10 * r02 + this.e11 * r12 + this.e12 * r22; var e21 = this.e20 * r01 + this.e21 * r11 + this.e22 * r21; var e22 = this.e20 * r02 + this.e21 * r12 + this.e22 * r22; this.e00 = this.e00 * r00 + this.e01 * r10 + this.e02 * r20; this.e01 = e01; this.e02 = e02; this.e10 = this.e10 * r00 + this.e11 * r10 + this.e12 * r20; this.e11 = e11; this.e12 = e12; this.e20 = this.e20 * r00 + this.e21 * r10 + this.e22 * r20; this.e21 = e21; this.e22 = e22; return this; } }, { key: "transpose", value: function transpose() { return new oimo.common.Mat3(this.e00, this.e10, this.e20, this.e01, this.e11, this.e21, this.e02, this.e12, this.e22); } }, { key: "transposeEq", value: function transposeEq() { var e10 = this.e01; var e20 = this.e02; var e21 = this.e12; this.e01 = this.e10; this.e02 = this.e20; this.e10 = e10; this.e12 = this.e21; this.e20 = e20; this.e21 = e21; return this; } }, { key: "determinant", value: function determinant() { return this.e00 * (this.e11 * this.e22 - this.e12 * this.e21) - this.e01 * (this.e10 * this.e22 - this.e12 * this.e20) + this.e02 * (this.e10 * this.e21 - this.e11 * this.e20); } }, { key: "trace", value: function trace() { return this.e00 + this.e11 + this.e22; } }, { key: "inverse", value: function inverse() { var d00 = this.e11 * this.e22 - this.e12 * this.e21; var d01 = this.e10 * this.e22 - this.e12 * this.e20; var d02 = this.e10 * this.e21 - this.e11 * this.e20; var invDet = this.e00 * d00 - this.e01 * d01 + this.e02 * d02; if (invDet != 0) { invDet = 1 / invDet; } return new oimo.common.Mat3(d00 * invDet, -(this.e01 * this.e22 - this.e02 * this.e21) * invDet, (this.e01 * this.e12 - this.e02 * this.e11) * invDet, -d01 * invDet, (this.e00 * this.e22 - this.e02 * this.e20) * invDet, -(this.e00 * this.e12 - this.e02 * this.e10) * invDet, d02 * invDet, -(this.e00 * this.e21 - this.e01 * this.e20) * invDet, (this.e00 * this.e11 - this.e01 * this.e10) * invDet); } }, { key: "inverseEq", value: function inverseEq() { var d00 = this.e11 * this.e22 - this.e12 * this.e21; var d01 = this.e10 * this.e22 - this.e12 * this.e20; var d02 = this.e10 * this.e21 - this.e11 * this.e20; var invDet = this.e00 * d00 - this.e01 * d01 + this.e02 * d02; if (invDet != 0) { invDet = 1 / invDet; } var t02 = (this.e01 * this.e12 - this.e02 * this.e11) * invDet; var t11 = (this.e00 * this.e22 - this.e02 * this.e20) * invDet; var t12 = -(this.e00 * this.e12 - this.e02 * this.e10) * invDet; var t21 = -(this.e00 * this.e21 - this.e01 * this.e20) * invDet; var t22 = (this.e00 * this.e11 - this.e01 * this.e10) * invDet; this.e00 = d00 * invDet; this.e01 = -(this.e01 * this.e22 - this.e02 * this.e21) * invDet; this.e02 = t02; this.e10 = -d01 * invDet; this.e11 = t11; this.e12 = t12; this.e20 = d02 * invDet; this.e21 = t21; this.e22 = t22; return this; } }, { key: "toArray", value: function toArray(columnMajor) { if (columnMajor == null) { columnMajor = false; } if (columnMajor) { return [this.e00, this.e10, this.e20, this.e01, this.e11, this.e21, this.e02, this.e12, this.e22]; } else { return [this.e00, this.e01, this.e02, this.e10, this.e11, this.e12, this.e20, this.e21, this.e22]; } } }, { key: "copyFrom", value: function copyFrom(m) { this.e00 = m.e00; this.e01 = m.e01; this.e02 = m.e02; this.e10 = m.e10; this.e11 = m.e11; this.e12 = m.e12; this.e20 = m.e20; this.e21 = m.e21; this.e22 = m.e22; return this; } }, { key: "clone", value: function clone() { return new oimo.common.Mat3(this.e00, this.e01, this.e02, this.e10, this.e11, this.e12, this.e20, this.e21, this.e22); } }, { key: "fromQuat", value: function fromQuat(q) { var x = q.x; var y = q.y; var z = q.z; var w = q.w; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; this.e00 = 1 - yy - zz; this.e01 = xy - wz; this.e02 = xz + wy; this.e10 = xy + wz; this.e11 = 1 - xx - zz; this.e12 = yz - wx; this.e20 = xz - wy; this.e21 = yz + wx; this.e22 = 1 - xx - yy; return this; } }, { key: "toQuat", value: function toQuat() { var _this = new oimo.common.Quat(); var e00 = this.e00; var e11 = this.e11; var e22 = this.e22; var t = e00 + e11 + e22; var s; if (t > 0) { s = Math.sqrt(t + 1); _this.w = 0.5 * s; s = 0.5 / s; _this.x = (this.e21 - this.e12) * s; _this.y = (this.e02 - this.e20) * s; _this.z = (this.e10 - this.e01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); _this.x = 0.5 * s; s = 0.5 / s; _this.y = (this.e01 + this.e10) * s; _this.z = (this.e02 + this.e20) * s; _this.w = (this.e21 - this.e12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); _this.z = 0.5 * s; s = 0.5 / s; _this.x = (this.e02 + this.e20) * s; _this.y = (this.e12 + this.e21) * s; _this.w = (this.e10 - this.e01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); _this.y = 0.5 * s; s = 0.5 / s; _this.x = (this.e01 + this.e10) * s; _this.z = (this.e12 + this.e21) * s; _this.w = (this.e02 - this.e20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); _this.z = 0.5 * s; s = 0.5 / s; _this.x = (this.e02 + this.e20) * s; _this.y = (this.e12 + this.e21) * s; _this.w = (this.e10 - this.e01) * s; } return _this; } }, { key: "fromEulerXyz", value: function fromEulerXyz(eulerAngles) { var sx = Math.sin(eulerAngles.x); var sy = Math.sin(eulerAngles.y); var sz = Math.sin(eulerAngles.z); var cx = Math.cos(eulerAngles.x); var cy = Math.cos(eulerAngles.y); var cz = Math.cos(eulerAngles.z); this.e00 = cy * cz; this.e01 = -cy * sz; this.e02 = sy; this.e10 = cx * sz + cz * sx * sy; this.e11 = cx * cz - sx * sy * sz; this.e12 = -cy * sx; this.e20 = sx * sz - cx * cz * sy; this.e21 = cz * sx + cx * sy * sz; this.e22 = cx * cy; return this; } }, { key: "toEulerXyz", value: function toEulerXyz() { var sy = this.e02; if (sy <= -1) { var xSubZ = Math.atan2(this.e21, this.e11); return new oimo.common.Vec3(xSubZ * 0.5, -1.570796326794895, -xSubZ * 0.5); } if (sy >= 1) { var xAddZ = Math.atan2(this.e21, this.e11); return new oimo.common.Vec3(xAddZ * 0.5, 1.570796326794895, xAddZ * 0.5); } return new oimo.common.Vec3(Math.atan2(-this.e12, this.e22), Math.asin(sy), Math.atan2(-this.e01, this.e00)); } }, { key: "getRow", value: function getRow(index) { if (index == 0) { return new oimo.common.Vec3(this.e00, this.e01, this.e02); } else if (index == 1) { return new oimo.common.Vec3(this.e10, this.e11, this.e12); } else if (index == 2) { return new oimo.common.Vec3(this.e20, this.e21, this.e22); } else { return null; } } }, { key: "getCol", value: function getCol(index) { if (index == 0) { return new oimo.common.Vec3(this.e00, this.e10, this.e20); } else if (index == 1) { return new oimo.common.Vec3(this.e01, this.e11, this.e21); } else if (index == 2) { return new oimo.common.Vec3(this.e02, this.e12, this.e22); } else { return null; } } }, { key: "getRowTo", value: function getRowTo(index, dst) { if (index == 0) { dst.init(this.e00, this.e01, this.e02); } else if (index == 1) { dst.init(this.e10, this.e11, this.e12); } else if (index == 2) { dst.init(this.e20, this.e21, this.e22); } else { dst.zero(); } } }, { key: "getColTo", value: function getColTo(index, dst) { if (index == 0) { dst.init(this.e00, this.e10, this.e20); } else if (index == 1) { dst.init(this.e01, this.e11, this.e21); } else if (index == 2) { dst.init(this.e02, this.e12, this.e22); } else { dst.zero(); } } }, { key: "fromRows", value: function fromRows(row0, row1, row2) { this.e00 = row0.x; this.e01 = row0.y; this.e02 = row0.z; this.e10 = row1.x; this.e11 = row1.y; this.e12 = row1.z; this.e20 = row2.x; this.e21 = row2.y; this.e22 = row2.z; return this; } }, { key: "fromCols", value: function fromCols(col0, col1, col2) { this.e00 = col0.x; this.e01 = col1.x; this.e02 = col2.x; this.e10 = col0.y; this.e11 = col1.y; this.e12 = col2.y; this.e20 = col0.z; this.e21 = col1.z; this.e22 = col2.z; return this; } }, { key: "toString", value: function toString() { return "Mat3[" + (this.e00 > 0 ? (this.e00 * 10000000 + 0.5 | 0) / 10000000 : (this.e00 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e01 > 0 ? (this.e01 * 10000000 + 0.5 | 0) / 10000000 : (this.e01 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e02 > 0 ? (this.e02 * 10000000 + 0.5 | 0) / 10000000 : (this.e02 * 10000000 - 0.5 | 0) / 10000000) + ",\n" + " " + (this.e10 > 0 ? (this.e10 * 10000000 + 0.5 | 0) / 10000000 : (this.e10 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e11 > 0 ? (this.e11 * 10000000 + 0.5 | 0) / 10000000 : (this.e11 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e12 > 0 ? (this.e12 * 10000000 + 0.5 | 0) / 10000000 : (this.e12 * 10000000 - 0.5 | 0) / 10000000) + ",\n" + " " + (this.e20 > 0 ? (this.e20 * 10000000 + 0.5 | 0) / 10000000 : (this.e20 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e21 > 0 ? (this.e21 * 10000000 + 0.5 | 0) / 10000000 : (this.e21 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e22 > 0 ? (this.e22 * 10000000 + 0.5 | 0) / 10000000 : (this.e22 * 10000000 - 0.5 | 0) / 10000000) + "]"; } }]); return oimo_common_Mat3; }(); oimo.common.Mat4 = /*#__PURE__*/function () { function oimo_common_Mat4(e00, e01, e02, e03, e10, e11, e12, e13, e20, e21, e22, e23, e30, e31, e32, e33) { _classCallCheck(this, oimo_common_Mat4); if (e33 == null) { e33 = 1; } if (e32 == null) { e32 = 0; } if (e31 == null) { e31 = 0; } if (e30 == null) { e30 = 0; } if (e23 == null) { e23 = 0; } if (e22 == null) { e22 = 1; } if (e21 == null) { e21 = 0; } if (e20 == null) { e20 = 0; } if (e13 == null) { e13 = 0; } if (e12 == null) { e12 = 0; } if (e11 == null) { e11 = 1; } if (e10 == null) { e10 = 0; } if (e03 == null) { e03 = 0; } if (e02 == null) { e02 = 0; } if (e01 == null) { e01 = 0; } if (e00 == null) { e00 = 1; } this.e00 = e00; this.e01 = e01; this.e02 = e02; this.e03 = e03; this.e10 = e10; this.e11 = e11; this.e12 = e12; this.e13 = e13; this.e20 = e20; this.e21 = e21; this.e22 = e22; this.e23 = e23; this.e30 = e30; this.e31 = e31; this.e32 = e32; this.e33 = e33; oimo.common.Mat4.numCreations++; } _createClass(oimo_common_Mat4, [{ key: "init", value: function init(e00, e01, e02, e03, e10, e11, e12, e13, e20, e21, e22, e23, e30, e31, e32, e33) { this.e00 = e00; this.e01 = e01; this.e02 = e02; this.e03 = e03; this.e10 = e10; this.e11 = e11; this.e12 = e12; this.e13 = e13; this.e20 = e20; this.e21 = e21; this.e22 = e22; this.e23 = e23; this.e30 = e30; this.e31 = e31; this.e32 = e32; this.e33 = e33; return this; } }, { key: "identity", value: function identity() { this.e00 = 1; this.e01 = 0; this.e02 = 0; this.e03 = 0; this.e10 = 0; this.e11 = 1; this.e12 = 0; this.e13 = 0; this.e20 = 0; this.e21 = 0; this.e22 = 1; this.e23 = 0; this.e30 = 0; this.e31 = 0; this.e32 = 0; this.e33 = 1; return this; } }, { key: "add", value: function add(m) { return new oimo.common.Mat4(this.e00 + m.e00, this.e01 + m.e01, this.e02 + m.e02, this.e03 + m.e03, this.e10 + m.e10, this.e11 + m.e11, this.e12 + m.e12, this.e13 + m.e13, this.e20 + m.e20, this.e21 + m.e21, this.e22 + m.e22, this.e23 + m.e23, this.e30 + m.e30, this.e31 + m.e31, this.e32 + m.e32, this.e33 + m.e33); } }, { key: "sub", value: function sub(m) { return new oimo.common.Mat4(this.e00 - m.e00, this.e01 - m.e01, this.e02 - m.e02, this.e03 - m.e03, this.e10 - m.e10, this.e11 - m.e11, this.e12 - m.e12, this.e13 - m.e13, this.e20 - m.e20, this.e21 - m.e21, this.e22 - m.e22, this.e23 - m.e23, this.e30 - m.e30, this.e31 - m.e31, this.e32 - m.e32, this.e33 - m.e33); } }, { key: "scale", value: function scale(s) { return new oimo.common.Mat4(this.e00 * s, this.e01 * s, this.e02 * s, this.e03 * s, this.e10 * s, this.e11 * s, this.e12 * s, this.e13 * s, this.e20 * s, this.e21 * s, this.e22 * s, this.e23 * s, this.e30 * s, this.e31 * s, this.e32 * s, this.e33 * s); } }, { key: "mul", value: function mul(m) { return new oimo.common.Mat4(this.e00 * m.e00 + this.e01 * m.e10 + this.e02 * m.e20 + this.e03 * m.e30, this.e00 * m.e01 + this.e01 * m.e11 + this.e02 * m.e21 + this.e03 * m.e31, this.e00 * m.e02 + this.e01 * m.e12 + this.e02 * m.e22 + this.e03 * m.e32, this.e00 * m.e03 + this.e01 * m.e13 + this.e02 * m.e23 + this.e03 * m.e33, this.e10 * m.e00 + this.e11 * m.e10 + this.e12 * m.e20 + this.e13 * m.e30, this.e10 * m.e01 + this.e11 * m.e11 + this.e12 * m.e21 + this.e13 * m.e31, this.e10 * m.e02 + this.e11 * m.e12 + this.e12 * m.e22 + this.e13 * m.e32, this.e10 * m.e03 + this.e11 * m.e13 + this.e12 * m.e23 + this.e13 * m.e33, this.e20 * m.e00 + this.e21 * m.e10 + this.e22 * m.e20 + this.e23 * m.e30, this.e20 * m.e01 + this.e21 * m.e11 + this.e22 * m.e21 + this.e23 * m.e31, this.e20 * m.e02 + this.e21 * m.e12 + this.e22 * m.e22 + this.e23 * m.e32, this.e20 * m.e03 + this.e21 * m.e13 + this.e22 * m.e23 + this.e23 * m.e33, this.e30 * m.e00 + this.e31 * m.e10 + this.e32 * m.e20 + this.e33 * m.e30, this.e30 * m.e01 + this.e31 * m.e11 + this.e32 * m.e21 + this.e33 * m.e31, this.e30 * m.e02 + this.e31 * m.e12 + this.e32 * m.e22 + this.e33 * m.e32, this.e30 * m.e03 + this.e31 * m.e13 + this.e32 * m.e23 + this.e33 * m.e33); } }, { key: "addEq", value: function addEq(m) { this.e00 += m.e00; this.e01 += m.e01; this.e02 += m.e02; this.e03 += m.e03; this.e10 += m.e10; this.e11 += m.e11; this.e12 += m.e12; this.e13 += m.e13; this.e20 += m.e20; this.e21 += m.e21; this.e22 += m.e22; this.e23 += m.e23; this.e30 += m.e30; this.e31 += m.e31; this.e32 += m.e32; this.e33 += m.e33; return this; } }, { key: "subEq", value: function subEq(m) { this.e00 -= m.e00; this.e01 -= m.e01; this.e02 -= m.e02; this.e03 -= m.e03; this.e10 -= m.e10; this.e11 -= m.e11; this.e12 -= m.e12; this.e13 -= m.e13; this.e20 -= m.e20; this.e21 -= m.e21; this.e22 -= m.e22; this.e23 -= m.e23; this.e30 -= m.e30; this.e31 -= m.e31; this.e32 -= m.e32; this.e33 -= m.e33; return this; } }, { key: "scaleEq", value: function scaleEq(s) { this.e00 *= s; this.e01 *= s; this.e02 *= s; this.e03 *= s; this.e10 *= s; this.e11 *= s; this.e12 *= s; this.e13 *= s; this.e20 *= s; this.e21 *= s; this.e22 *= s; this.e23 *= s; this.e30 *= s; this.e31 *= s; this.e32 *= s; this.e33 *= s; return this; } }, { key: "mulEq", value: function mulEq(m) { var e01 = this.e00 * m.e01 + this.e01 * m.e11 + this.e02 * m.e21 + this.e03 * m.e31; var e02 = this.e00 * m.e02 + this.e01 * m.e12 + this.e02 * m.e22 + this.e03 * m.e32; var e03 = this.e00 * m.e03 + this.e01 * m.e13 + this.e02 * m.e23 + this.e03 * m.e33; var e10 = this.e10 * m.e00 + this.e11 * m.e10 + this.e12 * m.e20 + this.e13 * m.e30; var e11 = this.e10 * m.e01 + this.e11 * m.e11 + this.e12 * m.e21 + this.e13 * m.e31; var e12 = this.e10 * m.e02 + this.e11 * m.e12 + this.e12 * m.e22 + this.e13 * m.e32; var e13 = this.e10 * m.e03 + this.e11 * m.e13 + this.e12 * m.e23 + this.e13 * m.e33; var e20 = this.e20 * m.e00 + this.e21 * m.e10 + this.e22 * m.e20 + this.e23 * m.e30; var e21 = this.e20 * m.e01 + this.e21 * m.e11 + this.e22 * m.e21 + this.e23 * m.e31; var e22 = this.e20 * m.e02 + this.e21 * m.e12 + this.e22 * m.e22 + this.e23 * m.e32; var e23 = this.e20 * m.e03 + this.e21 * m.e13 + this.e22 * m.e23 + this.e23 * m.e33; var e30 = this.e30 * m.e00 + this.e31 * m.e10 + this.e32 * m.e20 + this.e33 * m.e30; var e31 = this.e30 * m.e01 + this.e31 * m.e11 + this.e32 * m.e21 + this.e33 * m.e31; var e32 = this.e30 * m.e02 + this.e31 * m.e12 + this.e32 * m.e22 + this.e33 * m.e32; var e33 = this.e30 * m.e03 + this.e31 * m.e13 + this.e32 * m.e23 + this.e33 * m.e33; this.e00 = this.e00 * m.e00 + this.e01 * m.e10 + this.e02 * m.e20 + this.e03 * m.e30; this.e01 = e01; this.e02 = e02; this.e03 = e03; this.e10 = e10; this.e11 = e11; this.e12 = e12; this.e13 = e13; this.e20 = e20; this.e21 = e21; this.e22 = e22; this.e23 = e23; this.e30 = e30; this.e31 = e31; this.e32 = e32; this.e33 = e33; return this; } }, { key: "prependScale", value: function prependScale(sx, sy, sz) { return new oimo.common.Mat4(this.e00 * sx, this.e01 * sx, this.e02 * sx, this.e03 * sx, this.e10 * sy, this.e11 * sy, this.e12 * sy, this.e13 * sy, this.e20 * sz, this.e21 * sz, this.e22 * sz, this.e23 * sz, this.e30, this.e31, this.e32, this.e33); } }, { key: "appendScale", value: function appendScale(sx, sy, sz) { return new oimo.common.Mat4(this.e00 * sx, this.e01 * sy, this.e02 * sz, this.e03, this.e10 * sx, this.e11 * sy, this.e12 * sz, this.e13, this.e20 * sx, this.e21 * sy, this.e22 * sz, this.e23, this.e30 * sx, this.e31 * sy, this.e32 * sz, this.e33); } }, { key: "prependRotation", value: function prependRotation(rad, axisX, axisY, axisZ) { var s = Math.sin(rad); var c = Math.cos(rad); var c1 = 1 - c; var r00 = axisX * axisX * c1 + c; var r01 = axisX * axisY * c1 - axisZ * s; var r02 = axisX * axisZ * c1 + axisY * s; var r10 = axisY * axisX * c1 + axisZ * s; var r11 = axisY * axisY * c1 + c; var r12 = axisY * axisZ * c1 - axisX * s; var r20 = axisZ * axisX * c1 - axisY * s; var r21 = axisZ * axisY * c1 + axisX * s; var r22 = axisZ * axisZ * c1 + c; return new oimo.common.Mat4(r00 * this.e00 + r01 * this.e10 + r02 * this.e20, r00 * this.e01 + r01 * this.e11 + r02 * this.e21, r00 * this.e02 + r01 * this.e12 + r02 * this.e22, r00 * this.e03 + r01 * this.e13 + r02 * this.e23, r10 * this.e00 + r11 * this.e10 + r12 * this.e20, r10 * this.e01 + r11 * this.e11 + r12 * this.e21, r10 * this.e02 + r11 * this.e12 + r12 * this.e22, r10 * this.e03 + r11 * this.e13 + r12 * this.e23, r20 * this.e00 + r21 * this.e10 + r22 * this.e20, r20 * this.e01 + r21 * this.e11 + r22 * this.e21, r20 * this.e02 + r21 * this.e12 + r22 * this.e22, r20 * this.e03 + r21 * this.e13 + r22 * this.e23, this.e30, this.e31, this.e32, this.e33); } }, { key: "appendRotation", value: function appendRotation(rad, axisX, axisY, axisZ) { var s = Math.sin(rad); var c = Math.cos(rad); var c1 = 1 - c; var r00 = axisX * axisX * c1 + c; var r01 = axisX * axisY * c1 - axisZ * s; var r02 = axisX * axisZ * c1 + axisY * s; var r10 = axisY * axisX * c1 + axisZ * s; var r11 = axisY * axisY * c1 + c; var r12 = axisY * axisZ * c1 - axisX * s; var r20 = axisZ * axisX * c1 - axisY * s; var r21 = axisZ * axisY * c1 + axisX * s; var r22 = axisZ * axisZ * c1 + c; return new oimo.common.Mat4(this.e00 * r00 + this.e01 * r10 + this.e02 * r20, this.e00 * r01 + this.e01 * r11 + this.e02 * r21, this.e00 * r02 + this.e01 * r12 + this.e02 * r22, this.e03, this.e10 * r00 + this.e11 * r10 + this.e12 * r20, this.e10 * r01 + this.e11 * r11 + this.e12 * r21, this.e10 * r02 + this.e11 * r12 + this.e12 * r22, this.e13, this.e20 * r00 + this.e21 * r10 + this.e22 * r20, this.e20 * r01 + this.e21 * r11 + this.e22 * r21, this.e20 * r02 + this.e21 * r12 + this.e22 * r22, this.e23, this.e30 * r00 + this.e31 * r10 + this.e32 * r20, this.e30 * r01 + this.e31 * r11 + this.e32 * r21, this.e30 * r02 + this.e31 * r12 + this.e32 * r22, this.e33); } }, { key: "prependTranslation", value: function prependTranslation(tx, ty, tz) { return new oimo.common.Mat4(this.e00 + tx * this.e30, this.e01 + tx * this.e31, this.e02 + tx * this.e32, this.e03 + tx * this.e33, this.e10 + ty * this.e30, this.e11 + ty * this.e31, this.e12 + ty * this.e32, this.e13 + ty * this.e33, this.e20 + tz * this.e30, this.e21 + tz * this.e31, this.e22 + tz * this.e32, this.e23 + tz * this.e33, this.e30, this.e31, this.e32, this.e33); } }, { key: "appendTranslation", value: function appendTranslation(tx, ty, tz) { return new oimo.common.Mat4(this.e00, this.e01, this.e02, this.e00 * tx + this.e01 * ty + this.e02 * tz + this.e03, this.e10, this.e11, this.e12, this.e10 * tx + this.e11 * ty + this.e12 * tz + this.e13, this.e20, this.e21, this.e22, this.e20 * tx + this.e21 * ty + this.e22 * tz + this.e23, this.e30, this.e31, this.e32, this.e30 * tx + this.e31 * ty + this.e32 * tz + this.e33); } }, { key: "prependScaleEq", value: function prependScaleEq(sx, sy, sz) { this.e00 *= sx; this.e01 *= sx; this.e02 *= sx; this.e03 *= sx; this.e10 *= sy; this.e11 *= sy; this.e12 *= sy; this.e13 *= sy; this.e20 *= sz; this.e21 *= sz; this.e22 *= sz; this.e23 *= sz; return this; } }, { key: "appendScaleEq", value: function appendScaleEq(sx, sy, sz) { this.e00 *= sx; this.e01 *= sy; this.e02 *= sz; this.e10 *= sx; this.e11 *= sy; this.e12 *= sz; this.e20 *= sx; this.e21 *= sy; this.e22 *= sz; this.e30 *= sx; this.e31 *= sy; this.e32 *= sz; return this; } }, { key: "prependRotationEq", value: function prependRotationEq(rad, axisX, axisY, axisZ) { var s = Math.sin(rad); var c = Math.cos(rad); var c1 = 1 - c; var r00 = axisX * axisX * c1 + c; var r01 = axisX * axisY * c1 - axisZ * s; var r02 = axisX * axisZ * c1 + axisY * s; var r10 = axisY * axisX * c1 + axisZ * s; var r11 = axisY * axisY * c1 + c; var r12 = axisY * axisZ * c1 - axisX * s; var r20 = axisZ * axisX * c1 - axisY * s; var r21 = axisZ * axisY * c1 + axisX * s; var r22 = axisZ * axisZ * c1 + c; var e10 = r10 * this.e00 + r11 * this.e10 + r12 * this.e20; var e11 = r10 * this.e01 + r11 * this.e11 + r12 * this.e21; var e12 = r10 * this.e02 + r11 * this.e12 + r12 * this.e22; var e13 = r10 * this.e03 + r11 * this.e13 + r12 * this.e23; var e20 = r20 * this.e00 + r21 * this.e10 + r22 * this.e20; var e21 = r20 * this.e01 + r21 * this.e11 + r22 * this.e21; var e22 = r20 * this.e02 + r21 * this.e12 + r22 * this.e22; var e23 = r20 * this.e03 + r21 * this.e13 + r22 * this.e23; this.e00 = r00 * this.e00 + r01 * this.e10 + r02 * this.e20; this.e01 = r00 * this.e01 + r01 * this.e11 + r02 * this.e21; this.e02 = r00 * this.e02 + r01 * this.e12 + r02 * this.e22; this.e03 = r00 * this.e03 + r01 * this.e13 + r02 * this.e23; this.e10 = e10; this.e11 = e11; this.e12 = e12; this.e13 = e13; this.e20 = e20; this.e21 = e21; this.e22 = e22; this.e23 = e23; return this; } }, { key: "appendRotationEq", value: function appendRotationEq(rad, axisX, axisY, axisZ) { var s = Math.sin(rad); var c = Math.cos(rad); var c1 = 1 - c; var r00 = axisX * axisX * c1 + c; var r01 = axisX * axisY * c1 - axisZ * s; var r02 = axisX * axisZ * c1 + axisY * s; var r10 = axisY * axisX * c1 + axisZ * s; var r11 = axisY * axisY * c1 + c; var r12 = axisY * axisZ * c1 - axisX * s; var r20 = axisZ * axisX * c1 - axisY * s; var r21 = axisZ * axisY * c1 + axisX * s; var r22 = axisZ * axisZ * c1 + c; var e01 = this.e00 * r01 + this.e01 * r11 + this.e02 * r21; var e02 = this.e00 * r02 + this.e01 * r12 + this.e02 * r22; var e11 = this.e10 * r01 + this.e11 * r11 + this.e12 * r21; var e12 = this.e10 * r02 + this.e11 * r12 + this.e12 * r22; var e21 = this.e20 * r01 + this.e21 * r11 + this.e22 * r21; var e22 = this.e20 * r02 + this.e21 * r12 + this.e22 * r22; var e31 = this.e30 * r01 + this.e31 * r11 + this.e32 * r21; var e32 = this.e30 * r02 + this.e31 * r12 + this.e32 * r22; this.e00 = this.e00 * r00 + this.e01 * r10 + this.e02 * r20; this.e01 = e01; this.e02 = e02; this.e10 = this.e10 * r00 + this.e11 * r10 + this.e12 * r20; this.e11 = e11; this.e12 = e12; this.e20 = this.e20 * r00 + this.e21 * r10 + this.e22 * r20; this.e21 = e21; this.e22 = e22; this.e30 = this.e30 * r00 + this.e31 * r10 + this.e32 * r20; this.e31 = e31; this.e32 = e32; return this; } }, { key: "prependTranslationEq", value: function prependTranslationEq(tx, ty, tz) { this.e00 += tx * this.e30; this.e01 += tx * this.e31; this.e02 += tx * this.e32; this.e03 += tx * this.e33; this.e10 += ty * this.e30; this.e11 += ty * this.e31; this.e12 += ty * this.e32; this.e13 += ty * this.e33; this.e20 += tz * this.e30; this.e21 += tz * this.e31; this.e22 += tz * this.e32; this.e23 += tz * this.e33; return this; } }, { key: "appendTranslationEq", value: function appendTranslationEq(tx, ty, tz) { var e03 = this.e00 * tx + this.e01 * ty + this.e02 * tz + this.e03; var e13 = this.e10 * tx + this.e11 * ty + this.e12 * tz + this.e13; var e23 = this.e20 * tx + this.e21 * ty + this.e22 * tz + this.e23; var e33 = this.e30 * tx + this.e31 * ty + this.e32 * tz + this.e33; this.e03 = e03; this.e13 = e13; this.e23 = e23; this.e33 = e33; return this; } }, { key: "transpose", value: function transpose() { return new oimo.common.Mat4(this.e00, this.e10, this.e20, this.e30, this.e01, this.e11, this.e21, this.e31, this.e02, this.e12, this.e22, this.e32, this.e03, this.e13, this.e23, this.e33); } }, { key: "transposeEq", value: function transposeEq() { var e10 = this.e01; var e20 = this.e02; var e21 = this.e12; var e30 = this.e03; var e31 = this.e13; var e32 = this.e23; this.e01 = this.e10; this.e02 = this.e20; this.e03 = this.e30; this.e10 = e10; this.e12 = this.e21; this.e13 = this.e31; this.e20 = e20; this.e21 = e21; this.e23 = this.e32; this.e30 = e30; this.e31 = e31; this.e32 = e32; return this; } }, { key: "determinant", value: function determinant() { var d23_01 = this.e20 * this.e31 - this.e21 * this.e30; var d23_02 = this.e20 * this.e32 - this.e22 * this.e30; var d23_03 = this.e20 * this.e33 - this.e23 * this.e30; var d23_12 = this.e21 * this.e32 - this.e22 * this.e31; var d23_13 = this.e21 * this.e33 - this.e23 * this.e31; var d23_23 = this.e22 * this.e33 - this.e23 * this.e32; return this.e00 * (this.e11 * d23_23 - this.e12 * d23_13 + this.e13 * d23_12) - this.e01 * (this.e10 * d23_23 - this.e12 * d23_03 + this.e13 * d23_02) + this.e02 * (this.e10 * d23_13 - this.e11 * d23_03 + this.e13 * d23_01) - this.e03 * (this.e10 * d23_12 - this.e11 * d23_02 + this.e12 * d23_01); } }, { key: "trace", value: function trace() { return this.e00 + this.e11 + this.e22 + this.e33; } }, { key: "inverse", value: function inverse() { var d01_01 = this.e00 * this.e11 - this.e01 * this.e10; var d01_02 = this.e00 * this.e12 - this.e02 * this.e10; var d01_03 = this.e00 * this.e13 - this.e03 * this.e10; var d01_12 = this.e01 * this.e12 - this.e02 * this.e11; var d01_13 = this.e01 * this.e13 - this.e03 * this.e11; var d01_23 = this.e02 * this.e13 - this.e03 * this.e12; var d23_01 = this.e20 * this.e31 - this.e21 * this.e30; var d23_02 = this.e20 * this.e32 - this.e22 * this.e30; var d23_03 = this.e20 * this.e33 - this.e23 * this.e30; var d23_12 = this.e21 * this.e32 - this.e22 * this.e31; var d23_13 = this.e21 * this.e33 - this.e23 * this.e31; var d23_23 = this.e22 * this.e33 - this.e23 * this.e32; var d00 = this.e11 * d23_23 - this.e12 * d23_13 + this.e13 * d23_12; var d01 = this.e10 * d23_23 - this.e12 * d23_03 + this.e13 * d23_02; var d02 = this.e10 * d23_13 - this.e11 * d23_03 + this.e13 * d23_01; var d03 = this.e10 * d23_12 - this.e11 * d23_02 + this.e12 * d23_01; var invDet = this.e00 * d00 - this.e01 * d01 + this.e02 * d02 - this.e03 * d03; if (invDet != 0) { invDet = 1 / invDet; } return new oimo.common.Mat4(d00 * invDet, -(this.e01 * d23_23 - this.e02 * d23_13 + this.e03 * d23_12) * invDet, (this.e31 * d01_23 - this.e32 * d01_13 + this.e33 * d01_12) * invDet, -(this.e21 * d01_23 - this.e22 * d01_13 + this.e23 * d01_12) * invDet, -d01 * invDet, (this.e00 * d23_23 - this.e02 * d23_03 + this.e03 * d23_02) * invDet, -(this.e30 * d01_23 - this.e32 * d01_03 + this.e33 * d01_02) * invDet, (this.e20 * d01_23 - this.e22 * d01_03 + this.e23 * d01_02) * invDet, d02 * invDet, -(this.e00 * d23_13 - this.e01 * d23_03 + this.e03 * d23_01) * invDet, (this.e30 * d01_13 - this.e31 * d01_03 + this.e33 * d01_01) * invDet, -(this.e20 * d01_13 - this.e21 * d01_03 + this.e23 * d01_01) * invDet, -d03 * invDet, (this.e00 * d23_12 - this.e01 * d23_02 + this.e02 * d23_01) * invDet, -(this.e30 * d01_12 - this.e31 * d01_02 + this.e32 * d01_01) * invDet, (this.e20 * d01_12 - this.e21 * d01_02 + this.e22 * d01_01) * invDet); } }, { key: "inverseEq", value: function inverseEq() { var d01_01 = this.e00 * this.e11 - this.e01 * this.e10; var d01_02 = this.e00 * this.e12 - this.e02 * this.e10; var d01_03 = this.e00 * this.e13 - this.e03 * this.e10; var d01_12 = this.e01 * this.e12 - this.e02 * this.e11; var d01_13 = this.e01 * this.e13 - this.e03 * this.e11; var d01_23 = this.e02 * this.e13 - this.e03 * this.e12; var d23_01 = this.e20 * this.e31 - this.e21 * this.e30; var d23_02 = this.e20 * this.e32 - this.e22 * this.e30; var d23_03 = this.e20 * this.e33 - this.e23 * this.e30; var d23_12 = this.e21 * this.e32 - this.e22 * this.e31; var d23_13 = this.e21 * this.e33 - this.e23 * this.e31; var d23_23 = this.e22 * this.e33 - this.e23 * this.e32; var d00 = this.e11 * d23_23 - this.e12 * d23_13 + this.e13 * d23_12; var d01 = this.e10 * d23_23 - this.e12 * d23_03 + this.e13 * d23_02; var d02 = this.e10 * d23_13 - this.e11 * d23_03 + this.e13 * d23_01; var d03 = this.e10 * d23_12 - this.e11 * d23_02 + this.e12 * d23_01; var invDet = this.e00 * d00 - this.e01 * d01 + this.e02 * d02 - this.e03 * d03; if (invDet != 0) { invDet = 1 / invDet; } var t11 = (this.e00 * d23_23 - this.e02 * d23_03 + this.e03 * d23_02) * invDet; var t21 = -(this.e00 * d23_13 - this.e01 * d23_03 + this.e03 * d23_01) * invDet; var t23 = -(this.e20 * d01_13 - this.e21 * d01_03 + this.e23 * d01_01) * invDet; var t31 = (this.e00 * d23_12 - this.e01 * d23_02 + this.e02 * d23_01) * invDet; var t32 = -(this.e30 * d01_12 - this.e31 * d01_02 + this.e32 * d01_01) * invDet; var t33 = (this.e20 * d01_12 - this.e21 * d01_02 + this.e22 * d01_01) * invDet; this.e00 = d00 * invDet; this.e01 = -(this.e01 * d23_23 - this.e02 * d23_13 + this.e03 * d23_12) * invDet; this.e02 = (this.e31 * d01_23 - this.e32 * d01_13 + this.e33 * d01_12) * invDet; this.e03 = -(this.e21 * d01_23 - this.e22 * d01_13 + this.e23 * d01_12) * invDet; this.e10 = -d01 * invDet; this.e11 = t11; this.e12 = -(this.e30 * d01_23 - this.e32 * d01_03 + this.e33 * d01_02) * invDet; this.e13 = (this.e20 * d01_23 - this.e22 * d01_03 + this.e23 * d01_02) * invDet; this.e20 = d02 * invDet; this.e21 = t21; this.e22 = (this.e30 * d01_13 - this.e31 * d01_03 + this.e33 * d01_01) * invDet; this.e23 = t23; this.e30 = -d03 * invDet; this.e31 = t31; this.e32 = t32; this.e33 = t33; return this; } }, { key: "lookAt", value: function lookAt(eyeX, eyeY, eyeZ, atX, atY, atZ, upX, upY, upZ) { var zx = eyeX - atX; var zy = eyeY - atY; var zz = eyeZ - atZ; var tmp = 1 / Math.sqrt(zx * zx + zy * zy + zz * zz); zx *= tmp; zy *= tmp; zz *= tmp; var xx = upY * zz - upZ * zy; var xy = upZ * zx - upX * zz; var xz = upX * zy - upY * zx; tmp = 1 / Math.sqrt(xx * xx + xy * xy + xz * xz); xx *= tmp; xy *= tmp; xz *= tmp; var yx = zy * xz - zz * xy; var yy = zz * xx - zx * xz; var yz = zx * xy - zy * xx; this.e00 = xx; this.e01 = xy; this.e02 = xz; this.e03 = -(xx * eyeX + xy * eyeY + xz * eyeZ); this.e10 = yx; this.e11 = yy; this.e12 = yz; this.e13 = -(yx * eyeX + yy * eyeY + yz * eyeZ); this.e20 = zx; this.e21 = zy; this.e22 = zz; this.e23 = -(zx * eyeX + zy * eyeY + zz * eyeZ); this.e30 = 0; this.e31 = 0; this.e32 = 0; this.e33 = 1; return this; } }, { key: "perspective", value: function perspective(fovY, aspect, near, far) { var h = 1 / Math.tan(fovY * 0.5); var fnf = far / (near - far); this.e00 = h / aspect; this.e01 = 0; this.e02 = 0; this.e03 = 0; this.e10 = 0; this.e11 = h; this.e12 = 0; this.e13 = 0; this.e20 = 0; this.e21 = 0; this.e22 = fnf; this.e23 = near * fnf; this.e30 = 0; this.e31 = 0; this.e32 = -1; this.e33 = 0; return this; } }, { key: "ortho", value: function ortho(width, height, near, far) { var nf = 1 / (near - far); this.e00 = 2 / width; this.e01 = 0; this.e02 = 0; this.e03 = 0; this.e10 = 0; this.e11 = 2 / height; this.e12 = 0; this.e13 = 0; this.e20 = 0; this.e21 = 0; this.e22 = nf; this.e23 = near * nf; this.e30 = 0; this.e31 = 0; this.e32 = 0; this.e33 = 1; return this; } }, { key: "toArray", value: function toArray(columnMajor) { if (columnMajor == null) { columnMajor = false; } if (columnMajor) { return [this.e00, this.e10, this.e20, this.e30, this.e01, this.e11, this.e21, this.e31, this.e02, this.e12, this.e22, this.e32, this.e03, this.e13, this.e23, this.e33]; } else { return [this.e00, this.e01, this.e02, this.e03, this.e10, this.e11, this.e12, this.e13, this.e20, this.e21, this.e22, this.e23, this.e30, this.e31, this.e32, this.e33]; } } }, { key: "copyFrom", value: function copyFrom(m) { this.e00 = m.e00; this.e01 = m.e01; this.e02 = m.e02; this.e03 = m.e03; this.e10 = m.e10; this.e11 = m.e11; this.e12 = m.e12; this.e13 = m.e13; this.e20 = m.e20; this.e21 = m.e21; this.e22 = m.e22; this.e23 = m.e23; this.e30 = m.e30; this.e31 = m.e31; this.e32 = m.e32; this.e33 = m.e33; return this; } }, { key: "fromMat3", value: function fromMat3(m) { this.e00 = m.e00; this.e01 = m.e01; this.e02 = m.e02; this.e03 = 0; this.e10 = m.e10; this.e11 = m.e11; this.e12 = m.e12; this.e13 = 0; this.e20 = m.e20; this.e21 = m.e21; this.e22 = m.e22; this.e23 = 0; this.e30 = 0; this.e31 = 0; this.e32 = 0; this.e33 = 1; return this; } }, { key: "fromTransform", value: function fromTransform(transform) { this.e00 = transform._rotation00; this.e01 = transform._rotation01; this.e02 = transform._rotation02; this.e10 = transform._rotation10; this.e11 = transform._rotation11; this.e12 = transform._rotation12; this.e20 = transform._rotation20; this.e21 = transform._rotation21; this.e22 = transform._rotation22; this.e03 = transform._positionX; this.e13 = transform._positionY; this.e23 = transform._positionZ; this.e30 = 0; this.e31 = 0; this.e32 = 0; this.e33 = 1; return this; } }, { key: "clone", value: function clone() { return new oimo.common.Mat4(this.e00, this.e01, this.e02, this.e03, this.e10, this.e11, this.e12, this.e13, this.e20, this.e21, this.e22, this.e23, this.e30, this.e31, this.e32, this.e33); } }, { key: "toString", value: function toString() { return "Mat4[" + (this.e00 > 0 ? (this.e00 * 10000000 + 0.5 | 0) / 10000000 : (this.e00 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e01 > 0 ? (this.e01 * 10000000 + 0.5 | 0) / 10000000 : (this.e01 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e02 > 0 ? (this.e02 * 10000000 + 0.5 | 0) / 10000000 : (this.e02 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e03 > 0 ? (this.e03 * 10000000 + 0.5 | 0) / 10000000 : (this.e03 * 10000000 - 0.5 | 0) / 10000000) + ",\n" + " " + (this.e10 > 0 ? (this.e10 * 10000000 + 0.5 | 0) / 10000000 : (this.e10 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e11 > 0 ? (this.e11 * 10000000 + 0.5 | 0) / 10000000 : (this.e11 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e12 > 0 ? (this.e12 * 10000000 + 0.5 | 0) / 10000000 : (this.e12 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e13 > 0 ? (this.e13 * 10000000 + 0.5 | 0) / 10000000 : (this.e13 * 10000000 - 0.5 | 0) / 10000000) + ",\n" + " " + (this.e20 > 0 ? (this.e20 * 10000000 + 0.5 | 0) / 10000000 : (this.e20 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e21 > 0 ? (this.e21 * 10000000 + 0.5 | 0) / 10000000 : (this.e21 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e22 > 0 ? (this.e22 * 10000000 + 0.5 | 0) / 10000000 : (this.e22 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e23 > 0 ? (this.e23 * 10000000 + 0.5 | 0) / 10000000 : (this.e23 * 10000000 - 0.5 | 0) / 10000000) + ",\n" + " " + (this.e30 > 0 ? (this.e30 * 10000000 + 0.5 | 0) / 10000000 : (this.e30 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e31 > 0 ? (this.e31 * 10000000 + 0.5 | 0) / 10000000 : (this.e31 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e32 > 0 ? (this.e32 * 10000000 + 0.5 | 0) / 10000000 : (this.e32 * 10000000 - 0.5 | 0) / 10000000) + ", " + (this.e33 > 0 ? (this.e33 * 10000000 + 0.5 | 0) / 10000000 : (this.e33 * 10000000 - 0.5 | 0) / 10000000) + "]"; } }]); return oimo_common_Mat4; }(); oimo.common.MathUtil = /*#__PURE__*/function () { function oimo_common_MathUtil() { _classCallCheck(this, oimo_common_MathUtil); } _createClass(oimo_common_MathUtil, null, [{ key: "abs", value: function abs(x) { if (x > 0) { return x; } else { return -x; } } }, { key: "sin", value: function sin(x) { return Math.sin(x); } }, { key: "cos", value: function cos(x) { return Math.cos(x); } }, { key: "tan", value: function tan(x) { return Math.tan(x); } }, { key: "asin", value: function asin(x) { return Math.asin(x); } }, { key: "acos", value: function acos(x) { return Math.acos(x); } }, { key: "atan", value: function atan(x) { return Math.atan(x); } }, { key: "safeAsin", value: function safeAsin(x) { if (x <= -1) { return -1.570796326794895; } if (x >= 1) { return 1.570796326794895; } return Math.asin(x); } }, { key: "safeAcos", value: function safeAcos(x) { if (x <= -1) { return 3.14159265358979; } if (x >= 1) { return 0; } return Math.acos(x); } }, { key: "atan2", value: function atan2(y, x) { return Math.atan2(y, x); } }, { key: "sqrt", value: function sqrt(x) { return Math.sqrt(x); } }, { key: "clamp", value: function clamp(x, min, max) { if (x < min) { return min; } else if (x > max) { return max; } else { return x; } } }, { key: "rand", value: function rand() { return Math.random(); } }, { key: "randIn", value: function randIn(min, max) { return min + Math.random() * (max - min); } }, { key: "randVec3In", value: function randVec3In(min, max) { return new oimo.common.Vec3(min + Math.random() * (max - min), min + Math.random() * (max - min), min + Math.random() * (max - min)); } }, { key: "randVec3", value: function randVec3() { return new oimo.common.Vec3(-1 + Math.random() * 2, -1 + Math.random() * 2, -1 + Math.random() * 2); } }]); return oimo_common_MathUtil; }(); oimo.common.Pool = /*#__PURE__*/function () { function oimo_common_Pool() { _classCallCheck(this, oimo_common_Pool); this.stackVec3 = new Array(256); this.sizeVec3 = 0; this.stackMat3 = new Array(256); this.sizeMat3 = 0; this.stackMat4 = new Array(256); this.sizeMat4 = 0; this.stackQuat = new Array(256); this.sizeQuat = 0; } _createClass(oimo_common_Pool, [{ key: "vec3", value: function vec3() { if (this.sizeVec3 == 0) { return new oimo.common.Vec3(); } else { return this.stackVec3[--this.sizeVec3]; } } }, { key: "mat3", value: function mat3() { if (this.sizeMat3 == 0) { return new oimo.common.Mat3(); } else { return this.stackMat3[--this.sizeMat3]; } } }, { key: "mat4", value: function mat4() { if (this.sizeMat4 == 0) { return new oimo.common.Mat4(); } else { return this.stackMat4[--this.sizeMat4]; } } }, { key: "quat", value: function quat() { if (this.sizeQuat == 0) { return new oimo.common.Quat(); } else { return this.stackQuat[--this.sizeQuat]; } } }, { key: "dispose", value: function dispose(vec3, mat3, mat4, quat) { if (vec3 != null) { vec3.zero(); if (this.sizeVec3 == this.stackVec3.length) { var newArray = new Array(this.sizeVec3 << 1); var _g = 0; var _g1 = this.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = this.stackVec3[i]; this.stackVec3[i] = null; } this.stackVec3 = newArray; } this.stackVec3[this.sizeVec3++] = vec3; } if (mat3 != null) { mat3.e00 = 1; mat3.e01 = 0; mat3.e02 = 0; mat3.e10 = 0; mat3.e11 = 1; mat3.e12 = 0; mat3.e20 = 0; mat3.e21 = 0; mat3.e22 = 1; if (this.sizeMat3 == this.stackMat3.length) { var _newArray = new Array(this.sizeMat3 << 1); var _g25 = 0; var _g26 = this.sizeMat3; while (_g25 < _g26) { var _i4 = _g25++; _newArray[_i4] = this.stackMat3[_i4]; this.stackMat3[_i4] = null; } this.stackMat3 = _newArray; } this.stackMat3[this.sizeMat3++] = mat3; } if (mat4 != null) { mat4.e00 = 1; mat4.e01 = 0; mat4.e02 = 0; mat4.e03 = 0; mat4.e10 = 0; mat4.e11 = 1; mat4.e12 = 0; mat4.e13 = 0; mat4.e20 = 0; mat4.e21 = 0; mat4.e22 = 1; mat4.e23 = 0; mat4.e30 = 0; mat4.e31 = 0; mat4.e32 = 0; mat4.e33 = 1; if (this.sizeMat4 == this.stackMat4.length) { var _newArray2 = new Array(this.sizeMat4 << 1); var _g27 = 0; var _g28 = this.sizeMat4; while (_g27 < _g28) { var _i5 = _g27++; _newArray2[_i5] = this.stackMat4[_i5]; this.stackMat4[_i5] = null; } this.stackMat4 = _newArray2; } this.stackMat4[this.sizeMat4++] = mat4; } if (quat != null) { quat.x = 0; quat.y = 0; quat.z = 0; quat.w = 1; if (this.sizeQuat == this.stackQuat.length) { var _newArray3 = new Array(this.sizeQuat << 1); var _g29 = 0; var _g30 = this.sizeQuat; while (_g29 < _g30) { var _i6 = _g29++; _newArray3[_i6] = this.stackQuat[_i6]; this.stackQuat[_i6] = null; } this.stackQuat = _newArray3; } this.stackQuat[this.sizeQuat++] = quat; } } }, { key: "disposeVec3", value: function disposeVec3(v) { v.zero(); if (this.sizeVec3 == this.stackVec3.length) { var newArray = new Array(this.sizeVec3 << 1); var _g = 0; var _g1 = this.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = this.stackVec3[i]; this.stackVec3[i] = null; } this.stackVec3 = newArray; } this.stackVec3[this.sizeVec3++] = v; } }, { key: "disposeMat3", value: function disposeMat3(m) { m.e00 = 1; m.e01 = 0; m.e02 = 0; m.e10 = 0; m.e11 = 1; m.e12 = 0; m.e20 = 0; m.e21 = 0; m.e22 = 1; if (this.sizeMat3 == this.stackMat3.length) { var newArray = new Array(this.sizeMat3 << 1); var _g = 0; var _g1 = this.sizeMat3; while (_g < _g1) { var i = _g++; newArray[i] = this.stackMat3[i]; this.stackMat3[i] = null; } this.stackMat3 = newArray; } this.stackMat3[this.sizeMat3++] = m; } }, { key: "disposeMat4", value: function disposeMat4(m) { m.e00 = 1; m.e01 = 0; m.e02 = 0; m.e03 = 0; m.e10 = 0; m.e11 = 1; m.e12 = 0; m.e13 = 0; m.e20 = 0; m.e21 = 0; m.e22 = 1; m.e23 = 0; m.e30 = 0; m.e31 = 0; m.e32 = 0; m.e33 = 1; if (this.sizeMat4 == this.stackMat4.length) { var newArray = new Array(this.sizeMat4 << 1); var _g = 0; var _g1 = this.sizeMat4; while (_g < _g1) { var i = _g++; newArray[i] = this.stackMat4[i]; this.stackMat4[i] = null; } this.stackMat4 = newArray; } this.stackMat4[this.sizeMat4++] = m; } }, { key: "disposeQuat", value: function disposeQuat(q) { q.x = 0; q.y = 0; q.z = 0; q.w = 1; if (this.sizeQuat == this.stackQuat.length) { var newArray = new Array(this.sizeQuat << 1); var _g = 0; var _g1 = this.sizeQuat; while (_g < _g1) { var i = _g++; newArray[i] = this.stackQuat[i]; this.stackQuat[i] = null; } this.stackQuat = newArray; } this.stackQuat[this.sizeQuat++] = q; } }]); return oimo_common_Pool; }(); oimo.common.Quat = /*#__PURE__*/function () { function oimo_common_Quat(x, y, z, w) { _classCallCheck(this, oimo_common_Quat); if (w == null) { w = 1; } if (z == null) { z = 0; } if (y == null) { y = 0; } if (x == null) { x = 0; } this.x = x; this.y = y; this.z = z; this.w = w; oimo.common.Quat.numCreations++; } _createClass(oimo_common_Quat, [{ key: "identity", value: function identity() { this.x = 0; this.y = 0; this.z = 0; this.w = 1; return this; } }, { key: "init", value: function init(x, y, z, w) { this.x = x; this.y = y; this.z = z; this.w = w; return this; } }, { key: "add", value: function add(q) { return new oimo.common.Quat(this.x + q.x, this.y + q.y, this.z + q.z, this.w + q.w); } }, { key: "sub", value: function sub(q) { return new oimo.common.Quat(this.x - q.x, this.y - q.y, this.z - q.z, this.w - q.w); } }, { key: "scale", value: function scale(s) { return new oimo.common.Quat(this.x * s, this.y * s, this.z * s, this.w * s); } }, { key: "addEq", value: function addEq(q) { this.x += q.x; this.y += q.y; this.z += q.z; this.w += q.w; return this; } }, { key: "subEq", value: function subEq(q) { this.x -= q.x; this.y -= q.y; this.z -= q.z; this.w -= q.w; return this; } }, { key: "scaleEq", value: function scaleEq(s) { this.x *= s; this.y *= s; this.z *= s; this.w *= s; return this; } }, { key: "length", value: function length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); } }, { key: "lengthSq", value: function lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; } }, { key: "dot", value: function dot(q) { return this.x * q.x + this.y * q.y + this.z * q.z + this.w * q.w; } }, { key: "normalized", value: function normalized() { var invLen = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); if (invLen > 0) { invLen = 1 / invLen; } return new oimo.common.Quat(this.x * invLen, this.y * invLen, this.z * invLen, this.w * invLen); } }, { key: "normalize", value: function normalize() { var invLen = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); if (invLen > 0) { invLen = 1 / invLen; } this.x *= invLen; this.y *= invLen; this.z *= invLen; this.w *= invLen; return this; } }, { key: "setArc", value: function setArc(v1, v2) { var x1 = v1.x; var y1 = v1.y; var z1 = v1.z; var x2 = v2.x; var y2 = v2.y; var z2 = v2.z; var d = x1 * x2 + y1 * y2 + z1 * z2; this.w = Math.sqrt((1 + d) * 0.5); if (this.w == 0) { x2 = x1 * x1; y2 = y1 * y1; z2 = z1 * z1; if (x2 < y2) { if (x2 < z2) { d = 1 / Math.sqrt(y2 + z2); this.x = 0; this.y = z1 * d; this.z = -y1 * d; } else { d = 1 / Math.sqrt(x2 + y2); this.z = 0; this.x = y1 * d; this.y = -x1 * d; } } else if (y2 < z2) { d = 1 / Math.sqrt(z2 + x2); this.y = 0; this.z = x1 * d; this.x = -z1 * d; } else { d = 1 / Math.sqrt(x2 + y2); this.z = 0; this.x = y1 * d; this.y = -x1 * d; } return this; } d = 0.5 / this.w; this.x = (y1 * z2 - z1 * y2) * d; this.y = (z1 * x2 - x1 * z2) * d; this.z = (x1 * y2 - y1 * x2) * d; return this; } }, { key: "slerp", value: function slerp(q, t) { var qx; var qy; var qz; var qw; var d = this.x * q.x + this.y * q.y + this.z * q.z + this.w * q.w; if (d < 0) { d = -d; qx = -q.x; qy = -q.y; qz = -q.z; qw = -q.w; } else { qx = q.x; qy = q.y; qz = q.z; qw = q.w; } if (d > 0.999999) { var _this = new oimo.common.Quat(this.x + (qx - this.x) * t, this.y + (qy - this.y) * t, this.z + (qz - this.z) * t, this.w + (qw - this.w) * t); var _invLen = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z + _this.w * _this.w); if (_invLen > 0) { _invLen = 1 / _invLen; } _this.x *= _invLen; _this.y *= _invLen; _this.z *= _invLen; _this.w *= _invLen; return _this; } var theta = t * Math.acos(d); qx -= this.x * d; qy -= this.y * d; qz -= this.z * d; qw -= this.w * d; var invLen = 1 / Math.sqrt(qx * qx + qy * qy + qz * qz + qw * qw); qx *= invLen; qy *= invLen; qz *= invLen; qw *= invLen; var sin = Math.sin(theta); var cos = Math.cos(theta); return new oimo.common.Quat(this.x * cos + qx * sin, this.y * cos + qy * sin, this.z * cos + qz * sin, this.w * cos + qw * sin); } }, { key: "copyFrom", value: function copyFrom(q) { this.x = q.x; this.y = q.y; this.z = q.z; this.w = q.w; return this; } }, { key: "clone", value: function clone() { return new oimo.common.Quat(this.x, this.y, this.z, this.w); } }, { key: "fromMat3", value: function fromMat3(m) { var e00 = m.e00; var e11 = m.e11; var e22 = m.e22; var t = e00 + e11 + e22; var s; if (t > 0) { s = Math.sqrt(t + 1); this.w = 0.5 * s; s = 0.5 / s; this.x = (m.e21 - m.e12) * s; this.y = (m.e02 - m.e20) * s; this.z = (m.e10 - m.e01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); this.x = 0.5 * s; s = 0.5 / s; this.y = (m.e01 + m.e10) * s; this.z = (m.e02 + m.e20) * s; this.w = (m.e21 - m.e12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); this.z = 0.5 * s; s = 0.5 / s; this.x = (m.e02 + m.e20) * s; this.y = (m.e12 + m.e21) * s; this.w = (m.e10 - m.e01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); this.y = 0.5 * s; s = 0.5 / s; this.x = (m.e01 + m.e10) * s; this.z = (m.e12 + m.e21) * s; this.w = (m.e02 - m.e20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); this.z = 0.5 * s; s = 0.5 / s; this.x = (m.e02 + m.e20) * s; this.y = (m.e12 + m.e21) * s; this.w = (m.e10 - m.e01) * s; } return this; } }, { key: "toMat3", value: function toMat3() { var _this = new oimo.common.Mat3(); var x = this.x; var y = this.y; var z = this.z; var w = this.w; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; _this.e00 = 1 - yy - zz; _this.e01 = xy - wz; _this.e02 = xz + wy; _this.e10 = xy + wz; _this.e11 = 1 - xx - zz; _this.e12 = yz - wx; _this.e20 = xz - wy; _this.e21 = yz + wx; _this.e22 = 1 - xx - yy; return _this; } }, { key: "toString", value: function toString() { return "Quat[" + (this.x > 0 ? (this.x * 10000000 + 0.5 | 0) / 10000000 : (this.x * 10000000 - 0.5 | 0) / 10000000) + " i,\n" + " " + (this.y > 0 ? (this.y * 10000000 + 0.5 | 0) / 10000000 : (this.y * 10000000 - 0.5 | 0) / 10000000) + " j,\n" + " " + (this.z > 0 ? (this.z * 10000000 + 0.5 | 0) / 10000000 : (this.z * 10000000 - 0.5 | 0) / 10000000) + " k,\n" + " " + (this.w > 0 ? (this.w * 10000000 + 0.5 | 0) / 10000000 : (this.w * 10000000 - 0.5 | 0) / 10000000) + "]"; } }]); return oimo_common_Quat; }(); if (!oimo.dynamics) oimo.dynamics = {}; oimo.dynamics.Contact = /*#__PURE__*/function () { function oimo_dynamics_Contact() { _classCallCheck(this, oimo_dynamics_Contact); this._next = null; this._prev = null; this._link1 = new oimo.dynamics.ContactLink(); this._link2 = new oimo.dynamics.ContactLink(); this._s1 = null; this._s2 = null; this._b1 = null; this._b2 = null; this._detector = null; this._cachedDetectorData = new oimo.collision.narrowphase.detector.CachedDetectorData(); this._detectorResult = new oimo.collision.narrowphase.DetectorResult(); this._latest = false; this._shouldBeSkipped = false; this._manifold = new oimo.dynamics.constraint.contact.Manifold(); this._updater = new oimo.dynamics.constraint.contact.ManifoldUpdater(this._manifold); this._contactConstraint = new oimo.dynamics.constraint.contact.ContactConstraint(this._manifold); this._touching = false; } _createClass(oimo_dynamics_Contact, [{ key: "_updateManifold", value: function _updateManifold() { if (this._detector == null) { return; } var ptouching = this._touching; var result = this._detectorResult; this._detector.detect(result, this._s1._geom, this._s2._geom, this._s1._transform, this._s2._transform, this._cachedDetectorData); this._touching = result.numPoints > 0; if (this._touching) { this._manifold._buildBasis(result.normal); if (result.getMaxDepth() > oimo.common.Setting.contactUseAlternativePositionCorrectionAlgorithmDepthThreshold) { this._contactConstraint._positionCorrectionAlgorithm = oimo.common.Setting.alternativeContactPositionCorrectionAlgorithm; } else { this._contactConstraint._positionCorrectionAlgorithm = oimo.common.Setting.defaultContactPositionCorrectionAlgorithm; } if (result.incremental) { this._updater.incrementalUpdate(result, this._b1._transform, this._b2._transform); } else { this._updater.totalUpdate(result, this._b1._transform, this._b2._transform); } } else { this._manifold._clear(); } if (this._touching && !ptouching) { var cc1 = this._s1._contactCallback; var cc2 = this._s2._contactCallback; if (cc1 == cc2) { cc2 = null; } if (cc1 != null) { cc1.beginContact(this); } if (cc2 != null) { cc2.beginContact(this); } } if (!this._touching && ptouching) { var _cc = this._s1._contactCallback; var _cc2 = this._s2._contactCallback; if (_cc == _cc2) { _cc2 = null; } if (_cc != null) { _cc.endContact(this); } if (_cc2 != null) { _cc2.endContact(this); } } if (this._touching) { var _cc3 = this._s1._contactCallback; var _cc4 = this._s2._contactCallback; if (_cc3 == _cc4) { _cc4 = null; } if (_cc3 != null) { _cc3.preSolve(this); } if (_cc4 != null) { _cc4.preSolve(this); } } } }, { key: "_postSolve", value: function _postSolve() { var cc1 = this._s1._contactCallback; var cc2 = this._s2._contactCallback; if (cc1 == cc2) { cc2 = null; } if (cc1 != null) { cc1.postSolve(this); } if (cc2 != null) { cc2.postSolve(this); } } }, { key: "getShape1", value: function getShape1() { return this._s1; } }, { key: "getShape2", value: function getShape2() { return this._s2; } }, { key: "isTouching", value: function isTouching() { return this._touching; } }, { key: "getManifold", value: function getManifold() { return this._manifold; } }, { key: "getContactConstraint", value: function getContactConstraint() { return this._contactConstraint; } }, { key: "getPrev", value: function getPrev() { return this._prev; } }, { key: "getNext", value: function getNext() { return this._next; } }]); return oimo_dynamics_Contact; }(); oimo.dynamics.ContactLink = /*#__PURE__*/function () { function oimo_dynamics_ContactLink() { _classCallCheck(this, oimo_dynamics_ContactLink); this._prev = null; this._next = null; this._contact = null; this._other = null; } _createClass(oimo_dynamics_ContactLink, [{ key: "getContact", value: function getContact() { return this._contact; } }, { key: "getOther", value: function getOther() { return this._other; } }, { key: "getPrev", value: function getPrev() { return this._prev; } }, { key: "getNext", value: function getNext() { return this._next; } }]); return oimo_dynamics_ContactLink; }(); oimo.dynamics.ContactManager = /*#__PURE__*/function () { function oimo_dynamics_ContactManager(broadPhase) { _classCallCheck(this, oimo_dynamics_ContactManager); this._broadPhase = broadPhase; this._collisionMatrix = new oimo.collision.narrowphase.CollisionMatrix(); this._numContacts = 0; } _createClass(oimo_dynamics_ContactManager, [{ key: "createContacts", value: function createContacts() { var pp = this._broadPhase._proxyPairList; while (pp != null) { var n = pp._next; while (true) { var s1 = void 0; var s2 = void 0; if (pp._p1._id < pp._p2._id) { s1 = pp._p1.userData; s2 = pp._p2.userData; } else { s1 = pp._p2.userData; s2 = pp._p1.userData; } if (!this.shouldCollide(s1, s2)) { break; } var b1 = s1._rigidBody; var b2 = s2._rigidBody; var l = void 0; if (b1._numContactLinks < b2._numContactLinks) { l = b1._contactLinkList; } else { l = b2._contactLinkList; } var id1 = s1._id; var id2 = s2._id; var found = false; while (l != null) { var c = l._contact; if (c._s1._id == id1 && c._s2._id == id2) { c._latest = true; found = true; break; } l = l._next; } if (!found) { var first = this._contactPool; if (first != null) { this._contactPool = first._next; first._next = null; } else { first = new oimo.dynamics.Contact(); } var _c61 = first; if (this._contactList == null) { this._contactList = _c61; this._contactListLast = _c61; } else { this._contactListLast._next = _c61; _c61._prev = this._contactListLast; this._contactListLast = _c61; } _c61._latest = true; var detector = this._collisionMatrix.detectors[s1._geom._type][s2._geom._type]; _c61._s1 = s1; _c61._s2 = s2; _c61._b1 = s1._rigidBody; _c61._b2 = s2._rigidBody; _c61._touching = false; if (_c61._b1._contactLinkList == null) { _c61._b1._contactLinkList = _c61._link1; _c61._b1._contactLinkListLast = _c61._link1; } else { _c61._b1._contactLinkListLast._next = _c61._link1; _c61._link1._prev = _c61._b1._contactLinkListLast; _c61._b1._contactLinkListLast = _c61._link1; } if (_c61._b2._contactLinkList == null) { _c61._b2._contactLinkList = _c61._link2; _c61._b2._contactLinkListLast = _c61._link2; } else { _c61._b2._contactLinkListLast._next = _c61._link2; _c61._link2._prev = _c61._b2._contactLinkListLast; _c61._b2._contactLinkListLast = _c61._link2; } _c61._b1._numContactLinks++; _c61._b2._numContactLinks++; _c61._link1._other = _c61._b2; _c61._link2._other = _c61._b1; _c61._link1._contact = _c61; _c61._link2._contact = _c61; _c61._detector = detector; var _this = _c61._contactConstraint; _this._s1 = s1; _this._s2 = s2; _this._b1 = _this._s1._rigidBody; _this._b2 = _this._s2._rigidBody; _this._tf1 = _this._b1._transform; _this._tf2 = _this._b2._transform; this._numContacts++; } break; } pp = n; } } }, { key: "destroyOutdatedContacts", value: function destroyOutdatedContacts() { var incremental = this._broadPhase._incremental; var c = this._contactList; while (c != null) { var n = c._next; while (true) { if (c._latest) { c._latest = false; c._shouldBeSkipped = false; break; } if (!incremental) { var prev = c._prev; var next = c._next; if (prev != null) { prev._next = next; } if (next != null) { next._prev = prev; } if (c == this._contactList) { this._contactList = this._contactList._next; } if (c == this._contactListLast) { this._contactListLast = this._contactListLast._prev; } c._next = null; c._prev = null; if (c._touching) { var cc1 = c._s1._contactCallback; var cc2 = c._s2._contactCallback; if (cc1 == cc2) { cc2 = null; } if (cc1 != null) { cc1.endContact(c); } if (cc2 != null) { cc2.endContact(c); } } var prev1 = c._link1._prev; var next1 = c._link1._next; if (prev1 != null) { prev1._next = next1; } if (next1 != null) { next1._prev = prev1; } if (c._link1 == c._b1._contactLinkList) { c._b1._contactLinkList = c._b1._contactLinkList._next; } if (c._link1 == c._b1._contactLinkListLast) { c._b1._contactLinkListLast = c._b1._contactLinkListLast._prev; } c._link1._next = null; c._link1._prev = null; var prev2 = c._link2._prev; var next2 = c._link2._next; if (prev2 != null) { prev2._next = next2; } if (next2 != null) { next2._prev = prev2; } if (c._link2 == c._b2._contactLinkList) { c._b2._contactLinkList = c._b2._contactLinkList._next; } if (c._link2 == c._b2._contactLinkListLast) { c._b2._contactLinkListLast = c._b2._contactLinkListLast._prev; } c._link2._next = null; c._link2._prev = null; c._b1._numContactLinks--; c._b2._numContactLinks--; c._link1._other = null; c._link2._other = null; c._link1._contact = null; c._link2._contact = null; c._s1 = null; c._s2 = null; c._b1 = null; c._b2 = null; c._touching = false; c._cachedDetectorData._clear(); c._manifold._clear(); c._detector = null; var _this = c._contactConstraint; _this._s1 = null; _this._s2 = null; _this._b1 = null; _this._b2 = null; _this._tf1 = null; _this._tf2 = null; c._next = this._contactPool; this._contactPool = c; this._numContacts--; break; } var s1 = c._s1; var s2 = c._s2; var r1 = s1._rigidBody; var r2 = s2._rigidBody; if (!(!r1._sleeping && r1._type != 1) && !(!r2._sleeping && r2._type != 1)) { c._shouldBeSkipped = true; break; } var aabb1 = s1._aabb; var aabb2 = s2._aabb; var proxy1 = s1._proxy; var proxy2 = s2._proxy; if (!(proxy1._aabbMinX < proxy2._aabbMaxX && proxy1._aabbMaxX > proxy2._aabbMinX && proxy1._aabbMinY < proxy2._aabbMaxY && proxy1._aabbMaxY > proxy2._aabbMinY && proxy1._aabbMinZ < proxy2._aabbMaxZ && proxy1._aabbMaxZ > proxy2._aabbMinZ) || !this.shouldCollide(s1, s2)) { var _prev = c._prev; var _next = c._next; if (_prev != null) { _prev._next = _next; } if (_next != null) { _next._prev = _prev; } if (c == this._contactList) { this._contactList = this._contactList._next; } if (c == this._contactListLast) { this._contactListLast = this._contactListLast._prev; } c._next = null; c._prev = null; if (c._touching) { var _cc5 = c._s1._contactCallback; var _cc6 = c._s2._contactCallback; if (_cc5 == _cc6) { _cc6 = null; } if (_cc5 != null) { _cc5.endContact(c); } if (_cc6 != null) { _cc6.endContact(c); } } var _prev2 = c._link1._prev; var _next2 = c._link1._next; if (_prev2 != null) { _prev2._next = _next2; } if (_next2 != null) { _next2._prev = _prev2; } if (c._link1 == c._b1._contactLinkList) { c._b1._contactLinkList = c._b1._contactLinkList._next; } if (c._link1 == c._b1._contactLinkListLast) { c._b1._contactLinkListLast = c._b1._contactLinkListLast._prev; } c._link1._next = null; c._link1._prev = null; var _prev3 = c._link2._prev; var _next3 = c._link2._next; if (_prev3 != null) { _prev3._next = _next3; } if (_next3 != null) { _next3._prev = _prev3; } if (c._link2 == c._b2._contactLinkList) { c._b2._contactLinkList = c._b2._contactLinkList._next; } if (c._link2 == c._b2._contactLinkListLast) { c._b2._contactLinkListLast = c._b2._contactLinkListLast._prev; } c._link2._next = null; c._link2._prev = null; c._b1._numContactLinks--; c._b2._numContactLinks--; c._link1._other = null; c._link2._other = null; c._link1._contact = null; c._link2._contact = null; c._s1 = null; c._s2 = null; c._b1 = null; c._b2 = null; c._touching = false; c._cachedDetectorData._clear(); c._manifold._clear(); c._detector = null; var _this84 = c._contactConstraint; _this84._s1 = null; _this84._s2 = null; _this84._b1 = null; _this84._b2 = null; _this84._tf1 = null; _this84._tf2 = null; c._next = this._contactPool; this._contactPool = c; this._numContacts--; break; } c._shouldBeSkipped = !(aabb1._minX < aabb2._maxX && aabb1._maxX > aabb2._minX && aabb1._minY < aabb2._maxY && aabb1._maxY > aabb2._minY && aabb1._minZ < aabb2._maxZ && aabb1._maxZ > aabb2._minZ); break; } c = n; } } }, { key: "shouldCollide", value: function shouldCollide(s1, s2) { var r1 = s1._rigidBody; var r2 = s2._rigidBody; if (r1 == r2) { return false; } if (r1._type != 0 && r2._type != 0) { return false; } if ((s1._collisionGroup & s2._collisionMask) == 0 || (s2._collisionGroup & s1._collisionMask) == 0) { return false; } var jl; var other; if (r1._numJointLinks < r2._numJointLinks) { jl = r1._jointLinkList; other = r2; } else { jl = r2._jointLinkList; other = r1; } while (jl != null) { if (jl._other == other && !jl._joint._allowCollision) { return false; } jl = jl._next; } return true; } }, { key: "_updateContacts", value: function _updateContacts() { this._broadPhase.collectPairs(); this.createContacts(); this.destroyOutdatedContacts(); } }, { key: "_postSolve", value: function _postSolve() { var c = this._contactList; while (c != null) { var n = c._next; if (c._touching) { c._postSolve(); } c = n; } } }, { key: "getNumContacts", value: function getNumContacts() { return this._numContacts; } }, { key: "getContactList", value: function getContactList() { return this._contactList; } }]); return oimo_dynamics_ContactManager; }(); oimo.dynamics.Island = /*#__PURE__*/function () { function oimo_dynamics_Island() { _classCallCheck(this, oimo_dynamics_Island); this.rigidBodies = new Array(oimo.common.Setting.islandInitialRigidBodyArraySize); this.solvers = new Array(oimo.common.Setting.islandInitialConstraintArraySize); this.solversSi = new Array(oimo.common.Setting.islandInitialConstraintArraySize); this.solversNgs = new Array(oimo.common.Setting.islandInitialConstraintArraySize); this.numRigidBodies = 0; this.numSolvers = 0; this.numSolversSi = 0; this.numSolversNgs = 0; } _createClass(oimo_dynamics_Island, [{ key: "_clear", value: function _clear() { while (this.numRigidBodies > 0) { this.rigidBodies[--this.numRigidBodies] = null; } while (this.numSolvers > 0) { this.solvers[--this.numSolvers] = null; } while (this.numSolversSi > 0) { this.solversSi[--this.numSolversSi] = null; } while (this.numSolversNgs > 0) { this.solversNgs[--this.numSolversNgs] = null; } } }, { key: "_addRigidBody", value: function _addRigidBody(rigidBody) { if (this.numRigidBodies == this.rigidBodies.length) { var newArray = new Array(this.numRigidBodies << 1); var _g = 0; var _g1 = this.numRigidBodies; while (_g < _g1) { var i = _g++; newArray[i] = this.rigidBodies[i]; this.rigidBodies[i] = null; } this.rigidBodies = newArray; } rigidBody._addedToIsland = true; this.rigidBodies[this.numRigidBodies++] = rigidBody; } }, { key: "_addConstraintSolver", value: function _addConstraintSolver(solver, positionCorrection) { if (this.numSolvers == this.solvers.length) { var newArray = new Array(this.numSolvers << 1); var _g = 0; var _g1 = this.numSolvers; while (_g < _g1) { var i = _g++; newArray[i] = this.solvers[i]; this.solvers[i] = null; } this.solvers = newArray; } solver._addedToIsland = true; this.solvers[this.numSolvers++] = solver; if (positionCorrection == oimo.dynamics.constraint.PositionCorrectionAlgorithm.SPLIT_IMPULSE) { if (this.numSolversSi == this.solversSi.length) { var _newArray4 = new Array(this.numSolversSi << 1); var _g31 = 0; var _g32 = this.numSolversSi; while (_g31 < _g32) { var _i7 = _g31++; _newArray4[_i7] = this.solversSi[_i7]; this.solversSi[_i7] = null; } this.solversSi = _newArray4; } this.solversSi[this.numSolversSi++] = solver; } if (positionCorrection == oimo.dynamics.constraint.PositionCorrectionAlgorithm.NGS) { if (this.numSolversNgs == this.solversNgs.length) { var _newArray5 = new Array(this.numSolversNgs << 1); var _g33 = 0; var _g34 = this.numSolversNgs; while (_g33 < _g34) { var _i8 = _g33++; _newArray5[_i8] = this.solversNgs[_i8]; this.solversNgs[_i8] = null; } this.solversNgs = _newArray5; } this.solversNgs[this.numSolversNgs++] = solver; } } }, { key: "_stepSingleRigidBody", value: function _stepSingleRigidBody(timeStep, rb) { var dt = timeStep.dt; var dst = rb._ptransform; var src = rb._transform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; rb._linearContactImpulseX = 0; rb._linearContactImpulseY = 0; rb._linearContactImpulseZ = 0; rb._angularContactImpulseX = 0; rb._angularContactImpulseY = 0; rb._angularContactImpulseZ = 0; if (rb._autoSleep && rb._velX * rb._velX + rb._velY * rb._velY + rb._velZ * rb._velZ < oimo.common.Setting.sleepingVelocityThreshold * oimo.common.Setting.sleepingVelocityThreshold && rb._angVelX * rb._angVelX + rb._angVelY * rb._angVelY + rb._angVelZ * rb._angVelZ < oimo.common.Setting.sleepingAngularVelocityThreshold * oimo.common.Setting.sleepingAngularVelocityThreshold) { rb._sleepTime += dt; if (rb._sleepTime > oimo.common.Setting.sleepingTimeThreshold) { rb._sleeping = true; rb._sleepTime = 0; } } else { rb._sleepTime = 0; } if (!rb._sleeping) { if (rb._type == 0) { var x = dt * rb._linearDamping; var x2 = x * x; var linScale = 1 / (1 + x + x2 * (0.5 + x * 0.16666666666666666 + x2 * 0.041666666666666664)); var x1 = dt * rb._angularDamping; var x21 = x1 * x1; var angScale = 1 / (1 + x1 + x21 * (0.5 + x1 * 0.16666666666666666 + x21 * 0.041666666666666664)); var linAccX; var linAccY; var linAccZ; var angAccX; var angAccY; var angAccZ; linAccX = this.gravityX * rb._gravityScale; linAccY = this.gravityY * rb._gravityScale; linAccZ = this.gravityZ * rb._gravityScale; linAccX += rb._forceX * rb._invMass; linAccY += rb._forceY * rb._invMass; linAccZ += rb._forceZ * rb._invMass; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = rb._invInertia00 * rb._torqueX + rb._invInertia01 * rb._torqueY + rb._invInertia02 * rb._torqueZ; __tmp__Y = rb._invInertia10 * rb._torqueX + rb._invInertia11 * rb._torqueY + rb._invInertia12 * rb._torqueZ; __tmp__Z = rb._invInertia20 * rb._torqueX + rb._invInertia21 * rb._torqueY + rb._invInertia22 * rb._torqueZ; angAccX = __tmp__X; angAccY = __tmp__Y; angAccZ = __tmp__Z; rb._velX += linAccX * dt; rb._velY += linAccY * dt; rb._velZ += linAccZ * dt; rb._velX *= linScale; rb._velY *= linScale; rb._velZ *= linScale; rb._angVelX += angAccX * dt; rb._angVelY += angAccY * dt; rb._angVelZ += angAccZ * dt; rb._angVelX *= angScale; rb._angVelY *= angScale; rb._angVelZ *= angScale; } rb._integrate(dt); var s = rb._shapeList; while (s != null) { var n = s._next; var tf1 = rb._ptransform; var tf2 = rb._transform; var _dst = s._ptransform; var src1 = s._localTransform; var __tmp__00 = void 0; var __tmp__01 = void 0; var __tmp__02 = void 0; var __tmp__10 = void 0; var __tmp__11 = void 0; var __tmp__12 = void 0; var __tmp__20 = void 0; var __tmp__21 = void 0; var __tmp__22 = void 0; __tmp__00 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; __tmp__01 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; __tmp__02 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; __tmp__10 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; __tmp__11 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; __tmp__12 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; __tmp__20 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; __tmp__21 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; __tmp__22 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; _dst._rotation00 = __tmp__00; _dst._rotation01 = __tmp__01; _dst._rotation02 = __tmp__02; _dst._rotation10 = __tmp__10; _dst._rotation11 = __tmp__11; _dst._rotation12 = __tmp__12; _dst._rotation20 = __tmp__20; _dst._rotation21 = __tmp__21; _dst._rotation22 = __tmp__22; var _tmp__X6 = void 0; var _tmp__Y6 = void 0; var _tmp__Z6 = void 0; _tmp__X6 = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; _tmp__Y6 = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; _tmp__Z6 = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; _dst._positionX = _tmp__X6; _dst._positionY = _tmp__Y6; _dst._positionZ = _tmp__Z6; _dst._positionX += tf1._positionX; _dst._positionY += tf1._positionY; _dst._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var __tmp__001 = void 0; var __tmp__011 = void 0; var __tmp__021 = void 0; var __tmp__101 = void 0; var __tmp__111 = void 0; var __tmp__121 = void 0; var __tmp__201 = void 0; var __tmp__211 = void 0; var __tmp__221 = void 0; __tmp__001 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; __tmp__011 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; __tmp__021 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; __tmp__101 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; __tmp__111 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; __tmp__121 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; __tmp__201 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; __tmp__211 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; __tmp__221 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = __tmp__001; dst1._rotation01 = __tmp__011; dst1._rotation02 = __tmp__021; dst1._rotation10 = __tmp__101; dst1._rotation11 = __tmp__111; dst1._rotation12 = __tmp__121; dst1._rotation20 = __tmp__201; dst1._rotation21 = __tmp__211; dst1._rotation22 = __tmp__221; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } } } }, { key: "_step", value: function _step(timeStep, numVelocityIterations, numPositionIterations) { var dt = timeStep.dt; var sleepIsland = true; var _g = 0; var _g1 = this.numRigidBodies; while (_g < _g1) { var rb = this.rigidBodies[_g++]; var dst = rb._ptransform; var src = rb._transform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; rb._linearContactImpulseX = 0; rb._linearContactImpulseY = 0; rb._linearContactImpulseZ = 0; rb._angularContactImpulseX = 0; rb._angularContactImpulseY = 0; rb._angularContactImpulseZ = 0; rb._sleeping = false; if (rb._autoSleep && rb._velX * rb._velX + rb._velY * rb._velY + rb._velZ * rb._velZ < oimo.common.Setting.sleepingVelocityThreshold * oimo.common.Setting.sleepingVelocityThreshold && rb._angVelX * rb._angVelX + rb._angVelY * rb._angVelY + rb._angVelZ * rb._angVelZ < oimo.common.Setting.sleepingAngularVelocityThreshold * oimo.common.Setting.sleepingAngularVelocityThreshold) { rb._sleepTime += dt; } else { rb._sleepTime = 0; } if (rb._sleepTime < oimo.common.Setting.sleepingTimeThreshold) { sleepIsland = false; } if (rb._type == 0) { var x = dt * rb._linearDamping; var x2 = x * x; var linScale = 1 / (1 + x + x2 * (0.5 + x * 0.16666666666666666 + x2 * 0.041666666666666664)); var x1 = dt * rb._angularDamping; var x21 = x1 * x1; var angScale = 1 / (1 + x1 + x21 * (0.5 + x1 * 0.16666666666666666 + x21 * 0.041666666666666664)); var linAccX = void 0; var linAccY = void 0; var linAccZ = void 0; var angAccX = void 0; var angAccY = void 0; var angAccZ = void 0; linAccX = this.gravityX * rb._gravityScale; linAccY = this.gravityY * rb._gravityScale; linAccZ = this.gravityZ * rb._gravityScale; linAccX += rb._forceX * rb._invMass; linAccY += rb._forceY * rb._invMass; linAccZ += rb._forceZ * rb._invMass; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = rb._invInertia00 * rb._torqueX + rb._invInertia01 * rb._torqueY + rb._invInertia02 * rb._torqueZ; __tmp__Y = rb._invInertia10 * rb._torqueX + rb._invInertia11 * rb._torqueY + rb._invInertia12 * rb._torqueZ; __tmp__Z = rb._invInertia20 * rb._torqueX + rb._invInertia21 * rb._torqueY + rb._invInertia22 * rb._torqueZ; angAccX = __tmp__X; angAccY = __tmp__Y; angAccZ = __tmp__Z; rb._velX += linAccX * dt; rb._velY += linAccY * dt; rb._velZ += linAccZ * dt; rb._velX *= linScale; rb._velY *= linScale; rb._velZ *= linScale; rb._angVelX += angAccX * dt; rb._angVelY += angAccY * dt; rb._angVelZ += angAccZ * dt; rb._angVelX *= angScale; rb._angVelY *= angScale; rb._angVelZ *= angScale; } } if (sleepIsland) { var _g35 = 0; var _g36 = this.numRigidBodies; while (_g35 < _g36) { var _rb = this.rigidBodies[_g35++]; _rb._sleeping = true; _rb._sleepTime = 0; } return; } var _g2 = 0; var _g3 = this.numSolvers; while (_g2 < _g3) { this.solvers[_g2++].preSolveVelocity(timeStep); } var _g4 = 0; var _g5 = this.numSolvers; while (_g4 < _g5) { this.solvers[_g4++].warmStart(timeStep); } var _g6 = 0; while (_g6 < numVelocityIterations) { ++_g6; var _g37 = 0; var _g38 = this.numSolvers; while (_g37 < _g38) { this.solvers[_g37++].solveVelocity(); } } var _g7 = 0; var _g8 = this.numSolvers; while (_g7 < _g8) { this.solvers[_g7++].postSolveVelocity(timeStep); } var _g9 = 0; var _g10 = this.numRigidBodies; while (_g9 < _g10) { this.rigidBodies[_g9++]._integrate(dt); } var _g11 = 0; var _g12 = this.numSolversSi; while (_g11 < _g12) { this.solversSi[_g11++].preSolvePosition(timeStep); } var _g13 = 0; while (_g13 < numPositionIterations) { ++_g13; var _g39 = 0; var _g40 = this.numSolversSi; while (_g39 < _g40) { this.solversSi[_g39++].solvePositionSplitImpulse(); } } var _g14 = 0; var _g15 = this.numRigidBodies; while (_g14 < _g15) { this.rigidBodies[_g14++]._integratePseudoVelocity(); } var _g16 = 0; var _g17 = this.numSolversNgs; while (_g16 < _g17) { this.solversNgs[_g16++].preSolvePosition(timeStep); } var _g18 = 0; while (_g18 < numPositionIterations) { ++_g18; var _g41 = 0; var _g42 = this.numSolversNgs; while (_g41 < _g42) { this.solversNgs[_g41++].solvePositionNgs(timeStep); } } var _g19 = 0; var _g20 = this.numSolvers; while (_g19 < _g20) { this.solvers[_g19++].postSolve(); } var _g21 = 0; var _g22 = this.numRigidBodies; while (_g21 < _g22) { var _rb2 = this.rigidBodies[_g21++]; var s = _rb2._shapeList; while (s != null) { var n = s._next; var tf1 = _rb2._ptransform; var tf2 = _rb2._transform; var _dst2 = s._ptransform; var src1 = s._localTransform; var __tmp__00 = void 0; var __tmp__01 = void 0; var __tmp__02 = void 0; var __tmp__10 = void 0; var __tmp__11 = void 0; var __tmp__12 = void 0; var __tmp__20 = void 0; var __tmp__21 = void 0; var __tmp__22 = void 0; __tmp__00 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; __tmp__01 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; __tmp__02 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; __tmp__10 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; __tmp__11 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; __tmp__12 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; __tmp__20 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; __tmp__21 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; __tmp__22 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; _dst2._rotation00 = __tmp__00; _dst2._rotation01 = __tmp__01; _dst2._rotation02 = __tmp__02; _dst2._rotation10 = __tmp__10; _dst2._rotation11 = __tmp__11; _dst2._rotation12 = __tmp__12; _dst2._rotation20 = __tmp__20; _dst2._rotation21 = __tmp__21; _dst2._rotation22 = __tmp__22; var _tmp__X7 = void 0; var _tmp__Y7 = void 0; var _tmp__Z7 = void 0; _tmp__X7 = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; _tmp__Y7 = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; _tmp__Z7 = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; _dst2._positionX = _tmp__X7; _dst2._positionY = _tmp__Y7; _dst2._positionZ = _tmp__Z7; _dst2._positionX += tf1._positionX; _dst2._positionY += tf1._positionY; _dst2._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var __tmp__001 = void 0; var __tmp__011 = void 0; var __tmp__021 = void 0; var __tmp__101 = void 0; var __tmp__111 = void 0; var __tmp__121 = void 0; var __tmp__201 = void 0; var __tmp__211 = void 0; var __tmp__221 = void 0; __tmp__001 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; __tmp__011 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; __tmp__021 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; __tmp__101 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; __tmp__111 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; __tmp__121 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; __tmp__201 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; __tmp__211 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; __tmp__221 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = __tmp__001; dst1._rotation01 = __tmp__011; dst1._rotation02 = __tmp__021; dst1._rotation10 = __tmp__101; dst1._rotation11 = __tmp__111; dst1._rotation12 = __tmp__121; dst1._rotation20 = __tmp__201; dst1._rotation21 = __tmp__211; dst1._rotation22 = __tmp__221; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } } } }]); return oimo_dynamics_Island; }(); oimo.dynamics.TimeStep = /*#__PURE__*/_createClass(function oimo_dynamics_TimeStep() { _classCallCheck(this, oimo_dynamics_TimeStep); this.dt = 0; this.invDt = 0; this.dtRatio = 1; }); oimo.dynamics.World = /*#__PURE__*/function () { function oimo_dynamics_World(broadPhaseType, gravity) { _classCallCheck(this, oimo_dynamics_World); if (broadPhaseType == null) { broadPhaseType = 2; } switch (broadPhaseType) { case 1: this._broadPhase = new oimo.collision.broadphase.bruteforce.BruteForceBroadPhase(); break; case 2: this._broadPhase = new oimo.collision.broadphase.bvh.BvhBroadPhase(); break; } this._contactManager = new oimo.dynamics.ContactManager(this._broadPhase); if (gravity == null) { gravity = new oimo.common.Vec3(0, -9.80665, 0); } this._gravity = new oimo.common.Vec3(gravity.x, gravity.y, gravity.z); this._rigidBodyList = null; this._rigidBodyListLast = null; this._jointList = null; this._jointListLast = null; this._numRigidBodies = 0; this._numShapes = 0; this._numJoints = 0; this._numIslands = 0; this._numVelocityIterations = 10; this._numPositionIterations = 5; this._rayCastWrapper = new oimo.dynamics._World.RayCastWrapper(); this._convexCastWrapper = new oimo.dynamics._World.ConvexCastWrapper(); this._aabbTestWrapper = new oimo.dynamics._World.AabbTestWrapper(); this._island = new oimo.dynamics.Island(); this._solversInIslands = new Array(oimo.common.Setting.islandInitialConstraintArraySize); this._rigidBodyStack = new Array(oimo.common.Setting.islandInitialRigidBodyArraySize); this._timeStep = new oimo.dynamics.TimeStep(); this._pool = new oimo.common.Pool(); this._shapeIdCount = 0; } _createClass(oimo_dynamics_World, [{ key: "_updateContacts", value: function _updateContacts() { var st = Date.now() / 1000; this._contactManager._updateContacts(); oimo.dynamics.common.Performance.broadPhaseCollisionTime = (Date.now() / 1000 - st) * 1000; var st1 = Date.now() / 1000; var c = this._contactManager._contactList; while (c != null) { var n = c._next; if (!c._shouldBeSkipped) { c._updateManifold(); } c = n; } oimo.dynamics.common.Performance.narrowPhaseCollisionTime = (Date.now() / 1000 - st1) * 1000; } }, { key: "_solveIslands", value: function _solveIslands() { var st = Date.now() / 1000; if (oimo.common.Setting.disableSleeping) { var _b54 = this._rigidBodyList; while (_b54 != null) { _b54._sleeping = false; _b54._sleepTime = 0; _b54 = _b54._next; } } if (this._rigidBodyStack.length < this._numRigidBodies) { var newStackSize = this._rigidBodyStack.length << 1; while (newStackSize < this._numRigidBodies) { newStackSize <<= 1; } this._rigidBodyStack = new Array(newStackSize); } this._numIslands = 0; var _this = this._island; var gravity = this._gravity; _this.gravityX = gravity.x; _this.gravityY = gravity.y; _this.gravityZ = gravity.z; var b = this._rigidBodyList; this._numSolversInIslands = 0; while (b != null) { var n = b._next; while (!(b._addedToIsland || b._sleeping || b._type == 1)) { if (b._numContactLinks == 0 && b._numJointLinks == 0) { this._island._stepSingleRigidBody(this._timeStep, b); this._numIslands++; break; } this.buildIsland(b); this._island._step(this._timeStep, this._numVelocityIterations, this._numPositionIterations); this._island._clear(); this._numIslands++; break; } b = n; } this._contactManager._postSolve(); b = this._rigidBodyList; while (b != null) { b._addedToIsland = false; b = b._next; } b = this._rigidBodyList; while (b != null) { b._forceX = 0; b._forceY = 0; b._forceZ = 0; b._torqueX = 0; b._torqueY = 0; b._torqueZ = 0; b = b._next; } while (this._numSolversInIslands > 0) { this._solversInIslands[--this._numSolversInIslands]._addedToIsland = false; this._solversInIslands[this._numSolversInIslands] = null; } oimo.dynamics.common.Performance.dynamicsTime = (Date.now() / 1000 - st) * 1000; } }, { key: "buildIsland", value: function buildIsland(base) { var stackCount = 1; this._island._addRigidBody(base); this._rigidBodyStack[0] = base; while (stackCount > 0) { var rb = this._rigidBodyStack[--stackCount]; this._rigidBodyStack[stackCount] = null; if (rb._type == 1) { continue; } var cl = rb._contactLinkList; while (cl != null) { var n = cl._next; var cc = cl._contact._contactConstraint; var ccs = cl._contact._contactConstraint._solver; if (cc.isTouching() && !ccs._addedToIsland) { if (this._solversInIslands.length == this._numSolversInIslands) { var newArray = new Array(this._numSolversInIslands << 1); var _g = 0; var _g1 = this._numSolversInIslands; while (_g < _g1) { var i = _g++; newArray[i] = this._solversInIslands[i]; this._solversInIslands[i] = null; } this._solversInIslands = newArray; } this._solversInIslands[this._numSolversInIslands++] = ccs; this._island._addConstraintSolver(ccs, cc._positionCorrectionAlgorithm); var other = cl._other; if (!other._addedToIsland) { this._island._addRigidBody(other); this._rigidBodyStack[stackCount++] = other; } } cl = n; } var jl = rb._jointLinkList; while (jl != null) { var _n2 = jl._next; var j = jl._joint; var js1 = j._solver; if (!js1._addedToIsland) { if (this._solversInIslands.length == this._numSolversInIslands) { var _newArray6 = new Array(this._numSolversInIslands << 1); var _g43 = 0; var _g44 = this._numSolversInIslands; while (_g43 < _g44) { var _i9 = _g43++; _newArray6[_i9] = this._solversInIslands[_i9]; this._solversInIslands[_i9] = null; } this._solversInIslands = _newArray6; } this._solversInIslands[this._numSolversInIslands++] = js1; this._island._addConstraintSolver(js1, j._positionCorrectionAlgorithm); var _other = jl._other; if (!_other._addedToIsland) { this._island._addRigidBody(_other); this._rigidBodyStack[stackCount++] = _other; } } jl = _n2; } } } }, { key: "_drawBvh", value: function _drawBvh(d, tree) { if (d.drawBvh) { this._drawBvhNode(d, tree._root, 0, d.style.bvhNodeColor); } } }, { key: "_drawBvhNode", value: function _drawBvhNode(d, node, level, color) { if (node == null) { return; } if (level >= d.drawBvhMinLevel && level <= d.drawBvhMaxLevel) { var _this = this._pool; var min = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; var _this1 = this._pool; var max = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3]; var v = min; v.x = node._aabbMinX; v.y = node._aabbMinY; v.z = node._aabbMinZ; var v1 = max; v1.x = node._aabbMaxX; v1.y = node._aabbMaxY; v1.z = node._aabbMaxZ; d.aabb(min, max, color); var _this2 = this._pool; if (min != null) { min.zero(); if (_this2.sizeVec3 == _this2.stackVec3.length) { var newArray = new Array(_this2.sizeVec3 << 1); var _g = 0; var _g1 = _this2.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = _this2.stackVec3[i]; _this2.stackVec3[i] = null; } _this2.stackVec3 = newArray; } _this2.stackVec3[_this2.sizeVec3++] = min; } var _this3 = this._pool; if (max != null) { max.zero(); if (_this3.sizeVec3 == _this3.stackVec3.length) { var _newArray7 = new Array(_this3.sizeVec3 << 1); var _g45 = 0; var _g46 = _this3.sizeVec3; while (_g45 < _g46) { var _i10 = _g45++; _newArray7[_i10] = _this3.stackVec3[_i10]; _this3.stackVec3[_i10] = null; } _this3.stackVec3 = _newArray7; } _this3.stackVec3[_this3.sizeVec3++] = max; } } this._drawBvhNode(d, node._children[0], level + 1, color); this._drawBvhNode(d, node._children[1], level + 1, color); } }, { key: "_drawRigidBodies", value: function _drawRigidBodies(d) { var style = d.style; var r = this._rigidBodyList; while (r != null) { var n = r._next; if (d.drawBases) { var _style = d.style; d.basis(r._transform, _style.basisLength, _style.basisColorX, _style.basisColorY, _style.basisColorZ); } var shapeColor = null; var isDynamic = r._type == 0; if (!isDynamic) { shapeColor = r._type == 2 ? style.kinematicShapeColor : style.staticShapeColor; } var s = r._shapeList; while (s != null) { var _n3 = s._next; if (isDynamic) { if ((s._id & 1) == 0) { shapeColor = r._sleeping ? style.sleepingShapeColor1 : r._sleepTime > oimo.common.Setting.sleepingTimeThreshold ? style.sleepyShapeColor1 : style.shapeColor1; } else { shapeColor = r._sleeping ? style.sleepingShapeColor2 : r._sleepTime > oimo.common.Setting.sleepingTimeThreshold ? style.sleepyShapeColor2 : style.shapeColor2; } } if (d.drawShapes) { var geom = s._geom; var tf = s._transform; switch (geom._type) { case 0: d.sphere(tf, geom._radius, shapeColor); break; case 1: var g = geom; var _this = this._pool; var hx = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; var v = hx; v.x = g._halfExtentsX; v.y = g._halfExtentsY; v.z = g._halfExtentsZ; d.box(tf, hx, shapeColor); var _this1 = this._pool; if (hx != null) { hx.zero(); if (_this1.sizeVec3 == _this1.stackVec3.length) { var newArray = new Array(_this1.sizeVec3 << 1); var _g47 = 0; var _g1 = _this1.sizeVec3; while (_g47 < _g1) { var i = _g47++; newArray[i] = _this1.stackVec3[i]; _this1.stackVec3[i] = null; } _this1.stackVec3 = newArray; } _this1.stackVec3[_this1.sizeVec3++] = hx; } break; case 2: var g1 = geom; d.cylinder(tf, g1._radius, g1._halfHeight, shapeColor); break; case 3: var g2 = geom; d.cone(tf, g2._radius, g2._halfHeight, shapeColor); break; case 4: var g3 = geom; d.capsule(tf, g3._radius, g3._halfHeight, shapeColor); break; case 5: var g4 = geom; var _n4 = g4._numVertices; var _this2 = this._pool; var v1 = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3]; var _this3 = this._pool; var v2 = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3]; var _this4 = this._pool; var v3 = _this4.sizeVec3 == 0 ? new oimo.common.Vec3() : _this4.stackVec3[--_this4.sizeVec3]; var _this5 = this._pool; var v12 = _this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3]; var _this6 = this._pool; var v13 = _this6.sizeVec3 == 0 ? new oimo.common.Vec3() : _this6.stackVec3[--_this6.sizeVec3]; var _this7 = this._pool; var normal = _this7.sizeVec3 == 0 ? new oimo.common.Vec3() : _this7.stackVec3[--_this7.sizeVec3]; var _this8 = this._pool; var m = _this8.sizeMat3 == 0 ? new oimo.common.Mat3() : _this8.stackMat3[--_this8.sizeMat3]; var _this9 = this._pool; var o = _this9.sizeVec3 == 0 ? new oimo.common.Vec3() : _this9.stackVec3[--_this9.sizeVec3]; var m1 = m; m1.e00 = tf._rotation00; m1.e01 = tf._rotation01; m1.e02 = tf._rotation02; m1.e10 = tf._rotation10; m1.e11 = tf._rotation11; m1.e12 = tf._rotation12; m1.e20 = tf._rotation20; m1.e21 = tf._rotation21; m1.e22 = tf._rotation22; var v4 = o; v4.x = tf._positionX; v4.y = tf._positionY; v4.z = tf._positionZ; var _g = 0; while (_g < _n4) { var _i11 = _g++; var _this85 = g4._tmpVertices[_i11]; var _v35 = g4._vertices[_i11]; _this85.x = _v35.x; _this85.y = _v35.y; _this85.z = _v35.z; var y = _this85.x * m.e10 + _this85.y * m.e11 + _this85.z * m.e12; var z = _this85.x * m.e20 + _this85.y * m.e21 + _this85.z * m.e22; _this85.x = _this85.x * m.e00 + _this85.y * m.e01 + _this85.z * m.e02; _this85.y = y; _this85.z = z; _this85.x += o.x; _this85.y += o.y; _this85.z += o.z; } if (_n4 > 30) { var _g48 = 0; while (_g48 < _n4) { var _i12 = _g48++; var _v36 = g4._tmpVertices[_i12]; v1.x = _v36.x; v1.y = _v36.y; v1.z = _v36.z; var _v37 = g4._tmpVertices[(_i12 + 1) % _n4]; v2.x = _v37.x; v2.y = _v37.y; v2.z = _v37.z; d.line(v1, v2, shapeColor); } } else if (this._debugDraw.wireframe || _n4 > 10) { var _g49 = 0; while (_g49 < _n4) { var _i13 = _g49++; var _v38 = g4._tmpVertices[_i13]; v1.x = _v38.x; v1.y = _v38.y; v1.z = _v38.z; var _g50 = 0; while (_g50 < _i13) { var _v39 = g4._tmpVertices[_g50++]; v2.x = _v39.x; v2.y = _v39.y; v2.z = _v39.z; d.line(v1, v2, shapeColor); } } } else { var _g51 = 0; while (_g51 < _n4) { var _i14 = _g51++; var _v40 = g4._tmpVertices[_i14]; v1.x = _v40.x; v1.y = _v40.y; v1.z = _v40.z; var _g52 = 0; while (_g52 < _i14) { var j = _g52++; var _v41 = g4._tmpVertices[j]; v2.x = _v41.x; v2.y = _v41.y; v2.z = _v41.z; var _g53 = 0; while (_g53 < j) { var _v42 = g4._tmpVertices[_g53++]; v3.x = _v42.x; v3.y = _v42.y; v3.z = _v42.z; v12.x = v2.x; v12.y = v2.y; v12.z = v2.z; var _this86 = v12; _this86.x -= v1.x; _this86.y -= v1.y; _this86.z -= v1.z; v13.x = v3.x; v13.y = v3.y; v13.z = v3.z; var _this87 = v13; _this87.x -= v1.x; _this87.y -= v1.y; _this87.z -= v1.z; normal.x = v12.x; normal.y = v12.y; normal.z = v12.z; var _this88 = normal; var _y3 = _this88.z * v13.x - _this88.x * v13.z; var _z3 = _this88.x * v13.y - _this88.y * v13.x; _this88.x = _this88.y * v13.z - _this88.z * v13.y; _this88.y = _y3; _this88.z = _z3; var invLen = Math.sqrt(_this88.x * _this88.x + _this88.y * _this88.y + _this88.z * _this88.z); if (invLen > 0) { invLen = 1 / invLen; } _this88.x *= invLen; _this88.y *= invLen; _this88.z *= invLen; d.triangle(v1, v2, v3, normal, normal, normal, shapeColor); normal.x = -normal.x; normal.y = -normal.y; normal.z = -normal.z; d.triangle(v1, v3, v2, normal, normal, normal, shapeColor); } } } } var _this10 = this._pool; if (v1 != null) { v1.zero(); if (_this10.sizeVec3 == _this10.stackVec3.length) { var _newArray8 = new Array(_this10.sizeVec3 << 1); var _g54 = 0; var _g55 = _this10.sizeVec3; while (_g54 < _g55) { var _i15 = _g54++; _newArray8[_i15] = _this10.stackVec3[_i15]; _this10.stackVec3[_i15] = null; } _this10.stackVec3 = _newArray8; } _this10.stackVec3[_this10.sizeVec3++] = v1; } var _this11 = this._pool; if (v2 != null) { v2.zero(); if (_this11.sizeVec3 == _this11.stackVec3.length) { var _newArray9 = new Array(_this11.sizeVec3 << 1); var _g56 = 0; var _g57 = _this11.sizeVec3; while (_g56 < _g57) { var _i16 = _g56++; _newArray9[_i16] = _this11.stackVec3[_i16]; _this11.stackVec3[_i16] = null; } _this11.stackVec3 = _newArray9; } _this11.stackVec3[_this11.sizeVec3++] = v2; } var _this12 = this._pool; if (v3 != null) { v3.zero(); if (_this12.sizeVec3 == _this12.stackVec3.length) { var _newArray10 = new Array(_this12.sizeVec3 << 1); var _g58 = 0; var _g59 = _this12.sizeVec3; while (_g58 < _g59) { var _i17 = _g58++; _newArray10[_i17] = _this12.stackVec3[_i17]; _this12.stackVec3[_i17] = null; } _this12.stackVec3 = _newArray10; } _this12.stackVec3[_this12.sizeVec3++] = v3; } var _this13 = this._pool; if (v12 != null) { v12.zero(); if (_this13.sizeVec3 == _this13.stackVec3.length) { var _newArray11 = new Array(_this13.sizeVec3 << 1); var _g60 = 0; var _g61 = _this13.sizeVec3; while (_g60 < _g61) { var _i18 = _g60++; _newArray11[_i18] = _this13.stackVec3[_i18]; _this13.stackVec3[_i18] = null; } _this13.stackVec3 = _newArray11; } _this13.stackVec3[_this13.sizeVec3++] = v12; } var _this14 = this._pool; if (v13 != null) { v13.zero(); if (_this14.sizeVec3 == _this14.stackVec3.length) { var _newArray12 = new Array(_this14.sizeVec3 << 1); var _g62 = 0; var _g63 = _this14.sizeVec3; while (_g62 < _g63) { var _i19 = _g62++; _newArray12[_i19] = _this14.stackVec3[_i19]; _this14.stackVec3[_i19] = null; } _this14.stackVec3 = _newArray12; } _this14.stackVec3[_this14.sizeVec3++] = v13; } var _this15 = this._pool; if (normal != null) { normal.zero(); if (_this15.sizeVec3 == _this15.stackVec3.length) { var _newArray13 = new Array(_this15.sizeVec3 << 1); var _g64 = 0; var _g65 = _this15.sizeVec3; while (_g64 < _g65) { var _i20 = _g64++; _newArray13[_i20] = _this15.stackVec3[_i20]; _this15.stackVec3[_i20] = null; } _this15.stackVec3 = _newArray13; } _this15.stackVec3[_this15.sizeVec3++] = normal; } var _this16 = this._pool; if (m != null) { m.e00 = 1; m.e01 = 0; m.e02 = 0; m.e10 = 0; m.e11 = 1; m.e12 = 0; m.e20 = 0; m.e21 = 0; m.e22 = 1; if (_this16.sizeMat3 == _this16.stackMat3.length) { var _newArray14 = new Array(_this16.sizeMat3 << 1); var _g66 = 0; var _g67 = _this16.sizeMat3; while (_g66 < _g67) { var _i21 = _g66++; _newArray14[_i21] = _this16.stackMat3[_i21]; _this16.stackMat3[_i21] = null; } _this16.stackMat3 = _newArray14; } _this16.stackMat3[_this16.sizeMat3++] = m; } var _this17 = this._pool; if (o != null) { o.zero(); if (_this17.sizeVec3 == _this17.stackVec3.length) { var _newArray15 = new Array(_this17.sizeVec3 << 1); var _g68 = 0; var _g69 = _this17.sizeVec3; while (_g68 < _g69) { var _i22 = _g68++; _newArray15[_i22] = _this17.stackVec3[_i22]; _this17.stackVec3[_i22] = null; } _this17.stackVec3 = _newArray15; } _this17.stackVec3[_this17.sizeVec3++] = o; } break; } } if (d.drawAabbs) { var aabb = s._aabb; var color = style.aabbColor; var _this89 = this._pool; var min = _this89.sizeVec3 == 0 ? new oimo.common.Vec3() : _this89.stackVec3[--_this89.sizeVec3]; var _this90 = this._pool; var max = _this90.sizeVec3 == 0 ? new oimo.common.Vec3() : _this90.stackVec3[--_this90.sizeVec3]; var _v43 = min; _v43.x = aabb._minX; _v43.y = aabb._minY; _v43.z = aabb._minZ; var _v44 = max; _v44.x = aabb._maxX; _v44.y = aabb._maxY; _v44.z = aabb._maxZ; d.aabb(min, max, color); var _this91 = this._pool; if (min != null) { min.zero(); if (_this91.sizeVec3 == _this91.stackVec3.length) { var _newArray16 = new Array(_this91.sizeVec3 << 1); var _g70 = 0; var _g71 = _this91.sizeVec3; while (_g70 < _g71) { var _i23 = _g70++; _newArray16[_i23] = _this91.stackVec3[_i23]; _this91.stackVec3[_i23] = null; } _this91.stackVec3 = _newArray16; } _this91.stackVec3[_this91.sizeVec3++] = min; } var _this92 = this._pool; if (max != null) { max.zero(); if (_this92.sizeVec3 == _this92.stackVec3.length) { var _newArray17 = new Array(_this92.sizeVec3 << 1); var _g72 = 0; var _g73 = _this92.sizeVec3; while (_g72 < _g73) { var _i24 = _g72++; _newArray17[_i24] = _this92.stackVec3[_i24]; _this92.stackVec3[_i24] = null; } _this92.stackVec3 = _newArray17; } _this92.stackVec3[_this92.sizeVec3++] = max; } } s = _n3; } r = n; } } }, { key: "_drawConstraints", value: function _drawConstraints(d) { var style = d.style; if (d.drawPairs || d.drawContacts) { var c = this._contactManager._contactList; while (c != null) { var n = c._next; if (d.drawPairs) { var color = style.pairColor; var _this = this._pool; var v1 = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; var _this1 = this._pool; var v2 = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3]; var v = v1; v.x = c._s1._transform._positionX; v.y = c._s1._transform._positionY; v.z = c._s1._transform._positionZ; var v3 = v2; v3.x = c._s2._transform._positionX; v3.y = c._s2._transform._positionY; v3.z = c._s2._transform._positionZ; d.line(v1, v2, color); var _this2 = this._pool; if (v1 != null) { v1.zero(); if (_this2.sizeVec3 == _this2.stackVec3.length) { var newArray = new Array(_this2.sizeVec3 << 1); var _g = 0; var _g1 = _this2.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = _this2.stackVec3[i]; _this2.stackVec3[i] = null; } _this2.stackVec3 = newArray; } _this2.stackVec3[_this2.sizeVec3++] = v1; } var _this3 = this._pool; if (v2 != null) { v2.zero(); if (_this3.sizeVec3 == _this3.stackVec3.length) { var _newArray18 = new Array(_this3.sizeVec3 << 1); var _g74 = 0; var _g75 = _this3.sizeVec3; while (_g74 < _g75) { var _i25 = _g74++; _newArray18[_i25] = _this3.stackVec3[_i25]; _this3.stackVec3[_i25] = null; } _this3.stackVec3 = _newArray18; } _this3.stackVec3[_this3.sizeVec3++] = v2; } } if (d.drawContacts) { var cc = c._contactConstraint; var ps = c._contactConstraint._manifold._points; var _g76 = 0; var _g77 = c._contactConstraint._manifold._numPoints; while (_g76 < _g77) { var p = ps[_g76++]; var _style2 = d.style; var _this93 = this._pool; var pos1 = _this93.sizeVec3 == 0 ? new oimo.common.Vec3() : _this93.stackVec3[--_this93.sizeVec3]; var _this94 = this._pool; var pos2 = _this94.sizeVec3 == 0 ? new oimo.common.Vec3() : _this94.stackVec3[--_this94.sizeVec3]; var _this95 = this._pool; var normal = _this95.sizeVec3 == 0 ? new oimo.common.Vec3() : _this95.stackVec3[--_this95.sizeVec3]; var _this96 = this._pool; var tangent = _this96.sizeVec3 == 0 ? new oimo.common.Vec3() : _this96.stackVec3[--_this96.sizeVec3]; var _this4 = this._pool; var binormal = _this4.sizeVec3 == 0 ? new oimo.common.Vec3() : _this4.stackVec3[--_this4.sizeVec3]; var _v45 = pos1; _v45.x = p._pos1X; _v45.y = p._pos1Y; _v45.z = p._pos1Z; var _v46 = pos2; _v46.x = p._pos2X; _v46.y = p._pos2Y; _v46.z = p._pos2Z; var _v47 = normal; _v47.x = cc._manifold._normalX; _v47.y = cc._manifold._normalY; _v47.z = cc._manifold._normalZ; var _v48 = tangent; _v48.x = cc._manifold._tangentX; _v48.y = cc._manifold._tangentY; _v48.z = cc._manifold._tangentZ; var v4 = binormal; v4.x = cc._manifold._binormalX; v4.y = cc._manifold._binormalY; v4.z = cc._manifold._binormalZ; if (p._disabled) { d.point(pos1, _style2.disabledContactColor); d.point(pos2, _style2.disabledContactColor); d.line(pos1, pos2, _style2.disabledContactColor); } else if (p._warmStarted) { var _color = void 0; switch (p._id & 3) { case 0: _color = _style2.contactColor; break; case 1: _color = _style2.contactColor2; break; case 2: _color = _style2.contactColor3; break; default: _color = _style2.contactColor4; } d.point(pos1, _color); d.point(pos2, _color); d.line(pos1, pos2, _style2.contactColor); } else { d.point(pos1, _style2.newContactColor); d.point(pos2, _style2.newContactColor); d.line(pos1, pos2, _style2.newContactColor); } pos2.x = pos1.x; pos2.y = pos1.y; pos2.z = pos1.z; var _this5 = pos2; var s = _style2.contactNormalLength; _this5.x += normal.x * s; _this5.y += normal.y * s; _this5.z += normal.z * s; d.line(pos1, pos2, _style2.contactNormalColor); if (d.drawContactBases) { pos2.x = pos1.x; pos2.y = pos1.y; pos2.z = pos1.z; var _this97 = pos2; var _s7 = _style2.contactTangentLength; _this97.x += tangent.x * _s7; _this97.y += tangent.y * _s7; _this97.z += tangent.z * _s7; d.line(pos1, pos2, _style2.contactTangentColor); pos2.x = pos1.x; pos2.y = pos1.y; pos2.z = pos1.z; var _this98 = pos2; var s1 = _style2.contactBinormalLength; _this98.x += binormal.x * s1; _this98.y += binormal.y * s1; _this98.z += binormal.z * s1; d.line(pos1, pos2, _style2.contactBinormalColor); } var _this6 = this._pool; if (pos1 != null) { pos1.zero(); if (_this6.sizeVec3 == _this6.stackVec3.length) { var _newArray19 = new Array(_this6.sizeVec3 << 1); var _g78 = 0; var _g79 = _this6.sizeVec3; while (_g78 < _g79) { var _i26 = _g78++; _newArray19[_i26] = _this6.stackVec3[_i26]; _this6.stackVec3[_i26] = null; } _this6.stackVec3 = _newArray19; } _this6.stackVec3[_this6.sizeVec3++] = pos1; } var _this7 = this._pool; if (pos2 != null) { pos2.zero(); if (_this7.sizeVec3 == _this7.stackVec3.length) { var _newArray20 = new Array(_this7.sizeVec3 << 1); var _g80 = 0; var _g81 = _this7.sizeVec3; while (_g80 < _g81) { var _i27 = _g80++; _newArray20[_i27] = _this7.stackVec3[_i27]; _this7.stackVec3[_i27] = null; } _this7.stackVec3 = _newArray20; } _this7.stackVec3[_this7.sizeVec3++] = pos2; } var _this8 = this._pool; if (normal != null) { normal.zero(); if (_this8.sizeVec3 == _this8.stackVec3.length) { var _newArray21 = new Array(_this8.sizeVec3 << 1); var _g82 = 0; var _g83 = _this8.sizeVec3; while (_g82 < _g83) { var _i28 = _g82++; _newArray21[_i28] = _this8.stackVec3[_i28]; _this8.stackVec3[_i28] = null; } _this8.stackVec3 = _newArray21; } _this8.stackVec3[_this8.sizeVec3++] = normal; } var _this9 = this._pool; if (tangent != null) { tangent.zero(); if (_this9.sizeVec3 == _this9.stackVec3.length) { var _newArray22 = new Array(_this9.sizeVec3 << 1); var _g84 = 0; var _g85 = _this9.sizeVec3; while (_g84 < _g85) { var _i29 = _g84++; _newArray22[_i29] = _this9.stackVec3[_i29]; _this9.stackVec3[_i29] = null; } _this9.stackVec3 = _newArray22; } _this9.stackVec3[_this9.sizeVec3++] = tangent; } var _this10 = this._pool; if (binormal != null) { binormal.zero(); if (_this10.sizeVec3 == _this10.stackVec3.length) { var _newArray23 = new Array(_this10.sizeVec3 << 1); var _g86 = 0; var _g87 = _this10.sizeVec3; while (_g86 < _g87) { var _i30 = _g86++; _newArray23[_i30] = _this10.stackVec3[_i30]; _this10.stackVec3[_i30] = null; } _this10.stackVec3 = _newArray23; } _this10.stackVec3[_this10.sizeVec3++] = binormal; } } } c = n; } } if (d.drawJoints) { var j = this._jointList; while (j != null) { var _n5 = j._next; var _this99 = this._pool; var p1 = _this99.sizeVec3 == 0 ? new oimo.common.Vec3() : _this99.stackVec3[--_this99.sizeVec3]; var _this100 = this._pool; var p2 = _this100.sizeVec3 == 0 ? new oimo.common.Vec3() : _this100.stackVec3[--_this100.sizeVec3]; var _v49 = p1; _v49.x = j._b1._transform._positionX; _v49.y = j._b1._transform._positionY; _v49.z = j._b1._transform._positionZ; var _v50 = p2; _v50.x = j._b2._transform._positionX; _v50.y = j._b2._transform._positionY; _v50.z = j._b2._transform._positionZ; var _this101 = this._pool; var anchor1 = _this101.sizeVec3 == 0 ? new oimo.common.Vec3() : _this101.stackVec3[--_this101.sizeVec3]; var _this102 = this._pool; var anchor2 = _this102.sizeVec3 == 0 ? new oimo.common.Vec3() : _this102.stackVec3[--_this102.sizeVec3]; var _this103 = this._pool; var basisX1 = _this103.sizeVec3 == 0 ? new oimo.common.Vec3() : _this103.stackVec3[--_this103.sizeVec3]; var _this104 = this._pool; var basisY1 = _this104.sizeVec3 == 0 ? new oimo.common.Vec3() : _this104.stackVec3[--_this104.sizeVec3]; var _this105 = this._pool; var basisZ1 = _this105.sizeVec3 == 0 ? new oimo.common.Vec3() : _this105.stackVec3[--_this105.sizeVec3]; var _this106 = this._pool; var basisX2 = _this106.sizeVec3 == 0 ? new oimo.common.Vec3() : _this106.stackVec3[--_this106.sizeVec3]; var _this107 = this._pool; var basisY2 = _this107.sizeVec3 == 0 ? new oimo.common.Vec3() : _this107.stackVec3[--_this107.sizeVec3]; var _this108 = this._pool; var basisZ2 = _this108.sizeVec3 == 0 ? new oimo.common.Vec3() : _this108.stackVec3[--_this108.sizeVec3]; var _v51 = anchor1; _v51.x = j._anchor1X; _v51.y = j._anchor1Y; _v51.z = j._anchor1Z; var _v52 = anchor2; _v52.x = j._anchor2X; _v52.y = j._anchor2Y; _v52.z = j._anchor2Z; var _v53 = basisX1; _v53.x = j._basisX1X; _v53.y = j._basisX1Y; _v53.z = j._basisX1Z; var v5 = basisY1; v5.x = j._basisY1X; v5.y = j._basisY1Y; v5.z = j._basisY1Z; var v6 = basisZ1; v6.x = j._basisZ1X; v6.y = j._basisZ1Y; v6.z = j._basisZ1Z; var v7 = basisX2; v7.x = j._basisX2X; v7.y = j._basisX2Y; v7.z = j._basisX2Z; var v8 = basisY2; v8.x = j._basisY2X; v8.y = j._basisY2Y; v8.z = j._basisY2Z; var v9 = basisZ2; v9.x = j._basisZ2X; v9.y = j._basisZ2Y; v9.z = j._basisZ2Z; d.line(p1, anchor1, d.style.jointLineColor); d.line(p2, anchor2, d.style.jointLineColor); if (d.drawJointLimits) { switch (j._type) { case 0: break; case 1: var lm = j._lm; this._drawRotationalLimit(d, anchor1, basisY1, basisZ1, basisY2, d.style.jointRotationalConstraintRadius, lm.lowerLimit, lm.upperLimit, d.style.jointLineColor); break; case 2: var j1 = j; var _color2 = d.style.jointLineColor; var rlm = j1._rotLm; var tlm = j1._translLm; this._drawRotationalLimit(d, anchor2, basisY1, basisZ1, basisY2, d.style.jointRotationalConstraintRadius, rlm.lowerLimit, rlm.upperLimit, _color2); this._drawTranslationalLimit(d, anchor1, basisX1, tlm.lowerLimit, tlm.upperLimit, _color2); break; case 3: var lm1 = j._lm; this._drawTranslationalLimit(d, anchor1, basisX1, lm1.lowerLimit, lm1.upperLimit, d.style.jointLineColor); break; case 4: var j2 = j; var radius = d.style.jointRotationalConstraintRadius; var color1 = d.style.jointLineColor; var lm11 = j2._lm1; var lm2 = j2._lm2; this._drawRotationalLimit(d, anchor1, basisY1, basisZ1, basisY1, radius, j2._angleX - lm11.upperLimit, j2._angleX - lm11.lowerLimit, color1); this._drawRotationalLimit(d, anchor2, basisX2, basisY2, basisX2, radius, lm2.lowerLimit - j2._angleZ, lm2.upperLimit - j2._angleZ, color1); break; case 5: var j3 = j; var radius1 = d.style.jointRotationalConstraintRadius; var color2 = d.style.jointLineColor; var lm3 = j3._twistLm; this._drawRotationalLimit(d, anchor2, basisY2, basisZ2, basisY2, radius1, lm3.lowerLimit - j3._twistAngle, lm3.upperLimit - j3._twistAngle, color2); this._drawEllipseOnSphere(d, anchor1, basisX1, basisY1, basisZ1, j3._maxSwingAngle1, j3._maxSwingAngle2, radius1, color2); var _this109 = this._pool; var _this11 = _this109.sizeVec3 == 0 ? new oimo.common.Vec3() : _this109.stackVec3[--_this109.sizeVec3]; _this11.x = anchor2.x; _this11.y = anchor2.y; _this11.z = anchor2.z; var _this12 = _this11; _this12.x += basisX2.x * radius1; _this12.y += basisX2.y * radius1; _this12.z += basisX2.z * radius1; d.line(anchor2, _this12, color2); var _this13 = this._pool; if (_this12 != null) { _this12.zero(); if (_this13.sizeVec3 == _this13.stackVec3.length) { var _newArray24 = new Array(_this13.sizeVec3 << 1); var _g88 = 0; var _g89 = _this13.sizeVec3; while (_g88 < _g89) { var _i31 = _g88++; _newArray24[_i31] = _this13.stackVec3[_i31]; _this13.stackVec3[_i31] = null; } _this13.stackVec3 = _newArray24; } _this13.stackVec3[_this13.sizeVec3++] = _this12; } break; case 6: var j4 = j; var radius2 = d.style.jointRotationalConstraintRadius; var color3 = d.style.jointLineColor; var rxlm = j4._rotLms[0]; var rylm = j4._rotLms[1]; var rzlm = j4._rotLms[2]; this._drawTranslationalLimit3D(d, anchor1, basisX1, basisY1, basisZ1, j4._translLms[0], j4._translLms[1], j4._translLms[2], color3); var _this14 = this._pool; var rotYAxis = _this14.sizeVec3 == 0 ? new oimo.common.Vec3() : _this14.stackVec3[--_this14.sizeVec3]; var v10 = rotYAxis; v10.x = j4._axisYX; v10.y = j4._axisYY; v10.z = j4._axisYZ; var _this15 = this._pool; var _this16 = _this15.sizeVec3 == 0 ? new oimo.common.Vec3() : _this15.stackVec3[--_this15.sizeVec3]; _this16.x = basisX1.x; _this16.y = basisX1.y; _this16.z = basisX1.z; var rotYBasisX = _this16; var _this17 = this._pool; var _this18 = _this17.sizeVec3 == 0 ? new oimo.common.Vec3() : _this17.stackVec3[--_this17.sizeVec3]; _this18.x = basisX1.x; _this18.y = basisX1.y; _this18.z = basisX1.z; var _this19 = _this18; var y = _this19.z * rotYAxis.x - _this19.x * rotYAxis.z; var z = _this19.x * rotYAxis.y - _this19.y * rotYAxis.x; _this19.x = _this19.y * rotYAxis.z - _this19.z * rotYAxis.y; _this19.y = y; _this19.z = z; this._drawRotationalLimit(d, anchor2, basisY1, basisZ1, basisY1, radius2, j4._angleX - rxlm.upperLimit, j4._angleX - rxlm.lowerLimit, color3); this._drawRotationalLimit(d, anchor2, rotYBasisX, _this19, rotYBasisX, radius2, rylm.lowerLimit - j4._angleY, rylm.upperLimit - j4._angleY, color3); this._drawRotationalLimit(d, anchor2, basisX2, basisY2, basisX2, radius2, rzlm.lowerLimit - j4._angleZ, rzlm.upperLimit - j4._angleZ, color3); break; } } d.line(anchor1, anchor2, d.style.jointErrorColor); var _this20 = this._pool; if (p1 != null) { p1.zero(); if (_this20.sizeVec3 == _this20.stackVec3.length) { var _newArray25 = new Array(_this20.sizeVec3 << 1); var _g90 = 0; var _g91 = _this20.sizeVec3; while (_g90 < _g91) { var _i32 = _g90++; _newArray25[_i32] = _this20.stackVec3[_i32]; _this20.stackVec3[_i32] = null; } _this20.stackVec3 = _newArray25; } _this20.stackVec3[_this20.sizeVec3++] = p1; } var _this21 = this._pool; if (p2 != null) { p2.zero(); if (_this21.sizeVec3 == _this21.stackVec3.length) { var _newArray26 = new Array(_this21.sizeVec3 << 1); var _g92 = 0; var _g93 = _this21.sizeVec3; while (_g92 < _g93) { var _i33 = _g92++; _newArray26[_i33] = _this21.stackVec3[_i33]; _this21.stackVec3[_i33] = null; } _this21.stackVec3 = _newArray26; } _this21.stackVec3[_this21.sizeVec3++] = p2; } var _this22 = this._pool; if (anchor1 != null) { anchor1.zero(); if (_this22.sizeVec3 == _this22.stackVec3.length) { var _newArray27 = new Array(_this22.sizeVec3 << 1); var _g94 = 0; var _g95 = _this22.sizeVec3; while (_g94 < _g95) { var _i34 = _g94++; _newArray27[_i34] = _this22.stackVec3[_i34]; _this22.stackVec3[_i34] = null; } _this22.stackVec3 = _newArray27; } _this22.stackVec3[_this22.sizeVec3++] = anchor1; } var _this23 = this._pool; if (anchor2 != null) { anchor2.zero(); if (_this23.sizeVec3 == _this23.stackVec3.length) { var _newArray28 = new Array(_this23.sizeVec3 << 1); var _g96 = 0; var _g97 = _this23.sizeVec3; while (_g96 < _g97) { var _i35 = _g96++; _newArray28[_i35] = _this23.stackVec3[_i35]; _this23.stackVec3[_i35] = null; } _this23.stackVec3 = _newArray28; } _this23.stackVec3[_this23.sizeVec3++] = anchor2; } var _this24 = this._pool; if (basisX1 != null) { basisX1.zero(); if (_this24.sizeVec3 == _this24.stackVec3.length) { var _newArray29 = new Array(_this24.sizeVec3 << 1); var _g98 = 0; var _g99 = _this24.sizeVec3; while (_g98 < _g99) { var _i36 = _g98++; _newArray29[_i36] = _this24.stackVec3[_i36]; _this24.stackVec3[_i36] = null; } _this24.stackVec3 = _newArray29; } _this24.stackVec3[_this24.sizeVec3++] = basisX1; } var _this25 = this._pool; if (basisY1 != null) { basisY1.zero(); if (_this25.sizeVec3 == _this25.stackVec3.length) { var _newArray30 = new Array(_this25.sizeVec3 << 1); var _g100 = 0; var _g101 = _this25.sizeVec3; while (_g100 < _g101) { var _i37 = _g100++; _newArray30[_i37] = _this25.stackVec3[_i37]; _this25.stackVec3[_i37] = null; } _this25.stackVec3 = _newArray30; } _this25.stackVec3[_this25.sizeVec3++] = basisY1; } var _this26 = this._pool; if (basisZ1 != null) { basisZ1.zero(); if (_this26.sizeVec3 == _this26.stackVec3.length) { var _newArray31 = new Array(_this26.sizeVec3 << 1); var _g102 = 0; var _g103 = _this26.sizeVec3; while (_g102 < _g103) { var _i38 = _g102++; _newArray31[_i38] = _this26.stackVec3[_i38]; _this26.stackVec3[_i38] = null; } _this26.stackVec3 = _newArray31; } _this26.stackVec3[_this26.sizeVec3++] = basisZ1; } var _this27 = this._pool; if (basisX2 != null) { basisX2.zero(); if (_this27.sizeVec3 == _this27.stackVec3.length) { var _newArray32 = new Array(_this27.sizeVec3 << 1); var _g104 = 0; var _g105 = _this27.sizeVec3; while (_g104 < _g105) { var _i39 = _g104++; _newArray32[_i39] = _this27.stackVec3[_i39]; _this27.stackVec3[_i39] = null; } _this27.stackVec3 = _newArray32; } _this27.stackVec3[_this27.sizeVec3++] = basisX2; } var _this28 = this._pool; if (basisY2 != null) { basisY2.zero(); if (_this28.sizeVec3 == _this28.stackVec3.length) { var _newArray33 = new Array(_this28.sizeVec3 << 1); var _g106 = 0; var _g107 = _this28.sizeVec3; while (_g106 < _g107) { var _i40 = _g106++; _newArray33[_i40] = _this28.stackVec3[_i40]; _this28.stackVec3[_i40] = null; } _this28.stackVec3 = _newArray33; } _this28.stackVec3[_this28.sizeVec3++] = basisY2; } var _this29 = this._pool; if (basisZ2 != null) { basisZ2.zero(); if (_this29.sizeVec3 == _this29.stackVec3.length) { var _newArray34 = new Array(_this29.sizeVec3 << 1); var _g108 = 0; var _g109 = _this29.sizeVec3; while (_g108 < _g109) { var _i41 = _g108++; _newArray34[_i41] = _this29.stackVec3[_i41]; _this29.stackVec3[_i41] = null; } _this29.stackVec3 = _newArray34; } _this29.stackVec3[_this29.sizeVec3++] = basisZ2; } j = _n5; } } } }, { key: "_drawRotationalLimit", value: function _drawRotationalLimit(d, center, ex, ey, needle, radius, min, max, color) { if (min != max) { var _this = this._pool; var _this1 = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; _this1.x = center.x; _this1.y = center.y; _this1.z = center.z; var _this2 = _this1; _this2.x += needle.x * radius; _this2.y += needle.y * radius; _this2.z += needle.z * radius; d.line(center, _this2, color); var _this3 = this._pool; if (_this2 != null) { _this2.zero(); if (_this3.sizeVec3 == _this3.stackVec3.length) { var newArray = new Array(_this3.sizeVec3 << 1); var _g = 0; var _g1 = _this3.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = _this3.stackVec3[i]; _this3.stackVec3[i] = null; } _this3.stackVec3 = newArray; } _this3.stackVec3[_this3.sizeVec3++] = _this2; } if (min > max) { d.ellipse(center, ex, ey, radius, radius, color); } else { d.arc(center, ex, ey, radius, radius, min, max, true, color); } } } }, { key: "_drawTranslationalLimit", value: function _drawTranslationalLimit(d, center, ex, min, max, color) { if (min < max) { var _this = this._pool; var _this1 = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; _this1.x = center.x; _this1.y = center.y; _this1.z = center.z; var _this2 = _this1; _this2.x += ex.x * min; _this2.y += ex.y * min; _this2.z += ex.z * min; var _this3 = this._pool; var _this4 = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3]; _this4.x = center.x; _this4.y = center.y; _this4.z = center.z; var _this5 = _this4; _this5.x += ex.x * max; _this5.y += ex.y * max; _this5.z += ex.z * max; d.line(_this2, _this5, color); var _this6 = this._pool; if (_this2 != null) { _this2.zero(); if (_this6.sizeVec3 == _this6.stackVec3.length) { var newArray = new Array(_this6.sizeVec3 << 1); var _g = 0; var _g1 = _this6.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = _this6.stackVec3[i]; _this6.stackVec3[i] = null; } _this6.stackVec3 = newArray; } _this6.stackVec3[_this6.sizeVec3++] = _this2; } var _this7 = this._pool; if (_this5 != null) { _this5.zero(); if (_this7.sizeVec3 == _this7.stackVec3.length) { var _newArray35 = new Array(_this7.sizeVec3 << 1); var _g110 = 0; var _g111 = _this7.sizeVec3; while (_g110 < _g111) { var _i42 = _g110++; _newArray35[_i42] = _this7.stackVec3[_i42]; _this7.stackVec3[_i42] = null; } _this7.stackVec3 = _newArray35; } _this7.stackVec3[_this7.sizeVec3++] = _this5; } } } }, { key: "_drawTranslationalLimit3D", value: function _drawTranslationalLimit3D(d, center, ex, ey, ez, xlm, ylm, zlm, color) { var minx = xlm.lowerLimit; var maxx = xlm.upperLimit; var miny = ylm.lowerLimit; var maxy = ylm.upperLimit; var minz = zlm.lowerLimit; var maxz = zlm.upperLimit; var _this = this._pool; if (_this.sizeVec3 == 0) { new oimo.common.Vec3(); } else { --_this.sizeVec3; } var _this1 = this._pool; if (_this1.sizeVec3 == 0) { new oimo.common.Vec3(); } else { --_this1.sizeVec3; } var _this2 = this._pool; var _this3 = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3]; _this3.x = center.x; _this3.y = center.y; _this3.z = center.z; var _this4 = _this3; _this4.x += ex.x * minx; _this4.y += ex.y * minx; _this4.z += ex.z * minx; _this4.x += ey.x * miny; _this4.y += ey.y * miny; _this4.z += ey.z * miny; _this4.x += ez.x * minz; _this4.y += ez.y * minz; _this4.z += ez.z * minz; var _this5 = this._pool; var _this6 = _this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3]; _this6.x = center.x; _this6.y = center.y; _this6.z = center.z; var _this7 = _this6; _this7.x += ex.x * minx; _this7.y += ex.y * minx; _this7.z += ex.z * minx; _this7.x += ey.x * miny; _this7.y += ey.y * miny; _this7.z += ey.z * miny; _this7.x += ez.x * maxz; _this7.y += ez.y * maxz; _this7.z += ez.z * maxz; var _this8 = this._pool; var _this9 = _this8.sizeVec3 == 0 ? new oimo.common.Vec3() : _this8.stackVec3[--_this8.sizeVec3]; _this9.x = center.x; _this9.y = center.y; _this9.z = center.z; var _this10 = _this9; _this10.x += ex.x * minx; _this10.y += ex.y * minx; _this10.z += ex.z * minx; _this10.x += ey.x * maxy; _this10.y += ey.y * maxy; _this10.z += ey.z * maxy; _this10.x += ez.x * minz; _this10.y += ez.y * minz; _this10.z += ez.z * minz; var _this11 = this._pool; var _this12 = _this11.sizeVec3 == 0 ? new oimo.common.Vec3() : _this11.stackVec3[--_this11.sizeVec3]; _this12.x = center.x; _this12.y = center.y; _this12.z = center.z; var _this13 = _this12; _this13.x += ex.x * minx; _this13.y += ex.y * minx; _this13.z += ex.z * minx; _this13.x += ey.x * maxy; _this13.y += ey.y * maxy; _this13.z += ey.z * maxy; _this13.x += ez.x * maxz; _this13.y += ez.y * maxz; _this13.z += ez.z * maxz; var _this14 = this._pool; var _this15 = _this14.sizeVec3 == 0 ? new oimo.common.Vec3() : _this14.stackVec3[--_this14.sizeVec3]; _this15.x = center.x; _this15.y = center.y; _this15.z = center.z; var _this16 = _this15; _this16.x += ex.x * maxx; _this16.y += ex.y * maxx; _this16.z += ex.z * maxx; _this16.x += ey.x * miny; _this16.y += ey.y * miny; _this16.z += ey.z * miny; _this16.x += ez.x * minz; _this16.y += ez.y * minz; _this16.z += ez.z * minz; var _this17 = this._pool; var _this18 = _this17.sizeVec3 == 0 ? new oimo.common.Vec3() : _this17.stackVec3[--_this17.sizeVec3]; _this18.x = center.x; _this18.y = center.y; _this18.z = center.z; var _this19 = _this18; _this19.x += ex.x * maxx; _this19.y += ex.y * maxx; _this19.z += ex.z * maxx; _this19.x += ey.x * miny; _this19.y += ey.y * miny; _this19.z += ey.z * miny; _this19.x += ez.x * maxz; _this19.y += ez.y * maxz; _this19.z += ez.z * maxz; var _this20 = this._pool; var _this21 = _this20.sizeVec3 == 0 ? new oimo.common.Vec3() : _this20.stackVec3[--_this20.sizeVec3]; _this21.x = center.x; _this21.y = center.y; _this21.z = center.z; var _this22 = _this21; _this22.x += ex.x * maxx; _this22.y += ex.y * maxx; _this22.z += ex.z * maxx; _this22.x += ey.x * maxy; _this22.y += ey.y * maxy; _this22.z += ey.z * maxy; _this22.x += ez.x * minz; _this22.y += ez.y * minz; _this22.z += ez.z * minz; var _this23 = this._pool; var _this24 = _this23.sizeVec3 == 0 ? new oimo.common.Vec3() : _this23.stackVec3[--_this23.sizeVec3]; _this24.x = center.x; _this24.y = center.y; _this24.z = center.z; var _this25 = _this24; _this25.x += ex.x * maxx; _this25.y += ex.y * maxx; _this25.z += ex.z * maxx; _this25.x += ey.x * maxy; _this25.y += ey.y * maxy; _this25.z += ey.z * maxy; _this25.x += ez.x * maxz; _this25.y += ez.y * maxz; _this25.z += ez.z * maxz; d.line(_this4, _this16, color); d.line(_this10, _this22, color); d.line(_this7, _this19, color); d.line(_this13, _this25, color); d.line(_this4, _this10, color); d.line(_this16, _this22, color); d.line(_this7, _this13, color); d.line(_this19, _this25, color); d.line(_this4, _this7, color); d.line(_this16, _this19, color); d.line(_this10, _this13, color); d.line(_this22, _this25, color); var _this26 = this._pool; if (_this4 != null) { _this4.zero(); if (_this26.sizeVec3 == _this26.stackVec3.length) { var newArray = new Array(_this26.sizeVec3 << 1); var _g = 0; var _g1 = _this26.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = _this26.stackVec3[i]; _this26.stackVec3[i] = null; } _this26.stackVec3 = newArray; } _this26.stackVec3[_this26.sizeVec3++] = _this4; } var _this27 = this._pool; if (_this7 != null) { _this7.zero(); if (_this27.sizeVec3 == _this27.stackVec3.length) { var _newArray36 = new Array(_this27.sizeVec3 << 1); var _g112 = 0; var _g113 = _this27.sizeVec3; while (_g112 < _g113) { var _i43 = _g112++; _newArray36[_i43] = _this27.stackVec3[_i43]; _this27.stackVec3[_i43] = null; } _this27.stackVec3 = _newArray36; } _this27.stackVec3[_this27.sizeVec3++] = _this7; } var _this28 = this._pool; if (_this10 != null) { _this10.zero(); if (_this28.sizeVec3 == _this28.stackVec3.length) { var _newArray37 = new Array(_this28.sizeVec3 << 1); var _g114 = 0; var _g115 = _this28.sizeVec3; while (_g114 < _g115) { var _i44 = _g114++; _newArray37[_i44] = _this28.stackVec3[_i44]; _this28.stackVec3[_i44] = null; } _this28.stackVec3 = _newArray37; } _this28.stackVec3[_this28.sizeVec3++] = _this10; } var _this29 = this._pool; if (_this13 != null) { _this13.zero(); if (_this29.sizeVec3 == _this29.stackVec3.length) { var _newArray38 = new Array(_this29.sizeVec3 << 1); var _g116 = 0; var _g117 = _this29.sizeVec3; while (_g116 < _g117) { var _i45 = _g116++; _newArray38[_i45] = _this29.stackVec3[_i45]; _this29.stackVec3[_i45] = null; } _this29.stackVec3 = _newArray38; } _this29.stackVec3[_this29.sizeVec3++] = _this13; } var _this30 = this._pool; if (_this16 != null) { _this16.zero(); if (_this30.sizeVec3 == _this30.stackVec3.length) { var _newArray39 = new Array(_this30.sizeVec3 << 1); var _g118 = 0; var _g119 = _this30.sizeVec3; while (_g118 < _g119) { var _i46 = _g118++; _newArray39[_i46] = _this30.stackVec3[_i46]; _this30.stackVec3[_i46] = null; } _this30.stackVec3 = _newArray39; } _this30.stackVec3[_this30.sizeVec3++] = _this16; } var _this31 = this._pool; if (_this19 != null) { _this19.zero(); if (_this31.sizeVec3 == _this31.stackVec3.length) { var _newArray40 = new Array(_this31.sizeVec3 << 1); var _g120 = 0; var _g121 = _this31.sizeVec3; while (_g120 < _g121) { var _i47 = _g120++; _newArray40[_i47] = _this31.stackVec3[_i47]; _this31.stackVec3[_i47] = null; } _this31.stackVec3 = _newArray40; } _this31.stackVec3[_this31.sizeVec3++] = _this19; } var _this32 = this._pool; if (_this22 != null) { _this22.zero(); if (_this32.sizeVec3 == _this32.stackVec3.length) { var _newArray41 = new Array(_this32.sizeVec3 << 1); var _g122 = 0; var _g123 = _this32.sizeVec3; while (_g122 < _g123) { var _i48 = _g122++; _newArray41[_i48] = _this32.stackVec3[_i48]; _this32.stackVec3[_i48] = null; } _this32.stackVec3 = _newArray41; } _this32.stackVec3[_this32.sizeVec3++] = _this22; } var _this33 = this._pool; if (_this25 != null) { _this25.zero(); if (_this33.sizeVec3 == _this33.stackVec3.length) { var _newArray42 = new Array(_this33.sizeVec3 << 1); var _g124 = 0; var _g125 = _this33.sizeVec3; while (_g124 < _g125) { var _i49 = _g124++; _newArray42[_i49] = _this33.stackVec3[_i49]; _this33.stackVec3[_i49] = null; } _this33.stackVec3 = _newArray42; } _this33.stackVec3[_this33.sizeVec3++] = _this25; } } }, { key: "_drawEllipseOnSphere", value: function _drawEllipseOnSphere(d, center, normal, x, y, radiansX, radiansY, radius, color) { var theta = 0; var _this = this._pool; var rotVec = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; var _this1 = this._pool; var rotQ = _this1.sizeQuat == 0 ? new oimo.common.Quat() : _this1.stackQuat[--_this1.sizeQuat]; var _this2 = this._pool; var rotM = _this2.sizeMat3 == 0 ? new oimo.common.Mat3() : _this2.stackMat3[--_this2.sizeMat3]; var _this3 = this._pool; var prevV = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3]; var _g = 0; while (_g < 17) { var i = _g++; var rx = Math.cos(theta) * radiansX; var ry = Math.sin(theta) * radiansY; var halfRotAng = Math.sqrt(rx * rx + ry * ry); var rotSin = Math.sin(halfRotAng * 0.5); var rotCos = Math.cos(halfRotAng * 0.5); var _this110 = rotVec.zero(); _this110.x += x.x * rx; _this110.y += x.y * rx; _this110.z += x.z * rx; _this110.x += y.x * ry; _this110.y += y.y * ry; _this110.z += y.z * ry; var s = 1 / halfRotAng * rotSin; rotVec.x *= s; rotVec.y *= s; rotVec.z *= s; rotQ.x = rotVec.x; rotQ.y = rotVec.y; rotQ.z = rotVec.z; rotQ.w = rotCos; var x1 = rotQ.x; var y1 = rotQ.y; var z = rotQ.z; var w = rotQ.w; var x2 = 2 * x1; var y2 = 2 * y1; var z2 = 2 * z; var xx = x1 * x2; var yy = y1 * y2; var zz = z * z2; var xy = x1 * y2; var yz = y1 * z2; var xz = x1 * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; rotM.e00 = 1 - yy - zz; rotM.e01 = xy - wz; rotM.e02 = xz + wy; rotM.e10 = xy + wz; rotM.e11 = 1 - xx - zz; rotM.e12 = yz - wx; rotM.e20 = xz - wy; rotM.e21 = yz + wx; rotM.e22 = 1 - xx - yy; var _this111 = this._pool; var _this112 = _this111.sizeVec3 == 0 ? new oimo.common.Vec3() : _this111.stackVec3[--_this111.sizeVec3]; _this112.x += normal.x * radius; _this112.y += normal.y * radius; _this112.z += normal.z * radius; var v = _this112; var y3 = v.x * rotM.e10 + v.y * rotM.e11 + v.z * rotM.e12; var z1 = v.x * rotM.e20 + v.y * rotM.e21 + v.z * rotM.e22; v.x = v.x * rotM.e00 + v.y * rotM.e01 + v.z * rotM.e02; v.y = y3; v.z = z1; v.x += center.x; v.y += center.y; v.z += center.z; if (i >= 1) { d.line(prevV, v, color); } var _this113 = this._pool; if (prevV != null) { prevV.zero(); if (_this113.sizeVec3 == _this113.stackVec3.length) { var newArray = new Array(_this113.sizeVec3 << 1); var _g126 = 0; var _g1 = _this113.sizeVec3; while (_g126 < _g1) { var _i50 = _g126++; newArray[_i50] = _this113.stackVec3[_i50]; _this113.stackVec3[_i50] = null; } _this113.stackVec3 = newArray; } _this113.stackVec3[_this113.sizeVec3++] = prevV; } prevV = v; theta += 0.39269908169872375; } var _this4 = this._pool; if (rotVec != null) { rotVec.zero(); if (_this4.sizeVec3 == _this4.stackVec3.length) { var _newArray43 = new Array(_this4.sizeVec3 << 1); var _g127 = 0; var _g128 = _this4.sizeVec3; while (_g127 < _g128) { var _i51 = _g127++; _newArray43[_i51] = _this4.stackVec3[_i51]; _this4.stackVec3[_i51] = null; } _this4.stackVec3 = _newArray43; } _this4.stackVec3[_this4.sizeVec3++] = rotVec; } var _this5 = this._pool; if (rotQ != null) { rotQ.x = 0; rotQ.y = 0; rotQ.z = 0; rotQ.w = 1; if (_this5.sizeQuat == _this5.stackQuat.length) { var _newArray44 = new Array(_this5.sizeQuat << 1); var _g129 = 0; var _g130 = _this5.sizeQuat; while (_g129 < _g130) { var _i52 = _g129++; _newArray44[_i52] = _this5.stackQuat[_i52]; _this5.stackQuat[_i52] = null; } _this5.stackQuat = _newArray44; } _this5.stackQuat[_this5.sizeQuat++] = rotQ; } var _this6 = this._pool; if (rotM != null) { rotM.e00 = 1; rotM.e01 = 0; rotM.e02 = 0; rotM.e10 = 0; rotM.e11 = 1; rotM.e12 = 0; rotM.e20 = 0; rotM.e21 = 0; rotM.e22 = 1; if (_this6.sizeMat3 == _this6.stackMat3.length) { var _newArray45 = new Array(_this6.sizeMat3 << 1); var _g131 = 0; var _g132 = _this6.sizeMat3; while (_g131 < _g132) { var _i53 = _g131++; _newArray45[_i53] = _this6.stackMat3[_i53]; _this6.stackMat3[_i53] = null; } _this6.stackMat3 = _newArray45; } _this6.stackMat3[_this6.sizeMat3++] = rotM; } var _this7 = this._pool; if (prevV != null) { prevV.zero(); if (_this7.sizeVec3 == _this7.stackVec3.length) { var _newArray46 = new Array(_this7.sizeVec3 << 1); var _g133 = 0; var _g134 = _this7.sizeVec3; while (_g133 < _g134) { var _i54 = _g133++; _newArray46[_i54] = _this7.stackVec3[_i54]; _this7.stackVec3[_i54] = null; } _this7.stackVec3 = _newArray46; } _this7.stackVec3[_this7.sizeVec3++] = prevV; } } }, { key: "step", value: function step(timeStep) { if (this._timeStep.dt > 0) { this._timeStep.dtRatio = timeStep / this._timeStep.dt; } this._timeStep.dt = timeStep; this._timeStep.invDt = 1 / timeStep; var st = Date.now() / 1000; this._updateContacts(); this._solveIslands(); oimo.dynamics.common.Performance.totalTime = (Date.now() / 1000 - st) * 1000; } }, { key: "addRigidBody", value: function addRigidBody(rigidBody) { if (rigidBody._world != null) { throw new Error("A rigid body cannot belong to multiple worlds."); } if (this._rigidBodyList == null) { this._rigidBodyList = rigidBody; this._rigidBodyListLast = rigidBody; } else { this._rigidBodyListLast._next = rigidBody; rigidBody._prev = this._rigidBodyListLast; this._rigidBodyListLast = rigidBody; } rigidBody._world = this; var s = rigidBody._shapeList; while (s != null) { var n = s._next; s._proxy = this._broadPhase.createProxy(s, s._aabb); s._id = this._shapeIdCount++; this._numShapes++; s = n; } this._numRigidBodies++; } }, { key: "removeRigidBody", value: function removeRigidBody(rigidBody) { if (rigidBody._world != this) { throw new Error("The rigid body doesn't belong to the world."); } var prev = rigidBody._prev; var next = rigidBody._next; if (prev != null) { prev._next = next; } if (next != null) { next._prev = prev; } if (rigidBody == this._rigidBodyList) { this._rigidBodyList = this._rigidBodyList._next; } if (rigidBody == this._rigidBodyListLast) { this._rigidBodyListLast = this._rigidBodyListLast._prev; } rigidBody._next = null; rigidBody._prev = null; rigidBody._world = null; var s = rigidBody._shapeList; while (s != null) { var n = s._next; this._broadPhase.destroyProxy(s._proxy); s._proxy = null; s._id = -1; var cl = s._rigidBody._contactLinkList; while (cl != null) { var _n6 = cl._next; var c = cl._contact; if (c._s1 == s || c._s2 == s) { var _this = cl._other; _this._sleeping = false; _this._sleepTime = 0; var _this1 = this._contactManager; var _prev4 = c._prev; var _next4 = c._next; if (_prev4 != null) { _prev4._next = _next4; } if (_next4 != null) { _next4._prev = _prev4; } if (c == _this1._contactList) { _this1._contactList = _this1._contactList._next; } if (c == _this1._contactListLast) { _this1._contactListLast = _this1._contactListLast._prev; } c._next = null; c._prev = null; if (c._touching) { var cc1 = c._s1._contactCallback; var cc2 = c._s2._contactCallback; if (cc1 == cc2) { cc2 = null; } if (cc1 != null) { cc1.endContact(c); } if (cc2 != null) { cc2.endContact(c); } } var prev1 = c._link1._prev; var next1 = c._link1._next; if (prev1 != null) { prev1._next = next1; } if (next1 != null) { next1._prev = prev1; } if (c._link1 == c._b1._contactLinkList) { c._b1._contactLinkList = c._b1._contactLinkList._next; } if (c._link1 == c._b1._contactLinkListLast) { c._b1._contactLinkListLast = c._b1._contactLinkListLast._prev; } c._link1._next = null; c._link1._prev = null; var prev2 = c._link2._prev; var next2 = c._link2._next; if (prev2 != null) { prev2._next = next2; } if (next2 != null) { next2._prev = prev2; } if (c._link2 == c._b2._contactLinkList) { c._b2._contactLinkList = c._b2._contactLinkList._next; } if (c._link2 == c._b2._contactLinkListLast) { c._b2._contactLinkListLast = c._b2._contactLinkListLast._prev; } c._link2._next = null; c._link2._prev = null; c._b1._numContactLinks--; c._b2._numContactLinks--; c._link1._other = null; c._link2._other = null; c._link1._contact = null; c._link2._contact = null; c._s1 = null; c._s2 = null; c._b1 = null; c._b2 = null; c._touching = false; c._cachedDetectorData._clear(); c._manifold._clear(); c._detector = null; var _this2 = c._contactConstraint; _this2._s1 = null; _this2._s2 = null; _this2._b1 = null; _this2._b2 = null; _this2._tf1 = null; _this2._tf2 = null; c._next = _this1._contactPool; _this1._contactPool = c; _this1._numContacts--; } cl = _n6; } this._numShapes--; s = n; } this._numRigidBodies--; } }, { key: "addJoint", value: function addJoint(joint) { if (joint._world != null) { throw new Error("A joint cannot belong to multiple worlds."); } if (this._jointList == null) { this._jointList = joint; this._jointListLast = joint; } else { this._jointListLast._next = joint; joint._prev = this._jointListLast; this._jointListLast = joint; } joint._world = this; joint._link1._other = joint._b2; joint._link2._other = joint._b1; if (joint._b1._jointLinkList == null) { joint._b1._jointLinkList = joint._link1; joint._b1._jointLinkListLast = joint._link1; } else { joint._b1._jointLinkListLast._next = joint._link1; joint._link1._prev = joint._b1._jointLinkListLast; joint._b1._jointLinkListLast = joint._link1; } if (joint._b2._jointLinkList == null) { joint._b2._jointLinkList = joint._link2; joint._b2._jointLinkListLast = joint._link2; } else { joint._b2._jointLinkListLast._next = joint._link2; joint._link2._prev = joint._b2._jointLinkListLast; joint._b2._jointLinkListLast = joint._link2; } joint._b1._numJointLinks++; joint._b2._numJointLinks++; var _this = joint._b1; _this._sleeping = false; _this._sleepTime = 0; var _this1 = joint._b2; _this1._sleeping = false; _this1._sleepTime = 0; joint._syncAnchors(); this._numJoints++; } }, { key: "removeJoint", value: function removeJoint(joint) { if (joint._world != this) { throw new Error("The joint doesn't belong to the world."); } var prev = joint._prev; var next = joint._next; if (prev != null) { prev._next = next; } if (next != null) { next._prev = prev; } if (joint == this._jointList) { this._jointList = this._jointList._next; } if (joint == this._jointListLast) { this._jointListLast = this._jointListLast._prev; } joint._next = null; joint._prev = null; joint._world = null; var prev1 = joint._link1._prev; var next1 = joint._link1._next; if (prev1 != null) { prev1._next = next1; } if (next1 != null) { next1._prev = prev1; } if (joint._link1 == joint._b1._jointLinkList) { joint._b1._jointLinkList = joint._b1._jointLinkList._next; } if (joint._link1 == joint._b1._jointLinkListLast) { joint._b1._jointLinkListLast = joint._b1._jointLinkListLast._prev; } joint._link1._next = null; joint._link1._prev = null; var prev2 = joint._link2._prev; var next2 = joint._link2._next; if (prev2 != null) { prev2._next = next2; } if (next2 != null) { next2._prev = prev2; } if (joint._link2 == joint._b2._jointLinkList) { joint._b2._jointLinkList = joint._b2._jointLinkList._next; } if (joint._link2 == joint._b2._jointLinkListLast) { joint._b2._jointLinkListLast = joint._b2._jointLinkListLast._prev; } joint._link2._next = null; joint._link2._prev = null; joint._link1._other = null; joint._link2._other = null; joint._b1._numJointLinks--; joint._b2._numJointLinks--; var _this = joint._b1; _this._sleeping = false; _this._sleepTime = 0; var _this1 = joint._b2; _this1._sleeping = false; _this1._sleepTime = 0; this._numJoints--; } }, { key: "setDebugDraw", value: function setDebugDraw(debugDraw) { this._debugDraw = debugDraw; } }, { key: "getDebugDraw", value: function getDebugDraw() { return this._debugDraw; } }, { key: "debugDraw", value: function debugDraw() { if (this._debugDraw != null) { if (this._broadPhase._type == 2) { this._drawBvh(this._debugDraw, this._broadPhase._tree); } this._drawRigidBodies(this._debugDraw); this._drawConstraints(this._debugDraw); } } }, { key: "rayCast", value: function rayCast(begin, end, callback) { var _this = this._rayCastWrapper.begin; _this.x = begin.x; _this.y = begin.y; _this.z = begin.z; var _this1 = this._rayCastWrapper.end; _this1.x = end.x; _this1.y = end.y; _this1.z = end.z; this._rayCastWrapper.callback = callback; this._broadPhase.rayCast(begin, end, this._rayCastWrapper); } }, { key: "convexCast", value: function convexCast(convex, begin, translation, callback) { this._convexCastWrapper.convex = convex; var _this = this._convexCastWrapper.begin; _this._positionX = begin._positionX; _this._positionY = begin._positionY; _this._positionZ = begin._positionZ; _this._rotation00 = begin._rotation00; _this._rotation01 = begin._rotation01; _this._rotation02 = begin._rotation02; _this._rotation10 = begin._rotation10; _this._rotation11 = begin._rotation11; _this._rotation12 = begin._rotation12; _this._rotation20 = begin._rotation20; _this._rotation21 = begin._rotation21; _this._rotation22 = begin._rotation22; var _this1 = this._convexCastWrapper.translation; _this1.x = translation.x; _this1.y = translation.y; _this1.z = translation.z; this._convexCastWrapper.callback = callback; this._broadPhase.convexCast(convex, begin, translation, this._convexCastWrapper); } }, { key: "aabbTest", value: function aabbTest(aabb, callback) { this._aabbTestWrapper._aabb.copyFrom(aabb); this._aabbTestWrapper._callback = callback; this._broadPhase.aabbTest(aabb, this._aabbTestWrapper); } }, { key: "getRigidBodyList", value: function getRigidBodyList() { return this._rigidBodyList; } }, { key: "getJointList", value: function getJointList() { return this._jointList; } }, { key: "getBroadPhase", value: function getBroadPhase() { return this._broadPhase; } }, { key: "getContactManager", value: function getContactManager() { return this._contactManager; } }, { key: "getNumRigidBodies", value: function getNumRigidBodies() { return this._numRigidBodies; } }, { key: "getNumJoints", value: function getNumJoints() { return this._numJoints; } }, { key: "getNumShapes", value: function getNumShapes() { return this._numShapes; } }, { key: "getNumIslands", value: function getNumIslands() { return this._numIslands; } }, { key: "getNumVelocityIterations", value: function getNumVelocityIterations() { return this._numVelocityIterations; } }, { key: "setNumVelocityIterations", value: function setNumVelocityIterations(numVelocityIterations) { this._numVelocityIterations = numVelocityIterations; } }, { key: "getNumPositionIterations", value: function getNumPositionIterations() { return this._numPositionIterations; } }, { key: "setNumPositionIterations", value: function setNumPositionIterations(numPositionIterations) { this._numPositionIterations = numPositionIterations; } }, { key: "getGravity", value: function getGravity() { return this._gravity; } }, { key: "setGravity", value: function setGravity(gravity) { var _this = this._gravity; _this.x = gravity.x; _this.y = gravity.y; _this.z = gravity.z; } }]); return oimo_dynamics_World; }(); if (!oimo.dynamics._World) oimo.dynamics._World = {}; oimo.dynamics._World.RayCastWrapper = /*#__PURE__*/function (_oimo$collision$broad4) { _inherits(oimo_dynamics__$World_RayCastWrapper, _oimo$collision$broad4); var _super19 = _createSuper(oimo_dynamics__$World_RayCastWrapper); function oimo_dynamics__$World_RayCastWrapper() { var _this114; _classCallCheck(this, oimo_dynamics__$World_RayCastWrapper); _this114 = _super19.call(this); _this114.rayCastHit = new oimo.collision.geometry.RayCastHit(); _this114.begin = new oimo.common.Vec3(); _this114.end = new oimo.common.Vec3(); _this114.callback = null; return _this114; } _createClass(oimo_dynamics__$World_RayCastWrapper, [{ key: "process", value: function process(proxy) { var shape = proxy.userData; if (shape._geom.rayCast(this.begin, this.end, shape._transform, this.rayCastHit)) { this.callback.process(shape, this.rayCastHit); } } }]); return oimo_dynamics__$World_RayCastWrapper; }(oimo.collision.broadphase.BroadPhaseProxyCallback); oimo.dynamics._World.ConvexCastWrapper = /*#__PURE__*/function (_oimo$collision$broad5) { _inherits(oimo_dynamics__$World_ConvexCastWrapper, _oimo$collision$broad5); var _super20 = _createSuper(oimo_dynamics__$World_ConvexCastWrapper); function oimo_dynamics__$World_ConvexCastWrapper() { var _this115; _classCallCheck(this, oimo_dynamics__$World_ConvexCastWrapper); _this115 = _super20.call(this); _this115.rayCastHit = new oimo.collision.geometry.RayCastHit(); _this115.begin = new oimo.common.Transform(); _this115.translation = new oimo.common.Vec3(); _this115.zero = new oimo.common.Vec3(); _this115.callback = null; _this115.convex = null; return _this115; } _createClass(oimo_dynamics__$World_ConvexCastWrapper, [{ key: "process", value: function process(proxy) { var shape = proxy.userData; var type = shape._geom._type; if (type < 0 || type > 5) { return; } if (oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance.convexCast(this.convex, shape._geom, this.begin, shape._transform, this.translation, this.zero, this.rayCastHit)) { this.callback.process(shape, this.rayCastHit); } } }]); return oimo_dynamics__$World_ConvexCastWrapper; }(oimo.collision.broadphase.BroadPhaseProxyCallback); oimo.dynamics._World.AabbTestWrapper = /*#__PURE__*/function (_oimo$collision$broad6) { _inherits(oimo_dynamics__$World_AabbTestWrapper, _oimo$collision$broad6); var _super21 = _createSuper(oimo_dynamics__$World_AabbTestWrapper); function oimo_dynamics__$World_AabbTestWrapper() { var _this116; _classCallCheck(this, oimo_dynamics__$World_AabbTestWrapper); _this116 = _super21.call(this); _this116._aabb = new oimo.collision.geometry.Aabb(); _this116._callback = null; return _this116; } _createClass(oimo_dynamics__$World_AabbTestWrapper, [{ key: "process", value: function process(proxy) { var shape = proxy.userData; var shapeAabb = shape._aabb; if (shapeAabb._minX < this._aabb._maxX && shapeAabb._maxX > this._aabb._minX && shapeAabb._minY < this._aabb._maxY && shapeAabb._maxY > this._aabb._minY && shapeAabb._minZ < this._aabb._maxZ && shapeAabb._maxZ > this._aabb._minZ) { this._callback.process(shape); } } }]); return oimo_dynamics__$World_AabbTestWrapper; }(oimo.collision.broadphase.BroadPhaseProxyCallback); if (!oimo.dynamics.callback) oimo.dynamics.callback = {}; oimo.dynamics.callback.AabbTestCallback = /*#__PURE__*/function () { function oimo_dynamics_callback_AabbTestCallback() { _classCallCheck(this, oimo_dynamics_callback_AabbTestCallback); } _createClass(oimo_dynamics_callback_AabbTestCallback, [{ key: "process", value: function process(shape) {} }]); return oimo_dynamics_callback_AabbTestCallback; }(); oimo.dynamics.callback.ContactCallback = /*#__PURE__*/function () { function oimo_dynamics_callback_ContactCallback() { _classCallCheck(this, oimo_dynamics_callback_ContactCallback); } _createClass(oimo_dynamics_callback_ContactCallback, [{ key: "beginContact", value: function beginContact(c) {} }, { key: "preSolve", value: function preSolve(c) {} }, { key: "postSolve", value: function postSolve(c) {} }, { key: "endContact", value: function endContact(c) {} }]); return oimo_dynamics_callback_ContactCallback; }(); oimo.dynamics.callback.RayCastCallback = /*#__PURE__*/function () { function oimo_dynamics_callback_RayCastCallback() { _classCallCheck(this, oimo_dynamics_callback_RayCastCallback); } _createClass(oimo_dynamics_callback_RayCastCallback, [{ key: "process", value: function process(shape, hit) {} }]); return oimo_dynamics_callback_RayCastCallback; }(); oimo.dynamics.callback.RayCastClosest = /*#__PURE__*/function (_oimo$dynamics$callba) { _inherits(oimo_dynamics_callback_RayCastClosest, _oimo$dynamics$callba); var _super22 = _createSuper(oimo_dynamics_callback_RayCastClosest); function oimo_dynamics_callback_RayCastClosest() { var _this117; _classCallCheck(this, oimo_dynamics_callback_RayCastClosest); _this117 = _super22.call(this); _this117.position = new oimo.common.Vec3(); _this117.normal = new oimo.common.Vec3(); _this117.shape = null; _this117.fraction = 1; _this117.position.zero(); _this117.normal.zero(); _this117.hit = false; return _this117; } _createClass(oimo_dynamics_callback_RayCastClosest, [{ key: "clear", value: function clear() { this.shape = null; this.fraction = 1; this.position.zero(); this.normal.zero(); this.hit = false; } }, { key: "process", value: function process(shape, hit) { if (hit.fraction < this.fraction) { this.shape = shape; this.hit = true; this.fraction = hit.fraction; var _this = this.position; var v = hit.position; _this.x = v.x; _this.y = v.y; _this.z = v.z; var _this1 = this.normal; var v1 = hit.normal; _this1.x = v1.x; _this1.y = v1.y; _this1.z = v1.z; } } }]); return oimo_dynamics_callback_RayCastClosest; }(oimo.dynamics.callback.RayCastCallback); if (!oimo.dynamics.common) oimo.dynamics.common = {}; oimo.dynamics.common.DebugDraw = /*#__PURE__*/function () { function oimo_dynamics_common_DebugDraw() { _classCallCheck(this, oimo_dynamics_common_DebugDraw); this.p = new oimo.common.Pool(); this.wireframe = false; this.drawShapes = true; this.drawBvh = false; this.drawBvhMinLevel = 0; this.drawBvhMaxLevel = 65536; this.drawAabbs = false; this.drawBases = false; this.drawPairs = false; this.drawContacts = false; this.drawJoints = true; this.drawJointLimits = false; this.sphereCoords = new Array(5); this.tmpSphereVerts = new Array(5); this.tmpSphereNorms = new Array(5); var _g = 0; while (_g < 5) { var i = _g++; var num = i == 0 || i == 4 ? 1 : 8; this.sphereCoords[i] = new Array(num); this.tmpSphereVerts[i] = new Array(num); this.tmpSphereNorms[i] = new Array(num); var _g135 = 0; while (_g135 < 8) { var j = _g135++; var theta = i * 0.7853981633974475; var phi = j * 0.7853981633974475; this.sphereCoords[i][j] = new oimo.common.Vec3(Math.sin(theta) * Math.cos(phi), Math.cos(theta), -Math.sin(theta) * Math.sin(phi)); this.tmpSphereVerts[i][j] = new oimo.common.Vec3(); this.tmpSphereNorms[i][j] = new oimo.common.Vec3(); } } this.circleCoords = new Array(8); this.circleCoordsShift = new Array(8); this.tmpCircleVerts1 = new Array(8); this.tmpCircleVerts2 = new Array(8); this.tmpCircleNorms = new Array(8); var _g1 = 0; while (_g1 < 8) { var _i55 = _g1++; this.circleCoords[_i55] = new oimo.common.Vec3(Math.cos(_i55 * 0.7853981633974475), 0, -Math.sin(_i55 * 0.7853981633974475)); this.circleCoordsShift[_i55] = new oimo.common.Vec3(Math.cos((_i55 + 0.5) * 0.7853981633974475), 0, -Math.sin((_i55 + 0.5) * 0.7853981633974475)); this.tmpCircleVerts1[_i55] = new oimo.common.Vec3(); this.tmpCircleVerts2[_i55] = new oimo.common.Vec3(); this.tmpCircleNorms[_i55] = new oimo.common.Vec3(); } this.style = new oimo.dynamics.common.DebugDrawStyle(); } _createClass(oimo_dynamics_common_DebugDraw, [{ key: "aabb", value: function aabb(min, max, color) { var _this = this.p; var v1 = (_this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]).init(min.x, min.y, min.z); var _this1 = this.p; var v2 = (_this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3]).init(min.x, min.y, max.z); var _this2 = this.p; var v3 = (_this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3]).init(min.x, max.y, min.z); var _this3 = this.p; var v4 = (_this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3]).init(min.x, max.y, max.z); var _this4 = this.p; var v5 = (_this4.sizeVec3 == 0 ? new oimo.common.Vec3() : _this4.stackVec3[--_this4.sizeVec3]).init(max.x, min.y, min.z); var _this5 = this.p; var v6 = (_this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3]).init(max.x, min.y, max.z); var _this6 = this.p; var v7 = (_this6.sizeVec3 == 0 ? new oimo.common.Vec3() : _this6.stackVec3[--_this6.sizeVec3]).init(max.x, max.y, min.z); var _this7 = this.p; var v8 = (_this7.sizeVec3 == 0 ? new oimo.common.Vec3() : _this7.stackVec3[--_this7.sizeVec3]).init(max.x, max.y, max.z); this.line(v1, v2, color); this.line(v3, v4, color); this.line(v5, v6, color); this.line(v7, v8, color); this.line(v1, v3, color); this.line(v2, v4, color); this.line(v5, v7, color); this.line(v6, v8, color); this.line(v1, v5, color); this.line(v2, v6, color); this.line(v3, v7, color); this.line(v4, v8, color); var _this8 = this.p; if (v1 != null) { v1.zero(); if (_this8.sizeVec3 == _this8.stackVec3.length) { var newArray = new Array(_this8.sizeVec3 << 1); var _g = 0; var _g1 = _this8.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = _this8.stackVec3[i]; _this8.stackVec3[i] = null; } _this8.stackVec3 = newArray; } _this8.stackVec3[_this8.sizeVec3++] = v1; } var _this9 = this.p; if (v2 != null) { v2.zero(); if (_this9.sizeVec3 == _this9.stackVec3.length) { var _newArray47 = new Array(_this9.sizeVec3 << 1); var _g136 = 0; var _g137 = _this9.sizeVec3; while (_g136 < _g137) { var _i56 = _g136++; _newArray47[_i56] = _this9.stackVec3[_i56]; _this9.stackVec3[_i56] = null; } _this9.stackVec3 = _newArray47; } _this9.stackVec3[_this9.sizeVec3++] = v2; } var _this10 = this.p; if (v3 != null) { v3.zero(); if (_this10.sizeVec3 == _this10.stackVec3.length) { var _newArray48 = new Array(_this10.sizeVec3 << 1); var _g138 = 0; var _g139 = _this10.sizeVec3; while (_g138 < _g139) { var _i57 = _g138++; _newArray48[_i57] = _this10.stackVec3[_i57]; _this10.stackVec3[_i57] = null; } _this10.stackVec3 = _newArray48; } _this10.stackVec3[_this10.sizeVec3++] = v3; } var _this11 = this.p; if (v4 != null) { v4.zero(); if (_this11.sizeVec3 == _this11.stackVec3.length) { var _newArray49 = new Array(_this11.sizeVec3 << 1); var _g140 = 0; var _g141 = _this11.sizeVec3; while (_g140 < _g141) { var _i58 = _g140++; _newArray49[_i58] = _this11.stackVec3[_i58]; _this11.stackVec3[_i58] = null; } _this11.stackVec3 = _newArray49; } _this11.stackVec3[_this11.sizeVec3++] = v4; } var _this12 = this.p; if (v5 != null) { v5.zero(); if (_this12.sizeVec3 == _this12.stackVec3.length) { var _newArray50 = new Array(_this12.sizeVec3 << 1); var _g142 = 0; var _g143 = _this12.sizeVec3; while (_g142 < _g143) { var _i59 = _g142++; _newArray50[_i59] = _this12.stackVec3[_i59]; _this12.stackVec3[_i59] = null; } _this12.stackVec3 = _newArray50; } _this12.stackVec3[_this12.sizeVec3++] = v5; } var _this13 = this.p; if (v6 != null) { v6.zero(); if (_this13.sizeVec3 == _this13.stackVec3.length) { var _newArray51 = new Array(_this13.sizeVec3 << 1); var _g144 = 0; var _g145 = _this13.sizeVec3; while (_g144 < _g145) { var _i60 = _g144++; _newArray51[_i60] = _this13.stackVec3[_i60]; _this13.stackVec3[_i60] = null; } _this13.stackVec3 = _newArray51; } _this13.stackVec3[_this13.sizeVec3++] = v6; } var _this14 = this.p; if (v7 != null) { v7.zero(); if (_this14.sizeVec3 == _this14.stackVec3.length) { var _newArray52 = new Array(_this14.sizeVec3 << 1); var _g146 = 0; var _g147 = _this14.sizeVec3; while (_g146 < _g147) { var _i61 = _g146++; _newArray52[_i61] = _this14.stackVec3[_i61]; _this14.stackVec3[_i61] = null; } _this14.stackVec3 = _newArray52; } _this14.stackVec3[_this14.sizeVec3++] = v7; } var _this15 = this.p; if (v8 != null) { v8.zero(); if (_this15.sizeVec3 == _this15.stackVec3.length) { var _newArray53 = new Array(_this15.sizeVec3 << 1); var _g148 = 0; var _g149 = _this15.sizeVec3; while (_g148 < _g149) { var _i62 = _g148++; _newArray53[_i62] = _this15.stackVec3[_i62]; _this15.stackVec3[_i62] = null; } _this15.stackVec3 = _newArray53; } _this15.stackVec3[_this15.sizeVec3++] = v8; } } }, { key: "basis", value: function basis(transform, length, colorX, colorY, colorZ) { var _this = this.p; var pos = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; var _this1 = this.p; var rot = _this1.sizeMat3 == 0 ? new oimo.common.Mat3() : _this1.stackMat3[--_this1.sizeMat3]; var _this2 = this.p; var ex = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3]; var _this3 = this.p; var ey = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3]; var _this4 = this.p; var ez = _this4.sizeVec3 == 0 ? new oimo.common.Vec3() : _this4.stackVec3[--_this4.sizeVec3]; var v = pos; v.x = transform._positionX; v.y = transform._positionY; v.z = transform._positionZ; var m = rot; m.e00 = transform._rotation00; m.e01 = transform._rotation01; m.e02 = transform._rotation02; m.e10 = transform._rotation10; m.e11 = transform._rotation11; m.e12 = transform._rotation12; m.e20 = transform._rotation20; m.e21 = transform._rotation21; m.e22 = transform._rotation22; ex.init(rot.e00, rot.e10, rot.e20); ey.init(rot.e01, rot.e11, rot.e21); ez.init(rot.e02, rot.e12, rot.e22); ex.x *= length; ex.y *= length; ex.z *= length; var _this5 = ex; _this5.x += pos.x; _this5.y += pos.y; _this5.z += pos.z; ey.x *= length; ey.y *= length; ey.z *= length; var _this6 = ey; _this6.x += pos.x; _this6.y += pos.y; _this6.z += pos.z; ez.x *= length; ez.y *= length; ez.z *= length; var _this7 = ez; _this7.x += pos.x; _this7.y += pos.y; _this7.z += pos.z; this.line(pos, ex, colorX); this.line(pos, ey, colorY); this.line(pos, ez, colorZ); var _this8 = this.p; if (pos != null) { pos.zero(); if (_this8.sizeVec3 == _this8.stackVec3.length) { var newArray = new Array(_this8.sizeVec3 << 1); var _g = 0; var _g1 = _this8.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = _this8.stackVec3[i]; _this8.stackVec3[i] = null; } _this8.stackVec3 = newArray; } _this8.stackVec3[_this8.sizeVec3++] = pos; } var _this9 = this.p; if (rot != null) { rot.e00 = 1; rot.e01 = 0; rot.e02 = 0; rot.e10 = 0; rot.e11 = 1; rot.e12 = 0; rot.e20 = 0; rot.e21 = 0; rot.e22 = 1; if (_this9.sizeMat3 == _this9.stackMat3.length) { var _newArray54 = new Array(_this9.sizeMat3 << 1); var _g150 = 0; var _g151 = _this9.sizeMat3; while (_g150 < _g151) { var _i63 = _g150++; _newArray54[_i63] = _this9.stackMat3[_i63]; _this9.stackMat3[_i63] = null; } _this9.stackMat3 = _newArray54; } _this9.stackMat3[_this9.sizeMat3++] = rot; } var _this10 = this.p; if (ex != null) { ex.zero(); if (_this10.sizeVec3 == _this10.stackVec3.length) { var _newArray55 = new Array(_this10.sizeVec3 << 1); var _g152 = 0; var _g153 = _this10.sizeVec3; while (_g152 < _g153) { var _i64 = _g152++; _newArray55[_i64] = _this10.stackVec3[_i64]; _this10.stackVec3[_i64] = null; } _this10.stackVec3 = _newArray55; } _this10.stackVec3[_this10.sizeVec3++] = ex; } var _this11 = this.p; if (ey != null) { ey.zero(); if (_this11.sizeVec3 == _this11.stackVec3.length) { var _newArray56 = new Array(_this11.sizeVec3 << 1); var _g154 = 0; var _g155 = _this11.sizeVec3; while (_g154 < _g155) { var _i65 = _g154++; _newArray56[_i65] = _this11.stackVec3[_i65]; _this11.stackVec3[_i65] = null; } _this11.stackVec3 = _newArray56; } _this11.stackVec3[_this11.sizeVec3++] = ey; } var _this12 = this.p; if (ez != null) { ez.zero(); if (_this12.sizeVec3 == _this12.stackVec3.length) { var _newArray57 = new Array(_this12.sizeVec3 << 1); var _g156 = 0; var _g157 = _this12.sizeVec3; while (_g156 < _g157) { var _i66 = _g156++; _newArray57[_i66] = _this12.stackVec3[_i66]; _this12.stackVec3[_i66] = null; } _this12.stackVec3 = _newArray57; } _this12.stackVec3[_this12.sizeVec3++] = ez; } } }, { key: "ellipse", value: function ellipse(center, ex, ey, radiusX, radiusY, color) { this.arc(center, ex, ey, radiusX, radiusY, 0, 6.28318530717958, false, color); } }, { key: "arc", value: function arc(center, ex, ey, radiusX, radiusY, startAngle, endAngle, drawSector, color) { var _this = this.p; var _this1 = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; _this1.x = ex.x; _this1.y = ex.y; _this1.z = ex.z; var _this2 = _this1; _this2.x *= radiusX; _this2.y *= radiusX; _this2.z *= radiusX; var _this3 = this.p; var _this4 = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3]; _this4.x = ey.x; _this4.y = ey.y; _this4.z = ey.z; var _this5 = _this4; _this5.x *= radiusY; _this5.y *= radiusY; _this5.z *= radiusY; var angDiff = endAngle - startAngle; if (angDiff < 0) { angDiff = -angDiff; } var n = angDiff / 0.52359877559829837 + 0.5 | 0; if (n == 0) { n = 1; } var theta = startAngle; var dt = (endAngle - startAngle) / n; var _this6 = this.p; var _this7 = _this6.sizeVec3 == 0 ? new oimo.common.Vec3() : _this6.stackVec3[--_this6.sizeVec3]; _this7.x = center.x; _this7.y = center.y; _this7.z = center.z; var _this8 = _this7; var s = Math.cos(startAngle); _this8.x += _this2.x * s; _this8.y += _this2.y * s; _this8.z += _this2.z * s; var s1 = Math.sin(startAngle); _this8.x += _this5.x * s1; _this8.y += _this5.y * s1; _this8.z += _this5.z * s1; var prevV = _this8; if (drawSector) { this.line(center, _this8, color); } var _g = 0; var _g1 = n; while (_g < _g1) { ++_g; theta += dt; var _this118 = this.p; var _this119 = _this118.sizeVec3 == 0 ? new oimo.common.Vec3() : _this118.stackVec3[--_this118.sizeVec3]; _this119.x = center.x; _this119.y = center.y; _this119.z = center.z; var _this120 = _this119; var _s8 = Math.cos(theta); _this120.x += _this2.x * _s8; _this120.y += _this2.y * _s8; _this120.z += _this2.z * _s8; var _s9 = Math.sin(theta); _this120.x += _this5.x * _s9; _this120.y += _this5.y * _s9; _this120.z += _this5.z * _s9; this.line(prevV, _this120, color); var _this121 = this.p; if (prevV != null) { prevV.zero(); if (_this121.sizeVec3 == _this121.stackVec3.length) { var newArray = new Array(_this121.sizeVec3 << 1); var _g158 = 0; var _g159 = _this121.sizeVec3; while (_g158 < _g159) { var i = _g158++; newArray[i] = _this121.stackVec3[i]; _this121.stackVec3[i] = null; } _this121.stackVec3 = newArray; } _this121.stackVec3[_this121.sizeVec3++] = prevV; } prevV = _this120; } if (drawSector) { this.line(center, prevV, color); } var _this9 = this.p; if (prevV != null) { prevV.zero(); if (_this9.sizeVec3 == _this9.stackVec3.length) { var _newArray58 = new Array(_this9.sizeVec3 << 1); var _g160 = 0; var _g161 = _this9.sizeVec3; while (_g160 < _g161) { var _i67 = _g160++; _newArray58[_i67] = _this9.stackVec3[_i67]; _this9.stackVec3[_i67] = null; } _this9.stackVec3 = _newArray58; } _this9.stackVec3[_this9.sizeVec3++] = prevV; } var _this10 = this.p; if (_this2 != null) { _this2.zero(); if (_this10.sizeVec3 == _this10.stackVec3.length) { var _newArray59 = new Array(_this10.sizeVec3 << 1); var _g162 = 0; var _g163 = _this10.sizeVec3; while (_g162 < _g163) { var _i68 = _g162++; _newArray59[_i68] = _this10.stackVec3[_i68]; _this10.stackVec3[_i68] = null; } _this10.stackVec3 = _newArray59; } _this10.stackVec3[_this10.sizeVec3++] = _this2; } var _this11 = this.p; if (_this5 != null) { _this5.zero(); if (_this11.sizeVec3 == _this11.stackVec3.length) { var _newArray60 = new Array(_this11.sizeVec3 << 1); var _g164 = 0; var _g165 = _this11.sizeVec3; while (_g164 < _g165) { var _i69 = _g164++; _newArray60[_i69] = _this11.stackVec3[_i69]; _this11.stackVec3[_i69] = null; } _this11.stackVec3 = _newArray60; } _this11.stackVec3[_this11.sizeVec3++] = _this5; } } }, { key: "cone", value: function cone(tf, radius, halfHeight, color) { var _this = this.p; var ex = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; var _this1 = this.p; var ey = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3]; var _this2 = this.p; var ez = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3]; var _this3 = this.p; var o = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3]; var _this4 = this.p; var m = _this4.sizeMat3 == 0 ? new oimo.common.Mat3() : _this4.stackMat3[--_this4.sizeMat3]; var v = o; v.x = tf._positionX; v.y = tf._positionY; v.z = tf._positionZ; var m1 = m; m1.e00 = tf._rotation00; m1.e01 = tf._rotation01; m1.e02 = tf._rotation02; m1.e10 = tf._rotation10; m1.e11 = tf._rotation11; m1.e12 = tf._rotation12; m1.e20 = tf._rotation20; m1.e21 = tf._rotation21; m1.e22 = tf._rotation22; ex.init(m.e00, m.e10, m.e20); ey.init(m.e01, m.e11, m.e21); ez.init(m.e02, m.e12, m.e22); var _this5 = this.p; var _this6 = _this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3]; _this6.x = o.x; _this6.y = o.y; _this6.z = o.z; var _this7 = _this6; _this7.x += ey.x * halfHeight; _this7.y += ey.y * halfHeight; _this7.z += ey.z * halfHeight; var _this8 = this.p; var _this9 = _this8.sizeVec3 == 0 ? new oimo.common.Vec3() : _this8.stackVec3[--_this8.sizeVec3]; _this9.x = o.x; _this9.y = o.y; _this9.z = o.z; var _this10 = _this9; var s = -halfHeight; _this10.x += ey.x * s; _this10.y += ey.y * s; _this10.z += ey.z * s; if (this.wireframe) { var _this122 = this.p; var _this123 = _this122.sizeVec3 == 0 ? new oimo.common.Vec3() : _this122.stackVec3[--_this122.sizeVec3]; _this123.x = _this10.x; _this123.y = _this10.y; _this123.z = _this10.z; var _this124 = _this123; var _s10 = -radius; _this124.x += ex.x * _s10; _this124.y += ex.y * _s10; _this124.z += ex.z * _s10; _this124.x += ez.x * 0; _this124.y += ez.y * 0; _this124.z += ez.z * 0; var _this125 = this.p; var _this126 = _this125.sizeVec3 == 0 ? new oimo.common.Vec3() : _this125.stackVec3[--_this125.sizeVec3]; _this126.x = _this10.x; _this126.y = _this10.y; _this126.z = _this10.z; var _this127 = _this126; _this127.x += ex.x * radius; _this127.y += ex.y * radius; _this127.z += ex.z * radius; _this127.x += ez.x * 0; _this127.y += ez.y * 0; _this127.z += ez.z * 0; var _this128 = this.p; var _this129 = _this128.sizeVec3 == 0 ? new oimo.common.Vec3() : _this128.stackVec3[--_this128.sizeVec3]; _this129.x = _this10.x; _this129.y = _this10.y; _this129.z = _this10.z; var _this130 = _this129; _this130.x += ex.x * 0; _this130.y += ex.y * 0; _this130.z += ex.z * 0; var s1 = -radius; _this130.x += ez.x * s1; _this130.y += ez.y * s1; _this130.z += ez.z * s1; var _this131 = this.p; var _this132 = _this131.sizeVec3 == 0 ? new oimo.common.Vec3() : _this131.stackVec3[--_this131.sizeVec3]; _this132.x = _this10.x; _this132.y = _this10.y; _this132.z = _this10.z; var _this133 = _this132; _this133.x += ex.x * 0; _this133.y += ex.y * 0; _this133.z += ex.z * 0; _this133.x += ez.x * radius; _this133.y += ez.y * radius; _this133.z += ez.z * radius; this.ellipse(_this10, ex, ez, radius, radius, color); this.line(_this7, _this124, color); this.line(_this7, _this127, color); this.line(_this7, _this130, color); this.line(_this7, _this133, color); var _this134 = this.p; if (_this124 != null) { _this124.zero(); if (_this134.sizeVec3 == _this134.stackVec3.length) { var newArray = new Array(_this134.sizeVec3 << 1); var _g = 0; var _g1 = _this134.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = _this134.stackVec3[i]; _this134.stackVec3[i] = null; } _this134.stackVec3 = newArray; } _this134.stackVec3[_this134.sizeVec3++] = _this124; } var _this135 = this.p; if (_this127 != null) { _this127.zero(); if (_this135.sizeVec3 == _this135.stackVec3.length) { var _newArray61 = new Array(_this135.sizeVec3 << 1); var _g166 = 0; var _g167 = _this135.sizeVec3; while (_g166 < _g167) { var _i70 = _g166++; _newArray61[_i70] = _this135.stackVec3[_i70]; _this135.stackVec3[_i70] = null; } _this135.stackVec3 = _newArray61; } _this135.stackVec3[_this135.sizeVec3++] = _this127; } var _this136 = this.p; if (_this130 != null) { _this130.zero(); if (_this136.sizeVec3 == _this136.stackVec3.length) { var _newArray62 = new Array(_this136.sizeVec3 << 1); var _g168 = 0; var _g169 = _this136.sizeVec3; while (_g168 < _g169) { var _i71 = _g168++; _newArray62[_i71] = _this136.stackVec3[_i71]; _this136.stackVec3[_i71] = null; } _this136.stackVec3 = _newArray62; } _this136.stackVec3[_this136.sizeVec3++] = _this130; } var _this137 = this.p; if (_this133 != null) { _this133.zero(); if (_this137.sizeVec3 == _this137.stackVec3.length) { var _newArray63 = new Array(_this137.sizeVec3 << 1); var _g170 = 0; var _g171 = _this137.sizeVec3; while (_g170 < _g171) { var _i72 = _g170++; _newArray63[_i72] = _this137.stackVec3[_i72]; _this137.stackVec3[_i72] = null; } _this137.stackVec3 = _newArray63; } _this137.stackVec3[_this137.sizeVec3++] = _this133; } } else { var invDenom = 1 / Math.sqrt(radius * radius + 4 * halfHeight * halfHeight); var cos = 2 * halfHeight * invDenom; var sin = radius * invDenom; var _g172 = 0; while (_g172 < 8) { var _i73 = _g172++; var _this138 = this.tmpCircleNorms[_i73]; var _v54 = this.circleCoords[_i73]; _this138.x = _v54.x; _this138.y = _v54.y; _this138.z = _v54.z; _this138.x *= cos; _this138.y *= cos; _this138.z *= cos; _this138.y += sin; var _this139 = this.tmpCircleNorms[_i73]; var y = _this139.x * m.e10 + _this139.y * m.e11 + _this139.z * m.e12; var z = _this139.x * m.e20 + _this139.y * m.e21 + _this139.z * m.e22; _this139.x = _this139.x * m.e00 + _this139.y * m.e01 + _this139.z * m.e02; _this139.y = y; _this139.z = z; var _this140 = this.tmpCircleVerts1[_i73]; var v1 = this.circleCoordsShift[_i73]; _this140.x = v1.x; _this140.y = v1.y; _this140.z = v1.z; _this140.x *= cos; _this140.y *= cos; _this140.z *= cos; _this140.y += sin; var _this141 = this.tmpCircleVerts1[_i73]; var y1 = _this141.x * m.e10 + _this141.y * m.e11 + _this141.z * m.e12; var z1 = _this141.x * m.e20 + _this141.y * m.e21 + _this141.z * m.e22; _this141.x = _this141.x * m.e00 + _this141.y * m.e01 + _this141.z * m.e02; _this141.y = y1; _this141.z = z1; var _this142 = this.tmpCircleVerts2[_i73]; var v2 = this.circleCoords[_i73]; _this142.x = v2.x; _this142.y = v2.y; _this142.z = v2.z; var y2 = _this142.x * m.e10 + _this142.y * m.e11 + _this142.z * m.e12; var z2 = _this142.x * m.e20 + _this142.y * m.e21 + _this142.z * m.e22; _this142.x = _this142.x * m.e00 + _this142.y * m.e01 + _this142.z * m.e02; _this142.y = y2; _this142.z = z2; _this142.x *= radius; _this142.y *= radius; _this142.z *= radius; _this142.x += o.x; _this142.y += o.y; _this142.z += o.z; var _this143 = this.tmpCircleVerts2[_i73]; var _s11 = -halfHeight; _this143.x += ey.x * _s11; _this143.y += ey.y * _s11; _this143.z += ey.z * _s11; } var _g173 = 0; while (_g173 < 8) { var _i74 = _g173++; var _v55 = this.tmpCircleVerts2[_i74]; var v3 = this.tmpCircleVerts2[(_i74 + 1) % 8]; var n1 = this.tmpCircleVerts1[_i74]; this.triangle(_this7, _v55, v3, n1, this.tmpCircleNorms[_i74], this.tmpCircleNorms[(_i74 + 1) % 8], color); _v55 = this.tmpCircleVerts2[(_i74 + 1) % 8]; v3 = this.tmpCircleVerts2[_i74]; var _this144 = this.p; var _this145 = _this144.sizeVec3 == 0 ? new oimo.common.Vec3() : _this144.stackVec3[--_this144.sizeVec3]; _this145.x = ey.x; _this145.y = ey.y; _this145.z = ey.z; var _this146 = _this145; _this146.x = -_this146.x; _this146.y = -_this146.y; _this146.z = -_this146.z; this.triangle(_this10, _v55, v3, _this146, _this146, _this146, color); var _this147 = this.p; if (_this146 != null) { _this146.zero(); if (_this147.sizeVec3 == _this147.stackVec3.length) { var _newArray64 = new Array(_this147.sizeVec3 << 1); var _g174 = 0; var _g175 = _this147.sizeVec3; while (_g174 < _g175) { var _i75 = _g174++; _newArray64[_i75] = _this147.stackVec3[_i75]; _this147.stackVec3[_i75] = null; } _this147.stackVec3 = _newArray64; } _this147.stackVec3[_this147.sizeVec3++] = _this146; } } } var _this11 = this.p; if (_this7 != null) { _this7.zero(); if (_this11.sizeVec3 == _this11.stackVec3.length) { var _newArray65 = new Array(_this11.sizeVec3 << 1); var _g176 = 0; var _g177 = _this11.sizeVec3; while (_g176 < _g177) { var _i76 = _g176++; _newArray65[_i76] = _this11.stackVec3[_i76]; _this11.stackVec3[_i76] = null; } _this11.stackVec3 = _newArray65; } _this11.stackVec3[_this11.sizeVec3++] = _this7; } var _this12 = this.p; if (_this10 != null) { _this10.zero(); if (_this12.sizeVec3 == _this12.stackVec3.length) { var _newArray66 = new Array(_this12.sizeVec3 << 1); var _g178 = 0; var _g179 = _this12.sizeVec3; while (_g178 < _g179) { var _i77 = _g178++; _newArray66[_i77] = _this12.stackVec3[_i77]; _this12.stackVec3[_i77] = null; } _this12.stackVec3 = _newArray66; } _this12.stackVec3[_this12.sizeVec3++] = _this10; } var _this13 = this.p; if (o != null) { o.zero(); if (_this13.sizeVec3 == _this13.stackVec3.length) { var _newArray67 = new Array(_this13.sizeVec3 << 1); var _g180 = 0; var _g181 = _this13.sizeVec3; while (_g180 < _g181) { var _i78 = _g180++; _newArray67[_i78] = _this13.stackVec3[_i78]; _this13.stackVec3[_i78] = null; } _this13.stackVec3 = _newArray67; } _this13.stackVec3[_this13.sizeVec3++] = o; } var _this14 = this.p; if (m != null) { m.e00 = 1; m.e01 = 0; m.e02 = 0; m.e10 = 0; m.e11 = 1; m.e12 = 0; m.e20 = 0; m.e21 = 0; m.e22 = 1; if (_this14.sizeMat3 == _this14.stackMat3.length) { var _newArray68 = new Array(_this14.sizeMat3 << 1); var _g182 = 0; var _g183 = _this14.sizeMat3; while (_g182 < _g183) { var _i79 = _g182++; _newArray68[_i79] = _this14.stackMat3[_i79]; _this14.stackMat3[_i79] = null; } _this14.stackMat3 = _newArray68; } _this14.stackMat3[_this14.sizeMat3++] = m; } var _this15 = this.p; if (ex != null) { ex.zero(); if (_this15.sizeVec3 == _this15.stackVec3.length) { var _newArray69 = new Array(_this15.sizeVec3 << 1); var _g184 = 0; var _g185 = _this15.sizeVec3; while (_g184 < _g185) { var _i80 = _g184++; _newArray69[_i80] = _this15.stackVec3[_i80]; _this15.stackVec3[_i80] = null; } _this15.stackVec3 = _newArray69; } _this15.stackVec3[_this15.sizeVec3++] = ex; } var _this16 = this.p; if (ey != null) { ey.zero(); if (_this16.sizeVec3 == _this16.stackVec3.length) { var _newArray70 = new Array(_this16.sizeVec3 << 1); var _g186 = 0; var _g187 = _this16.sizeVec3; while (_g186 < _g187) { var _i81 = _g186++; _newArray70[_i81] = _this16.stackVec3[_i81]; _this16.stackVec3[_i81] = null; } _this16.stackVec3 = _newArray70; } _this16.stackVec3[_this16.sizeVec3++] = ey; } var _this17 = this.p; if (ez != null) { ez.zero(); if (_this17.sizeVec3 == _this17.stackVec3.length) { var _newArray71 = new Array(_this17.sizeVec3 << 1); var _g188 = 0; var _g189 = _this17.sizeVec3; while (_g188 < _g189) { var _i82 = _g188++; _newArray71[_i82] = _this17.stackVec3[_i82]; _this17.stackVec3[_i82] = null; } _this17.stackVec3 = _newArray71; } _this17.stackVec3[_this17.sizeVec3++] = ez; } } }, { key: "cylinder", value: function cylinder(tf, radius, halfHeight, color) { var _this = this.p; var ex = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; var _this1 = this.p; var ey = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3]; var _this2 = this.p; var ez = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3]; var _this3 = this.p; var o = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3]; var _this4 = this.p; var m = _this4.sizeMat3 == 0 ? new oimo.common.Mat3() : _this4.stackMat3[--_this4.sizeMat3]; var v = o; v.x = tf._positionX; v.y = tf._positionY; v.z = tf._positionZ; var m1 = m; m1.e00 = tf._rotation00; m1.e01 = tf._rotation01; m1.e02 = tf._rotation02; m1.e10 = tf._rotation10; m1.e11 = tf._rotation11; m1.e12 = tf._rotation12; m1.e20 = tf._rotation20; m1.e21 = tf._rotation21; m1.e22 = tf._rotation22; ex.init(m.e00, m.e10, m.e20); ey.init(m.e01, m.e11, m.e21); ez.init(m.e02, m.e12, m.e22); var _this5 = this.p; var _this6 = _this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3]; _this6.x = o.x; _this6.y = o.y; _this6.z = o.z; var _this7 = _this6; _this7.x += ey.x * halfHeight; _this7.y += ey.y * halfHeight; _this7.z += ey.z * halfHeight; var _this8 = this.p; var _this9 = _this8.sizeVec3 == 0 ? new oimo.common.Vec3() : _this8.stackVec3[--_this8.sizeVec3]; _this9.x = o.x; _this9.y = o.y; _this9.z = o.z; var _this10 = _this9; var s = -halfHeight; _this10.x += ey.x * s; _this10.y += ey.y * s; _this10.z += ey.z * s; if (this.wireframe) { var _this148 = this.p; var _this149 = _this148.sizeVec3 == 0 ? new oimo.common.Vec3() : _this148.stackVec3[--_this148.sizeVec3]; _this149.x = _this7.x; _this149.y = _this7.y; _this149.z = _this7.z; var _this150 = _this149; var _s12 = -radius; _this150.x += ex.x * _s12; _this150.y += ex.y * _s12; _this150.z += ex.z * _s12; _this150.x += ez.x * 0; _this150.y += ez.y * 0; _this150.z += ez.z * 0; var _this151 = this.p; var _this152 = _this151.sizeVec3 == 0 ? new oimo.common.Vec3() : _this151.stackVec3[--_this151.sizeVec3]; _this152.x = _this7.x; _this152.y = _this7.y; _this152.z = _this7.z; var _this153 = _this152; _this153.x += ex.x * radius; _this153.y += ex.y * radius; _this153.z += ex.z * radius; _this153.x += ez.x * 0; _this153.y += ez.y * 0; _this153.z += ez.z * 0; var _this154 = this.p; var _this155 = _this154.sizeVec3 == 0 ? new oimo.common.Vec3() : _this154.stackVec3[--_this154.sizeVec3]; _this155.x = _this7.x; _this155.y = _this7.y; _this155.z = _this7.z; var _this156 = _this155; _this156.x += ex.x * 0; _this156.y += ex.y * 0; _this156.z += ex.z * 0; var s1 = -radius; _this156.x += ez.x * s1; _this156.y += ez.y * s1; _this156.z += ez.z * s1; var _this157 = this.p; var _this158 = _this157.sizeVec3 == 0 ? new oimo.common.Vec3() : _this157.stackVec3[--_this157.sizeVec3]; _this158.x = _this7.x; _this158.y = _this7.y; _this158.z = _this7.z; var _this159 = _this158; _this159.x += ex.x * 0; _this159.y += ex.y * 0; _this159.z += ex.z * 0; _this159.x += ez.x * radius; _this159.y += ez.y * radius; _this159.z += ez.z * radius; var _this160 = this.p; var _this161 = _this160.sizeVec3 == 0 ? new oimo.common.Vec3() : _this160.stackVec3[--_this160.sizeVec3]; _this161.x = _this10.x; _this161.y = _this10.y; _this161.z = _this10.z; var _this162 = _this161; var s2 = -radius; _this162.x += ex.x * s2; _this162.y += ex.y * s2; _this162.z += ex.z * s2; _this162.x += ez.x * 0; _this162.y += ez.y * 0; _this162.z += ez.z * 0; var _this163 = this.p; var _this18 = _this163.sizeVec3 == 0 ? new oimo.common.Vec3() : _this163.stackVec3[--_this163.sizeVec3]; _this18.x = _this10.x; _this18.y = _this10.y; _this18.z = _this10.z; var _this19 = _this18; _this19.x += ex.x * radius; _this19.y += ex.y * radius; _this19.z += ex.z * radius; _this19.x += ez.x * 0; _this19.y += ez.y * 0; _this19.z += ez.z * 0; var _this20 = this.p; var _this21 = _this20.sizeVec3 == 0 ? new oimo.common.Vec3() : _this20.stackVec3[--_this20.sizeVec3]; _this21.x = _this10.x; _this21.y = _this10.y; _this21.z = _this10.z; var _this22 = _this21; _this22.x += ex.x * 0; _this22.y += ex.y * 0; _this22.z += ex.z * 0; var s3 = -radius; _this22.x += ez.x * s3; _this22.y += ez.y * s3; _this22.z += ez.z * s3; var _this23 = this.p; var _this24 = _this23.sizeVec3 == 0 ? new oimo.common.Vec3() : _this23.stackVec3[--_this23.sizeVec3]; _this24.x = _this10.x; _this24.y = _this10.y; _this24.z = _this10.z; var _this25 = _this24; _this25.x += ex.x * 0; _this25.y += ex.y * 0; _this25.z += ex.z * 0; _this25.x += ez.x * radius; _this25.y += ez.y * radius; _this25.z += ez.z * radius; this.ellipse(_this7, ex, ez, radius, radius, color); this.ellipse(_this10, ex, ez, radius, radius, color); this.line(_this150, _this162, color); this.line(_this153, _this19, color); this.line(_this156, _this22, color); this.line(_this159, _this25, color); var _this26 = this.p; if (_this150 != null) { _this150.zero(); if (_this26.sizeVec3 == _this26.stackVec3.length) { var newArray = new Array(_this26.sizeVec3 << 1); var _g = 0; var _g1 = _this26.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = _this26.stackVec3[i]; _this26.stackVec3[i] = null; } _this26.stackVec3 = newArray; } _this26.stackVec3[_this26.sizeVec3++] = _this150; } var _this27 = this.p; if (_this153 != null) { _this153.zero(); if (_this27.sizeVec3 == _this27.stackVec3.length) { var _newArray72 = new Array(_this27.sizeVec3 << 1); var _g190 = 0; var _g191 = _this27.sizeVec3; while (_g190 < _g191) { var _i83 = _g190++; _newArray72[_i83] = _this27.stackVec3[_i83]; _this27.stackVec3[_i83] = null; } _this27.stackVec3 = _newArray72; } _this27.stackVec3[_this27.sizeVec3++] = _this153; } var _this28 = this.p; if (_this156 != null) { _this156.zero(); if (_this28.sizeVec3 == _this28.stackVec3.length) { var _newArray73 = new Array(_this28.sizeVec3 << 1); var _g192 = 0; var _g193 = _this28.sizeVec3; while (_g192 < _g193) { var _i84 = _g192++; _newArray73[_i84] = _this28.stackVec3[_i84]; _this28.stackVec3[_i84] = null; } _this28.stackVec3 = _newArray73; } _this28.stackVec3[_this28.sizeVec3++] = _this156; } var _this29 = this.p; if (_this159 != null) { _this159.zero(); if (_this29.sizeVec3 == _this29.stackVec3.length) { var _newArray74 = new Array(_this29.sizeVec3 << 1); var _g194 = 0; var _g195 = _this29.sizeVec3; while (_g194 < _g195) { var _i85 = _g194++; _newArray74[_i85] = _this29.stackVec3[_i85]; _this29.stackVec3[_i85] = null; } _this29.stackVec3 = _newArray74; } _this29.stackVec3[_this29.sizeVec3++] = _this159; } var _this30 = this.p; if (_this162 != null) { _this162.zero(); if (_this30.sizeVec3 == _this30.stackVec3.length) { var _newArray75 = new Array(_this30.sizeVec3 << 1); var _g196 = 0; var _g197 = _this30.sizeVec3; while (_g196 < _g197) { var _i86 = _g196++; _newArray75[_i86] = _this30.stackVec3[_i86]; _this30.stackVec3[_i86] = null; } _this30.stackVec3 = _newArray75; } _this30.stackVec3[_this30.sizeVec3++] = _this162; } var _this31 = this.p; if (_this19 != null) { _this19.zero(); if (_this31.sizeVec3 == _this31.stackVec3.length) { var _newArray76 = new Array(_this31.sizeVec3 << 1); var _g198 = 0; var _g199 = _this31.sizeVec3; while (_g198 < _g199) { var _i87 = _g198++; _newArray76[_i87] = _this31.stackVec3[_i87]; _this31.stackVec3[_i87] = null; } _this31.stackVec3 = _newArray76; } _this31.stackVec3[_this31.sizeVec3++] = _this19; } var _this32 = this.p; if (_this22 != null) { _this22.zero(); if (_this32.sizeVec3 == _this32.stackVec3.length) { var _newArray77 = new Array(_this32.sizeVec3 << 1); var _g200 = 0; var _g201 = _this32.sizeVec3; while (_g200 < _g201) { var _i88 = _g200++; _newArray77[_i88] = _this32.stackVec3[_i88]; _this32.stackVec3[_i88] = null; } _this32.stackVec3 = _newArray77; } _this32.stackVec3[_this32.sizeVec3++] = _this22; } var _this33 = this.p; if (_this25 != null) { _this25.zero(); if (_this33.sizeVec3 == _this33.stackVec3.length) { var _newArray78 = new Array(_this33.sizeVec3 << 1); var _g202 = 0; var _g203 = _this33.sizeVec3; while (_g202 < _g203) { var _i89 = _g202++; _newArray78[_i89] = _this33.stackVec3[_i89]; _this33.stackVec3[_i89] = null; } _this33.stackVec3 = _newArray78; } _this33.stackVec3[_this33.sizeVec3++] = _this25; } } else { var _g204 = 0; while (_g204 < 8) { var _i90 = _g204++; var _this164 = this.tmpCircleNorms[_i90]; var _v56 = this.circleCoords[_i90]; _this164.x = _v56.x; _this164.y = _v56.y; _this164.z = _v56.z; var y = _this164.x * m.e10 + _this164.y * m.e11 + _this164.z * m.e12; var z = _this164.x * m.e20 + _this164.y * m.e21 + _this164.z * m.e22; _this164.x = _this164.x * m.e00 + _this164.y * m.e01 + _this164.z * m.e02; _this164.y = y; _this164.z = z; var _this165 = this.tmpCircleVerts1[_i90]; var v1 = this.tmpCircleNorms[_i90]; _this165.x = v1.x; _this165.y = v1.y; _this165.z = v1.z; _this165.x *= radius; _this165.y *= radius; _this165.z *= radius; _this165.x += o.x; _this165.y += o.y; _this165.z += o.z; var _this166 = this.tmpCircleVerts2[_i90]; var v2 = this.tmpCircleVerts1[_i90]; _this166.x = v2.x; _this166.y = v2.y; _this166.z = v2.z; var _this167 = this.tmpCircleVerts1[_i90]; _this167.x += ey.x * halfHeight; _this167.y += ey.y * halfHeight; _this167.z += ey.z * halfHeight; var _this168 = this.tmpCircleVerts2[_i90]; var _s13 = -halfHeight; _this168.x += ey.x * _s13; _this168.y += ey.y * _s13; _this168.z += ey.z * _s13; } var _g205 = 0; while (_g205 < 8) { var _i91 = _g205++; var _v57 = void 0; var _v58 = this.tmpCircleVerts1[_i91]; var v3 = this.tmpCircleVerts1[(_i91 + 1) % 8]; var n1 = ey; this.triangle(_this7, _v58, v3, n1, n1, n1, color); _v58 = this.tmpCircleVerts2[(_i91 + 1) % 8]; v3 = this.tmpCircleVerts2[_i91]; var _this169 = this.p; var _this170 = _this169.sizeVec3 == 0 ? new oimo.common.Vec3() : _this169.stackVec3[--_this169.sizeVec3]; _this170.x = ey.x; _this170.y = ey.y; _this170.z = ey.z; var _this171 = _this170; _this171.x = -_this171.x; _this171.y = -_this171.y; _this171.z = -_this171.z; this.triangle(_this10, _v58, v3, _this171, _this171, _this171, color); var _this172 = this.p; if (_this171 != null) { _this171.zero(); if (_this172.sizeVec3 == _this172.stackVec3.length) { var _newArray79 = new Array(_this172.sizeVec3 << 1); var _g206 = 0; var _g207 = _this172.sizeVec3; while (_g206 < _g207) { var _i92 = _g206++; _newArray79[_i92] = _this172.stackVec3[_i92]; _this172.stackVec3[_i92] = null; } _this172.stackVec3 = _newArray79; } _this172.stackVec3[_this172.sizeVec3++] = _this171; } _v57 = this.tmpCircleVerts1[_i91]; _v58 = this.tmpCircleVerts2[_i91]; v3 = this.tmpCircleVerts2[(_i91 + 1) % 8]; n1 = this.tmpCircleNorms[_i91]; var n2 = this.tmpCircleNorms[(_i91 + 1) % 8]; this.rect(_v57, _v58, v3, this.tmpCircleVerts1[(_i91 + 1) % 8], n1, n1, n2, n2, color); } } var _this11 = this.p; if (_this7 != null) { _this7.zero(); if (_this11.sizeVec3 == _this11.stackVec3.length) { var _newArray80 = new Array(_this11.sizeVec3 << 1); var _g208 = 0; var _g209 = _this11.sizeVec3; while (_g208 < _g209) { var _i93 = _g208++; _newArray80[_i93] = _this11.stackVec3[_i93]; _this11.stackVec3[_i93] = null; } _this11.stackVec3 = _newArray80; } _this11.stackVec3[_this11.sizeVec3++] = _this7; } var _this12 = this.p; if (_this10 != null) { _this10.zero(); if (_this12.sizeVec3 == _this12.stackVec3.length) { var _newArray81 = new Array(_this12.sizeVec3 << 1); var _g210 = 0; var _g211 = _this12.sizeVec3; while (_g210 < _g211) { var _i94 = _g210++; _newArray81[_i94] = _this12.stackVec3[_i94]; _this12.stackVec3[_i94] = null; } _this12.stackVec3 = _newArray81; } _this12.stackVec3[_this12.sizeVec3++] = _this10; } var _this13 = this.p; if (o != null) { o.zero(); if (_this13.sizeVec3 == _this13.stackVec3.length) { var _newArray82 = new Array(_this13.sizeVec3 << 1); var _g212 = 0; var _g213 = _this13.sizeVec3; while (_g212 < _g213) { var _i95 = _g212++; _newArray82[_i95] = _this13.stackVec3[_i95]; _this13.stackVec3[_i95] = null; } _this13.stackVec3 = _newArray82; } _this13.stackVec3[_this13.sizeVec3++] = o; } var _this14 = this.p; if (m != null) { m.e00 = 1; m.e01 = 0; m.e02 = 0; m.e10 = 0; m.e11 = 1; m.e12 = 0; m.e20 = 0; m.e21 = 0; m.e22 = 1; if (_this14.sizeMat3 == _this14.stackMat3.length) { var _newArray83 = new Array(_this14.sizeMat3 << 1); var _g214 = 0; var _g215 = _this14.sizeMat3; while (_g214 < _g215) { var _i96 = _g214++; _newArray83[_i96] = _this14.stackMat3[_i96]; _this14.stackMat3[_i96] = null; } _this14.stackMat3 = _newArray83; } _this14.stackMat3[_this14.sizeMat3++] = m; } var _this15 = this.p; if (ex != null) { ex.zero(); if (_this15.sizeVec3 == _this15.stackVec3.length) { var _newArray84 = new Array(_this15.sizeVec3 << 1); var _g216 = 0; var _g217 = _this15.sizeVec3; while (_g216 < _g217) { var _i97 = _g216++; _newArray84[_i97] = _this15.stackVec3[_i97]; _this15.stackVec3[_i97] = null; } _this15.stackVec3 = _newArray84; } _this15.stackVec3[_this15.sizeVec3++] = ex; } var _this16 = this.p; if (ey != null) { ey.zero(); if (_this16.sizeVec3 == _this16.stackVec3.length) { var _newArray85 = new Array(_this16.sizeVec3 << 1); var _g218 = 0; var _g219 = _this16.sizeVec3; while (_g218 < _g219) { var _i98 = _g218++; _newArray85[_i98] = _this16.stackVec3[_i98]; _this16.stackVec3[_i98] = null; } _this16.stackVec3 = _newArray85; } _this16.stackVec3[_this16.sizeVec3++] = ey; } var _this17 = this.p; if (ez != null) { ez.zero(); if (_this17.sizeVec3 == _this17.stackVec3.length) { var _newArray86 = new Array(_this17.sizeVec3 << 1); var _g220 = 0; var _g221 = _this17.sizeVec3; while (_g220 < _g221) { var _i99 = _g220++; _newArray86[_i99] = _this17.stackVec3[_i99]; _this17.stackVec3[_i99] = null; } _this17.stackVec3 = _newArray86; } _this17.stackVec3[_this17.sizeVec3++] = ez; } } }, { key: "capsule", value: function capsule(tf, radius, halfHeight, color) { var _this = this.p; var ex = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; var _this1 = this.p; var ey = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3]; var _this2 = this.p; var ez = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3]; var _this3 = this.p; var o = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3]; var _this4 = this.p; var m = _this4.sizeMat3 == 0 ? new oimo.common.Mat3() : _this4.stackMat3[--_this4.sizeMat3]; var v = o; v.x = tf._positionX; v.y = tf._positionY; v.z = tf._positionZ; var m1 = m; m1.e00 = tf._rotation00; m1.e01 = tf._rotation01; m1.e02 = tf._rotation02; m1.e10 = tf._rotation10; m1.e11 = tf._rotation11; m1.e12 = tf._rotation12; m1.e20 = tf._rotation20; m1.e21 = tf._rotation21; m1.e22 = tf._rotation22; ex.init(m.e00, m.e10, m.e20); ey.init(m.e01, m.e11, m.e21); ez.init(m.e02, m.e12, m.e22); var vs = this.tmpSphereVerts; var ns = this.tmpSphereNorms; var _g = 0; while (_g < 5) { var i2 = _g++; var n = this.tmpSphereVerts[i2].length; var _g222 = 0; while (_g222 < n) { var j2 = _g222++; var _this173 = ns[i2][j2]; var _v59 = this.sphereCoords[i2][j2]; _this173.x = _v59.x; _this173.y = _v59.y; _this173.z = _v59.z; var y = _this173.x * m.e10 + _this173.y * m.e11 + _this173.z * m.e12; var z = _this173.x * m.e20 + _this173.y * m.e21 + _this173.z * m.e22; _this173.x = _this173.x * m.e00 + _this173.y * m.e01 + _this173.z * m.e02; _this173.y = y; _this173.z = z; } } var _g1 = 0; while (_g1 < 4) { var i = _g1++; if (i == 0) { var _g224 = 0; while (_g224 < 3) { var _i100 = _g224++; var _n7 = this.tmpSphereVerts[_i100].length; var _g225 = 0; while (_g225 < _n7) { var _j = _g225++; var _this174 = vs[_i100][_j]; var _v60 = ns[_i100][_j]; _this174.x = _v60.x; _this174.y = _v60.y; _this174.z = _v60.z; _this174.x *= radius; _this174.y *= radius; _this174.z *= radius; _this174.x += o.x; _this174.y += o.y; _this174.z += o.z; _this174.x += ey.x * halfHeight; _this174.y += ey.y * halfHeight; _this174.z += ey.z * halfHeight; } } } if (i == 2) { var _g226 = 2; while (_g226 < 5) { var _i101 = _g226++; var _n8 = this.tmpSphereVerts[_i101].length; var _g227 = 0; while (_g227 < _n8) { var _j2 = _g227++; var _this175 = vs[_i101][_j2]; var _v61 = ns[_i101][_j2]; _this175.x = _v61.x; _this175.y = _v61.y; _this175.z = _v61.z; _this175.x *= radius; _this175.y *= radius; _this175.z *= radius; _this175.x += o.x; _this175.y += o.y; _this175.z += o.z; var _s14 = -halfHeight; _this175.x += ey.x * _s14; _this175.y += ey.y * _s14; _this175.z += ey.z * _s14; } } } var _g223 = 0; while (_g223 < 8) { var j = _g223++; var v1 = void 0; var v2 = void 0; var v3 = void 0; var v4 = void 0; var n1 = void 0; var n2 = void 0; var n3 = void 0; var n4 = void 0; if (i == 0) { if (this.wireframe) { v1 = vs[0][0]; v2 = vs[1][j]; this.line(v1, v2, color); } else { v1 = vs[0][0]; v2 = vs[1][j]; v3 = vs[1][(j + 1) % 8]; n1 = ns[0][0]; n2 = ns[1][j]; n3 = ns[1][(j + 1) % 8]; this.triangle(v1, v2, v3, n1, n2, n3, color); } } else if (i == 3) { if (this.wireframe) { v1 = vs[4][0]; v2 = vs[i][(j + 1) % 8]; v3 = vs[i][j]; this.line(v1, v2, color); this.line(v2, v3, color); } else { v1 = vs[4][0]; v2 = vs[i][(j + 1) % 8]; v3 = vs[i][j]; n1 = ns[4][0]; n2 = ns[i][(j + 1) % 8]; n3 = ns[i][j]; this.triangle(v1, v2, v3, n1, n2, n3, color); } } else if (this.wireframe) { v1 = vs[i][j]; v2 = vs[i][(j + 1) % 8]; v3 = vs[i + 1][j]; this.line(v1, v2, color); this.line(v1, v3, color); } else { v1 = vs[i][j]; v2 = vs[i][(j + 1) % 8]; v3 = vs[i + 1][j]; v4 = vs[i + 1][(j + 1) % 8]; n1 = ns[i][j]; n2 = ns[i][(j + 1) % 8]; n3 = ns[i + 1][j]; n4 = ns[i + 1][(j + 1) % 8]; this.rect(v1, v3, v4, v2, n1, n3, n4, n2, color); } } } var _this5 = this.p; var _this6 = _this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3]; _this6.x = o.x; _this6.y = o.y; _this6.z = o.z; var _this7 = _this6; _this7.x += ey.x * halfHeight; _this7.y += ey.y * halfHeight; _this7.z += ey.z * halfHeight; var _this8 = this.p; var _this9 = _this8.sizeVec3 == 0 ? new oimo.common.Vec3() : _this8.stackVec3[--_this8.sizeVec3]; _this9.x = o.x; _this9.y = o.y; _this9.z = o.z; var _this10 = _this9; var s = -halfHeight; _this10.x += ey.x * s; _this10.y += ey.y * s; _this10.z += ey.z * s; if (this.wireframe) { var _this176 = this.p; var _this177 = _this176.sizeVec3 == 0 ? new oimo.common.Vec3() : _this176.stackVec3[--_this176.sizeVec3]; _this177.x = _this7.x; _this177.y = _this7.y; _this177.z = _this7.z; var _this178 = _this177; var _s15 = -radius; _this178.x += ex.x * _s15; _this178.y += ex.y * _s15; _this178.z += ex.z * _s15; _this178.x += ez.x * 0; _this178.y += ez.y * 0; _this178.z += ez.z * 0; var _this179 = this.p; var _this180 = _this179.sizeVec3 == 0 ? new oimo.common.Vec3() : _this179.stackVec3[--_this179.sizeVec3]; _this180.x = _this7.x; _this180.y = _this7.y; _this180.z = _this7.z; var _this181 = _this180; _this181.x += ex.x * radius; _this181.y += ex.y * radius; _this181.z += ex.z * radius; _this181.x += ez.x * 0; _this181.y += ez.y * 0; _this181.z += ez.z * 0; var _this182 = this.p; var _this183 = _this182.sizeVec3 == 0 ? new oimo.common.Vec3() : _this182.stackVec3[--_this182.sizeVec3]; _this183.x = _this7.x; _this183.y = _this7.y; _this183.z = _this7.z; var _this184 = _this183; _this184.x += ex.x * 0; _this184.y += ex.y * 0; _this184.z += ex.z * 0; var s1 = -radius; _this184.x += ez.x * s1; _this184.y += ez.y * s1; _this184.z += ez.z * s1; var _this185 = this.p; var _this186 = _this185.sizeVec3 == 0 ? new oimo.common.Vec3() : _this185.stackVec3[--_this185.sizeVec3]; _this186.x = _this7.x; _this186.y = _this7.y; _this186.z = _this7.z; var _this187 = _this186; _this187.x += ex.x * 0; _this187.y += ex.y * 0; _this187.z += ex.z * 0; _this187.x += ez.x * radius; _this187.y += ez.y * radius; _this187.z += ez.z * radius; var _this188 = this.p; var _this189 = _this188.sizeVec3 == 0 ? new oimo.common.Vec3() : _this188.stackVec3[--_this188.sizeVec3]; _this189.x = _this10.x; _this189.y = _this10.y; _this189.z = _this10.z; var _this190 = _this189; var s2 = -radius; _this190.x += ex.x * s2; _this190.y += ex.y * s2; _this190.z += ex.z * s2; _this190.x += ez.x * 0; _this190.y += ez.y * 0; _this190.z += ez.z * 0; var _this191 = this.p; var _this18 = _this191.sizeVec3 == 0 ? new oimo.common.Vec3() : _this191.stackVec3[--_this191.sizeVec3]; _this18.x = _this10.x; _this18.y = _this10.y; _this18.z = _this10.z; var _this19 = _this18; _this19.x += ex.x * radius; _this19.y += ex.y * radius; _this19.z += ex.z * radius; _this19.x += ez.x * 0; _this19.y += ez.y * 0; _this19.z += ez.z * 0; var _this20 = this.p; var _this21 = _this20.sizeVec3 == 0 ? new oimo.common.Vec3() : _this20.stackVec3[--_this20.sizeVec3]; _this21.x = _this10.x; _this21.y = _this10.y; _this21.z = _this10.z; var _this22 = _this21; _this22.x += ex.x * 0; _this22.y += ex.y * 0; _this22.z += ex.z * 0; var s3 = -radius; _this22.x += ez.x * s3; _this22.y += ez.y * s3; _this22.z += ez.z * s3; var _this23 = this.p; var _this24 = _this23.sizeVec3 == 0 ? new oimo.common.Vec3() : _this23.stackVec3[--_this23.sizeVec3]; _this24.x = _this10.x; _this24.y = _this10.y; _this24.z = _this10.z; var _this25 = _this24; _this25.x += ex.x * 0; _this25.y += ex.y * 0; _this25.z += ex.z * 0; _this25.x += ez.x * radius; _this25.y += ez.y * radius; _this25.z += ez.z * radius; this.ellipse(_this7, ex, ez, radius, radius, color); this.ellipse(_this10, ex, ez, radius, radius, color); this.line(_this178, _this190, color); this.line(_this181, _this19, color); this.line(_this184, _this22, color); this.line(_this187, _this25, color); var _this26 = this.p; if (_this178 != null) { _this178.zero(); if (_this26.sizeVec3 == _this26.stackVec3.length) { var newArray = new Array(_this26.sizeVec3 << 1); var _g228 = 0; var _g229 = _this26.sizeVec3; while (_g228 < _g229) { var _i102 = _g228++; newArray[_i102] = _this26.stackVec3[_i102]; _this26.stackVec3[_i102] = null; } _this26.stackVec3 = newArray; } _this26.stackVec3[_this26.sizeVec3++] = _this178; } var _this27 = this.p; if (_this181 != null) { _this181.zero(); if (_this27.sizeVec3 == _this27.stackVec3.length) { var _newArray87 = new Array(_this27.sizeVec3 << 1); var _g230 = 0; var _g231 = _this27.sizeVec3; while (_g230 < _g231) { var _i103 = _g230++; _newArray87[_i103] = _this27.stackVec3[_i103]; _this27.stackVec3[_i103] = null; } _this27.stackVec3 = _newArray87; } _this27.stackVec3[_this27.sizeVec3++] = _this181; } var _this28 = this.p; if (_this184 != null) { _this184.zero(); if (_this28.sizeVec3 == _this28.stackVec3.length) { var _newArray88 = new Array(_this28.sizeVec3 << 1); var _g232 = 0; var _g233 = _this28.sizeVec3; while (_g232 < _g233) { var _i104 = _g232++; _newArray88[_i104] = _this28.stackVec3[_i104]; _this28.stackVec3[_i104] = null; } _this28.stackVec3 = _newArray88; } _this28.stackVec3[_this28.sizeVec3++] = _this184; } var _this29 = this.p; if (_this187 != null) { _this187.zero(); if (_this29.sizeVec3 == _this29.stackVec3.length) { var _newArray89 = new Array(_this29.sizeVec3 << 1); var _g234 = 0; var _g235 = _this29.sizeVec3; while (_g234 < _g235) { var _i105 = _g234++; _newArray89[_i105] = _this29.stackVec3[_i105]; _this29.stackVec3[_i105] = null; } _this29.stackVec3 = _newArray89; } _this29.stackVec3[_this29.sizeVec3++] = _this187; } var _this30 = this.p; if (_this190 != null) { _this190.zero(); if (_this30.sizeVec3 == _this30.stackVec3.length) { var _newArray90 = new Array(_this30.sizeVec3 << 1); var _g236 = 0; var _g237 = _this30.sizeVec3; while (_g236 < _g237) { var _i106 = _g236++; _newArray90[_i106] = _this30.stackVec3[_i106]; _this30.stackVec3[_i106] = null; } _this30.stackVec3 = _newArray90; } _this30.stackVec3[_this30.sizeVec3++] = _this190; } var _this31 = this.p; if (_this19 != null) { _this19.zero(); if (_this31.sizeVec3 == _this31.stackVec3.length) { var _newArray91 = new Array(_this31.sizeVec3 << 1); var _g238 = 0; var _g239 = _this31.sizeVec3; while (_g238 < _g239) { var _i107 = _g238++; _newArray91[_i107] = _this31.stackVec3[_i107]; _this31.stackVec3[_i107] = null; } _this31.stackVec3 = _newArray91; } _this31.stackVec3[_this31.sizeVec3++] = _this19; } var _this32 = this.p; if (_this22 != null) { _this22.zero(); if (_this32.sizeVec3 == _this32.stackVec3.length) { var _newArray92 = new Array(_this32.sizeVec3 << 1); var _g240 = 0; var _g241 = _this32.sizeVec3; while (_g240 < _g241) { var _i108 = _g240++; _newArray92[_i108] = _this32.stackVec3[_i108]; _this32.stackVec3[_i108] = null; } _this32.stackVec3 = _newArray92; } _this32.stackVec3[_this32.sizeVec3++] = _this22; } var _this33 = this.p; if (_this25 != null) { _this25.zero(); if (_this33.sizeVec3 == _this33.stackVec3.length) { var _newArray93 = new Array(_this33.sizeVec3 << 1); var _g242 = 0; var _g243 = _this33.sizeVec3; while (_g242 < _g243) { var _i109 = _g242++; _newArray93[_i109] = _this33.stackVec3[_i109]; _this33.stackVec3[_i109] = null; } _this33.stackVec3 = _newArray93; } _this33.stackVec3[_this33.sizeVec3++] = _this25; } } else { var _g244 = 0; while (_g244 < 8) { var _i110 = _g244++; var _this192 = this.tmpCircleNorms[_i110]; var _v62 = this.circleCoords[_i110]; _this192.x = _v62.x; _this192.y = _v62.y; _this192.z = _v62.z; var _y4 = _this192.x * m.e10 + _this192.y * m.e11 + _this192.z * m.e12; var _z4 = _this192.x * m.e20 + _this192.y * m.e21 + _this192.z * m.e22; _this192.x = _this192.x * m.e00 + _this192.y * m.e01 + _this192.z * m.e02; _this192.y = _y4; _this192.z = _z4; var _this193 = this.tmpCircleVerts1[_i110]; var _v63 = this.tmpCircleNorms[_i110]; _this193.x = _v63.x; _this193.y = _v63.y; _this193.z = _v63.z; _this193.x *= radius; _this193.y *= radius; _this193.z *= radius; _this193.x += o.x; _this193.y += o.y; _this193.z += o.z; var _this194 = this.tmpCircleVerts2[_i110]; var _v64 = this.tmpCircleVerts1[_i110]; _this194.x = _v64.x; _this194.y = _v64.y; _this194.z = _v64.z; var _this195 = this.tmpCircleVerts1[_i110]; _this195.x += ey.x * halfHeight; _this195.y += ey.y * halfHeight; _this195.z += ey.z * halfHeight; var _this196 = this.tmpCircleVerts2[_i110]; var _s16 = -halfHeight; _this196.x += ey.x * _s16; _this196.y += ey.y * _s16; _this196.z += ey.z * _s16; } var _g245 = 0; while (_g245 < 8) { var _i111 = _g245++; var _n9 = this.tmpCircleNorms[_i111]; var _n10 = this.tmpCircleNorms[(_i111 + 1) % 8]; this.rect(this.tmpCircleVerts1[_i111], this.tmpCircleVerts2[_i111], this.tmpCircleVerts2[(_i111 + 1) % 8], this.tmpCircleVerts1[(_i111 + 1) % 8], _n9, _n9, _n10, _n10, color); } } var _this11 = this.p; if (_this7 != null) { _this7.zero(); if (_this11.sizeVec3 == _this11.stackVec3.length) { var _newArray94 = new Array(_this11.sizeVec3 << 1); var _g246 = 0; var _g247 = _this11.sizeVec3; while (_g246 < _g247) { var _i112 = _g246++; _newArray94[_i112] = _this11.stackVec3[_i112]; _this11.stackVec3[_i112] = null; } _this11.stackVec3 = _newArray94; } _this11.stackVec3[_this11.sizeVec3++] = _this7; } var _this12 = this.p; if (_this10 != null) { _this10.zero(); if (_this12.sizeVec3 == _this12.stackVec3.length) { var _newArray95 = new Array(_this12.sizeVec3 << 1); var _g248 = 0; var _g249 = _this12.sizeVec3; while (_g248 < _g249) { var _i113 = _g248++; _newArray95[_i113] = _this12.stackVec3[_i113]; _this12.stackVec3[_i113] = null; } _this12.stackVec3 = _newArray95; } _this12.stackVec3[_this12.sizeVec3++] = _this10; } var _this13 = this.p; if (o != null) { o.zero(); if (_this13.sizeVec3 == _this13.stackVec3.length) { var _newArray96 = new Array(_this13.sizeVec3 << 1); var _g250 = 0; var _g251 = _this13.sizeVec3; while (_g250 < _g251) { var _i114 = _g250++; _newArray96[_i114] = _this13.stackVec3[_i114]; _this13.stackVec3[_i114] = null; } _this13.stackVec3 = _newArray96; } _this13.stackVec3[_this13.sizeVec3++] = o; } var _this14 = this.p; if (m != null) { m.e00 = 1; m.e01 = 0; m.e02 = 0; m.e10 = 0; m.e11 = 1; m.e12 = 0; m.e20 = 0; m.e21 = 0; m.e22 = 1; if (_this14.sizeMat3 == _this14.stackMat3.length) { var _newArray97 = new Array(_this14.sizeMat3 << 1); var _g252 = 0; var _g253 = _this14.sizeMat3; while (_g252 < _g253) { var _i115 = _g252++; _newArray97[_i115] = _this14.stackMat3[_i115]; _this14.stackMat3[_i115] = null; } _this14.stackMat3 = _newArray97; } _this14.stackMat3[_this14.sizeMat3++] = m; } var _this15 = this.p; if (ex != null) { ex.zero(); if (_this15.sizeVec3 == _this15.stackVec3.length) { var _newArray98 = new Array(_this15.sizeVec3 << 1); var _g254 = 0; var _g255 = _this15.sizeVec3; while (_g254 < _g255) { var _i116 = _g254++; _newArray98[_i116] = _this15.stackVec3[_i116]; _this15.stackVec3[_i116] = null; } _this15.stackVec3 = _newArray98; } _this15.stackVec3[_this15.sizeVec3++] = ex; } var _this16 = this.p; if (ey != null) { ey.zero(); if (_this16.sizeVec3 == _this16.stackVec3.length) { var _newArray99 = new Array(_this16.sizeVec3 << 1); var _g256 = 0; var _g257 = _this16.sizeVec3; while (_g256 < _g257) { var _i117 = _g256++; _newArray99[_i117] = _this16.stackVec3[_i117]; _this16.stackVec3[_i117] = null; } _this16.stackVec3 = _newArray99; } _this16.stackVec3[_this16.sizeVec3++] = ey; } var _this17 = this.p; if (ez != null) { ez.zero(); if (_this17.sizeVec3 == _this17.stackVec3.length) { var _newArray100 = new Array(_this17.sizeVec3 << 1); var _g258 = 0; var _g259 = _this17.sizeVec3; while (_g258 < _g259) { var _i118 = _g258++; _newArray100[_i118] = _this17.stackVec3[_i118]; _this17.stackVec3[_i118] = null; } _this17.stackVec3 = _newArray100; } _this17.stackVec3[_this17.sizeVec3++] = ez; } } }, { key: "sphere", value: function sphere(tf, radius, color) { var _this = this.p; var o = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; var _this1 = this.p; var m = _this1.sizeMat3 == 0 ? new oimo.common.Mat3() : _this1.stackMat3[--_this1.sizeMat3]; var v = o; v.x = tf._positionX; v.y = tf._positionY; v.z = tf._positionZ; var m1 = m; m1.e00 = tf._rotation00; m1.e01 = tf._rotation01; m1.e02 = tf._rotation02; m1.e10 = tf._rotation10; m1.e11 = tf._rotation11; m1.e12 = tf._rotation12; m1.e20 = tf._rotation20; m1.e21 = tf._rotation21; m1.e22 = tf._rotation22; var vs = this.tmpSphereVerts; var ns = this.tmpSphereNorms; var _g = 0; while (_g < 5) { var i = _g++; var n = this.tmpSphereVerts[i].length; var _g260 = 0; while (_g260 < n) { var j = _g260++; var _this197 = ns[i][j]; var _v65 = this.sphereCoords[i][j]; _this197.x = _v65.x; _this197.y = _v65.y; _this197.z = _v65.z; var y = _this197.x * m.e10 + _this197.y * m.e11 + _this197.z * m.e12; var z = _this197.x * m.e20 + _this197.y * m.e21 + _this197.z * m.e22; _this197.x = _this197.x * m.e00 + _this197.y * m.e01 + _this197.z * m.e02; _this197.y = y; _this197.z = z; var _this198 = vs[i][j]; var v1 = ns[i][j]; _this198.x = v1.x; _this198.y = v1.y; _this198.z = v1.z; _this198.x *= radius; _this198.y *= radius; _this198.z *= radius; _this198.x += o.x; _this198.y += o.y; _this198.z += o.z; } } var _g1 = 0; while (_g1 < 4) { var _i119 = _g1++; var _g261 = 0; while (_g261 < 8) { var _j3 = _g261++; var _v66 = void 0; var v2 = void 0; var v3 = void 0; var v4 = void 0; var n1 = void 0; var n2 = void 0; var n3 = void 0; var n4 = void 0; if (_i119 == 0) { if (this.wireframe) { _v66 = vs[0][0]; v2 = vs[1][_j3]; this.line(_v66, v2, color); } else { _v66 = vs[0][0]; v2 = vs[1][_j3]; v3 = vs[1][(_j3 + 1) % 8]; n1 = ns[0][0]; n2 = ns[1][_j3]; n3 = ns[1][(_j3 + 1) % 8]; this.triangle(_v66, v2, v3, n1, n2, n3, color); } } else if (_i119 == 3) { if (this.wireframe) { _v66 = vs[4][0]; v2 = vs[_i119][(_j3 + 1) % 8]; v3 = vs[_i119][_j3]; this.line(_v66, v2, color); this.line(v2, v3, color); } else { _v66 = vs[4][0]; v2 = vs[_i119][(_j3 + 1) % 8]; v3 = vs[_i119][_j3]; n1 = ns[4][0]; n2 = ns[_i119][(_j3 + 1) % 8]; n3 = ns[_i119][_j3]; this.triangle(_v66, v2, v3, n1, n2, n3, color); } } else if (this.wireframe) { _v66 = vs[_i119][_j3]; v2 = vs[_i119][(_j3 + 1) % 8]; v3 = vs[_i119 + 1][_j3]; this.line(_v66, v2, color); this.line(_v66, v3, color); } else { _v66 = vs[_i119][_j3]; v2 = vs[_i119][(_j3 + 1) % 8]; v3 = vs[_i119 + 1][_j3]; v4 = vs[_i119 + 1][(_j3 + 1) % 8]; n1 = ns[_i119][_j3]; n2 = ns[_i119][(_j3 + 1) % 8]; n3 = ns[_i119 + 1][_j3]; n4 = ns[_i119 + 1][(_j3 + 1) % 8]; this.rect(_v66, v3, v4, v2, n1, n3, n4, n2, color); } } } var _this2 = this.p; if (o != null) { o.zero(); if (_this2.sizeVec3 == _this2.stackVec3.length) { var newArray = new Array(_this2.sizeVec3 << 1); var _g262 = 0; var _g263 = _this2.sizeVec3; while (_g262 < _g263) { var _i120 = _g262++; newArray[_i120] = _this2.stackVec3[_i120]; _this2.stackVec3[_i120] = null; } _this2.stackVec3 = newArray; } _this2.stackVec3[_this2.sizeVec3++] = o; } var _this3 = this.p; if (m != null) { m.e00 = 1; m.e01 = 0; m.e02 = 0; m.e10 = 0; m.e11 = 1; m.e12 = 0; m.e20 = 0; m.e21 = 0; m.e22 = 1; if (_this3.sizeMat3 == _this3.stackMat3.length) { var _newArray101 = new Array(_this3.sizeMat3 << 1); var _g264 = 0; var _g265 = _this3.sizeMat3; while (_g264 < _g265) { var _i121 = _g264++; _newArray101[_i121] = _this3.stackMat3[_i121]; _this3.stackMat3[_i121] = null; } _this3.stackMat3 = _newArray101; } _this3.stackMat3[_this3.sizeMat3++] = m; } } }, { key: "box", value: function box(tf, halfExtents, color) { var _this = this.p; var ex = _this.sizeVec3 == 0 ? new oimo.common.Vec3() : _this.stackVec3[--_this.sizeVec3]; var _this1 = this.p; var ey = _this1.sizeVec3 == 0 ? new oimo.common.Vec3() : _this1.stackVec3[--_this1.sizeVec3]; var _this2 = this.p; var ez = _this2.sizeVec3 == 0 ? new oimo.common.Vec3() : _this2.stackVec3[--_this2.sizeVec3]; var _this3 = this.p; var o = _this3.sizeVec3 == 0 ? new oimo.common.Vec3() : _this3.stackVec3[--_this3.sizeVec3]; var _this4 = this.p; var m = _this4.sizeMat3 == 0 ? new oimo.common.Mat3() : _this4.stackMat3[--_this4.sizeMat3]; var v = o; v.x = tf._positionX; v.y = tf._positionY; v.z = tf._positionZ; var m1 = m; m1.e00 = tf._rotation00; m1.e01 = tf._rotation01; m1.e02 = tf._rotation02; m1.e10 = tf._rotation10; m1.e11 = tf._rotation11; m1.e12 = tf._rotation12; m1.e20 = tf._rotation20; m1.e21 = tf._rotation21; m1.e22 = tf._rotation22; ex.init(m.e00, m.e10, m.e20); ey.init(m.e01, m.e11, m.e21); ez.init(m.e02, m.e12, m.e22); var hx = halfExtents.x; var hy = halfExtents.y; var hz = halfExtents.z; var _this5 = this.p; var _this6 = _this5.sizeVec3 == 0 ? new oimo.common.Vec3() : _this5.stackVec3[--_this5.sizeVec3]; _this6.x = o.x; _this6.y = o.y; _this6.z = o.z; var _this7 = _this6; var s = -hx; _this7.x += ex.x * s; _this7.y += ex.y * s; _this7.z += ex.z * s; var s1 = -hy; _this7.x += ey.x * s1; _this7.y += ey.y * s1; _this7.z += ey.z * s1; var s2 = -hz; _this7.x += ez.x * s2; _this7.y += ez.y * s2; _this7.z += ez.z * s2; var _this8 = this.p; var _this9 = _this8.sizeVec3 == 0 ? new oimo.common.Vec3() : _this8.stackVec3[--_this8.sizeVec3]; _this9.x = o.x; _this9.y = o.y; _this9.z = o.z; var _this10 = _this9; var s3 = -hx; _this10.x += ex.x * s3; _this10.y += ex.y * s3; _this10.z += ex.z * s3; var s4 = -hy; _this10.x += ey.x * s4; _this10.y += ey.y * s4; _this10.z += ey.z * s4; _this10.x += ez.x * hz; _this10.y += ez.y * hz; _this10.z += ez.z * hz; var _this11 = this.p; var _this12 = _this11.sizeVec3 == 0 ? new oimo.common.Vec3() : _this11.stackVec3[--_this11.sizeVec3]; _this12.x = o.x; _this12.y = o.y; _this12.z = o.z; var _this13 = _this12; var s5 = -hx; _this13.x += ex.x * s5; _this13.y += ex.y * s5; _this13.z += ex.z * s5; _this13.x += ey.x * hy; _this13.y += ey.y * hy; _this13.z += ey.z * hy; var s6 = -hz; _this13.x += ez.x * s6; _this13.y += ez.y * s6; _this13.z += ez.z * s6; var _this14 = this.p; var _this15 = _this14.sizeVec3 == 0 ? new oimo.common.Vec3() : _this14.stackVec3[--_this14.sizeVec3]; _this15.x = o.x; _this15.y = o.y; _this15.z = o.z; var _this16 = _this15; var s7 = -hx; _this16.x += ex.x * s7; _this16.y += ex.y * s7; _this16.z += ex.z * s7; _this16.x += ey.x * hy; _this16.y += ey.y * hy; _this16.z += ey.z * hy; _this16.x += ez.x * hz; _this16.y += ez.y * hz; _this16.z += ez.z * hz; var _this17 = this.p; var _this18 = _this17.sizeVec3 == 0 ? new oimo.common.Vec3() : _this17.stackVec3[--_this17.sizeVec3]; _this18.x = o.x; _this18.y = o.y; _this18.z = o.z; var _this19 = _this18; _this19.x += ex.x * hx; _this19.y += ex.y * hx; _this19.z += ex.z * hx; var s8 = -hy; _this19.x += ey.x * s8; _this19.y += ey.y * s8; _this19.z += ey.z * s8; var s9 = -hz; _this19.x += ez.x * s9; _this19.y += ez.y * s9; _this19.z += ez.z * s9; var _this20 = this.p; var _this21 = _this20.sizeVec3 == 0 ? new oimo.common.Vec3() : _this20.stackVec3[--_this20.sizeVec3]; _this21.x = o.x; _this21.y = o.y; _this21.z = o.z; var _this22 = _this21; _this22.x += ex.x * hx; _this22.y += ex.y * hx; _this22.z += ex.z * hx; var s10 = -hy; _this22.x += ey.x * s10; _this22.y += ey.y * s10; _this22.z += ey.z * s10; _this22.x += ez.x * hz; _this22.y += ez.y * hz; _this22.z += ez.z * hz; var _this23 = this.p; var _this24 = _this23.sizeVec3 == 0 ? new oimo.common.Vec3() : _this23.stackVec3[--_this23.sizeVec3]; _this24.x = o.x; _this24.y = o.y; _this24.z = o.z; var _this25 = _this24; _this25.x += ex.x * hx; _this25.y += ex.y * hx; _this25.z += ex.z * hx; _this25.x += ey.x * hy; _this25.y += ey.y * hy; _this25.z += ey.z * hy; var s11 = -hz; _this25.x += ez.x * s11; _this25.y += ez.y * s11; _this25.z += ez.z * s11; var _this26 = this.p; var _this27 = _this26.sizeVec3 == 0 ? new oimo.common.Vec3() : _this26.stackVec3[--_this26.sizeVec3]; _this27.x = o.x; _this27.y = o.y; _this27.z = o.z; var _this28 = _this27; _this28.x += ex.x * hx; _this28.y += ex.y * hx; _this28.z += ex.z * hx; _this28.x += ey.x * hy; _this28.y += ey.y * hy; _this28.z += ey.z * hy; _this28.x += ez.x * hz; _this28.y += ez.y * hz; _this28.z += ez.z * hz; if (this.wireframe) { this.line(_this7, _this10, color); this.line(_this13, _this16, color); this.line(_this19, _this22, color); this.line(_this25, _this28, color); this.line(_this7, _this13, color); this.line(_this10, _this16, color); this.line(_this19, _this25, color); this.line(_this22, _this28, color); this.line(_this7, _this19, color); this.line(_this10, _this22, color); this.line(_this13, _this25, color); this.line(_this16, _this28, color); } else { var _this199 = this.p; var _this200 = _this199.sizeVec3 == 0 ? new oimo.common.Vec3() : _this199.stackVec3[--_this199.sizeVec3]; _this200.x = ex.x; _this200.y = ex.y; _this200.z = ex.z; var _this201 = _this200; _this201.x = -_this201.x; _this201.y = -_this201.y; _this201.z = -_this201.z; var _this202 = this.p; var _this203 = _this202.sizeVec3 == 0 ? new oimo.common.Vec3() : _this202.stackVec3[--_this202.sizeVec3]; _this203.x = ey.x; _this203.y = ey.y; _this203.z = ey.z; var _this204 = _this203; _this204.x = -_this204.x; _this204.y = -_this204.y; _this204.z = -_this204.z; var _this205 = this.p; var _this206 = _this205.sizeVec3 == 0 ? new oimo.common.Vec3() : _this205.stackVec3[--_this205.sizeVec3]; _this206.x = ez.x; _this206.y = ez.y; _this206.z = ez.z; var _this207 = _this206; _this207.x = -_this207.x; _this207.y = -_this207.y; _this207.z = -_this207.z; this.rect(_this7, _this10, _this16, _this13, _this201, _this201, _this201, _this201, color); this.rect(_this19, _this25, _this28, _this22, ex, ex, ex, ex, color); this.rect(_this7, _this19, _this22, _this10, _this204, _this204, _this204, _this204, color); this.rect(_this13, _this16, _this28, _this25, ey, ey, ey, ey, color); this.rect(_this7, _this13, _this25, _this19, _this207, _this207, _this207, _this207, color); this.rect(_this10, _this22, _this28, _this16, ez, ez, ez, ez, color); var _this208 = this.p; if (_this201 != null) { _this201.zero(); if (_this208.sizeVec3 == _this208.stackVec3.length) { var newArray = new Array(_this208.sizeVec3 << 1); var _g = 0; var _g1 = _this208.sizeVec3; while (_g < _g1) { var i = _g++; newArray[i] = _this208.stackVec3[i]; _this208.stackVec3[i] = null; } _this208.stackVec3 = newArray; } _this208.stackVec3[_this208.sizeVec3++] = _this201; } var _this209 = this.p; if (_this204 != null) { _this204.zero(); if (_this209.sizeVec3 == _this209.stackVec3.length) { var _newArray102 = new Array(_this209.sizeVec3 << 1); var _g266 = 0; var _g267 = _this209.sizeVec3; while (_g266 < _g267) { var _i122 = _g266++; _newArray102[_i122] = _this209.stackVec3[_i122]; _this209.stackVec3[_i122] = null; } _this209.stackVec3 = _newArray102; } _this209.stackVec3[_this209.sizeVec3++] = _this204; } var _this210 = this.p; if (_this207 != null) { _this207.zero(); if (_this210.sizeVec3 == _this210.stackVec3.length) { var _newArray103 = new Array(_this210.sizeVec3 << 1); var _g268 = 0; var _g269 = _this210.sizeVec3; while (_g268 < _g269) { var _i123 = _g268++; _newArray103[_i123] = _this210.stackVec3[_i123]; _this210.stackVec3[_i123] = null; } _this210.stackVec3 = _newArray103; } _this210.stackVec3[_this210.sizeVec3++] = _this207; } } var _this29 = this.p; if (_this7 != null) { _this7.zero(); if (_this29.sizeVec3 == _this29.stackVec3.length) { var _newArray104 = new Array(_this29.sizeVec3 << 1); var _g270 = 0; var _g271 = _this29.sizeVec3; while (_g270 < _g271) { var _i124 = _g270++; _newArray104[_i124] = _this29.stackVec3[_i124]; _this29.stackVec3[_i124] = null; } _this29.stackVec3 = _newArray104; } _this29.stackVec3[_this29.sizeVec3++] = _this7; } var _this30 = this.p; if (_this10 != null) { _this10.zero(); if (_this30.sizeVec3 == _this30.stackVec3.length) { var _newArray105 = new Array(_this30.sizeVec3 << 1); var _g272 = 0; var _g273 = _this30.sizeVec3; while (_g272 < _g273) { var _i125 = _g272++; _newArray105[_i125] = _this30.stackVec3[_i125]; _this30.stackVec3[_i125] = null; } _this30.stackVec3 = _newArray105; } _this30.stackVec3[_this30.sizeVec3++] = _this10; } var _this31 = this.p; if (_this13 != null) { _this13.zero(); if (_this31.sizeVec3 == _this31.stackVec3.length) { var _newArray106 = new Array(_this31.sizeVec3 << 1); var _g274 = 0; var _g275 = _this31.sizeVec3; while (_g274 < _g275) { var _i126 = _g274++; _newArray106[_i126] = _this31.stackVec3[_i126]; _this31.stackVec3[_i126] = null; } _this31.stackVec3 = _newArray106; } _this31.stackVec3[_this31.sizeVec3++] = _this13; } var _this32 = this.p; if (_this16 != null) { _this16.zero(); if (_this32.sizeVec3 == _this32.stackVec3.length) { var _newArray107 = new Array(_this32.sizeVec3 << 1); var _g276 = 0; var _g277 = _this32.sizeVec3; while (_g276 < _g277) { var _i127 = _g276++; _newArray107[_i127] = _this32.stackVec3[_i127]; _this32.stackVec3[_i127] = null; } _this32.stackVec3 = _newArray107; } _this32.stackVec3[_this32.sizeVec3++] = _this16; } var _this33 = this.p; if (_this19 != null) { _this19.zero(); if (_this33.sizeVec3 == _this33.stackVec3.length) { var _newArray108 = new Array(_this33.sizeVec3 << 1); var _g278 = 0; var _g279 = _this33.sizeVec3; while (_g278 < _g279) { var _i128 = _g278++; _newArray108[_i128] = _this33.stackVec3[_i128]; _this33.stackVec3[_i128] = null; } _this33.stackVec3 = _newArray108; } _this33.stackVec3[_this33.sizeVec3++] = _this19; } var _this34 = this.p; if (_this22 != null) { _this22.zero(); if (_this34.sizeVec3 == _this34.stackVec3.length) { var _newArray109 = new Array(_this34.sizeVec3 << 1); var _g280 = 0; var _g281 = _this34.sizeVec3; while (_g280 < _g281) { var _i129 = _g280++; _newArray109[_i129] = _this34.stackVec3[_i129]; _this34.stackVec3[_i129] = null; } _this34.stackVec3 = _newArray109; } _this34.stackVec3[_this34.sizeVec3++] = _this22; } var _this35 = this.p; if (_this25 != null) { _this25.zero(); if (_this35.sizeVec3 == _this35.stackVec3.length) { var _newArray110 = new Array(_this35.sizeVec3 << 1); var _g282 = 0; var _g283 = _this35.sizeVec3; while (_g282 < _g283) { var _i130 = _g282++; _newArray110[_i130] = _this35.stackVec3[_i130]; _this35.stackVec3[_i130] = null; } _this35.stackVec3 = _newArray110; } _this35.stackVec3[_this35.sizeVec3++] = _this25; } var _this36 = this.p; if (_this28 != null) { _this28.zero(); if (_this36.sizeVec3 == _this36.stackVec3.length) { var _newArray111 = new Array(_this36.sizeVec3 << 1); var _g284 = 0; var _g285 = _this36.sizeVec3; while (_g284 < _g285) { var _i131 = _g284++; _newArray111[_i131] = _this36.stackVec3[_i131]; _this36.stackVec3[_i131] = null; } _this36.stackVec3 = _newArray111; } _this36.stackVec3[_this36.sizeVec3++] = _this28; } var _this37 = this.p; if (o != null) { o.zero(); if (_this37.sizeVec3 == _this37.stackVec3.length) { var _newArray112 = new Array(_this37.sizeVec3 << 1); var _g286 = 0; var _g287 = _this37.sizeVec3; while (_g286 < _g287) { var _i132 = _g286++; _newArray112[_i132] = _this37.stackVec3[_i132]; _this37.stackVec3[_i132] = null; } _this37.stackVec3 = _newArray112; } _this37.stackVec3[_this37.sizeVec3++] = o; } var _this38 = this.p; if (m != null) { m.e00 = 1; m.e01 = 0; m.e02 = 0; m.e10 = 0; m.e11 = 1; m.e12 = 0; m.e20 = 0; m.e21 = 0; m.e22 = 1; if (_this38.sizeMat3 == _this38.stackMat3.length) { var _newArray113 = new Array(_this38.sizeMat3 << 1); var _g288 = 0; var _g289 = _this38.sizeMat3; while (_g288 < _g289) { var _i133 = _g288++; _newArray113[_i133] = _this38.stackMat3[_i133]; _this38.stackMat3[_i133] = null; } _this38.stackMat3 = _newArray113; } _this38.stackMat3[_this38.sizeMat3++] = m; } var _this39 = this.p; if (ex != null) { ex.zero(); if (_this39.sizeVec3 == _this39.stackVec3.length) { var _newArray114 = new Array(_this39.sizeVec3 << 1); var _g290 = 0; var _g291 = _this39.sizeVec3; while (_g290 < _g291) { var _i134 = _g290++; _newArray114[_i134] = _this39.stackVec3[_i134]; _this39.stackVec3[_i134] = null; } _this39.stackVec3 = _newArray114; } _this39.stackVec3[_this39.sizeVec3++] = ex; } var _this40 = this.p; if (ey != null) { ey.zero(); if (_this40.sizeVec3 == _this40.stackVec3.length) { var _newArray115 = new Array(_this40.sizeVec3 << 1); var _g292 = 0; var _g293 = _this40.sizeVec3; while (_g292 < _g293) { var _i135 = _g292++; _newArray115[_i135] = _this40.stackVec3[_i135]; _this40.stackVec3[_i135] = null; } _this40.stackVec3 = _newArray115; } _this40.stackVec3[_this40.sizeVec3++] = ey; } var _this41 = this.p; if (ez != null) { ez.zero(); if (_this41.sizeVec3 == _this41.stackVec3.length) { var _newArray116 = new Array(_this41.sizeVec3 << 1); var _g294 = 0; var _g295 = _this41.sizeVec3; while (_g294 < _g295) { var _i136 = _g294++; _newArray116[_i136] = _this41.stackVec3[_i136]; _this41.stackVec3[_i136] = null; } _this41.stackVec3 = _newArray116; } _this41.stackVec3[_this41.sizeVec3++] = ez; } } }, { key: "rect", value: function rect(v1, v2, v3, v4, n1, n2, n3, n4, color) { this.triangle(v1, v2, v3, n1, n2, n3, color); this.triangle(v1, v3, v4, n1, n3, n4, color); } }, { key: "point", value: function point(v, color) {} }, { key: "triangle", value: function triangle(v1, v2, v3, n1, n2, n3, color) {} }, { key: "line", value: function line(v1, v2, color) {} }]); return oimo_dynamics_common_DebugDraw; }(); oimo.dynamics.common.DebugDrawStyle = /*#__PURE__*/_createClass(function oimo_dynamics_common_DebugDrawStyle() { _classCallCheck(this, oimo_dynamics_common_DebugDrawStyle); this.basisColorZ = new oimo.common.Vec3(0.0, 0.0, 1.0); this.basisColorY = new oimo.common.Vec3(0.0, 1.0, 0.0); this.basisColorX = new oimo.common.Vec3(1.0, 0.0, 0.0); this.basisLength = 0.5; this.jointRotationalConstraintRadius = 0.3; this.jointErrorColor = new oimo.common.Vec3(1.0, 0.1, 0.1); this.jointLineColor = new oimo.common.Vec3(0.8, 0.8, 0.8); this.contactBinormalLength = 0.5; this.contactTangentLength = 0.5; this.contactNormalLength = 0.5; this.contactBinormalColor = new oimo.common.Vec3(0.2, 0.2, 1.0); this.contactTangentColor = new oimo.common.Vec3(0.1, 0.8, 0.1); this.contactNormalColor = new oimo.common.Vec3(1.0, 0.1, 0.1); this.disabledContactColor = new oimo.common.Vec3(0.5, 0.1, 0.1); this.newContactColor = new oimo.common.Vec3(1.0, 1.0, 0.1); this.contactColor4 = new oimo.common.Vec3(0.8, 0.1, 1.0); this.contactColor3 = new oimo.common.Vec3(0.1, 0.8, 0.6); this.contactColor2 = new oimo.common.Vec3(1.0, 0.6, 0.1); this.contactColor = new oimo.common.Vec3(1.0, 0.1, 0.1); this.pairColor = new oimo.common.Vec3(1.0, 1.0, 0.1); this.bvhNodeColor = new oimo.common.Vec3(0.4, 0.4, 0.4); this.aabbColor = new oimo.common.Vec3(1.0, 0.1, 0.1); this.kinematicShapeColor = new oimo.common.Vec3(1.0, 0.5, 0.1); this.staticShapeColor = new oimo.common.Vec3(0.7, 0.7, 0.7); this.sleepingShapeColor2 = new oimo.common.Vec3(0.2, 0.8, 0.5); this.sleepingShapeColor1 = new oimo.common.Vec3(0.3, 0.3, 0.8); this.sleepyShapeColor2 = new oimo.common.Vec3(0.6, 0.8, 0.3); this.sleepyShapeColor1 = new oimo.common.Vec3(0.5, 0.25, 0.6); this.shapeColor2 = new oimo.common.Vec3(1.0, 0.8, 0.1); this.shapeColor1 = new oimo.common.Vec3(0.7, 0.2, 0.4); }); oimo.dynamics.common.Performance = /*#__PURE__*/_createClass(function oimo_dynamics_common_Performance() { _classCallCheck(this, oimo_dynamics_common_Performance); }); if (!oimo.dynamics.constraint) oimo.dynamics.constraint = {}; oimo.dynamics.constraint.ConstraintSolver = /*#__PURE__*/function () { function oimo_dynamics_constraint_ConstraintSolver() { _classCallCheck(this, oimo_dynamics_constraint_ConstraintSolver); this._b1 = null; this._b2 = null; this._addedToIsland = false; } _createClass(oimo_dynamics_constraint_ConstraintSolver, [{ key: "preSolveVelocity", value: function preSolveVelocity(timeStep) {} }, { key: "warmStart", value: function warmStart(timeStep) {} }, { key: "solveVelocity", value: function solveVelocity() {} }, { key: "postSolveVelocity", value: function postSolveVelocity(timeStep) {} }, { key: "preSolvePosition", value: function preSolvePosition(timeStep) {} }, { key: "solvePositionSplitImpulse", value: function solvePositionSplitImpulse() {} }, { key: "solvePositionNgs", value: function solvePositionNgs(timeStep) {} }, { key: "postSolve", value: function postSolve() {} }]); return oimo_dynamics_constraint_ConstraintSolver; }(); oimo.dynamics.constraint.PositionCorrectionAlgorithm = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_PositionCorrectionAlgorithm() { _classCallCheck(this, oimo_dynamics_constraint_PositionCorrectionAlgorithm); }); if (!oimo.dynamics.constraint.contact) oimo.dynamics.constraint.contact = {}; oimo.dynamics.constraint.contact.ContactConstraint = /*#__PURE__*/function () { function oimo_dynamics_constraint_contact_ContactConstraint(manifold) { _classCallCheck(this, oimo_dynamics_constraint_contact_ContactConstraint); this._solver = new oimo.dynamics.constraint.solver.pgs.PgsContactConstraintSolver(this); this._manifold = manifold; } _createClass(oimo_dynamics_constraint_contact_ContactConstraint, [{ key: "_getVelocitySolverInfo", value: function _getVelocitySolverInfo(timeStep, info) { info.b1 = this._b1; info.b2 = this._b2; var normalX; var normalY; var normalZ; var tangentX; var tangentY; var tangentZ; var binormalX; var binormalY; var binormalZ; normalX = this._manifold._normalX; normalY = this._manifold._normalY; normalZ = this._manifold._normalZ; tangentX = this._manifold._tangentX; tangentY = this._manifold._tangentY; tangentZ = this._manifold._tangentZ; binormalX = this._manifold._binormalX; binormalY = this._manifold._binormalY; binormalZ = this._manifold._binormalZ; var friction = Math.sqrt(this._s1._friction * this._s2._friction); var restitution = Math.sqrt(this._s1._restitution * this._s2._restitution); var num = this._manifold._numPoints; info.numRows = 0; var _g = 0; while (_g < num) { var p = this._manifold._points[_g++]; if (p._depth < 0) { p._disabled = true; var _this = p._impulse; _this.impulseN = 0; _this.impulseT = 0; _this.impulseB = 0; _this.impulseP = 0; _this.impulseLX = 0; _this.impulseLY = 0; _this.impulseLZ = 0; continue; } else { p._disabled = false; } var row = info.rows[info.numRows++]; row.friction = friction; row.cfm = 0; var j = row.jacobianN; j.lin1X = normalX; j.lin1Y = normalY; j.lin1Z = normalZ; j.lin2X = normalX; j.lin2Y = normalY; j.lin2Z = normalZ; j.ang1X = p._relPos1Y * normalZ - p._relPos1Z * normalY; j.ang1Y = p._relPos1Z * normalX - p._relPos1X * normalZ; j.ang1Z = p._relPos1X * normalY - p._relPos1Y * normalX; j.ang2X = p._relPos2Y * normalZ - p._relPos2Z * normalY; j.ang2Y = p._relPos2Z * normalX - p._relPos2X * normalZ; j.ang2Z = p._relPos2X * normalY - p._relPos2Y * normalX; j = row.jacobianT; j.lin1X = tangentX; j.lin1Y = tangentY; j.lin1Z = tangentZ; j.lin2X = tangentX; j.lin2Y = tangentY; j.lin2Z = tangentZ; j.ang1X = p._relPos1Y * tangentZ - p._relPos1Z * tangentY; j.ang1Y = p._relPos1Z * tangentX - p._relPos1X * tangentZ; j.ang1Z = p._relPos1X * tangentY - p._relPos1Y * tangentX; j.ang2X = p._relPos2Y * tangentZ - p._relPos2Z * tangentY; j.ang2Y = p._relPos2Z * tangentX - p._relPos2X * tangentZ; j.ang2Z = p._relPos2X * tangentY - p._relPos2Y * tangentX; j = row.jacobianB; j.lin1X = binormalX; j.lin1Y = binormalY; j.lin1Z = binormalZ; j.lin2X = binormalX; j.lin2Y = binormalY; j.lin2Z = binormalZ; j.ang1X = p._relPos1Y * binormalZ - p._relPos1Z * binormalY; j.ang1Y = p._relPos1Z * binormalX - p._relPos1X * binormalZ; j.ang1Z = p._relPos1X * binormalY - p._relPos1Y * binormalX; j.ang2X = p._relPos2Y * binormalZ - p._relPos2Z * binormalY; j.ang2Y = p._relPos2Z * binormalX - p._relPos2X * binormalZ; j.ang2Z = p._relPos2X * binormalY - p._relPos2Y * binormalX; j = row.jacobianN; var rvn = j.lin1X * this._b1._velX + j.lin1Y * this._b1._velY + j.lin1Z * this._b1._velZ + (j.ang1X * this._b1._angVelX + j.ang1Y * this._b1._angVelY + j.ang1Z * this._b1._angVelZ) - (j.lin2X * this._b2._velX + j.lin2Y * this._b2._velY + j.lin2Z * this._b2._velZ + (j.ang2X * this._b2._angVelX + j.ang2Y * this._b2._angVelY + j.ang2Z * this._b2._angVelZ)); if (rvn < -oimo.common.Setting.contactEnableBounceThreshold && !p._warmStarted) { row.rhs = -rvn * restitution; } else { row.rhs = 0; } if (this._positionCorrectionAlgorithm == oimo.dynamics.constraint.PositionCorrectionAlgorithm.BAUMGARTE) { if (p._depth > oimo.common.Setting.linearSlop) { var minRhs = (p._depth - oimo.common.Setting.linearSlop) * oimo.common.Setting.velocityBaumgarte * timeStep.invDt; if (row.rhs < minRhs) { row.rhs = minRhs; } } } if (!p._warmStarted) { var _this211 = p._impulse; _this211.impulseN = 0; _this211.impulseT = 0; _this211.impulseB = 0; _this211.impulseP = 0; _this211.impulseLX = 0; _this211.impulseLY = 0; _this211.impulseLZ = 0; } row.impulse = p._impulse; } } }, { key: "_getPositionSolverInfo", value: function _getPositionSolverInfo(info) { info.b1 = this._b1; info.b2 = this._b2; var normalX; var normalY; var normalZ; normalX = this._manifold._normalX; normalY = this._manifold._normalY; normalZ = this._manifold._normalZ; var num = this._manifold._numPoints; info.numRows = 0; var _g = 0; while (_g < num) { var p = this._manifold._points[_g++]; if (p._disabled) { continue; } var row = info.rows[info.numRows++]; var j = row.jacobianN; j.lin1X = normalX; j.lin1Y = normalY; j.lin1Z = normalZ; j.lin2X = normalX; j.lin2Y = normalY; j.lin2Z = normalZ; j.ang1X = p._relPos1Y * normalZ - p._relPos1Z * normalY; j.ang1Y = p._relPos1Z * normalX - p._relPos1X * normalZ; j.ang1Z = p._relPos1X * normalY - p._relPos1Y * normalX; j.ang2X = p._relPos2Y * normalZ - p._relPos2Z * normalY; j.ang2Y = p._relPos2Z * normalX - p._relPos2X * normalZ; j.ang2Z = p._relPos2X * normalY - p._relPos2Y * normalX; row.rhs = p._depth - oimo.common.Setting.linearSlop; if (row.rhs < 0) { row.rhs = 0; } row.impulse = p._impulse; } } }, { key: "_syncManifold", value: function _syncManifold() { this._manifold._updateDepthsAndPositions(this._tf1, this._tf2); } }, { key: "getShape1", value: function getShape1() { return this._s1; } }, { key: "getShape2", value: function getShape2() { return this._s2; } }, { key: "getManifold", value: function getManifold() { return this._manifold; } }, { key: "isTouching", value: function isTouching() { var _g = 0; var _g1 = this._manifold._numPoints; while (_g < _g1) { if (this._manifold._points[_g++]._depth >= 0) { return true; } } return false; } }]); return oimo_dynamics_constraint_contact_ContactConstraint; }(); oimo.dynamics.constraint.contact.ContactImpulse = /*#__PURE__*/function () { function oimo_dynamics_constraint_contact_ContactImpulse() { _classCallCheck(this, oimo_dynamics_constraint_contact_ContactImpulse); this.impulseN = 0; this.impulseT = 0; this.impulseB = 0; this.impulseP = 0; this.impulseLX = 0; this.impulseLY = 0; this.impulseLZ = 0; } _createClass(oimo_dynamics_constraint_contact_ContactImpulse, [{ key: "copyFrom", value: function copyFrom(imp) { this.impulseN = imp.impulseN; this.impulseT = imp.impulseT; this.impulseB = imp.impulseB; this.impulseLX = imp.impulseLX; this.impulseLY = imp.impulseLY; this.impulseLZ = imp.impulseLZ; } }]); return oimo_dynamics_constraint_contact_ContactImpulse; }(); oimo.dynamics.constraint.contact.Manifold = /*#__PURE__*/function () { function oimo_dynamics_constraint_contact_Manifold() { _classCallCheck(this, oimo_dynamics_constraint_contact_Manifold); this._normalX = 0; this._normalY = 0; this._normalZ = 0; this._tangentX = 0; this._tangentY = 0; this._tangentZ = 0; this._binormalX = 0; this._binormalY = 0; this._binormalZ = 0; this._numPoints = 0; this._points = new Array(oimo.common.Setting.maxManifoldPoints); var _g = 0; var _g1 = oimo.common.Setting.maxManifoldPoints; while (_g < _g1) { this._points[_g++] = new oimo.dynamics.constraint.contact.ManifoldPoint(); } } _createClass(oimo_dynamics_constraint_contact_Manifold, [{ key: "_clear", value: function _clear() { var _g = 0; var _g1 = this._numPoints; while (_g < _g1) { var _this = this._points[_g++]; _this._localPos1X = 0; _this._localPos1Y = 0; _this._localPos1Z = 0; _this._localPos2X = 0; _this._localPos2Y = 0; _this._localPos2Z = 0; _this._relPos1X = 0; _this._relPos1Y = 0; _this._relPos1Z = 0; _this._relPos2X = 0; _this._relPos2Y = 0; _this._relPos2Z = 0; _this._pos1X = 0; _this._pos1Y = 0; _this._pos1Z = 0; _this._pos2X = 0; _this._pos2Y = 0; _this._pos2Z = 0; _this._depth = 0; var _this1 = _this._impulse; _this1.impulseN = 0; _this1.impulseT = 0; _this1.impulseB = 0; _this1.impulseP = 0; _this1.impulseLX = 0; _this1.impulseLY = 0; _this1.impulseLZ = 0; _this._warmStarted = false; _this._disabled = false; _this._id = -1; } this._numPoints = 0; } }, { key: "_buildBasis", value: function _buildBasis(normal) { this._normalX = normal.x; this._normalY = normal.y; this._normalZ = normal.z; var nx = normal.x; var ny = normal.y; var nz = normal.z; var nx2 = nx * nx; var ny2 = ny * ny; var nz2 = nz * nz; var tx; var ty; var tz; var bx; var by; var bz; if (nx2 < ny2) { if (nx2 < nz2) { var invL = 1 / Math.sqrt(ny2 + nz2); tx = 0; ty = -nz * invL; tz = ny * invL; bx = ny * tz - nz * ty; by = -nx * tz; bz = nx * ty; } else { var _invL = 1 / Math.sqrt(nx2 + ny2); tx = -ny * _invL; ty = nx * _invL; tz = 0; bx = -nz * ty; by = nz * tx; bz = nx * ty - ny * tx; } } else if (ny2 < nz2) { var _invL2 = 1 / Math.sqrt(nx2 + nz2); tx = nz * _invL2; ty = 0; tz = -nx * _invL2; bx = ny * tz; by = nz * tx - nx * tz; bz = -ny * tx; } else { var _invL3 = 1 / Math.sqrt(nx2 + ny2); tx = -ny * _invL3; ty = nx * _invL3; tz = 0; bx = -nz * ty; by = nz * tx; bz = nx * ty - ny * tx; } this._tangentX = tx; this._tangentY = ty; this._tangentZ = tz; this._binormalX = bx; this._binormalY = by; this._binormalZ = bz; } }, { key: "_updateDepthsAndPositions", value: function _updateDepthsAndPositions(tf1, tf2) { var _g = 0; var _g1 = this._numPoints; while (_g < _g1) { var p = this._points[_g++]; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * p._localPos1X + tf1._rotation01 * p._localPos1Y + tf1._rotation02 * p._localPos1Z; __tmp__Y = tf1._rotation10 * p._localPos1X + tf1._rotation11 * p._localPos1Y + tf1._rotation12 * p._localPos1Z; __tmp__Z = tf1._rotation20 * p._localPos1X + tf1._rotation21 * p._localPos1Y + tf1._rotation22 * p._localPos1Z; p._relPos1X = __tmp__X; p._relPos1Y = __tmp__Y; p._relPos1Z = __tmp__Z; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * p._localPos2X + tf2._rotation01 * p._localPos2Y + tf2._rotation02 * p._localPos2Z; __tmp__Y1 = tf2._rotation10 * p._localPos2X + tf2._rotation11 * p._localPos2Y + tf2._rotation12 * p._localPos2Z; __tmp__Z1 = tf2._rotation20 * p._localPos2X + tf2._rotation21 * p._localPos2Y + tf2._rotation22 * p._localPos2Z; p._relPos2X = __tmp__X1; p._relPos2Y = __tmp__Y1; p._relPos2Z = __tmp__Z1; p._pos1X = p._relPos1X + tf1._positionX; p._pos1Y = p._relPos1Y + tf1._positionY; p._pos1Z = p._relPos1Z + tf1._positionZ; p._pos2X = p._relPos2X + tf2._positionX; p._pos2Y = p._relPos2Y + tf2._positionY; p._pos2Z = p._relPos2Z + tf2._positionZ; var diffX = void 0; var diffY = void 0; var diffZ = void 0; diffX = p._pos1X - p._pos2X; diffY = p._pos1Y - p._pos2Y; diffZ = p._pos1Z - p._pos2Z; p._depth = -(diffX * this._normalX + diffY * this._normalY + diffZ * this._normalZ); } } }, { key: "getNormal", value: function getNormal() { var v = new oimo.common.Vec3(); v.x = this._normalX; v.y = this._normalY; v.z = this._normalZ; return v; } }, { key: "getNormalTo", value: function getNormalTo(normal) { normal.x = this._normalX; normal.y = this._normalY; normal.z = this._normalZ; } }, { key: "getTangent", value: function getTangent() { var v = new oimo.common.Vec3(); v.x = this._tangentX; v.y = this._tangentY; v.z = this._tangentZ; return v; } }, { key: "getTangentTo", value: function getTangentTo(tangent) { tangent.x = this._tangentX; tangent.y = this._tangentY; tangent.z = this._tangentZ; } }, { key: "getBinormal", value: function getBinormal() { var v = new oimo.common.Vec3(); v.x = this._binormalX; v.y = this._binormalY; v.z = this._binormalZ; return v; } }, { key: "getBinormalTo", value: function getBinormalTo(binormal) { binormal.x = this._binormalX; binormal.y = this._binormalY; binormal.z = this._binormalZ; } }, { key: "getPoints", value: function getPoints() { return this._points; } }, { key: "getNumPoints", value: function getNumPoints() { return this._numPoints; } }]); return oimo_dynamics_constraint_contact_Manifold; }(); oimo.dynamics.constraint.contact.ManifoldPoint = /*#__PURE__*/function () { function oimo_dynamics_constraint_contact_ManifoldPoint() { _classCallCheck(this, oimo_dynamics_constraint_contact_ManifoldPoint); this._localPos1X = 0; this._localPos1Y = 0; this._localPos1Z = 0; this._localPos2X = 0; this._localPos2Y = 0; this._localPos2Z = 0; this._relPos1X = 0; this._relPos1Y = 0; this._relPos1Z = 0; this._relPos2X = 0; this._relPos2Y = 0; this._relPos2Z = 0; this._pos1X = 0; this._pos1Y = 0; this._pos1Z = 0; this._pos2X = 0; this._pos2Y = 0; this._pos2Z = 0; this._depth = 0; this._impulse = new oimo.dynamics.constraint.contact.ContactImpulse(); this._warmStarted = false; this._disabled = false; this._id = -1; } _createClass(oimo_dynamics_constraint_contact_ManifoldPoint, [{ key: "getPosition1", value: function getPosition1() { var v = new oimo.common.Vec3(); v.x = this._pos1X; v.y = this._pos1Y; v.z = this._pos1Z; return v; } }, { key: "getPosition1To", value: function getPosition1To(position) { position.x = this._pos1X; position.y = this._pos1Y; position.z = this._pos1Z; } }, { key: "getPosition2", value: function getPosition2() { var v = new oimo.common.Vec3(); v.x = this._pos2X; v.y = this._pos2Y; v.z = this._pos2Z; return v; } }, { key: "getPosition2To", value: function getPosition2To(position) { position.x = this._pos2X; position.y = this._pos2Y; position.z = this._pos2Z; } }, { key: "getDepth", value: function getDepth() { return this._depth; } }, { key: "isWarmStarted", value: function isWarmStarted() { return this._warmStarted; } }, { key: "getNormalImpulse", value: function getNormalImpulse() { return this._impulse.impulseN; } }, { key: "getTangentImpulse", value: function getTangentImpulse() { return this._impulse.impulseT; } }, { key: "getBinormalImpulse", value: function getBinormalImpulse() { return this._impulse.impulseB; } }, { key: "isEnabled", value: function isEnabled() { return !this._disabled; } }]); return oimo_dynamics_constraint_contact_ManifoldPoint; }(); oimo.dynamics.constraint.contact.ManifoldUpdater = /*#__PURE__*/function () { function oimo_dynamics_constraint_contact_ManifoldUpdater(manifold) { _classCallCheck(this, oimo_dynamics_constraint_contact_ManifoldUpdater); this._manifold = manifold; this.numOldPoints = 0; this.oldPoints = new Array(oimo.common.Setting.maxManifoldPoints); var _g = 0; var _g1 = oimo.common.Setting.maxManifoldPoints; while (_g < _g1) { this.oldPoints[_g++] = new oimo.dynamics.constraint.contact.ManifoldPoint(); } } _createClass(oimo_dynamics_constraint_contact_ManifoldUpdater, [{ key: "removeOutdatedPoints", value: function removeOutdatedPoints() { var index = this._manifold._numPoints; while (--index >= 0) { var p = this._manifold._points[index]; var diffX = void 0; var diffY = void 0; var diffZ = void 0; diffX = p._pos1X - p._pos2X; diffY = p._pos1Y - p._pos2Y; diffZ = p._pos1Z - p._pos2Z; var dotN = this._manifold._normalX * diffX + this._manifold._normalY * diffY + this._manifold._normalZ * diffZ; if (dotN > oimo.common.Setting.contactPersistenceThreshold) { this.removeManifoldPoint(index); continue; } diffX += this._manifold._normalX * -dotN; diffY += this._manifold._normalY * -dotN; diffZ += this._manifold._normalZ * -dotN; if (diffX * diffX + diffY * diffY + diffZ * diffZ > oimo.common.Setting.contactPersistenceThreshold * oimo.common.Setting.contactPersistenceThreshold) { this.removeManifoldPoint(index); continue; } } } }, { key: "removeManifoldPoint", value: function removeManifoldPoint(index) { var lastIndex = --this._manifold._numPoints; if (index != lastIndex) { var tmp = this._manifold._points[index]; this._manifold._points[index] = this._manifold._points[lastIndex]; this._manifold._points[lastIndex] = tmp; } var _this = this._manifold._points[lastIndex]; _this._localPos1X = 0; _this._localPos1Y = 0; _this._localPos1Z = 0; _this._localPos2X = 0; _this._localPos2Y = 0; _this._localPos2Z = 0; _this._relPos1X = 0; _this._relPos1Y = 0; _this._relPos1Z = 0; _this._relPos2X = 0; _this._relPos2Y = 0; _this._relPos2Z = 0; _this._pos1X = 0; _this._pos1Y = 0; _this._pos1Z = 0; _this._pos2X = 0; _this._pos2Y = 0; _this._pos2Z = 0; _this._depth = 0; var _this1 = _this._impulse; _this1.impulseN = 0; _this1.impulseT = 0; _this1.impulseB = 0; _this1.impulseP = 0; _this1.impulseLX = 0; _this1.impulseLY = 0; _this1.impulseLZ = 0; _this._warmStarted = false; _this._disabled = false; _this._id = -1; } }, { key: "addManifoldPoint", value: function addManifoldPoint(point, tf1, tf2) { var num = this._manifold._numPoints; if (num == oimo.common.Setting.maxManifoldPoints) { var targetIndex = this.computeTargetIndex(point, tf1, tf2); var _this212 = this._manifold._points[targetIndex]; var _v67 = point.position1; _this212._pos1X = _v67.x; _this212._pos1Y = _v67.y; _this212._pos1Z = _v67.z; var _v68 = point.position2; _this212._pos2X = _v68.x; _this212._pos2Y = _v68.y; _this212._pos2Z = _v68.z; _this212._relPos1X = _this212._pos1X - tf1._positionX; _this212._relPos1Y = _this212._pos1Y - tf1._positionY; _this212._relPos1Z = _this212._pos1Z - tf1._positionZ; _this212._relPos2X = _this212._pos2X - tf2._positionX; _this212._relPos2Y = _this212._pos2Y - tf2._positionY; _this212._relPos2Z = _this212._pos2Z - tf2._positionZ; var _tmp__X8; var _tmp__Y8; var _tmp__Z8; _tmp__X8 = tf1._rotation00 * _this212._relPos1X + tf1._rotation10 * _this212._relPos1Y + tf1._rotation20 * _this212._relPos1Z; _tmp__Y8 = tf1._rotation01 * _this212._relPos1X + tf1._rotation11 * _this212._relPos1Y + tf1._rotation21 * _this212._relPos1Z; _tmp__Z8 = tf1._rotation02 * _this212._relPos1X + tf1._rotation12 * _this212._relPos1Y + tf1._rotation22 * _this212._relPos1Z; _this212._localPos1X = _tmp__X8; _this212._localPos1Y = _tmp__Y8; _this212._localPos1Z = _tmp__Z8; var _tmp__X9; var _tmp__Y9; var _tmp__Z9; _tmp__X9 = tf2._rotation00 * _this212._relPos2X + tf2._rotation10 * _this212._relPos2Y + tf2._rotation20 * _this212._relPos2Z; _tmp__Y9 = tf2._rotation01 * _this212._relPos2X + tf2._rotation11 * _this212._relPos2Y + tf2._rotation21 * _this212._relPos2Z; _tmp__Z9 = tf2._rotation02 * _this212._relPos2X + tf2._rotation12 * _this212._relPos2Y + tf2._rotation22 * _this212._relPos2Z; _this212._localPos2X = _tmp__X9; _this212._localPos2Y = _tmp__Y9; _this212._localPos2Z = _tmp__Z9; _this212._depth = point.depth; var _this213 = _this212._impulse; _this213.impulseN = 0; _this213.impulseT = 0; _this213.impulseB = 0; _this213.impulseP = 0; _this213.impulseLX = 0; _this213.impulseLY = 0; _this213.impulseLZ = 0; _this212._id = point.id; _this212._warmStarted = false; _this212._disabled = false; return; } var _this = this._manifold._points[num]; var v = point.position1; _this._pos1X = v.x; _this._pos1Y = v.y; _this._pos1Z = v.z; var v1 = point.position2; _this._pos2X = v1.x; _this._pos2Y = v1.y; _this._pos2Z = v1.z; _this._relPos1X = _this._pos1X - tf1._positionX; _this._relPos1Y = _this._pos1Y - tf1._positionY; _this._relPos1Z = _this._pos1Z - tf1._positionZ; _this._relPos2X = _this._pos2X - tf2._positionX; _this._relPos2Y = _this._pos2Y - tf2._positionY; _this._relPos2Z = _this._pos2Z - tf2._positionZ; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = tf1._rotation00 * _this._relPos1X + tf1._rotation10 * _this._relPos1Y + tf1._rotation20 * _this._relPos1Z; __tmp__Y = tf1._rotation01 * _this._relPos1X + tf1._rotation11 * _this._relPos1Y + tf1._rotation21 * _this._relPos1Z; __tmp__Z = tf1._rotation02 * _this._relPos1X + tf1._rotation12 * _this._relPos1Y + tf1._rotation22 * _this._relPos1Z; _this._localPos1X = __tmp__X; _this._localPos1Y = __tmp__Y; _this._localPos1Z = __tmp__Z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = tf2._rotation00 * _this._relPos2X + tf2._rotation10 * _this._relPos2Y + tf2._rotation20 * _this._relPos2Z; __tmp__Y1 = tf2._rotation01 * _this._relPos2X + tf2._rotation11 * _this._relPos2Y + tf2._rotation21 * _this._relPos2Z; __tmp__Z1 = tf2._rotation02 * _this._relPos2X + tf2._rotation12 * _this._relPos2Y + tf2._rotation22 * _this._relPos2Z; _this._localPos2X = __tmp__X1; _this._localPos2Y = __tmp__Y1; _this._localPos2Z = __tmp__Z1; _this._depth = point.depth; var _this1 = _this._impulse; _this1.impulseN = 0; _this1.impulseT = 0; _this1.impulseB = 0; _this1.impulseP = 0; _this1.impulseLX = 0; _this1.impulseLY = 0; _this1.impulseLZ = 0; _this._id = point.id; _this._warmStarted = false; _this._disabled = false; this._manifold._numPoints++; } }, { key: "computeTargetIndex", value: function computeTargetIndex(newPoint, tf1, tf2) { var p1 = this._manifold._points[0]; var p2 = this._manifold._points[1]; var p3 = this._manifold._points[2]; var p4 = this._manifold._points[3]; var maxDepth = p1._depth; var maxDepthIndex = 0; if (p2._depth > maxDepth) { maxDepth = p2._depth; maxDepthIndex = 1; } if (p3._depth > maxDepth) { maxDepth = p3._depth; maxDepthIndex = 2; } if (p4._depth > maxDepth) { maxDepthIndex = 3; } var rp1X; var rp1Y; var rp1Z; var v = newPoint.position1; rp1X = v.x; rp1Y = v.y; rp1Z = v.z; rp1X -= tf1._positionX; rp1Y -= tf1._positionY; rp1Z -= tf1._positionZ; var p1X = p2._relPos1X; var p1Y = p2._relPos1Y; var p1Z = p2._relPos1Z; var p2X = p3._relPos1X; var p2Y = p3._relPos1Y; var p2Z = p3._relPos1Z; var p3X = p4._relPos1X; var p3Y = p4._relPos1Y; var p3Z = p4._relPos1Z; var v12X; var v12Y; var v12Z; var v34X; var v34Y; var v34Z; var v13X; var v13Y; var v13Z; var v24X; var v24Y; var v24Z; var v14X; var v14Y; var v14Z; var v23X; var v23Y; var v23Z; v12X = p2X - p1X; v12Y = p2Y - p1Y; v12Z = p2Z - p1Z; v34X = rp1X - p3X; v34Y = rp1Y - p3Y; v34Z = rp1Z - p3Z; v13X = p3X - p1X; v13Y = p3Y - p1Y; v13Z = p3Z - p1Z; v24X = rp1X - p2X; v24Y = rp1Y - p2Y; v24Z = rp1Z - p2Z; v14X = rp1X - p1X; v14Y = rp1Y - p1Y; v14Z = rp1Z - p1Z; v23X = p3X - p2X; v23Y = p3Y - p2Y; v23Z = p3Z - p2Z; var cross1X; var cross1Y; var cross1Z; var cross2X; var cross2Y; var cross2Z; var cross3X; var cross3Y; var cross3Z; cross1X = v12Y * v34Z - v12Z * v34Y; cross1Y = v12Z * v34X - v12X * v34Z; cross1Z = v12X * v34Y - v12Y * v34X; cross2X = v13Y * v24Z - v13Z * v24Y; cross2Y = v13Z * v24X - v13X * v24Z; cross2Z = v13X * v24Y - v13Y * v24X; cross3X = v14Y * v23Z - v14Z * v23Y; cross3Y = v14Z * v23X - v14X * v23Z; cross3Z = v14X * v23Y - v14Y * v23X; var a1 = cross1X * cross1X + cross1Y * cross1Y + cross1Z * cross1Z; var a2 = cross2X * cross2X + cross2Y * cross2Y + cross2Z * cross2Z; var a3 = cross3X * cross3X + cross3Y * cross3Y + cross3Z * cross3Z; var p1X1 = p1._relPos1X; var p1Y1 = p1._relPos1Y; var p1Z1 = p1._relPos1Z; var p2X1 = p3._relPos1X; var p2Y1 = p3._relPos1Y; var p2Z1 = p3._relPos1Z; var p3X1 = p4._relPos1X; var p3Y1 = p4._relPos1Y; var p3Z1 = p4._relPos1Z; var v12X1; var v12Y1; var v12Z1; var v34X1; var v34Y1; var v34Z1; var v13X1; var v13Y1; var v13Z1; var v24X1; var v24Y1; var v24Z1; var v14X1; var v14Y1; var v14Z1; var v23X1; var v23Y1; var v23Z1; v12X1 = p2X1 - p1X1; v12Y1 = p2Y1 - p1Y1; v12Z1 = p2Z1 - p1Z1; v34X1 = rp1X - p3X1; v34Y1 = rp1Y - p3Y1; v34Z1 = rp1Z - p3Z1; v13X1 = p3X1 - p1X1; v13Y1 = p3Y1 - p1Y1; v13Z1 = p3Z1 - p1Z1; v24X1 = rp1X - p2X1; v24Y1 = rp1Y - p2Y1; v24Z1 = rp1Z - p2Z1; v14X1 = rp1X - p1X1; v14Y1 = rp1Y - p1Y1; v14Z1 = rp1Z - p1Z1; v23X1 = p3X1 - p2X1; v23Y1 = p3Y1 - p2Y1; v23Z1 = p3Z1 - p2Z1; var cross1X1; var cross1Y1; var cross1Z1; var cross2X1; var cross2Y1; var cross2Z1; var cross3X1; var cross3Y1; var cross3Z1; cross1X1 = v12Y1 * v34Z1 - v12Z1 * v34Y1; cross1Y1 = v12Z1 * v34X1 - v12X1 * v34Z1; cross1Z1 = v12X1 * v34Y1 - v12Y1 * v34X1; cross2X1 = v13Y1 * v24Z1 - v13Z1 * v24Y1; cross2Y1 = v13Z1 * v24X1 - v13X1 * v24Z1; cross2Z1 = v13X1 * v24Y1 - v13Y1 * v24X1; cross3X1 = v14Y1 * v23Z1 - v14Z1 * v23Y1; cross3Y1 = v14Z1 * v23X1 - v14X1 * v23Z1; cross3Z1 = v14X1 * v23Y1 - v14Y1 * v23X1; var a11 = cross1X1 * cross1X1 + cross1Y1 * cross1Y1 + cross1Z1 * cross1Z1; var a21 = cross2X1 * cross2X1 + cross2Y1 * cross2Y1 + cross2Z1 * cross2Z1; var a31 = cross3X1 * cross3X1 + cross3Y1 * cross3Y1 + cross3Z1 * cross3Z1; var a22 = a11 > a21 ? a11 > a31 ? a11 : a31 : a21 > a31 ? a21 : a31; var p1X2 = p1._relPos1X; var p1Y2 = p1._relPos1Y; var p1Z2 = p1._relPos1Z; var p2X2 = p2._relPos1X; var p2Y2 = p2._relPos1Y; var p2Z2 = p2._relPos1Z; var p3X2 = p4._relPos1X; var p3Y2 = p4._relPos1Y; var p3Z2 = p4._relPos1Z; var v12X2; var v12Y2; var v12Z2; var v34X2; var v34Y2; var v34Z2; var v13X2; var v13Y2; var v13Z2; var v24X2; var v24Y2; var v24Z2; var v14X2; var v14Y2; var v14Z2; var v23X2; var v23Y2; var v23Z2; v12X2 = p2X2 - p1X2; v12Y2 = p2Y2 - p1Y2; v12Z2 = p2Z2 - p1Z2; v34X2 = rp1X - p3X2; v34Y2 = rp1Y - p3Y2; v34Z2 = rp1Z - p3Z2; v13X2 = p3X2 - p1X2; v13Y2 = p3Y2 - p1Y2; v13Z2 = p3Z2 - p1Z2; v24X2 = rp1X - p2X2; v24Y2 = rp1Y - p2Y2; v24Z2 = rp1Z - p2Z2; v14X2 = rp1X - p1X2; v14Y2 = rp1Y - p1Y2; v14Z2 = rp1Z - p1Z2; v23X2 = p3X2 - p2X2; v23Y2 = p3Y2 - p2Y2; v23Z2 = p3Z2 - p2Z2; var cross1X2; var cross1Y2; var cross1Z2; var cross2X2; var cross2Y2; var cross2Z2; var cross3X2; var cross3Y2; var cross3Z2; cross1X2 = v12Y2 * v34Z2 - v12Z2 * v34Y2; cross1Y2 = v12Z2 * v34X2 - v12X2 * v34Z2; cross1Z2 = v12X2 * v34Y2 - v12Y2 * v34X2; cross2X2 = v13Y2 * v24Z2 - v13Z2 * v24Y2; cross2Y2 = v13Z2 * v24X2 - v13X2 * v24Z2; cross2Z2 = v13X2 * v24Y2 - v13Y2 * v24X2; cross3X2 = v14Y2 * v23Z2 - v14Z2 * v23Y2; cross3Y2 = v14Z2 * v23X2 - v14X2 * v23Z2; cross3Z2 = v14X2 * v23Y2 - v14Y2 * v23X2; var a12 = cross1X2 * cross1X2 + cross1Y2 * cross1Y2 + cross1Z2 * cross1Z2; var a23 = cross2X2 * cross2X2 + cross2Y2 * cross2Y2 + cross2Z2 * cross2Z2; var a32 = cross3X2 * cross3X2 + cross3Y2 * cross3Y2 + cross3Z2 * cross3Z2; var a33 = a12 > a23 ? a12 > a32 ? a12 : a32 : a23 > a32 ? a23 : a32; var p1X3 = p1._relPos1X; var p1Y3 = p1._relPos1Y; var p1Z3 = p1._relPos1Z; var p2X3 = p2._relPos1X; var p2Y3 = p2._relPos1Y; var p2Z3 = p2._relPos1Z; var p3X3 = p3._relPos1X; var p3Y3 = p3._relPos1Y; var p3Z3 = p3._relPos1Z; var v12X3; var v12Y3; var v12Z3; var v34X3; var v34Y3; var v34Z3; var v13X3; var v13Y3; var v13Z3; var v24X3; var v24Y3; var v24Z3; var v14X3; var v14Y3; var v14Z3; var v23X3; var v23Y3; var v23Z3; v12X3 = p2X3 - p1X3; v12Y3 = p2Y3 - p1Y3; v12Z3 = p2Z3 - p1Z3; v34X3 = rp1X - p3X3; v34Y3 = rp1Y - p3Y3; v34Z3 = rp1Z - p3Z3; v13X3 = p3X3 - p1X3; v13Y3 = p3Y3 - p1Y3; v13Z3 = p3Z3 - p1Z3; v24X3 = rp1X - p2X3; v24Y3 = rp1Y - p2Y3; v24Z3 = rp1Z - p2Z3; v14X3 = rp1X - p1X3; v14Y3 = rp1Y - p1Y3; v14Z3 = rp1Z - p1Z3; v23X3 = p3X3 - p2X3; v23Y3 = p3Y3 - p2Y3; v23Z3 = p3Z3 - p2Z3; var cross1X3; var cross1Y3; var cross1Z3; var cross2X3; var cross2Y3; var cross2Z3; var cross3X3; var cross3Y3; var cross3Z3; cross1X3 = v12Y3 * v34Z3 - v12Z3 * v34Y3; cross1Y3 = v12Z3 * v34X3 - v12X3 * v34Z3; cross1Z3 = v12X3 * v34Y3 - v12Y3 * v34X3; cross2X3 = v13Y3 * v24Z3 - v13Z3 * v24Y3; cross2Y3 = v13Z3 * v24X3 - v13X3 * v24Z3; cross2Z3 = v13X3 * v24Y3 - v13Y3 * v24X3; cross3X3 = v14Y3 * v23Z3 - v14Z3 * v23Y3; cross3Y3 = v14Z3 * v23X3 - v14X3 * v23Z3; cross3Z3 = v14X3 * v23Y3 - v14Y3 * v23X3; var a13 = cross1X3 * cross1X3 + cross1Y3 * cross1Y3 + cross1Z3 * cross1Z3; var a24 = cross2X3 * cross2X3 + cross2Y3 * cross2Y3 + cross2Z3 * cross2Z3; var a34 = cross3X3 * cross3X3 + cross3Y3 * cross3Y3 + cross3Z3 * cross3Z3; var a4 = a13 > a24 ? a13 > a34 ? a13 : a34 : a24 > a34 ? a24 : a34; var max = a1 > a2 ? a1 > a3 ? a1 : a3 : a2 > a3 ? a2 : a3; var target = 0; if (a22 > max && maxDepthIndex != 1 || maxDepthIndex == 0) { max = a22; target = 1; } if (a33 > max && maxDepthIndex != 2) { max = a33; target = 2; } if (a4 > max && maxDepthIndex != 3) { target = 3; } return target; } }, { key: "computeRelativePositions", value: function computeRelativePositions(tf1, tf2) { var num = this._manifold._numPoints; var _g = 0; while (_g < num) { var p = this._manifold._points[_g++]; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * p._localPos1X + tf1._rotation01 * p._localPos1Y + tf1._rotation02 * p._localPos1Z; __tmp__Y = tf1._rotation10 * p._localPos1X + tf1._rotation11 * p._localPos1Y + tf1._rotation12 * p._localPos1Z; __tmp__Z = tf1._rotation20 * p._localPos1X + tf1._rotation21 * p._localPos1Y + tf1._rotation22 * p._localPos1Z; p._relPos1X = __tmp__X; p._relPos1Y = __tmp__Y; p._relPos1Z = __tmp__Z; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * p._localPos2X + tf2._rotation01 * p._localPos2Y + tf2._rotation02 * p._localPos2Z; __tmp__Y1 = tf2._rotation10 * p._localPos2X + tf2._rotation11 * p._localPos2Y + tf2._rotation12 * p._localPos2Z; __tmp__Z1 = tf2._rotation20 * p._localPos2X + tf2._rotation21 * p._localPos2Y + tf2._rotation22 * p._localPos2Z; p._relPos2X = __tmp__X1; p._relPos2Y = __tmp__Y1; p._relPos2Z = __tmp__Z1; p._warmStarted = true; } } }, { key: "findNearestContactPointIndex", value: function findNearestContactPointIndex(target, tf1, tf2) { var nearestSq = oimo.common.Setting.contactPersistenceThreshold * oimo.common.Setting.contactPersistenceThreshold; var idx = -1; var _g = 0; var _g1 = this._manifold._numPoints; while (_g < _g1) { var i = _g++; var mp = this._manifold._points[i]; var rp1X = void 0; var rp1Y = void 0; var rp1Z = void 0; var rp2X = void 0; var rp2Y = void 0; var rp2Z = void 0; var v = target.position1; rp1X = v.x; rp1Y = v.y; rp1Z = v.z; var v1 = target.position2; rp2X = v1.x; rp2Y = v1.y; rp2Z = v1.z; rp1X -= tf1._positionX; rp1Y -= tf1._positionY; rp1Z -= tf1._positionZ; rp2X -= tf2._positionX; rp2Y -= tf2._positionY; rp2Z -= tf2._positionZ; var diff1X = void 0; var diff1Y = void 0; var diff1Z = void 0; var diff2X = void 0; var diff2Y = void 0; var diff2Z = void 0; diff1X = mp._relPos1X - rp1X; diff1Y = mp._relPos1Y - rp1Y; diff1Z = mp._relPos1Z - rp1Z; diff2X = mp._relPos2X - rp2X; diff2Y = mp._relPos2Y - rp2Y; diff2Z = mp._relPos2Z - rp2Z; var sq1 = diff1X * diff1X + diff1Y * diff1Y + diff1Z * diff1Z; var sq2 = diff2X * diff2X + diff2Y * diff2Y + diff2Z * diff2Z; var d = sq1 < sq2 ? sq1 : sq2; if (d < nearestSq) { nearestSq = d; idx = i; } } return idx; } }, { key: "totalUpdate", value: function totalUpdate(result, tf1, tf2) { this.numOldPoints = this._manifold._numPoints; var _g = 0; var _g1 = this.numOldPoints; while (_g < _g1) { var i = _g++; var _this = this.oldPoints[i]; var cp = this._manifold._points[i]; _this._localPos1X = cp._localPos1X; _this._localPos1Y = cp._localPos1Y; _this._localPos1Z = cp._localPos1Z; _this._localPos2X = cp._localPos2X; _this._localPos2Y = cp._localPos2Y; _this._localPos2Z = cp._localPos2Z; _this._relPos1X = cp._relPos1X; _this._relPos1Y = cp._relPos1Y; _this._relPos1Z = cp._relPos1Z; _this._relPos2X = cp._relPos2X; _this._relPos2Y = cp._relPos2Y; _this._relPos2Z = cp._relPos2Z; _this._pos1X = cp._pos1X; _this._pos1Y = cp._pos1Y; _this._pos1Z = cp._pos1Z; _this._pos2X = cp._pos2X; _this._pos2Y = cp._pos2Y; _this._pos2Z = cp._pos2Z; _this._depth = cp._depth; _this._impulse.copyFrom(cp._impulse); _this._id = cp._id; _this._warmStarted = cp._warmStarted; _this._disabled = false; } var num = result.numPoints; this._manifold._numPoints = num; var _g2 = 0; while (_g2 < num) { var _i137 = _g2++; var p = this._manifold._points[_i137]; var ref = result.points[_i137]; var v = ref.position1; p._pos1X = v.x; p._pos1Y = v.y; p._pos1Z = v.z; var v1 = ref.position2; p._pos2X = v1.x; p._pos2Y = v1.y; p._pos2Z = v1.z; p._relPos1X = p._pos1X - tf1._positionX; p._relPos1Y = p._pos1Y - tf1._positionY; p._relPos1Z = p._pos1Z - tf1._positionZ; p._relPos2X = p._pos2X - tf2._positionX; p._relPos2Y = p._pos2Y - tf2._positionY; p._relPos2Z = p._pos2Z - tf2._positionZ; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * p._relPos1X + tf1._rotation10 * p._relPos1Y + tf1._rotation20 * p._relPos1Z; __tmp__Y = tf1._rotation01 * p._relPos1X + tf1._rotation11 * p._relPos1Y + tf1._rotation21 * p._relPos1Z; __tmp__Z = tf1._rotation02 * p._relPos1X + tf1._rotation12 * p._relPos1Y + tf1._rotation22 * p._relPos1Z; p._localPos1X = __tmp__X; p._localPos1Y = __tmp__Y; p._localPos1Z = __tmp__Z; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * p._relPos2X + tf2._rotation10 * p._relPos2Y + tf2._rotation20 * p._relPos2Z; __tmp__Y1 = tf2._rotation01 * p._relPos2X + tf2._rotation11 * p._relPos2Y + tf2._rotation21 * p._relPos2Z; __tmp__Z1 = tf2._rotation02 * p._relPos2X + tf2._rotation12 * p._relPos2Y + tf2._rotation22 * p._relPos2Z; p._localPos2X = __tmp__X1; p._localPos2Y = __tmp__Y1; p._localPos2Z = __tmp__Z1; p._depth = ref.depth; var _this214 = p._impulse; _this214.impulseN = 0; _this214.impulseT = 0; _this214.impulseB = 0; _this214.impulseP = 0; _this214.impulseLX = 0; _this214.impulseLY = 0; _this214.impulseLZ = 0; p._id = ref.id; p._warmStarted = false; p._disabled = false; var _g296 = 0; var _g297 = this.numOldPoints; while (_g296 < _g297) { var ocp = this.oldPoints[_g296++]; if (p._id == ocp._id) { p._impulse.copyFrom(ocp._impulse); p._warmStarted = true; break; } } } } }, { key: "incrementalUpdate", value: function incrementalUpdate(result, tf1, tf2) { this._manifold._updateDepthsAndPositions(tf1, tf2); var _g = 0; var _g1 = this._manifold._numPoints; while (_g < _g1) { this._manifold._points[_g++]._warmStarted = true; } var newPoint = result.points[0]; var index = this.findNearestContactPointIndex(newPoint, tf1, tf2); if (index == -1) { this.addManifoldPoint(newPoint, tf1, tf2); } else { var cp = this._manifold._points[index]; var v = newPoint.position1; cp._pos1X = v.x; cp._pos1Y = v.y; cp._pos1Z = v.z; var v1 = newPoint.position2; cp._pos2X = v1.x; cp._pos2Y = v1.y; cp._pos2Z = v1.z; cp._relPos1X = cp._pos1X - tf1._positionX; cp._relPos1Y = cp._pos1Y - tf1._positionY; cp._relPos1Z = cp._pos1Z - tf1._positionZ; cp._relPos2X = cp._pos2X - tf2._positionX; cp._relPos2Y = cp._pos2Y - tf2._positionY; cp._relPos2Z = cp._pos2Z - tf2._positionZ; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = tf1._rotation00 * cp._relPos1X + tf1._rotation10 * cp._relPos1Y + tf1._rotation20 * cp._relPos1Z; __tmp__Y = tf1._rotation01 * cp._relPos1X + tf1._rotation11 * cp._relPos1Y + tf1._rotation21 * cp._relPos1Z; __tmp__Z = tf1._rotation02 * cp._relPos1X + tf1._rotation12 * cp._relPos1Y + tf1._rotation22 * cp._relPos1Z; cp._localPos1X = __tmp__X; cp._localPos1Y = __tmp__Y; cp._localPos1Z = __tmp__Z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = tf2._rotation00 * cp._relPos2X + tf2._rotation10 * cp._relPos2Y + tf2._rotation20 * cp._relPos2Z; __tmp__Y1 = tf2._rotation01 * cp._relPos2X + tf2._rotation11 * cp._relPos2Y + tf2._rotation21 * cp._relPos2Z; __tmp__Z1 = tf2._rotation02 * cp._relPos2X + tf2._rotation12 * cp._relPos2Y + tf2._rotation22 * cp._relPos2Z; cp._localPos2X = __tmp__X1; cp._localPos2Y = __tmp__Y1; cp._localPos2Z = __tmp__Z1; cp._depth = newPoint.depth; } this.removeOutdatedPoints(); } }]); return oimo_dynamics_constraint_contact_ManifoldUpdater; }(); if (!oimo.dynamics.constraint.info) oimo.dynamics.constraint.info = {}; oimo.dynamics.constraint.info.JacobianRow = /*#__PURE__*/function () { function oimo_dynamics_constraint_info_JacobianRow() { _classCallCheck(this, oimo_dynamics_constraint_info_JacobianRow); this.lin1X = 0; this.lin1Y = 0; this.lin1Z = 0; this.lin2X = 0; this.lin2Y = 0; this.lin2Z = 0; this.ang1X = 0; this.ang1Y = 0; this.ang1Z = 0; this.ang2X = 0; this.ang2Y = 0; this.ang2Z = 0; this.flag = 0; } _createClass(oimo_dynamics_constraint_info_JacobianRow, [{ key: "updateSparsity", value: function updateSparsity() { this.flag = 0; if (!(this.lin1X == 0 && this.lin1Y == 0 && this.lin1Z == 0) || !(this.lin2X == 0 && this.lin2Y == 0 && this.lin2Z == 0)) { this.flag |= 1; } if (!(this.ang1X == 0 && this.ang1Y == 0 && this.ang1Z == 0) || !(this.ang2X == 0 && this.ang2Y == 0 && this.ang2Z == 0)) { this.flag |= 2; } } }]); return oimo_dynamics_constraint_info_JacobianRow; }(); if (!oimo.dynamics.constraint.info.contact) oimo.dynamics.constraint.info.contact = {}; oimo.dynamics.constraint.info.contact.ContactSolverInfo = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_info_contact_ContactSolverInfo() { _classCallCheck(this, oimo_dynamics_constraint_info_contact_ContactSolverInfo); this.b1 = null; this.b2 = null; this.numRows = 0; this.rows = new Array(oimo.common.Setting.maxManifoldPoints); var _g = 0; var _g1 = this.rows.length; while (_g < _g1) { this.rows[_g++] = new oimo.dynamics.constraint.info.contact.ContactSolverInfoRow(); } }); oimo.dynamics.constraint.info.contact.ContactSolverInfoRow = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_info_contact_ContactSolverInfoRow() { _classCallCheck(this, oimo_dynamics_constraint_info_contact_ContactSolverInfoRow); this.jacobianN = new oimo.dynamics.constraint.info.JacobianRow(); this.jacobianT = new oimo.dynamics.constraint.info.JacobianRow(); this.jacobianB = new oimo.dynamics.constraint.info.JacobianRow(); this.rhs = 0; this.cfm = 0; this.friction = 0; this.impulse = null; }); if (!oimo.dynamics.constraint.info.joint) oimo.dynamics.constraint.info.joint = {}; oimo.dynamics.constraint.info.joint.JointSolverInfo = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_info_joint_JointSolverInfo() { _classCallCheck(this, oimo_dynamics_constraint_info_joint_JointSolverInfo); this.b1 = null; this.b2 = null; this.numRows = 0; this.rows = new Array(oimo.common.Setting.maxJacobianRows); var _g = 0; var _g1 = this.rows.length; while (_g < _g1) { this.rows[_g++] = new oimo.dynamics.constraint.info.joint.JointSolverInfoRow(); } }); oimo.dynamics.constraint.info.joint.JointSolverInfoRow = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_info_joint_JointSolverInfoRow() { _classCallCheck(this, oimo_dynamics_constraint_info_joint_JointSolverInfoRow); this.jacobian = new oimo.dynamics.constraint.info.JacobianRow(); this.rhs = 0; this.cfm = 0; this.minImpulse = 0; this.maxImpulse = 0; this.motorSpeed = 0; this.motorMaxImpulse = 0; this.impulse = null; }); if (!oimo.dynamics.constraint.joint) oimo.dynamics.constraint.joint = {}; oimo.dynamics.constraint.joint.BasisTracker = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_joint_BasisTracker(joint) { _classCallCheck(this, oimo_dynamics_constraint_joint_BasisTracker); this.joint = joint; this.xX = 0; this.xY = 0; this.xZ = 0; this.yX = 0; this.yY = 0; this.yZ = 0; this.zX = 0; this.zY = 0; this.zZ = 0; }); oimo.dynamics.constraint.joint.Joint = /*#__PURE__*/function () { function oimo_dynamics_constraint_joint_Joint(config, type) { _classCallCheck(this, oimo_dynamics_constraint_joint_Joint); this._link1 = new oimo.dynamics.constraint.joint.JointLink(this); this._link2 = new oimo.dynamics.constraint.joint.JointLink(this); this._positionCorrectionAlgorithm = oimo.common.Setting.defaultJointPositionCorrectionAlgorithm; this._type = type; this._world = null; this._b1 = config.rigidBody1; this._b2 = config.rigidBody2; this._allowCollision = config.allowCollision; this._breakForce = config.breakForce; this._breakTorque = config.breakTorque; switch (config.solverType) { case 0: this._solver = new oimo.dynamics.constraint.solver.pgs.PgsJointConstraintSolver(this); break; case 1: this._solver = new oimo.dynamics.constraint.solver.direct.DirectJointConstraintSolver(this); break; } var v = config.localAnchor1; this._localAnchor1X = v.x; this._localAnchor1Y = v.y; this._localAnchor1Z = v.z; var v1 = config.localAnchor2; this._localAnchor2X = v1.x; this._localAnchor2Y = v1.y; this._localAnchor2Z = v1.z; this._relativeAnchor1X = 0; this._relativeAnchor1Y = 0; this._relativeAnchor1Z = 0; this._relativeAnchor2X = 0; this._relativeAnchor2Y = 0; this._relativeAnchor2Z = 0; this._anchor1X = 0; this._anchor1Y = 0; this._anchor1Z = 0; this._anchor2X = 0; this._anchor2Y = 0; this._anchor2Z = 0; this._localBasisX1X = 0; this._localBasisX1Y = 0; this._localBasisX1Z = 0; this._localBasisY1X = 0; this._localBasisY1Y = 0; this._localBasisY1Z = 0; this._localBasisZ1X = 0; this._localBasisZ1Y = 0; this._localBasisZ1Z = 0; this._localBasisX2X = 0; this._localBasisX2Y = 0; this._localBasisX2Z = 0; this._localBasisY2X = 0; this._localBasisY2Y = 0; this._localBasisY2Z = 0; this._localBasisZ2X = 0; this._localBasisZ2Y = 0; this._localBasisZ2Z = 0; this._impulses = new Array(oimo.common.Setting.maxJacobianRows); var _g = 0; var _g1 = oimo.common.Setting.maxJacobianRows; while (_g < _g1) { this._impulses[_g++] = new oimo.dynamics.constraint.joint.JointImpulse(); } } _createClass(oimo_dynamics_constraint_joint_Joint, [{ key: "buildLocalBasesFromX", value: function buildLocalBasesFromX() { if (this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z == 0) { this._localBasisX1X = 1; this._localBasisX1Y = 0; this._localBasisX1Z = 0; } else { var l = this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z; if (l > 0) { l = 1 / Math.sqrt(l); } this._localBasisX1X *= l; this._localBasisX1Y *= l; this._localBasisX1Z *= l; } if (this._localBasisX2X * this._localBasisX2X + this._localBasisX2Y * this._localBasisX2Y + this._localBasisX2Z * this._localBasisX2Z == 0) { this._localBasisX2X = 1; this._localBasisX2Y = 0; this._localBasisX2Z = 0; } else { var _l32 = this._localBasisX2X * this._localBasisX2X + this._localBasisX2Y * this._localBasisX2Y + this._localBasisX2Z * this._localBasisX2Z; if (_l32 > 0) { _l32 = 1 / Math.sqrt(_l32); } this._localBasisX2X *= _l32; this._localBasisX2Y *= _l32; this._localBasisX2Z *= _l32; } var slerpQX; var slerpQY; var slerpQZ; var slerpQW; var slerpM00; var slerpM01; var slerpM02; var slerpM10; var slerpM11; var slerpM12; var slerpM20; var slerpM21; var slerpM22; var d = this._localBasisX1X * this._localBasisX2X + this._localBasisX1Y * this._localBasisX2Y + this._localBasisX1Z * this._localBasisX2Z; if (d < -0.999999999) { var vX; var vY; var vZ; var _x5 = this._localBasisX1X; var _y5 = this._localBasisX1Y; var _z5 = this._localBasisX1Z; var _x6 = _x5 * _x5; var _y6 = _y5 * _y5; var _z6 = _z5 * _z5; var _d37; if (_x6 < _y6) { if (_x6 < _z6) { _d37 = 1 / Math.sqrt(_y6 + _z6); vX = 0; vY = _z5 * _d37; vZ = -_y5 * _d37; } else { _d37 = 1 / Math.sqrt(_x6 + _y6); vX = _y5 * _d37; vY = -_x5 * _d37; vZ = 0; } } else if (_y6 < _z6) { _d37 = 1 / Math.sqrt(_z6 + _x6); vX = -_z5 * _d37; vY = 0; vZ = _x5 * _d37; } else { _d37 = 1 / Math.sqrt(_x6 + _y6); vX = _y5 * _d37; vY = -_x5 * _d37; vZ = 0; } slerpQX = vX; slerpQY = vY; slerpQZ = vZ; slerpQW = 0; } else { var cX; var cY; var cZ; cX = this._localBasisX1Y * this._localBasisX2Z - this._localBasisX1Z * this._localBasisX2Y; cY = this._localBasisX1Z * this._localBasisX2X - this._localBasisX1X * this._localBasisX2Z; cZ = this._localBasisX1X * this._localBasisX2Y - this._localBasisX1Y * this._localBasisX2X; var _w = Math.sqrt((1 + d) * 0.5); d = 0.5 / _w; cX *= d; cY *= d; cZ *= d; slerpQX = cX; slerpQY = cY; slerpQZ = cZ; slerpQW = _w; } var x = slerpQX; var y = slerpQY; var z = slerpQZ; var w = slerpQW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; slerpM00 = 1 - yy - zz; slerpM01 = xy - wz; slerpM02 = xz + wy; slerpM10 = xy + wz; slerpM11 = 1 - xx - zz; slerpM12 = yz - wx; slerpM20 = xz - wy; slerpM21 = yz + wx; slerpM22 = 1 - xx - yy; var x1 = this._localBasisX1X; var y1 = this._localBasisX1Y; var z1 = this._localBasisX1Z; var x21 = x1 * x1; var y21 = y1 * y1; var z21 = z1 * z1; var d1; if (x21 < y21) { if (x21 < z21) { d1 = 1 / Math.sqrt(y21 + z21); this._localBasisY1X = 0; this._localBasisY1Y = z1 * d1; this._localBasisY1Z = -y1 * d1; } else { d1 = 1 / Math.sqrt(x21 + y21); this._localBasisY1X = y1 * d1; this._localBasisY1Y = -x1 * d1; this._localBasisY1Z = 0; } } else if (y21 < z21) { d1 = 1 / Math.sqrt(z21 + x21); this._localBasisY1X = -z1 * d1; this._localBasisY1Y = 0; this._localBasisY1Z = x1 * d1; } else { d1 = 1 / Math.sqrt(x21 + y21); this._localBasisY1X = y1 * d1; this._localBasisY1Y = -x1 * d1; this._localBasisY1Z = 0; } this._localBasisZ1X = this._localBasisX1Y * this._localBasisY1Z - this._localBasisX1Z * this._localBasisY1Y; this._localBasisZ1Y = this._localBasisX1Z * this._localBasisY1X - this._localBasisX1X * this._localBasisY1Z; this._localBasisZ1Z = this._localBasisX1X * this._localBasisY1Y - this._localBasisX1Y * this._localBasisY1X; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = slerpM00 * this._localBasisX1X + slerpM01 * this._localBasisX1Y + slerpM02 * this._localBasisX1Z; __tmp__Y = slerpM10 * this._localBasisX1X + slerpM11 * this._localBasisX1Y + slerpM12 * this._localBasisX1Z; __tmp__Z = slerpM20 * this._localBasisX1X + slerpM21 * this._localBasisX1Y + slerpM22 * this._localBasisX1Z; this._localBasisX2X = __tmp__X; this._localBasisX2Y = __tmp__Y; this._localBasisX2Z = __tmp__Z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = slerpM00 * this._localBasisY1X + slerpM01 * this._localBasisY1Y + slerpM02 * this._localBasisY1Z; __tmp__Y1 = slerpM10 * this._localBasisY1X + slerpM11 * this._localBasisY1Y + slerpM12 * this._localBasisY1Z; __tmp__Z1 = slerpM20 * this._localBasisY1X + slerpM21 * this._localBasisY1Y + slerpM22 * this._localBasisY1Z; this._localBasisY2X = __tmp__X1; this._localBasisY2Y = __tmp__Y1; this._localBasisY2Z = __tmp__Z1; var __tmp__X2; var __tmp__Y2; var __tmp__Z2; __tmp__X2 = slerpM00 * this._localBasisZ1X + slerpM01 * this._localBasisZ1Y + slerpM02 * this._localBasisZ1Z; __tmp__Y2 = slerpM10 * this._localBasisZ1X + slerpM11 * this._localBasisZ1Y + slerpM12 * this._localBasisZ1Z; __tmp__Z2 = slerpM20 * this._localBasisZ1X + slerpM21 * this._localBasisZ1Y + slerpM22 * this._localBasisZ1Z; this._localBasisZ2X = __tmp__X2; this._localBasisZ2Y = __tmp__Y2; this._localBasisZ2Z = __tmp__Z2; } }, { key: "buildLocalBasesFromXY", value: function buildLocalBasesFromXY() { if (this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z == 0) { this._localBasisX1X = 1; this._localBasisX1Y = 0; this._localBasisX1Z = 0; } else { var l = this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z; if (l > 0) { l = 1 / Math.sqrt(l); } this._localBasisX1X *= l; this._localBasisX1Y *= l; this._localBasisX1Z *= l; } if (this._localBasisX2X * this._localBasisX2X + this._localBasisX2Y * this._localBasisX2Y + this._localBasisX2Z * this._localBasisX2Z == 0) { this._localBasisX2X = 1; this._localBasisX2Y = 0; this._localBasisX2Z = 0; } else { var _l33 = this._localBasisX2X * this._localBasisX2X + this._localBasisX2Y * this._localBasisX2Y + this._localBasisX2Z * this._localBasisX2Z; if (_l33 > 0) { _l33 = 1 / Math.sqrt(_l33); } this._localBasisX2X *= _l33; this._localBasisX2Y *= _l33; this._localBasisX2Z *= _l33; } this._localBasisZ1X = this._localBasisX1Y * this._localBasisY1Z - this._localBasisX1Z * this._localBasisY1Y; this._localBasisZ1Y = this._localBasisX1Z * this._localBasisY1X - this._localBasisX1X * this._localBasisY1Z; this._localBasisZ1Z = this._localBasisX1X * this._localBasisY1Y - this._localBasisX1Y * this._localBasisY1X; this._localBasisZ2X = this._localBasisX2Y * this._localBasisY2Z - this._localBasisX2Z * this._localBasisY2Y; this._localBasisZ2Y = this._localBasisX2Z * this._localBasisY2X - this._localBasisX2X * this._localBasisY2Z; this._localBasisZ2Z = this._localBasisX2X * this._localBasisY2Y - this._localBasisX2Y * this._localBasisY2X; if (this._localBasisZ1X * this._localBasisZ1X + this._localBasisZ1Y * this._localBasisZ1Y + this._localBasisZ1Z * this._localBasisZ1Z == 0) { var x1 = this._localBasisX1X; var y1 = this._localBasisX1Y; var z1 = this._localBasisX1Z; var x2 = x1 * x1; var y2 = y1 * y1; var z2 = z1 * z1; var d; if (x2 < y2) { if (x2 < z2) { d = 1 / Math.sqrt(y2 + z2); this._localBasisY1X = 0; this._localBasisY1Y = z1 * d; this._localBasisY1Z = -y1 * d; } else { d = 1 / Math.sqrt(x2 + y2); this._localBasisY1X = y1 * d; this._localBasisY1Y = -x1 * d; this._localBasisY1Z = 0; } } else if (y2 < z2) { d = 1 / Math.sqrt(z2 + x2); this._localBasisY1X = -z1 * d; this._localBasisY1Y = 0; this._localBasisY1Z = x1 * d; } else { d = 1 / Math.sqrt(x2 + y2); this._localBasisY1X = y1 * d; this._localBasisY1Y = -x1 * d; this._localBasisY1Z = 0; } this._localBasisZ1X = this._localBasisX1Y * this._localBasisY1Z - this._localBasisX1Z * this._localBasisY1Y; this._localBasisZ1Y = this._localBasisX1Z * this._localBasisY1X - this._localBasisX1X * this._localBasisY1Z; this._localBasisZ1Z = this._localBasisX1X * this._localBasisY1Y - this._localBasisX1Y * this._localBasisY1X; } else { var _l34 = this._localBasisZ1X * this._localBasisZ1X + this._localBasisZ1Y * this._localBasisZ1Y + this._localBasisZ1Z * this._localBasisZ1Z; if (_l34 > 0) { _l34 = 1 / Math.sqrt(_l34); } this._localBasisZ1X *= _l34; this._localBasisZ1Y *= _l34; this._localBasisZ1Z *= _l34; this._localBasisY1X = this._localBasisZ1Y * this._localBasisX1Z - this._localBasisZ1Z * this._localBasisX1Y; this._localBasisY1Y = this._localBasisZ1Z * this._localBasisX1X - this._localBasisZ1X * this._localBasisX1Z; this._localBasisY1Z = this._localBasisZ1X * this._localBasisX1Y - this._localBasisZ1Y * this._localBasisX1X; } if (this._localBasisZ2X * this._localBasisZ2X + this._localBasisZ2Y * this._localBasisZ2Y + this._localBasisZ2Z * this._localBasisZ2Z == 0) { var _x7 = this._localBasisX2X; var _y7 = this._localBasisX2Y; var _z7 = this._localBasisX2Z; var _x8 = _x7 * _x7; var _y8 = _y7 * _y7; var _z8 = _z7 * _z7; var _d38; if (_x8 < _y8) { if (_x8 < _z8) { _d38 = 1 / Math.sqrt(_y8 + _z8); this._localBasisY2X = 0; this._localBasisY2Y = _z7 * _d38; this._localBasisY2Z = -_y7 * _d38; } else { _d38 = 1 / Math.sqrt(_x8 + _y8); this._localBasisY2X = _y7 * _d38; this._localBasisY2Y = -_x7 * _d38; this._localBasisY2Z = 0; } } else if (_y8 < _z8) { _d38 = 1 / Math.sqrt(_z8 + _x8); this._localBasisY2X = -_z7 * _d38; this._localBasisY2Y = 0; this._localBasisY2Z = _x7 * _d38; } else { _d38 = 1 / Math.sqrt(_x8 + _y8); this._localBasisY2X = _y7 * _d38; this._localBasisY2Y = -_x7 * _d38; this._localBasisY2Z = 0; } this._localBasisZ2X = this._localBasisX2Y * this._localBasisY2Z - this._localBasisX2Z * this._localBasisY2Y; this._localBasisZ2Y = this._localBasisX2Z * this._localBasisY2X - this._localBasisX2X * this._localBasisY2Z; this._localBasisZ2Z = this._localBasisX2X * this._localBasisY2Y - this._localBasisX2Y * this._localBasisY2X; } else { var _l35 = this._localBasisZ2X * this._localBasisZ2X + this._localBasisZ2Y * this._localBasisZ2Y + this._localBasisZ2Z * this._localBasisZ2Z; if (_l35 > 0) { _l35 = 1 / Math.sqrt(_l35); } this._localBasisZ2X *= _l35; this._localBasisZ2Y *= _l35; this._localBasisZ2Z *= _l35; this._localBasisY2X = this._localBasisZ2Y * this._localBasisX2Z - this._localBasisZ2Z * this._localBasisX2Y; this._localBasisY2Y = this._localBasisZ2Z * this._localBasisX2X - this._localBasisZ2X * this._localBasisX2Z; this._localBasisY2Z = this._localBasisZ2X * this._localBasisX2Y - this._localBasisZ2Y * this._localBasisX2X; } } }, { key: "buildLocalBasesFromX1Z2", value: function buildLocalBasesFromX1Z2() { if (this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z == 0) { this._localBasisX1X = 1; this._localBasisX1Y = 0; this._localBasisX1Z = 0; } else { var l = this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z; if (l > 0) { l = 1 / Math.sqrt(l); } this._localBasisX1X *= l; this._localBasisX1Y *= l; this._localBasisX1Z *= l; } if (this._localBasisZ2X * this._localBasisZ2X + this._localBasisZ2Y * this._localBasisZ2Y + this._localBasisZ2Z * this._localBasisZ2Z == 0) { this._localBasisZ2X = 0; this._localBasisZ2Y = 0; this._localBasisZ2Z = 1; } else { var _l36 = this._localBasisZ2X * this._localBasisZ2X + this._localBasisZ2Y * this._localBasisZ2Y + this._localBasisZ2Z * this._localBasisZ2Z; if (_l36 > 0) { _l36 = 1 / Math.sqrt(_l36); } this._localBasisZ2X *= _l36; this._localBasisZ2Y *= _l36; this._localBasisZ2Z *= _l36; } var tf1 = this._b1._transform; var tf2 = this._b2._transform; var worldX1X; var worldX1Y; var worldX1Z; var worldZ1X; var worldZ1Y; var worldZ1Z; var worldYX; var worldYY; var worldYZ; var worldX2X; var worldX2Y; var worldX2Z; var worldZ2X; var worldZ2Y; var worldZ2Z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = tf1._rotation00 * this._localBasisX1X + tf1._rotation01 * this._localBasisX1Y + tf1._rotation02 * this._localBasisX1Z; __tmp__Y = tf1._rotation10 * this._localBasisX1X + tf1._rotation11 * this._localBasisX1Y + tf1._rotation12 * this._localBasisX1Z; __tmp__Z = tf1._rotation20 * this._localBasisX1X + tf1._rotation21 * this._localBasisX1Y + tf1._rotation22 * this._localBasisX1Z; worldX1X = __tmp__X; worldX1Y = __tmp__Y; worldX1Z = __tmp__Z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = tf2._rotation00 * this._localBasisZ2X + tf2._rotation01 * this._localBasisZ2Y + tf2._rotation02 * this._localBasisZ2Z; __tmp__Y1 = tf2._rotation10 * this._localBasisZ2X + tf2._rotation11 * this._localBasisZ2Y + tf2._rotation12 * this._localBasisZ2Z; __tmp__Z1 = tf2._rotation20 * this._localBasisZ2X + tf2._rotation21 * this._localBasisZ2Y + tf2._rotation22 * this._localBasisZ2Z; worldZ2X = __tmp__X1; worldZ2Y = __tmp__Y1; worldZ2Z = __tmp__Z1; worldYX = worldZ2Y * worldX1Z - worldZ2Z * worldX1Y; worldYY = worldZ2Z * worldX1X - worldZ2X * worldX1Z; worldYZ = worldZ2X * worldX1Y - worldZ2Y * worldX1X; if (worldYX * worldYX + worldYY * worldYY + worldYZ * worldYZ == 0) { var x1 = worldX1X; var y1 = worldX1Y; var z1 = worldX1Z; var x2 = x1 * x1; var y2 = y1 * y1; var z2 = z1 * z1; var d; if (x2 < y2) { if (x2 < z2) { d = 1 / Math.sqrt(y2 + z2); worldYX = 0; worldYY = z1 * d; worldYZ = -y1 * d; } else { d = 1 / Math.sqrt(x2 + y2); worldYX = y1 * d; worldYY = -x1 * d; worldYZ = 0; } } else if (y2 < z2) { d = 1 / Math.sqrt(z2 + x2); worldYX = -z1 * d; worldYY = 0; worldYZ = x1 * d; } else { d = 1 / Math.sqrt(x2 + y2); worldYX = y1 * d; worldYY = -x1 * d; worldYZ = 0; } } worldZ1X = worldX1Y * worldYZ - worldX1Z * worldYY; worldZ1Y = worldX1Z * worldYX - worldX1X * worldYZ; worldZ1Z = worldX1X * worldYY - worldX1Y * worldYX; worldX2X = worldYY * worldZ2Z - worldYZ * worldZ2Y; worldX2Y = worldYZ * worldZ2X - worldYX * worldZ2Z; worldX2Z = worldYX * worldZ2Y - worldYY * worldZ2X; var __tmp__X2; var __tmp__Y2; var __tmp__Z2; __tmp__X2 = tf1._rotation00 * worldX1X + tf1._rotation10 * worldX1Y + tf1._rotation20 * worldX1Z; __tmp__Y2 = tf1._rotation01 * worldX1X + tf1._rotation11 * worldX1Y + tf1._rotation21 * worldX1Z; __tmp__Z2 = tf1._rotation02 * worldX1X + tf1._rotation12 * worldX1Y + tf1._rotation22 * worldX1Z; this._localBasisX1X = __tmp__X2; this._localBasisX1Y = __tmp__Y2; this._localBasisX1Z = __tmp__Z2; var __tmp__X3; var __tmp__Y3; var __tmp__Z3; __tmp__X3 = tf1._rotation00 * worldYX + tf1._rotation10 * worldYY + tf1._rotation20 * worldYZ; __tmp__Y3 = tf1._rotation01 * worldYX + tf1._rotation11 * worldYY + tf1._rotation21 * worldYZ; __tmp__Z3 = tf1._rotation02 * worldYX + tf1._rotation12 * worldYY + tf1._rotation22 * worldYZ; this._localBasisY1X = __tmp__X3; this._localBasisY1Y = __tmp__Y3; this._localBasisY1Z = __tmp__Z3; var __tmp__X4; var __tmp__Y4; var __tmp__Z4; __tmp__X4 = tf1._rotation00 * worldZ1X + tf1._rotation10 * worldZ1Y + tf1._rotation20 * worldZ1Z; __tmp__Y4 = tf1._rotation01 * worldZ1X + tf1._rotation11 * worldZ1Y + tf1._rotation21 * worldZ1Z; __tmp__Z4 = tf1._rotation02 * worldZ1X + tf1._rotation12 * worldZ1Y + tf1._rotation22 * worldZ1Z; this._localBasisZ1X = __tmp__X4; this._localBasisZ1Y = __tmp__Y4; this._localBasisZ1Z = __tmp__Z4; var __tmp__X5; var __tmp__Y5; var __tmp__Z5; __tmp__X5 = tf2._rotation00 * worldX2X + tf2._rotation10 * worldX2Y + tf2._rotation20 * worldX2Z; __tmp__Y5 = tf2._rotation01 * worldX2X + tf2._rotation11 * worldX2Y + tf2._rotation21 * worldX2Z; __tmp__Z5 = tf2._rotation02 * worldX2X + tf2._rotation12 * worldX2Y + tf2._rotation22 * worldX2Z; this._localBasisX2X = __tmp__X5; this._localBasisX2Y = __tmp__Y5; this._localBasisX2Z = __tmp__Z5; var __tmp__X6; var __tmp__Y6; var __tmp__Z6; __tmp__X6 = tf2._rotation00 * worldYX + tf2._rotation10 * worldYY + tf2._rotation20 * worldYZ; __tmp__Y6 = tf2._rotation01 * worldYX + tf2._rotation11 * worldYY + tf2._rotation21 * worldYZ; __tmp__Z6 = tf2._rotation02 * worldYX + tf2._rotation12 * worldYY + tf2._rotation22 * worldYZ; this._localBasisY2X = __tmp__X6; this._localBasisY2Y = __tmp__Y6; this._localBasisY2Z = __tmp__Z6; var __tmp__X7; var __tmp__Y7; var __tmp__Z7; __tmp__X7 = tf2._rotation00 * worldZ2X + tf2._rotation10 * worldZ2Y + tf2._rotation20 * worldZ2Z; __tmp__Y7 = tf2._rotation01 * worldZ2X + tf2._rotation11 * worldZ2Y + tf2._rotation21 * worldZ2Z; __tmp__Z7 = tf2._rotation02 * worldZ2X + tf2._rotation12 * worldZ2Y + tf2._rotation22 * worldZ2Z; this._localBasisZ2X = __tmp__X7; this._localBasisZ2Y = __tmp__Y7; this._localBasisZ2Z = __tmp__Z7; } }, { key: "buildLocalBasesFromXY1X2", value: function buildLocalBasesFromXY1X2() { if (this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z == 0) { this._localBasisX1X = 1; this._localBasisX1Y = 0; this._localBasisX1Z = 0; } else { var l = this._localBasisX1X * this._localBasisX1X + this._localBasisX1Y * this._localBasisX1Y + this._localBasisX1Z * this._localBasisX1Z; if (l > 0) { l = 1 / Math.sqrt(l); } this._localBasisX1X *= l; this._localBasisX1Y *= l; this._localBasisX1Z *= l; } this._localBasisZ1X = this._localBasisX1Y * this._localBasisY1Z - this._localBasisX1Z * this._localBasisY1Y; this._localBasisZ1Y = this._localBasisX1Z * this._localBasisY1X - this._localBasisX1X * this._localBasisY1Z; this._localBasisZ1Z = this._localBasisX1X * this._localBasisY1Y - this._localBasisX1Y * this._localBasisY1X; if (this._localBasisZ1X * this._localBasisZ1X + this._localBasisZ1Y * this._localBasisZ1Y + this._localBasisZ1Z * this._localBasisZ1Z == 0) { var x1 = this._localBasisX1X; var y1 = this._localBasisX1Y; var z1 = this._localBasisX1Z; var _x9 = x1 * x1; var _y9 = y1 * y1; var _z9 = z1 * z1; var _d39; if (_x9 < _y9) { if (_x9 < _z9) { _d39 = 1 / Math.sqrt(_y9 + _z9); this._localBasisY1X = 0; this._localBasisY1Y = z1 * _d39; this._localBasisY1Z = -y1 * _d39; } else { _d39 = 1 / Math.sqrt(_x9 + _y9); this._localBasisY1X = y1 * _d39; this._localBasisY1Y = -x1 * _d39; this._localBasisY1Z = 0; } } else if (_y9 < _z9) { _d39 = 1 / Math.sqrt(_z9 + _x9); this._localBasisY1X = -z1 * _d39; this._localBasisY1Y = 0; this._localBasisY1Z = x1 * _d39; } else { _d39 = 1 / Math.sqrt(_x9 + _y9); this._localBasisY1X = y1 * _d39; this._localBasisY1Y = -x1 * _d39; this._localBasisY1Z = 0; } this._localBasisZ1X = this._localBasisX1Y * this._localBasisY1Z - this._localBasisX1Z * this._localBasisY1Y; this._localBasisZ1Y = this._localBasisX1Z * this._localBasisY1X - this._localBasisX1X * this._localBasisY1Z; this._localBasisZ1Z = this._localBasisX1X * this._localBasisY1Y - this._localBasisX1Y * this._localBasisY1X; } else { var _l37 = this._localBasisZ1X * this._localBasisZ1X + this._localBasisZ1Y * this._localBasisZ1Y + this._localBasisZ1Z * this._localBasisZ1Z; if (_l37 > 0) { _l37 = 1 / Math.sqrt(_l37); } this._localBasisZ1X *= _l37; this._localBasisZ1Y *= _l37; this._localBasisZ1Z *= _l37; this._localBasisY1X = this._localBasisZ1Y * this._localBasisX1Z - this._localBasisZ1Z * this._localBasisX1Y; this._localBasisY1Y = this._localBasisZ1Z * this._localBasisX1X - this._localBasisZ1X * this._localBasisX1Z; this._localBasisY1Z = this._localBasisZ1X * this._localBasisX1Y - this._localBasisZ1Y * this._localBasisX1X; } var slerpQX; var slerpQY; var slerpQZ; var slerpQW; var slerpM00; var slerpM01; var slerpM02; var slerpM10; var slerpM11; var slerpM12; var slerpM20; var slerpM21; var slerpM22; var d = this._localBasisX1X * this._localBasisX2X + this._localBasisX1Y * this._localBasisX2Y + this._localBasisX1Z * this._localBasisX2Z; if (d < -0.999999999) { var vX; var vY; var vZ; var _x10 = this._localBasisX1X; var _y10 = this._localBasisX1Y; var _z10 = this._localBasisX1Z; var _x11 = _x10 * _x10; var _y11 = _y10 * _y10; var _z11 = _z10 * _z10; var _d40; if (_x11 < _y11) { if (_x11 < _z11) { _d40 = 1 / Math.sqrt(_y11 + _z11); vX = 0; vY = _z10 * _d40; vZ = -_y10 * _d40; } else { _d40 = 1 / Math.sqrt(_x11 + _y11); vX = _y10 * _d40; vY = -_x10 * _d40; vZ = 0; } } else if (_y11 < _z11) { _d40 = 1 / Math.sqrt(_z11 + _x11); vX = -_z10 * _d40; vY = 0; vZ = _x10 * _d40; } else { _d40 = 1 / Math.sqrt(_x11 + _y11); vX = _y10 * _d40; vY = -_x10 * _d40; vZ = 0; } slerpQX = vX; slerpQY = vY; slerpQZ = vZ; slerpQW = 0; } else { var cX; var cY; var cZ; cX = this._localBasisX1Y * this._localBasisX2Z - this._localBasisX1Z * this._localBasisX2Y; cY = this._localBasisX1Z * this._localBasisX2X - this._localBasisX1X * this._localBasisX2Z; cZ = this._localBasisX1X * this._localBasisX2Y - this._localBasisX1Y * this._localBasisX2X; var _w2 = Math.sqrt((1 + d) * 0.5); d = 0.5 / _w2; cX *= d; cY *= d; cZ *= d; slerpQX = cX; slerpQY = cY; slerpQZ = cZ; slerpQW = _w2; } var x = slerpQX; var y = slerpQY; var z = slerpQZ; var w = slerpQW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; slerpM00 = 1 - yy - zz; slerpM01 = xy - wz; slerpM02 = xz + wy; slerpM10 = xy + wz; slerpM11 = 1 - xx - zz; slerpM12 = yz - wx; slerpM20 = xz - wy; slerpM21 = yz + wx; slerpM22 = 1 - xx - yy; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = slerpM00 * this._localBasisX1X + slerpM01 * this._localBasisX1Y + slerpM02 * this._localBasisX1Z; __tmp__Y = slerpM10 * this._localBasisX1X + slerpM11 * this._localBasisX1Y + slerpM12 * this._localBasisX1Z; __tmp__Z = slerpM20 * this._localBasisX1X + slerpM21 * this._localBasisX1Y + slerpM22 * this._localBasisX1Z; this._localBasisX2X = __tmp__X; this._localBasisX2Y = __tmp__Y; this._localBasisX2Z = __tmp__Z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = slerpM00 * this._localBasisY1X + slerpM01 * this._localBasisY1Y + slerpM02 * this._localBasisY1Z; __tmp__Y1 = slerpM10 * this._localBasisY1X + slerpM11 * this._localBasisY1Y + slerpM12 * this._localBasisY1Z; __tmp__Z1 = slerpM20 * this._localBasisY1X + slerpM21 * this._localBasisY1Y + slerpM22 * this._localBasisY1Z; this._localBasisY2X = __tmp__X1; this._localBasisY2Y = __tmp__Y1; this._localBasisY2Z = __tmp__Z1; var __tmp__X2; var __tmp__Y2; var __tmp__Z2; __tmp__X2 = slerpM00 * this._localBasisZ1X + slerpM01 * this._localBasisZ1Y + slerpM02 * this._localBasisZ1Z; __tmp__Y2 = slerpM10 * this._localBasisZ1X + slerpM11 * this._localBasisZ1Y + slerpM12 * this._localBasisZ1Z; __tmp__Z2 = slerpM20 * this._localBasisZ1X + slerpM21 * this._localBasisZ1Y + slerpM22 * this._localBasisZ1Z; this._localBasisZ2X = __tmp__X2; this._localBasisZ2Y = __tmp__Y2; this._localBasisZ2Z = __tmp__Z2; } }, { key: "setSolverInfoRowLinear", value: function setSolverInfoRowLinear(row, diff, lm, mass, sd, timeStep, isPositionPart) { var cfmFactor; var erp; var slop = oimo.common.Setting.linearSlop; if (isPositionPart) { cfmFactor = 0; erp = 1; } else { if (sd.frequency > 0) { slop = 0; var omega = 6.28318530717958 * sd.frequency; var zeta = sd.dampingRatio; if (zeta < oimo.common.Setting.minSpringDamperDampingRatio) { zeta = oimo.common.Setting.minSpringDamperDampingRatio; } var h = timeStep.dt; var c = 2 * zeta * omega; var k = omega * omega; if (sd.useSymplecticEuler) { cfmFactor = 1 / (h * c); erp = k / c; } else { cfmFactor = 1 / (h * (h * k + c)); erp = k / (h * k + c); } } else { cfmFactor = 0; erp = this.getErp(timeStep, false); } if (lm.motorForce > 0) { row.motorSpeed = lm.motorSpeed; row.motorMaxImpulse = lm.motorForce * timeStep.dt; } else { row.motorSpeed = 0; row.motorMaxImpulse = 0; } } var lower = lm.lowerLimit; var upper = lm.upperLimit; var minImp; var maxImp; var error; if (lower > upper) { minImp = 0; maxImp = 0; error = 0; } else if (lower == upper) { minImp = -1e65536; maxImp = 1e65536; error = diff - lower; } else if (diff < lower) { minImp = -1e65536; maxImp = 0; error = diff - lower + slop; if (error > 0) { error = 0; } } else if (diff > upper) { minImp = 0; maxImp = 1e65536; error = diff - upper - slop; if (error < 0) { error = 0; } } else { minImp = 0; maxImp = 0; error = 0; } row.minImpulse = minImp; row.maxImpulse = maxImp; row.cfm = cfmFactor * (mass == 0 ? 0 : 1 / mass); row.rhs = error * erp; } }, { key: "setSolverInfoRowAngular", value: function setSolverInfoRowAngular(row, diff, lm, mass, sd, timeStep, isPositionPart) { var cfmFactor; var erp; var slop = oimo.common.Setting.angularSlop; if (isPositionPart) { cfmFactor = 0; erp = 1; } else { if (sd.frequency > 0) { slop = 0; var omega = 6.28318530717958 * sd.frequency; var zeta = sd.dampingRatio; if (zeta < oimo.common.Setting.minSpringDamperDampingRatio) { zeta = oimo.common.Setting.minSpringDamperDampingRatio; } var h = timeStep.dt; var c = 2 * zeta * omega; var k = omega * omega; if (sd.useSymplecticEuler) { cfmFactor = 1 / (h * c); erp = k / c; } else { cfmFactor = 1 / (h * (h * k + c)); erp = k / (h * k + c); } } else { cfmFactor = 0; erp = this.getErp(timeStep, false); } if (lm.motorTorque > 0) { row.motorSpeed = lm.motorSpeed; row.motorMaxImpulse = lm.motorTorque * timeStep.dt; } else { row.motorSpeed = 0; row.motorMaxImpulse = 0; } } var lower = lm.lowerLimit; var upper = lm.upperLimit; var mid = (lower + upper) * 0.5; diff -= mid; diff = ((diff + 3.14159265358979) % 6.28318530717958 + 6.28318530717958) % 6.28318530717958 - 3.14159265358979; diff += mid; var minImp; var maxImp; var error; if (lower > upper) { minImp = 0; maxImp = 0; error = 0; } else if (lower == upper) { minImp = -1e65536; maxImp = 1e65536; error = diff - lower; } else if (diff < lower) { minImp = -1e65536; maxImp = 0; error = diff - lower + slop; if (error > 0) { error = 0; } } else if (diff > upper) { minImp = 0; maxImp = 1e65536; error = diff - upper - slop; if (error < 0) { error = 0; } } else { minImp = 0; maxImp = 0; error = 0; } row.minImpulse = minImp; row.maxImpulse = maxImp; row.cfm = cfmFactor * (mass == 0 ? 0 : 1 / mass); row.rhs = error * erp; } }, { key: "getErp", value: function getErp(timeStep, isPositionPart) { if (isPositionPart) { return 1; } else if (this._positionCorrectionAlgorithm == oimo.dynamics.constraint.PositionCorrectionAlgorithm.BAUMGARTE) { return timeStep.invDt * oimo.common.Setting.velocityBaumgarte; } else { return 0; } } }, { key: "computeEffectiveInertiaMoment", value: function computeEffectiveInertiaMoment(axisX, axisY, axisZ) { var ia1X; var ia1Y; var ia1Z; var ia2X; var ia2Y; var ia2Z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._b1._invInertia00 * axisX + this._b1._invInertia01 * axisY + this._b1._invInertia02 * axisZ; __tmp__Y = this._b1._invInertia10 * axisX + this._b1._invInertia11 * axisY + this._b1._invInertia12 * axisZ; __tmp__Z = this._b1._invInertia20 * axisX + this._b1._invInertia21 * axisY + this._b1._invInertia22 * axisZ; ia1X = __tmp__X; ia1Y = __tmp__Y; ia1Z = __tmp__Z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = this._b2._invInertia00 * axisX + this._b2._invInertia01 * axisY + this._b2._invInertia02 * axisZ; __tmp__Y1 = this._b2._invInertia10 * axisX + this._b2._invInertia11 * axisY + this._b2._invInertia12 * axisZ; __tmp__Z1 = this._b2._invInertia20 * axisX + this._b2._invInertia21 * axisY + this._b2._invInertia22 * axisZ; ia2X = __tmp__X1; ia2Y = __tmp__Y1; ia2Z = __tmp__Z1; var invI1 = ia1X * axisX + ia1Y * axisY + ia1Z * axisZ; var invI2 = ia2X * axisX + ia2Y * axisY + ia2Z * axisZ; if (invI1 > 0) { var dot = axisX * this._relativeAnchor1X + axisY * this._relativeAnchor1Y + axisZ * this._relativeAnchor1Z; var projsq = this._relativeAnchor1X * this._relativeAnchor1X + this._relativeAnchor1Y * this._relativeAnchor1Y + this._relativeAnchor1Z * this._relativeAnchor1Z - dot * dot; if (projsq > 0) { if (this._b1._invMass > 0) { invI1 = 1 / (1 / invI1 + this._b1._mass * projsq); } else { invI1 = 0; } } } if (invI2 > 0) { var _dot = axisX * this._relativeAnchor2X + axisY * this._relativeAnchor2Y + axisZ * this._relativeAnchor2Z; var _projsq = this._relativeAnchor2X * this._relativeAnchor2X + this._relativeAnchor2Y * this._relativeAnchor2Y + this._relativeAnchor2Z * this._relativeAnchor2Z - _dot * _dot; if (_projsq > 0) { if (this._b2._invMass > 0) { invI2 = 1 / (1 / invI2 + this._b2._mass * _projsq); } else { invI2 = 0; } } } if (invI1 + invI2 == 0) { return 0; } else { return 1 / (invI1 + invI2); } } }, { key: "computeEffectiveInertiaMoment2", value: function computeEffectiveInertiaMoment2(axis1X, axis1Y, axis1Z, axis2X, axis2Y, axis2Z) { var ia1X; var ia1Y; var ia1Z; var ia2X; var ia2Y; var ia2Z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._b1._invInertia00 * axis1X + this._b1._invInertia01 * axis1Y + this._b1._invInertia02 * axis1Z; __tmp__Y = this._b1._invInertia10 * axis1X + this._b1._invInertia11 * axis1Y + this._b1._invInertia12 * axis1Z; __tmp__Z = this._b1._invInertia20 * axis1X + this._b1._invInertia21 * axis1Y + this._b1._invInertia22 * axis1Z; ia1X = __tmp__X; ia1Y = __tmp__Y; ia1Z = __tmp__Z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = this._b2._invInertia00 * axis2X + this._b2._invInertia01 * axis2Y + this._b2._invInertia02 * axis2Z; __tmp__Y1 = this._b2._invInertia10 * axis2X + this._b2._invInertia11 * axis2Y + this._b2._invInertia12 * axis2Z; __tmp__Z1 = this._b2._invInertia20 * axis2X + this._b2._invInertia21 * axis2Y + this._b2._invInertia22 * axis2Z; ia2X = __tmp__X1; ia2Y = __tmp__Y1; ia2Z = __tmp__Z1; var invI1 = ia1X * axis1X + ia1Y * axis1Y + ia1Z * axis1Z; var invI2 = ia2X * axis2X + ia2Y * axis2Y + ia2Z * axis2Z; if (invI1 > 0) { var rsq = this._relativeAnchor1X * this._relativeAnchor1X + this._relativeAnchor1Y * this._relativeAnchor1Y + this._relativeAnchor1Z * this._relativeAnchor1Z; var dot = axis1X * this._relativeAnchor1X + axis1Y * this._relativeAnchor1Y + axis1Z * this._relativeAnchor1Z; var projsq = rsq * rsq - dot * dot; if (projsq > 0) { if (this._b1._invMass > 0) { invI1 = 1 / (1 / invI1 + this._b1._mass * projsq); } else { invI1 = 0; } } } if (invI2 > 0) { var _rsq = this._relativeAnchor2X * this._relativeAnchor2X + this._relativeAnchor2Y * this._relativeAnchor2Y + this._relativeAnchor2Z * this._relativeAnchor2Z; var _dot2 = axis2X * this._relativeAnchor2X + axis2Y * this._relativeAnchor2Y + axis2Z * this._relativeAnchor2Z; var _projsq2 = _rsq * _rsq - _dot2 * _dot2; if (_projsq2 > 0) { if (this._b2._invMass > 0) { invI2 = 1 / (1 / invI2 + this._b2._mass * _projsq2); } else { invI2 = 0; } } } if (invI1 + invI2 == 0) { return 0; } else { return 1 / (invI1 + invI2); } } }, { key: "_syncAnchors", value: function _syncAnchors() { var tf1 = this._b1._transform; var tf2 = this._b2._transform; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = tf1._rotation00 * this._localAnchor1X + tf1._rotation01 * this._localAnchor1Y + tf1._rotation02 * this._localAnchor1Z; __tmp__Y = tf1._rotation10 * this._localAnchor1X + tf1._rotation11 * this._localAnchor1Y + tf1._rotation12 * this._localAnchor1Z; __tmp__Z = tf1._rotation20 * this._localAnchor1X + tf1._rotation21 * this._localAnchor1Y + tf1._rotation22 * this._localAnchor1Z; this._relativeAnchor1X = __tmp__X; this._relativeAnchor1Y = __tmp__Y; this._relativeAnchor1Z = __tmp__Z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = tf2._rotation00 * this._localAnchor2X + tf2._rotation01 * this._localAnchor2Y + tf2._rotation02 * this._localAnchor2Z; __tmp__Y1 = tf2._rotation10 * this._localAnchor2X + tf2._rotation11 * this._localAnchor2Y + tf2._rotation12 * this._localAnchor2Z; __tmp__Z1 = tf2._rotation20 * this._localAnchor2X + tf2._rotation21 * this._localAnchor2Y + tf2._rotation22 * this._localAnchor2Z; this._relativeAnchor2X = __tmp__X1; this._relativeAnchor2Y = __tmp__Y1; this._relativeAnchor2Z = __tmp__Z1; this._anchor1X = this._relativeAnchor1X + tf1._positionX; this._anchor1Y = this._relativeAnchor1Y + tf1._positionY; this._anchor1Z = this._relativeAnchor1Z + tf1._positionZ; this._anchor2X = this._relativeAnchor2X + tf2._positionX; this._anchor2Y = this._relativeAnchor2Y + tf2._positionY; this._anchor2Z = this._relativeAnchor2Z + tf2._positionZ; var __tmp__X2; var __tmp__Y2; var __tmp__Z2; __tmp__X2 = tf1._rotation00 * this._localBasisX1X + tf1._rotation01 * this._localBasisX1Y + tf1._rotation02 * this._localBasisX1Z; __tmp__Y2 = tf1._rotation10 * this._localBasisX1X + tf1._rotation11 * this._localBasisX1Y + tf1._rotation12 * this._localBasisX1Z; __tmp__Z2 = tf1._rotation20 * this._localBasisX1X + tf1._rotation21 * this._localBasisX1Y + tf1._rotation22 * this._localBasisX1Z; this._basisX1X = __tmp__X2; this._basisX1Y = __tmp__Y2; this._basisX1Z = __tmp__Z2; var __tmp__X3; var __tmp__Y3; var __tmp__Z3; __tmp__X3 = tf1._rotation00 * this._localBasisY1X + tf1._rotation01 * this._localBasisY1Y + tf1._rotation02 * this._localBasisY1Z; __tmp__Y3 = tf1._rotation10 * this._localBasisY1X + tf1._rotation11 * this._localBasisY1Y + tf1._rotation12 * this._localBasisY1Z; __tmp__Z3 = tf1._rotation20 * this._localBasisY1X + tf1._rotation21 * this._localBasisY1Y + tf1._rotation22 * this._localBasisY1Z; this._basisY1X = __tmp__X3; this._basisY1Y = __tmp__Y3; this._basisY1Z = __tmp__Z3; var __tmp__X4; var __tmp__Y4; var __tmp__Z4; __tmp__X4 = tf1._rotation00 * this._localBasisZ1X + tf1._rotation01 * this._localBasisZ1Y + tf1._rotation02 * this._localBasisZ1Z; __tmp__Y4 = tf1._rotation10 * this._localBasisZ1X + tf1._rotation11 * this._localBasisZ1Y + tf1._rotation12 * this._localBasisZ1Z; __tmp__Z4 = tf1._rotation20 * this._localBasisZ1X + tf1._rotation21 * this._localBasisZ1Y + tf1._rotation22 * this._localBasisZ1Z; this._basisZ1X = __tmp__X4; this._basisZ1Y = __tmp__Y4; this._basisZ1Z = __tmp__Z4; var __tmp__X5; var __tmp__Y5; var __tmp__Z5; __tmp__X5 = tf2._rotation00 * this._localBasisX2X + tf2._rotation01 * this._localBasisX2Y + tf2._rotation02 * this._localBasisX2Z; __tmp__Y5 = tf2._rotation10 * this._localBasisX2X + tf2._rotation11 * this._localBasisX2Y + tf2._rotation12 * this._localBasisX2Z; __tmp__Z5 = tf2._rotation20 * this._localBasisX2X + tf2._rotation21 * this._localBasisX2Y + tf2._rotation22 * this._localBasisX2Z; this._basisX2X = __tmp__X5; this._basisX2Y = __tmp__Y5; this._basisX2Z = __tmp__Z5; var __tmp__X6; var __tmp__Y6; var __tmp__Z6; __tmp__X6 = tf2._rotation00 * this._localBasisY2X + tf2._rotation01 * this._localBasisY2Y + tf2._rotation02 * this._localBasisY2Z; __tmp__Y6 = tf2._rotation10 * this._localBasisY2X + tf2._rotation11 * this._localBasisY2Y + tf2._rotation12 * this._localBasisY2Z; __tmp__Z6 = tf2._rotation20 * this._localBasisY2X + tf2._rotation21 * this._localBasisY2Y + tf2._rotation22 * this._localBasisY2Z; this._basisY2X = __tmp__X6; this._basisY2Y = __tmp__Y6; this._basisY2Z = __tmp__Z6; var __tmp__X7; var __tmp__Y7; var __tmp__Z7; __tmp__X7 = tf2._rotation00 * this._localBasisZ2X + tf2._rotation01 * this._localBasisZ2Y + tf2._rotation02 * this._localBasisZ2Z; __tmp__Y7 = tf2._rotation10 * this._localBasisZ2X + tf2._rotation11 * this._localBasisZ2Y + tf2._rotation12 * this._localBasisZ2Z; __tmp__Z7 = tf2._rotation20 * this._localBasisZ2X + tf2._rotation21 * this._localBasisZ2Y + tf2._rotation22 * this._localBasisZ2Z; this._basisZ2X = __tmp__X7; this._basisZ2Y = __tmp__Y7; this._basisZ2Z = __tmp__Z7; } }, { key: "_getVelocitySolverInfo", value: function _getVelocitySolverInfo(timeStep, info) { info.b1 = this._b1; info.b2 = this._b2; info.numRows = 0; } }, { key: "_getPositionSolverInfo", value: function _getPositionSolverInfo(info) { info.b1 = this._b1; info.b2 = this._b2; info.numRows = 0; } }, { key: "_checkDestruction", value: function _checkDestruction() { var torqueSq = this._appliedTorqueX * this._appliedTorqueX + this._appliedTorqueY * this._appliedTorqueY + this._appliedTorqueZ * this._appliedTorqueZ; if (this._breakForce > 0 && this._appliedForceX * this._appliedForceX + this._appliedForceY * this._appliedForceY + this._appliedForceZ * this._appliedForceZ > this._breakForce * this._breakForce) { this._world.removeJoint(this); return; } if (this._breakTorque > 0 && torqueSq > this._breakTorque * this._breakTorque) { this._world.removeJoint(this); return; } } }, { key: "getRigidBody1", value: function getRigidBody1() { return this._b1; } }, { key: "getRigidBody2", value: function getRigidBody2() { return this._b2; } }, { key: "getType", value: function getType() { return this._type; } }, { key: "getAnchor1", value: function getAnchor1() { var v = new oimo.common.Vec3(); v.x = this._anchor1X; v.y = this._anchor1Y; v.z = this._anchor1Z; return v; } }, { key: "getAnchor2", value: function getAnchor2() { var v = new oimo.common.Vec3(); v.x = this._anchor2X; v.y = this._anchor2Y; v.z = this._anchor2Z; return v; } }, { key: "getAnchor1To", value: function getAnchor1To(anchor) { anchor.x = this._anchor1X; anchor.y = this._anchor1Y; anchor.z = this._anchor1Z; } }, { key: "getAnchor2To", value: function getAnchor2To(anchor) { anchor.x = this._anchor2X; anchor.y = this._anchor2Y; anchor.z = this._anchor2Z; } }, { key: "getLocalAnchor1", value: function getLocalAnchor1() { var v = new oimo.common.Vec3(); v.x = this._localAnchor1X; v.y = this._localAnchor1Y; v.z = this._localAnchor1Z; return v; } }, { key: "getLocalAnchor2", value: function getLocalAnchor2() { var v = new oimo.common.Vec3(); v.x = this._localAnchor2X; v.y = this._localAnchor2Y; v.z = this._localAnchor2Z; return v; } }, { key: "getLocalAnchor1To", value: function getLocalAnchor1To(localAnchor) { localAnchor.x = this._localAnchor1X; localAnchor.y = this._localAnchor1Y; localAnchor.z = this._localAnchor1Z; } }, { key: "getLocalAnchor2To", value: function getLocalAnchor2To(localAnchor) { localAnchor.x = this._localAnchor2X; localAnchor.y = this._localAnchor2Y; localAnchor.z = this._localAnchor2Z; } }, { key: "getBasis1", value: function getBasis1() { var m = new oimo.common.Mat3(); var b00; var b01; var b02; var b10; var b11; var b12; var b20; var b21; var b22; b00 = this._basisX1X; b01 = this._basisY1X; b02 = this._basisZ1X; b10 = this._basisX1Y; b11 = this._basisY1Y; b12 = this._basisZ1Y; b20 = this._basisX1Z; b21 = this._basisY1Z; b22 = this._basisZ1Z; m.e00 = b00; m.e01 = b01; m.e02 = b02; m.e10 = b10; m.e11 = b11; m.e12 = b12; m.e20 = b20; m.e21 = b21; m.e22 = b22; return m; } }, { key: "getBasis2", value: function getBasis2() { var m = new oimo.common.Mat3(); var b00; var b01; var b02; var b10; var b11; var b12; var b20; var b21; var b22; b00 = this._basisX2X; b01 = this._basisY2X; b02 = this._basisZ2X; b10 = this._basisX2Y; b11 = this._basisY2Y; b12 = this._basisZ2Y; b20 = this._basisX2Z; b21 = this._basisY2Z; b22 = this._basisZ2Z; m.e00 = b00; m.e01 = b01; m.e02 = b02; m.e10 = b10; m.e11 = b11; m.e12 = b12; m.e20 = b20; m.e21 = b21; m.e22 = b22; return m; } }, { key: "getBasis1To", value: function getBasis1To(basis) { var b00; var b01; var b02; var b10; var b11; var b12; var b20; var b21; var b22; b00 = this._basisX1X; b01 = this._basisY1X; b02 = this._basisZ1X; b10 = this._basisX1Y; b11 = this._basisY1Y; b12 = this._basisZ1Y; b20 = this._basisX1Z; b21 = this._basisY1Z; b22 = this._basisZ1Z; basis.e00 = b00; basis.e01 = b01; basis.e02 = b02; basis.e10 = b10; basis.e11 = b11; basis.e12 = b12; basis.e20 = b20; basis.e21 = b21; basis.e22 = b22; } }, { key: "getBasis2To", value: function getBasis2To(basis) { var b00; var b01; var b02; var b10; var b11; var b12; var b20; var b21; var b22; b00 = this._basisX2X; b01 = this._basisY2X; b02 = this._basisZ2X; b10 = this._basisX2Y; b11 = this._basisY2Y; b12 = this._basisZ2Y; b20 = this._basisX2Z; b21 = this._basisY2Z; b22 = this._basisZ2Z; basis.e00 = b00; basis.e01 = b01; basis.e02 = b02; basis.e10 = b10; basis.e11 = b11; basis.e12 = b12; basis.e20 = b20; basis.e21 = b21; basis.e22 = b22; } }, { key: "getAllowCollision", value: function getAllowCollision() { return this._allowCollision; } }, { key: "setAllowCollision", value: function setAllowCollision(allowCollision) { this._allowCollision = allowCollision; } }, { key: "getBreakForce", value: function getBreakForce() { return this._breakForce; } }, { key: "setBreakForce", value: function setBreakForce(breakForce) { this._breakForce = breakForce; } }, { key: "getBreakTorque", value: function getBreakTorque() { return this._breakTorque; } }, { key: "setBreakTorque", value: function setBreakTorque(breakTorque) { this._breakTorque = breakTorque; } }, { key: "getPositionCorrectionAlgorithm", value: function getPositionCorrectionAlgorithm() { return this._positionCorrectionAlgorithm; } }, { key: "setPositionCorrectionAlgorithm", value: function setPositionCorrectionAlgorithm(positionCorrectionAlgorithm) { switch (positionCorrectionAlgorithm) { case 0: case 1: case 2: break; default: throw new Error("invalid position correction algorithm id: " + positionCorrectionAlgorithm); } this._positionCorrectionAlgorithm = positionCorrectionAlgorithm; } }, { key: "getAppliedForce", value: function getAppliedForce() { var v = new oimo.common.Vec3(); v.x = this._appliedForceX; v.y = this._appliedForceY; v.z = this._appliedForceZ; return v; } }, { key: "getAppliedForceTo", value: function getAppliedForceTo(appliedForce) { appliedForce.x = this._appliedForceX; appliedForce.y = this._appliedForceY; appliedForce.z = this._appliedForceZ; } }, { key: "getAppliedTorque", value: function getAppliedTorque() { var v = new oimo.common.Vec3(); v.x = this._appliedTorqueX; v.y = this._appliedTorqueY; v.z = this._appliedTorqueZ; return v; } }, { key: "getAppliedTorqueTo", value: function getAppliedTorqueTo(appliedTorque) { appliedTorque.x = this._appliedTorqueX; appliedTorque.y = this._appliedTorqueY; appliedTorque.z = this._appliedTorqueZ; } }, { key: "getPrev", value: function getPrev() { return this._prev; } }, { key: "getNext", value: function getNext() { return this._next; } }]); return oimo_dynamics_constraint_joint_Joint; }(); oimo.dynamics.constraint.joint.CylindricalJoint = /*#__PURE__*/function (_oimo$dynamics$constr) { _inherits(oimo_dynamics_constraint_joint_CylindricalJoint, _oimo$dynamics$constr); var _super23 = _createSuper(oimo_dynamics_constraint_joint_CylindricalJoint); function oimo_dynamics_constraint_joint_CylindricalJoint(config) { var _this215; _classCallCheck(this, oimo_dynamics_constraint_joint_CylindricalJoint); _this215 = _super23.call(this, config, 2); var v = config.localAxis1; _this215._localBasisX1X = v.x; _this215._localBasisX1Y = v.y; _this215._localBasisX1Z = v.z; var v1 = config.localAxis2; _this215._localBasisX2X = v1.x; _this215._localBasisX2Y = v1.y; _this215._localBasisX2Z = v1.z; _this215.buildLocalBasesFromX(); _this215.angle = 0; _this215.angularErrorY = 0; _this215.angularErrorZ = 0; _this215.translation = 0; _this215.linearErrorY = 0; _this215.linearErrorZ = 0; _this215._basis = new oimo.dynamics.constraint.joint.BasisTracker(_assertThisInitialized(_this215)); _this215._translSd = config.translationalSpringDamper.clone(); _this215._translLm = config.translationalLimitMotor.clone(); _this215._rotSd = config.rotationalSpringDamper.clone(); _this215._rotLm = config.rotationalLimitMotor.clone(); return _this215; } _createClass(oimo_dynamics_constraint_joint_CylindricalJoint, [{ key: "getInfo", value: function getInfo(info, timeStep, isPositionPart) { var erp = this.getErp(timeStep, isPositionPart); var linRhsY = this.linearErrorY * erp; var linRhsZ = this.linearErrorZ * erp; var angRhsY = this.angularErrorY * erp; var angRhsZ = this.angularErrorZ * erp; var j; var translationalMotorMass = 1 / (this._b1._invMass + this._b2._invMass); var rotationalMotorMass = this.computeEffectiveInertiaMoment(this._basis.xX, this._basis.xY, this._basis.xZ); if (this._translSd.frequency <= 0 || !isPositionPart) { var _impulse = this._impulses[0]; var _row = info.rows[info.numRows++]; var _this216 = _row.jacobian; _this216.lin1X = 0; _this216.lin1Y = 0; _this216.lin1Z = 0; _this216.lin2X = 0; _this216.lin2Y = 0; _this216.lin2Z = 0; _this216.ang1X = 0; _this216.ang1Y = 0; _this216.ang1Z = 0; _this216.ang2X = 0; _this216.ang2Y = 0; _this216.ang2Z = 0; _row.rhs = 0; _row.cfm = 0; _row.minImpulse = 0; _row.maxImpulse = 0; _row.motorSpeed = 0; _row.motorMaxImpulse = 0; _row.impulse = null; _row.impulse = _impulse; this.setSolverInfoRowLinear(_row, this.translation, this._translLm, translationalMotorMass, this._translSd, timeStep, isPositionPart); j = _row.jacobian; j.lin1X = this._basis.xX; j.lin1Y = this._basis.xY; j.lin1Z = this._basis.xZ; j.lin2X = this._basis.xX; j.lin2Y = this._basis.xY; j.lin2Z = this._basis.xZ; j.ang1X = this._relativeAnchor1Y * this._basis.xZ - this._relativeAnchor1Z * this._basis.xY; j.ang1Y = this._relativeAnchor1Z * this._basis.xX - this._relativeAnchor1X * this._basis.xZ; j.ang1Z = this._relativeAnchor1X * this._basis.xY - this._relativeAnchor1Y * this._basis.xX; j.ang2X = this._relativeAnchor2Y * this._basis.xZ - this._relativeAnchor2Z * this._basis.xY; j.ang2Y = this._relativeAnchor2Z * this._basis.xX - this._relativeAnchor2X * this._basis.xZ; j.ang2Z = this._relativeAnchor2X * this._basis.xY - this._relativeAnchor2Y * this._basis.xX; } var impulse = this._impulses[1]; var row = info.rows[info.numRows++]; var _this = row.jacobian; _this.lin1X = 0; _this.lin1Y = 0; _this.lin1Z = 0; _this.lin2X = 0; _this.lin2Y = 0; _this.lin2Z = 0; _this.ang1X = 0; _this.ang1Y = 0; _this.ang1Z = 0; _this.ang2X = 0; _this.ang2Y = 0; _this.ang2Z = 0; row.rhs = 0; row.cfm = 0; row.minImpulse = 0; row.maxImpulse = 0; row.motorSpeed = 0; row.motorMaxImpulse = 0; row.impulse = null; row.impulse = impulse; row.rhs = linRhsY; row.cfm = 0; row.minImpulse = -1e65536; row.maxImpulse = 1e65536; j = row.jacobian; j.lin1X = this._basis.yX; j.lin1Y = this._basis.yY; j.lin1Z = this._basis.yZ; j.lin2X = this._basis.yX; j.lin2Y = this._basis.yY; j.lin2Z = this._basis.yZ; j.ang1X = this._relativeAnchor1Y * this._basis.yZ - this._relativeAnchor1Z * this._basis.yY; j.ang1Y = this._relativeAnchor1Z * this._basis.yX - this._relativeAnchor1X * this._basis.yZ; j.ang1Z = this._relativeAnchor1X * this._basis.yY - this._relativeAnchor1Y * this._basis.yX; j.ang2X = this._relativeAnchor2Y * this._basis.yZ - this._relativeAnchor2Z * this._basis.yY; j.ang2Y = this._relativeAnchor2Z * this._basis.yX - this._relativeAnchor2X * this._basis.yZ; j.ang2Z = this._relativeAnchor2X * this._basis.yY - this._relativeAnchor2Y * this._basis.yX; var impulse1 = this._impulses[2]; var row1 = info.rows[info.numRows++]; var _this1 = row1.jacobian; _this1.lin1X = 0; _this1.lin1Y = 0; _this1.lin1Z = 0; _this1.lin2X = 0; _this1.lin2Y = 0; _this1.lin2Z = 0; _this1.ang1X = 0; _this1.ang1Y = 0; _this1.ang1Z = 0; _this1.ang2X = 0; _this1.ang2Y = 0; _this1.ang2Z = 0; row1.rhs = 0; row1.cfm = 0; row1.minImpulse = 0; row1.maxImpulse = 0; row1.motorSpeed = 0; row1.motorMaxImpulse = 0; row1.impulse = null; row1.impulse = impulse1; row1.rhs = linRhsZ; row1.cfm = 0; row1.minImpulse = -1e65536; row1.maxImpulse = 1e65536; j = row1.jacobian; j.lin1X = this._basis.zX; j.lin1Y = this._basis.zY; j.lin1Z = this._basis.zZ; j.lin2X = this._basis.zX; j.lin2Y = this._basis.zY; j.lin2Z = this._basis.zZ; j.ang1X = this._relativeAnchor1Y * this._basis.zZ - this._relativeAnchor1Z * this._basis.zY; j.ang1Y = this._relativeAnchor1Z * this._basis.zX - this._relativeAnchor1X * this._basis.zZ; j.ang1Z = this._relativeAnchor1X * this._basis.zY - this._relativeAnchor1Y * this._basis.zX; j.ang2X = this._relativeAnchor2Y * this._basis.zZ - this._relativeAnchor2Z * this._basis.zY; j.ang2Y = this._relativeAnchor2Z * this._basis.zX - this._relativeAnchor2X * this._basis.zZ; j.ang2Z = this._relativeAnchor2X * this._basis.zY - this._relativeAnchor2Y * this._basis.zX; if (this._rotSd.frequency <= 0 || !isPositionPart) { var _impulse2 = this._impulses[3]; var _row2 = info.rows[info.numRows++]; var _this217 = _row2.jacobian; _this217.lin1X = 0; _this217.lin1Y = 0; _this217.lin1Z = 0; _this217.lin2X = 0; _this217.lin2Y = 0; _this217.lin2Z = 0; _this217.ang1X = 0; _this217.ang1Y = 0; _this217.ang1Z = 0; _this217.ang2X = 0; _this217.ang2Y = 0; _this217.ang2Z = 0; _row2.rhs = 0; _row2.cfm = 0; _row2.minImpulse = 0; _row2.maxImpulse = 0; _row2.motorSpeed = 0; _row2.motorMaxImpulse = 0; _row2.impulse = null; _row2.impulse = _impulse2; this.setSolverInfoRowAngular(_row2, this.angle, this._rotLm, rotationalMotorMass, this._rotSd, timeStep, isPositionPart); j = _row2.jacobian; j.ang1X = this._basis.xX; j.ang1Y = this._basis.xY; j.ang1Z = this._basis.xZ; j.ang2X = this._basis.xX; j.ang2Y = this._basis.xY; j.ang2Z = this._basis.xZ; } var impulse2 = this._impulses[4]; var row2 = info.rows[info.numRows++]; var _this2 = row2.jacobian; _this2.lin1X = 0; _this2.lin1Y = 0; _this2.lin1Z = 0; _this2.lin2X = 0; _this2.lin2Y = 0; _this2.lin2Z = 0; _this2.ang1X = 0; _this2.ang1Y = 0; _this2.ang1Z = 0; _this2.ang2X = 0; _this2.ang2Y = 0; _this2.ang2Z = 0; row2.rhs = 0; row2.cfm = 0; row2.minImpulse = 0; row2.maxImpulse = 0; row2.motorSpeed = 0; row2.motorMaxImpulse = 0; row2.impulse = null; row2.impulse = impulse2; row2.rhs = angRhsY; row2.cfm = 0; row2.minImpulse = -1e65536; row2.maxImpulse = 1e65536; j = row2.jacobian; j.ang1X = this._basis.yX; j.ang1Y = this._basis.yY; j.ang1Z = this._basis.yZ; j.ang2X = this._basis.yX; j.ang2Y = this._basis.yY; j.ang2Z = this._basis.yZ; var impulse3 = this._impulses[5]; var row3 = info.rows[info.numRows++]; var _this3 = row3.jacobian; _this3.lin1X = 0; _this3.lin1Y = 0; _this3.lin1Z = 0; _this3.lin2X = 0; _this3.lin2Y = 0; _this3.lin2Z = 0; _this3.ang1X = 0; _this3.ang1Y = 0; _this3.ang1Z = 0; _this3.ang2X = 0; _this3.ang2Y = 0; _this3.ang2Z = 0; row3.rhs = 0; row3.cfm = 0; row3.minImpulse = 0; row3.maxImpulse = 0; row3.motorSpeed = 0; row3.motorMaxImpulse = 0; row3.impulse = null; row3.impulse = impulse3; row3.rhs = angRhsZ; row3.cfm = 0; row3.minImpulse = -1e65536; row3.maxImpulse = 1e65536; j = row3.jacobian; j.ang1X = this._basis.zX; j.ang1Y = this._basis.zY; j.ang1Z = this._basis.zZ; j.ang2X = this._basis.zX; j.ang2Y = this._basis.zY; j.ang2Z = this._basis.zZ; } }, { key: "_syncAnchors", value: function _syncAnchors() { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_CylindricalJoint.prototype), "_syncAnchors", this).call(this); var _this = this._basis; var invM1 = _this.joint._b1._invMass; var invM2 = _this.joint._b2._invMass; var qX; var qY; var qZ; var qW; var idQX; var idQY; var idQZ; var idQW; var slerpQX; var slerpQY; var slerpQZ; var slerpQW; var slerpM00; var slerpM01; var slerpM02; var slerpM10; var slerpM11; var slerpM12; var slerpM20; var slerpM21; var slerpM22; var newXX; var newXY; var newXZ; var newYX; var newYY; var newYZ; var newZX; var newZY; var newZZ; var prevXX; var prevXY; var prevXZ; var prevYX; var prevYY; var prevYZ; var d = _this.joint._basisX1X * _this.joint._basisX2X + _this.joint._basisX1Y * _this.joint._basisX2Y + _this.joint._basisX1Z * _this.joint._basisX2Z; if (d < -0.999999999) { var vX; var vY; var vZ; var _x12 = _this.joint._basisX1X; var _y12 = _this.joint._basisX1Y; var _z12 = _this.joint._basisX1Z; var _x13 = _x12 * _x12; var _y13 = _y12 * _y12; var _z13 = _z12 * _z12; var _d41; if (_x13 < _y13) { if (_x13 < _z13) { _d41 = 1 / Math.sqrt(_y13 + _z13); vX = 0; vY = _z12 * _d41; vZ = -_y12 * _d41; } else { _d41 = 1 / Math.sqrt(_x13 + _y13); vX = _y12 * _d41; vY = -_x12 * _d41; vZ = 0; } } else if (_y13 < _z13) { _d41 = 1 / Math.sqrt(_z13 + _x13); vX = -_z12 * _d41; vY = 0; vZ = _x12 * _d41; } else { _d41 = 1 / Math.sqrt(_x13 + _y13); vX = _y12 * _d41; vY = -_x12 * _d41; vZ = 0; } qX = vX; qY = vY; qZ = vZ; qW = 0; } else { var cX; var cY; var cZ; cX = _this.joint._basisX1Y * _this.joint._basisX2Z - _this.joint._basisX1Z * _this.joint._basisX2Y; cY = _this.joint._basisX1Z * _this.joint._basisX2X - _this.joint._basisX1X * _this.joint._basisX2Z; cZ = _this.joint._basisX1X * _this.joint._basisX2Y - _this.joint._basisX1Y * _this.joint._basisX2X; var _w3 = Math.sqrt((1 + d) * 0.5); d = 0.5 / _w3; cX *= d; cY *= d; cZ *= d; qX = cX; qY = cY; qZ = cZ; qW = _w3; } idQX = 0; idQY = 0; idQZ = 0; idQW = 1; var q1X; var q1Y; var q1Z; var q1W; var q2X; var q2Y; var q2Z; var q2W; q1X = idQX; q1Y = idQY; q1Z = idQZ; q1W = idQW; q2X = qX; q2Y = qY; q2Z = qZ; q2W = qW; var d1 = q1X * q2X + q1Y * q2Y + q1Z * q2Z + q1W * q2W; if (d1 < 0) { d1 = -d1; q2X = -q2X; q2Y = -q2Y; q2Z = -q2Z; q2W = -q2W; } if (d1 > 0.999999) { var dqX; var dqY; var dqZ; var dqW; dqX = q2X - q1X; dqY = q2Y - q1Y; dqZ = q2Z - q1Z; dqW = q2W - q1W; q2X = q1X + dqX * (invM1 / (invM1 + invM2)); q2Y = q1Y + dqY * (invM1 / (invM1 + invM2)); q2Z = q1Z + dqZ * (invM1 / (invM1 + invM2)); q2W = q1W + dqW * (invM1 / (invM1 + invM2)); var _l38 = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W; if (_l38 > 1e-32) { _l38 = 1 / Math.sqrt(_l38); } slerpQX = q2X * _l38; slerpQY = q2Y * _l38; slerpQZ = q2Z * _l38; slerpQW = q2W * _l38; } else { var _theta = invM1 / (invM1 + invM2) * Math.acos(d1); q2X += q1X * -d1; q2Y += q1Y * -d1; q2Z += q1Z * -d1; q2W += q1W * -d1; var _l39 = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W; if (_l39 > 1e-32) { _l39 = 1 / Math.sqrt(_l39); } q2X *= _l39; q2Y *= _l39; q2Z *= _l39; q2W *= _l39; var sin = Math.sin(_theta); var _cos = Math.cos(_theta); q1X *= _cos; q1Y *= _cos; q1Z *= _cos; q1W *= _cos; slerpQX = q1X + q2X * sin; slerpQY = q1Y + q2Y * sin; slerpQZ = q1Z + q2Z * sin; slerpQW = q1W + q2W * sin; } var x = slerpQX; var y = slerpQY; var z = slerpQZ; var w = slerpQW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; slerpM00 = 1 - yy - zz; slerpM01 = xy - wz; slerpM02 = xz + wy; slerpM10 = xy + wz; slerpM11 = 1 - xx - zz; slerpM12 = yz - wx; slerpM20 = xz - wy; slerpM21 = yz + wx; slerpM22 = 1 - xx - yy; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = slerpM00 * _this.joint._basisX1X + slerpM01 * _this.joint._basisX1Y + slerpM02 * _this.joint._basisX1Z; __tmp__Y = slerpM10 * _this.joint._basisX1X + slerpM11 * _this.joint._basisX1Y + slerpM12 * _this.joint._basisX1Z; __tmp__Z = slerpM20 * _this.joint._basisX1X + slerpM21 * _this.joint._basisX1Y + slerpM22 * _this.joint._basisX1Z; newXX = __tmp__X; newXY = __tmp__Y; newXZ = __tmp__Z; prevXX = _this.xX; prevXY = _this.xY; prevXZ = _this.xZ; prevYX = _this.yX; prevYY = _this.yY; prevYZ = _this.yZ; var d2 = prevXX * newXX + prevXY * newXY + prevXZ * newXZ; if (d2 < -0.999999999) { var _vX; var _vY; var _vZ; var _x14 = prevXX; var _y14 = prevXY; var _z14 = prevXZ; var _x15 = _x14 * _x14; var _y15 = _y14 * _y14; var _z15 = _z14 * _z14; var _d42; if (_x15 < _y15) { if (_x15 < _z15) { _d42 = 1 / Math.sqrt(_y15 + _z15); _vX = 0; _vY = _z14 * _d42; _vZ = -_y14 * _d42; } else { _d42 = 1 / Math.sqrt(_x15 + _y15); _vX = _y14 * _d42; _vY = -_x14 * _d42; _vZ = 0; } } else if (_y15 < _z15) { _d42 = 1 / Math.sqrt(_z15 + _x15); _vX = -_z14 * _d42; _vY = 0; _vZ = _x14 * _d42; } else { _d42 = 1 / Math.sqrt(_x15 + _y15); _vX = _y14 * _d42; _vY = -_x14 * _d42; _vZ = 0; } slerpQX = _vX; slerpQY = _vY; slerpQZ = _vZ; slerpQW = 0; } else { var _cX; var _cY; var _cZ; _cX = prevXY * newXZ - prevXZ * newXY; _cY = prevXZ * newXX - prevXX * newXZ; _cZ = prevXX * newXY - prevXY * newXX; var _w4 = Math.sqrt((1 + d2) * 0.5); d2 = 0.5 / _w4; _cX *= d2; _cY *= d2; _cZ *= d2; slerpQX = _cX; slerpQY = _cY; slerpQZ = _cZ; slerpQW = _w4; } var x1 = slerpQX; var y1 = slerpQY; var z1 = slerpQZ; var w1 = slerpQW; var x21 = 2 * x1; var y21 = 2 * y1; var z21 = 2 * z1; var xx1 = x1 * x21; var yy1 = y1 * y21; var zz1 = z1 * z21; var xy1 = x1 * y21; var yz1 = y1 * z21; var xz1 = x1 * z21; var wx1 = w1 * x21; var wy1 = w1 * y21; var wz1 = w1 * z21; slerpM00 = 1 - yy1 - zz1; slerpM01 = xy1 - wz1; slerpM02 = xz1 + wy1; slerpM10 = xy1 + wz1; slerpM11 = 1 - xx1 - zz1; slerpM12 = yz1 - wx1; slerpM20 = xz1 - wy1; slerpM21 = yz1 + wx1; slerpM22 = 1 - xx1 - yy1; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = slerpM00 * prevYX + slerpM01 * prevYY + slerpM02 * prevYZ; __tmp__Y1 = slerpM10 * prevYX + slerpM11 * prevYY + slerpM12 * prevYZ; __tmp__Z1 = slerpM20 * prevYX + slerpM21 * prevYY + slerpM22 * prevYZ; newYX = __tmp__X1; newYY = __tmp__Y1; newYZ = __tmp__Z1; newZX = newXY * newYZ - newXZ * newYY; newZY = newXZ * newYX - newXX * newYZ; newZZ = newXX * newYY - newXY * newYX; if (newZX * newZX + newZY * newZY + newZZ * newZZ > 1e-6) { var _l40 = newZX * newZX + newZY * newZY + newZZ * newZZ; if (_l40 > 0) { _l40 = 1 / Math.sqrt(_l40); } newZX *= _l40; newZY *= _l40; newZZ *= _l40; } else { var _x16 = newXX; var _y16 = newXY; var _z16 = newXZ; var _x17 = _x16 * _x16; var _y17 = _y16 * _y16; var _z17 = _z16 * _z16; var _d43; if (_x17 < _y17) { if (_x17 < _z17) { _d43 = 1 / Math.sqrt(_y17 + _z17); newZX = 0; newZY = _z16 * _d43; newZZ = -_y16 * _d43; } else { _d43 = 1 / Math.sqrt(_x17 + _y17); newZX = _y16 * _d43; newZY = -_x16 * _d43; newZZ = 0; } } else if (_y17 < _z17) { _d43 = 1 / Math.sqrt(_z17 + _x17); newZX = -_z16 * _d43; newZY = 0; newZZ = _x16 * _d43; } else { _d43 = 1 / Math.sqrt(_x17 + _y17); newZX = _y16 * _d43; newZY = -_x16 * _d43; newZZ = 0; } } newYX = newZY * newXZ - newZZ * newXY; newYY = newZZ * newXX - newZX * newXZ; newYZ = newZX * newXY - newZY * newXX; _this.xX = newXX; _this.xY = newXY; _this.xZ = newXZ; _this.yX = newYX; _this.yY = newYY; _this.yZ = newYZ; _this.zX = newZX; _this.zY = newZY; _this.zZ = newZZ; var angErrorX; var angErrorY; var angErrorZ; angErrorX = this._basisX1Y * this._basisX2Z - this._basisX1Z * this._basisX2Y; angErrorY = this._basisX1Z * this._basisX2X - this._basisX1X * this._basisX2Z; angErrorZ = this._basisX1X * this._basisX2Y - this._basisX1Y * this._basisX2X; var cos = this._basisX1X * this._basisX2X + this._basisX1Y * this._basisX2Y + this._basisX1Z * this._basisX2Z; var theta = cos <= -1 ? 3.14159265358979 : cos >= 1 ? 0 : Math.acos(cos); var l = angErrorX * angErrorX + angErrorY * angErrorY + angErrorZ * angErrorZ; if (l > 0) { l = 1 / Math.sqrt(l); } angErrorX *= l; angErrorY *= l; angErrorZ *= l; angErrorX *= theta; angErrorY *= theta; angErrorZ *= theta; this.angularErrorY = angErrorX * this._basis.yX + angErrorY * this._basis.yY + angErrorZ * this._basis.yZ; this.angularErrorZ = angErrorX * this._basis.zX + angErrorY * this._basis.zY + angErrorZ * this._basis.zZ; var perpCrossX; var perpCrossY; var perpCrossZ; perpCrossX = this._basisY1Y * this._basisY2Z - this._basisY1Z * this._basisY2Y; perpCrossY = this._basisY1Z * this._basisY2X - this._basisY1X * this._basisY2Z; perpCrossZ = this._basisY1X * this._basisY2Y - this._basisY1Y * this._basisY2X; cos = this._basisY1X * this._basisY2X + this._basisY1Y * this._basisY2Y + this._basisY1Z * this._basisY2Z; this.angle = cos <= -1 ? 3.14159265358979 : cos >= 1 ? 0 : Math.acos(cos); if (perpCrossX * this._basis.xX + perpCrossY * this._basis.xY + perpCrossZ * this._basis.xZ < 0) { this.angle = -this.angle; } var anchorDiffX; var anchorDiffY; var anchorDiffZ; anchorDiffX = this._anchor2X - this._anchor1X; anchorDiffY = this._anchor2Y - this._anchor1Y; anchorDiffZ = this._anchor2Z - this._anchor1Z; this.translation = anchorDiffX * this._basis.xX + anchorDiffY * this._basis.xY + anchorDiffZ * this._basis.xZ; this.linearErrorY = anchorDiffX * this._basis.yX + anchorDiffY * this._basis.yY + anchorDiffZ * this._basis.yZ; this.linearErrorZ = anchorDiffX * this._basis.zX + anchorDiffY * this._basis.zY + anchorDiffZ * this._basis.zZ; } }, { key: "_getVelocitySolverInfo", value: function _getVelocitySolverInfo(timeStep, info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_CylindricalJoint.prototype), "_getVelocitySolverInfo", this).call(this, timeStep, info); this.getInfo(info, timeStep, false); } }, { key: "_getPositionSolverInfo", value: function _getPositionSolverInfo(info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_CylindricalJoint.prototype), "_getPositionSolverInfo", this).call(this, info); this.getInfo(info, null, true); } }, { key: "getAxis1", value: function getAxis1() { var v = new oimo.common.Vec3(); v.x = this._basisX1X; v.y = this._basisX1Y; v.z = this._basisX1Z; return v; } }, { key: "getAxis2", value: function getAxis2() { var v = new oimo.common.Vec3(); v.x = this._basisX2X; v.y = this._basisX2Y; v.z = this._basisX2Z; return v; } }, { key: "getAxis1To", value: function getAxis1To(axis) { axis.x = this._basisX1X; axis.y = this._basisX1Y; axis.z = this._basisX1Z; } }, { key: "getAxis2To", value: function getAxis2To(axis) { axis.x = this._basisX2X; axis.y = this._basisX2Y; axis.z = this._basisX2Z; } }, { key: "getLocalAxis1", value: function getLocalAxis1() { var v = new oimo.common.Vec3(); v.x = this._localBasisX1X; v.y = this._localBasisX1Y; v.z = this._localBasisX1Z; return v; } }, { key: "getLocalAxis2", value: function getLocalAxis2() { var v = new oimo.common.Vec3(); v.x = this._localBasisX2X; v.y = this._localBasisX2Y; v.z = this._localBasisX2Z; return v; } }, { key: "getLocalAxis1To", value: function getLocalAxis1To(axis) { axis.x = this._localBasisX1X; axis.y = this._localBasisX1Y; axis.z = this._localBasisX1Z; } }, { key: "getLocalAxis2To", value: function getLocalAxis2To(axis) { axis.x = this._localBasisX2X; axis.y = this._localBasisX2Y; axis.z = this._localBasisX2Z; } }, { key: "getTranslationalSpringDamper", value: function getTranslationalSpringDamper() { return this._translSd; } }, { key: "getRotationalSpringDamper", value: function getRotationalSpringDamper() { return this._rotSd; } }, { key: "getTranslationalLimitMotor", value: function getTranslationalLimitMotor() { return this._translLm; } }, { key: "getRotationalLimitMotor", value: function getRotationalLimitMotor() { return this._rotLm; } }, { key: "getAngle", value: function getAngle() { return this.angle; } }, { key: "getTranslation", value: function getTranslation() { return this.translation; } }]); return oimo_dynamics_constraint_joint_CylindricalJoint; }(oimo.dynamics.constraint.joint.Joint); oimo.dynamics.constraint.joint.JointConfig = /*#__PURE__*/function () { function oimo_dynamics_constraint_joint_JointConfig() { _classCallCheck(this, oimo_dynamics_constraint_joint_JointConfig); this.rigidBody1 = null; this.rigidBody2 = null; this.localAnchor1 = new oimo.common.Vec3(); this.localAnchor2 = new oimo.common.Vec3(); this.allowCollision = false; this.solverType = oimo.common.Setting.defaultJointConstraintSolverType; this.positionCorrectionAlgorithm = oimo.common.Setting.defaultJointPositionCorrectionAlgorithm; this.breakForce = 0; this.breakTorque = 0; } _createClass(oimo_dynamics_constraint_joint_JointConfig, [{ key: "_init", value: function _init(rb1, rb2, worldAnchor) { this.rigidBody1 = rb1; this.rigidBody2 = rb2; var _this = this.rigidBody1; var localPoint = this.localAnchor1; var vX; var vY; var vZ; vX = worldAnchor.x; vY = worldAnchor.y; vZ = worldAnchor.z; vX -= _this._transform._positionX; vY -= _this._transform._positionY; vZ -= _this._transform._positionZ; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = _this._transform._rotation00 * vX + _this._transform._rotation10 * vY + _this._transform._rotation20 * vZ; __tmp__Y = _this._transform._rotation01 * vX + _this._transform._rotation11 * vY + _this._transform._rotation21 * vZ; __tmp__Z = _this._transform._rotation02 * vX + _this._transform._rotation12 * vY + _this._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; localPoint.x = vX; localPoint.y = vY; localPoint.z = vZ; var _this1 = this.rigidBody2; var localPoint1 = this.localAnchor2; var vX1; var vY1; var vZ1; vX1 = worldAnchor.x; vY1 = worldAnchor.y; vZ1 = worldAnchor.z; vX1 -= _this1._transform._positionX; vY1 -= _this1._transform._positionY; vZ1 -= _this1._transform._positionZ; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = _this1._transform._rotation00 * vX1 + _this1._transform._rotation10 * vY1 + _this1._transform._rotation20 * vZ1; __tmp__Y1 = _this1._transform._rotation01 * vX1 + _this1._transform._rotation11 * vY1 + _this1._transform._rotation21 * vZ1; __tmp__Z1 = _this1._transform._rotation02 * vX1 + _this1._transform._rotation12 * vY1 + _this1._transform._rotation22 * vZ1; vX1 = __tmp__X1; vY1 = __tmp__Y1; vZ1 = __tmp__Z1; localPoint1.x = vX1; localPoint1.y = vY1; localPoint1.z = vZ1; } }]); return oimo_dynamics_constraint_joint_JointConfig; }(); oimo.dynamics.constraint.joint.CylindricalJointConfig = /*#__PURE__*/function (_oimo$dynamics$constr2) { _inherits(oimo_dynamics_constraint_joint_CylindricalJointConfig, _oimo$dynamics$constr2); var _super24 = _createSuper(oimo_dynamics_constraint_joint_CylindricalJointConfig); function oimo_dynamics_constraint_joint_CylindricalJointConfig() { var _this218; _classCallCheck(this, oimo_dynamics_constraint_joint_CylindricalJointConfig); _this218 = _super24.call(this); _this218.localAxis1 = new oimo.common.Vec3(1, 0, 0); _this218.localAxis2 = new oimo.common.Vec3(1, 0, 0); _this218.translationalLimitMotor = new oimo.dynamics.constraint.joint.TranslationalLimitMotor(); _this218.translationalSpringDamper = new oimo.dynamics.constraint.joint.SpringDamper(); _this218.rotationalLimitMotor = new oimo.dynamics.constraint.joint.RotationalLimitMotor(); _this218.rotationalSpringDamper = new oimo.dynamics.constraint.joint.SpringDamper(); return _this218; } _createClass(oimo_dynamics_constraint_joint_CylindricalJointConfig, [{ key: "init", value: function init(rigidBody1, rigidBody2, worldAnchor, worldAxis) { this._init(rigidBody1, rigidBody2, worldAnchor); var localVector = this.localAxis1; var vX; var vY; var vZ; vX = worldAxis.x; vY = worldAxis.y; vZ = worldAxis.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = rigidBody1._transform._rotation00 * vX + rigidBody1._transform._rotation10 * vY + rigidBody1._transform._rotation20 * vZ; __tmp__Y = rigidBody1._transform._rotation01 * vX + rigidBody1._transform._rotation11 * vY + rigidBody1._transform._rotation21 * vZ; __tmp__Z = rigidBody1._transform._rotation02 * vX + rigidBody1._transform._rotation12 * vY + rigidBody1._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; localVector.x = vX; localVector.y = vY; localVector.z = vZ; var localVector1 = this.localAxis2; var vX1; var vY1; var vZ1; vX1 = worldAxis.x; vY1 = worldAxis.y; vZ1 = worldAxis.z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = rigidBody2._transform._rotation00 * vX1 + rigidBody2._transform._rotation10 * vY1 + rigidBody2._transform._rotation20 * vZ1; __tmp__Y1 = rigidBody2._transform._rotation01 * vX1 + rigidBody2._transform._rotation11 * vY1 + rigidBody2._transform._rotation21 * vZ1; __tmp__Z1 = rigidBody2._transform._rotation02 * vX1 + rigidBody2._transform._rotation12 * vY1 + rigidBody2._transform._rotation22 * vZ1; vX1 = __tmp__X1; vY1 = __tmp__Y1; vZ1 = __tmp__Z1; localVector1.x = vX1; localVector1.y = vY1; localVector1.z = vZ1; return this; } }]); return oimo_dynamics_constraint_joint_CylindricalJointConfig; }(oimo.dynamics.constraint.joint.JointConfig); oimo.dynamics.constraint.joint.GenericJoint = /*#__PURE__*/function (_oimo$dynamics$constr3) { _inherits(oimo_dynamics_constraint_joint_GenericJoint, _oimo$dynamics$constr3); var _super25 = _createSuper(oimo_dynamics_constraint_joint_GenericJoint); function oimo_dynamics_constraint_joint_GenericJoint(config) { var _this219; _classCallCheck(this, oimo_dynamics_constraint_joint_GenericJoint); _this219 = _super25.call(this, config, oimo.dynamics.constraint.joint.JointType.GENERIC); var tmp; var _this = config.localBasis1; if (!(_this.e00 * (_this.e11 * _this.e22 - _this.e12 * _this.e21) - _this.e01 * (_this.e10 * _this.e22 - _this.e12 * _this.e20) + _this.e02 * (_this.e10 * _this.e21 - _this.e11 * _this.e20) < 0)) { var _this220 = config.localBasis2; tmp = _this220.e00 * (_this220.e11 * _this220.e22 - _this220.e12 * _this220.e21) - _this220.e01 * (_this220.e10 * _this220.e22 - _this220.e12 * _this220.e20) + _this220.e02 * (_this220.e10 * _this220.e21 - _this220.e11 * _this220.e20) < 0; } else { tmp = true; } if (tmp) { console.log("src/oimo/dynamics/constraint/joint/GenericJoint.hx:50:", "[warning] joint basis must be right handed"); } var lb100; var lb101; var lb102; var lb110; var lb111; var lb112; var lb120; var lb121; var lb122; var lb200; var lb201; var lb202; var lb210; var lb211; var lb212; var lb220; var lb221; var lb222; var m = config.localBasis1; lb100 = m.e00; lb101 = m.e01; lb102 = m.e02; lb110 = m.e10; lb111 = m.e11; lb112 = m.e12; lb120 = m.e20; lb121 = m.e21; lb122 = m.e22; var m1 = config.localBasis2; lb200 = m1.e00; lb201 = m1.e01; lb202 = m1.e02; lb210 = m1.e10; lb211 = m1.e11; lb212 = m1.e12; lb220 = m1.e20; lb221 = m1.e21; lb222 = m1.e22; _this219._localBasisX1X = lb100; _this219._localBasisX1Y = lb110; _this219._localBasisX1Z = lb120; _this219._localBasisY1X = lb101; _this219._localBasisY1Y = lb111; _this219._localBasisY1Z = lb121; _this219._localBasisZ1X = lb102; _this219._localBasisZ1Y = lb112; _this219._localBasisZ1Z = lb122; _this219._localBasisX2X = lb200; _this219._localBasisX2Y = lb210; _this219._localBasisX2Z = lb220; _this219._localBasisY2X = lb201; _this219._localBasisY2Y = lb211; _this219._localBasisY2Z = lb221; _this219._localBasisZ2X = lb202; _this219._localBasisZ2Y = lb212; _this219._localBasisZ2Z = lb222; _this219._angleX = 0; _this219._angleY = 0; _this219._angleZ = 0; _this219.translationX = 0; _this219.translationY = 0; _this219.translationZ = 0; _this219.xSingular = false; _this219.ySingular = false; _this219.zSingular = false; _this219._translLms = new Array(3); _this219._translSds = new Array(3); _this219._rotLms = new Array(3); _this219._rotSds = new Array(3); _this219._translLms[0] = config.translationalLimitMotors[0].clone(); _this219._translLms[1] = config.translationalLimitMotors[1].clone(); _this219._translLms[2] = config.translationalLimitMotors[2].clone(); _this219._translSds[0] = config.translationalSpringDampers[0].clone(); _this219._translSds[1] = config.translationalSpringDampers[1].clone(); _this219._translSds[2] = config.translationalSpringDampers[2].clone(); _this219._rotLms[0] = config.rotationalLimitMotors[0].clone(); _this219._rotLms[1] = config.rotationalLimitMotors[1].clone(); _this219._rotLms[2] = config.rotationalLimitMotors[2].clone(); _this219._rotSds[0] = config.rotationalSpringDampers[0].clone(); _this219._rotSds[1] = config.rotationalSpringDampers[1].clone(); _this219._rotSds[2] = config.rotationalSpringDampers[2].clone(); return _this219; } _createClass(oimo_dynamics_constraint_joint_GenericJoint, [{ key: "getInfo", value: function getInfo(info, timeStep, isPositionPart) { var j; var translMotorMass = 1 / (this._b1._invMass + this._b2._invMass); var motorMassX = this.computeEffectiveInertiaMoment(this._axisXX, this._axisXY, this._axisXZ); var motorMassY = this.computeEffectiveInertiaMoment(this._axisYX, this._axisYY, this._axisYZ); var motorMassZ = this.computeEffectiveInertiaMoment(this._axisZX, this._axisZY, this._axisZZ); if (this._translSds[0].frequency <= 0 || !isPositionPart) { var impulse = this._impulses[0]; var row = info.rows[info.numRows++]; var _this = row.jacobian; _this.lin1X = 0; _this.lin1Y = 0; _this.lin1Z = 0; _this.lin2X = 0; _this.lin2Y = 0; _this.lin2Z = 0; _this.ang1X = 0; _this.ang1Y = 0; _this.ang1Z = 0; _this.ang2X = 0; _this.ang2Y = 0; _this.ang2Z = 0; row.rhs = 0; row.cfm = 0; row.minImpulse = 0; row.maxImpulse = 0; row.motorSpeed = 0; row.motorMaxImpulse = 0; row.impulse = null; row.impulse = impulse; this.setSolverInfoRowLinear(row, this.translationX, this._translLms[0], translMotorMass, this._translSds[0], timeStep, isPositionPart); j = row.jacobian; j.lin1X = this._basisX1X; j.lin1Y = this._basisX1Y; j.lin1Z = this._basisX1Z; j.lin2X = this._basisX1X; j.lin2Y = this._basisX1Y; j.lin2Z = this._basisX1Z; j.ang1X = this._relativeAnchor1Y * this._basisX1Z - this._relativeAnchor1Z * this._basisX1Y; j.ang1Y = this._relativeAnchor1Z * this._basisX1X - this._relativeAnchor1X * this._basisX1Z; j.ang1Z = this._relativeAnchor1X * this._basisX1Y - this._relativeAnchor1Y * this._basisX1X; j.ang2X = this._relativeAnchor2Y * this._basisX1Z - this._relativeAnchor2Z * this._basisX1Y; j.ang2Y = this._relativeAnchor2Z * this._basisX1X - this._relativeAnchor2X * this._basisX1Z; j.ang2Z = this._relativeAnchor2X * this._basisX1Y - this._relativeAnchor2Y * this._basisX1X; } if (this._translSds[1].frequency <= 0 || !isPositionPart) { var _impulse3 = this._impulses[1]; var _row3 = info.rows[info.numRows++]; var _this221 = _row3.jacobian; _this221.lin1X = 0; _this221.lin1Y = 0; _this221.lin1Z = 0; _this221.lin2X = 0; _this221.lin2Y = 0; _this221.lin2Z = 0; _this221.ang1X = 0; _this221.ang1Y = 0; _this221.ang1Z = 0; _this221.ang2X = 0; _this221.ang2Y = 0; _this221.ang2Z = 0; _row3.rhs = 0; _row3.cfm = 0; _row3.minImpulse = 0; _row3.maxImpulse = 0; _row3.motorSpeed = 0; _row3.motorMaxImpulse = 0; _row3.impulse = null; _row3.impulse = _impulse3; this.setSolverInfoRowLinear(_row3, this.translationY, this._translLms[1], translMotorMass, this._translSds[1], timeStep, isPositionPart); j = _row3.jacobian; j.lin1X = this._basisY1X; j.lin1Y = this._basisY1Y; j.lin1Z = this._basisY1Z; j.lin2X = this._basisY1X; j.lin2Y = this._basisY1Y; j.lin2Z = this._basisY1Z; j.ang1X = this._relativeAnchor1Y * this._basisY1Z - this._relativeAnchor1Z * this._basisY1Y; j.ang1Y = this._relativeAnchor1Z * this._basisY1X - this._relativeAnchor1X * this._basisY1Z; j.ang1Z = this._relativeAnchor1X * this._basisY1Y - this._relativeAnchor1Y * this._basisY1X; j.ang2X = this._relativeAnchor2Y * this._basisY1Z - this._relativeAnchor2Z * this._basisY1Y; j.ang2Y = this._relativeAnchor2Z * this._basisY1X - this._relativeAnchor2X * this._basisY1Z; j.ang2Z = this._relativeAnchor2X * this._basisY1Y - this._relativeAnchor2Y * this._basisY1X; } if (this._translSds[2].frequency <= 0 || !isPositionPart) { var _impulse4 = this._impulses[2]; var _row4 = info.rows[info.numRows++]; var _this222 = _row4.jacobian; _this222.lin1X = 0; _this222.lin1Y = 0; _this222.lin1Z = 0; _this222.lin2X = 0; _this222.lin2Y = 0; _this222.lin2Z = 0; _this222.ang1X = 0; _this222.ang1Y = 0; _this222.ang1Z = 0; _this222.ang2X = 0; _this222.ang2Y = 0; _this222.ang2Z = 0; _row4.rhs = 0; _row4.cfm = 0; _row4.minImpulse = 0; _row4.maxImpulse = 0; _row4.motorSpeed = 0; _row4.motorMaxImpulse = 0; _row4.impulse = null; _row4.impulse = _impulse4; this.setSolverInfoRowLinear(_row4, this.translationZ, this._translLms[2], translMotorMass, this._translSds[2], timeStep, isPositionPart); j = _row4.jacobian; j.lin1X = this._basisZ1X; j.lin1Y = this._basisZ1Y; j.lin1Z = this._basisZ1Z; j.lin2X = this._basisZ1X; j.lin2Y = this._basisZ1Y; j.lin2Z = this._basisZ1Z; j.ang1X = this._relativeAnchor1Y * this._basisZ1Z - this._relativeAnchor1Z * this._basisZ1Y; j.ang1Y = this._relativeAnchor1Z * this._basisZ1X - this._relativeAnchor1X * this._basisZ1Z; j.ang1Z = this._relativeAnchor1X * this._basisZ1Y - this._relativeAnchor1Y * this._basisZ1X; j.ang2X = this._relativeAnchor2Y * this._basisZ1Z - this._relativeAnchor2Z * this._basisZ1Y; j.ang2Y = this._relativeAnchor2Z * this._basisZ1X - this._relativeAnchor2X * this._basisZ1Z; j.ang2Z = this._relativeAnchor2X * this._basisZ1Y - this._relativeAnchor2Y * this._basisZ1X; } if (!this.xSingular && (this._rotSds[0].frequency <= 0 || !isPositionPart)) { var _impulse5 = this._impulses[3]; var _row5 = info.rows[info.numRows++]; var _this223 = _row5.jacobian; _this223.lin1X = 0; _this223.lin1Y = 0; _this223.lin1Z = 0; _this223.lin2X = 0; _this223.lin2Y = 0; _this223.lin2Z = 0; _this223.ang1X = 0; _this223.ang1Y = 0; _this223.ang1Z = 0; _this223.ang2X = 0; _this223.ang2Y = 0; _this223.ang2Z = 0; _row5.rhs = 0; _row5.cfm = 0; _row5.minImpulse = 0; _row5.maxImpulse = 0; _row5.motorSpeed = 0; _row5.motorMaxImpulse = 0; _row5.impulse = null; _row5.impulse = _impulse5; this.setSolverInfoRowAngular(_row5, this._angleX, this._rotLms[0], motorMassX, this._rotSds[0], timeStep, isPositionPart); j = _row5.jacobian; j.ang1X = this._axisXX; j.ang1Y = this._axisXY; j.ang1Z = this._axisXZ; j.ang2X = this._axisXX; j.ang2Y = this._axisXY; j.ang2Z = this._axisXZ; } if (!this.ySingular && (this._rotSds[1].frequency <= 0 || !isPositionPart)) { var _impulse6 = this._impulses[4]; var _row6 = info.rows[info.numRows++]; var _this224 = _row6.jacobian; _this224.lin1X = 0; _this224.lin1Y = 0; _this224.lin1Z = 0; _this224.lin2X = 0; _this224.lin2Y = 0; _this224.lin2Z = 0; _this224.ang1X = 0; _this224.ang1Y = 0; _this224.ang1Z = 0; _this224.ang2X = 0; _this224.ang2Y = 0; _this224.ang2Z = 0; _row6.rhs = 0; _row6.cfm = 0; _row6.minImpulse = 0; _row6.maxImpulse = 0; _row6.motorSpeed = 0; _row6.motorMaxImpulse = 0; _row6.impulse = null; _row6.impulse = _impulse6; this.setSolverInfoRowAngular(_row6, this._angleY, this._rotLms[1], motorMassY, this._rotSds[1], timeStep, isPositionPart); j = _row6.jacobian; j.ang1X = this._axisYX; j.ang1Y = this._axisYY; j.ang1Z = this._axisYZ; j.ang2X = this._axisYX; j.ang2Y = this._axisYY; j.ang2Z = this._axisYZ; } if (!this.zSingular && (this._rotSds[2].frequency <= 0 || !isPositionPart)) { var _impulse7 = this._impulses[5]; var _row7 = info.rows[info.numRows++]; var _this225 = _row7.jacobian; _this225.lin1X = 0; _this225.lin1Y = 0; _this225.lin1Z = 0; _this225.lin2X = 0; _this225.lin2Y = 0; _this225.lin2Z = 0; _this225.ang1X = 0; _this225.ang1Y = 0; _this225.ang1Z = 0; _this225.ang2X = 0; _this225.ang2Y = 0; _this225.ang2Z = 0; _row7.rhs = 0; _row7.cfm = 0; _row7.minImpulse = 0; _row7.maxImpulse = 0; _row7.motorSpeed = 0; _row7.motorMaxImpulse = 0; _row7.impulse = null; _row7.impulse = _impulse7; this.setSolverInfoRowAngular(_row7, this._angleZ, this._rotLms[2], motorMassZ, this._rotSds[2], timeStep, isPositionPart); j = _row7.jacobian; j.ang1X = this._axisZX; j.ang1Y = this._axisZY; j.ang1Z = this._axisZZ; j.ang2X = this._axisZX; j.ang2Y = this._axisZY; j.ang2Z = this._axisZZ; } } }, { key: "_syncAnchors", value: function _syncAnchors() { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_GenericJoint.prototype), "_syncAnchors", this).call(this); var angleAxisXX; var angleAxisXY; var angleAxisXZ; var angleAxisYX; var angleAxisYY; var angleAxisYZ; var angleAxisZX; var angleAxisZY; var angleAxisZZ; angleAxisXX = this._basisX1X; angleAxisXY = this._basisX1Y; angleAxisXZ = this._basisX1Z; angleAxisZX = this._basisZ2X; angleAxisZY = this._basisZ2Y; angleAxisZZ = this._basisZ2Z; angleAxisYX = angleAxisZY * angleAxisXZ - angleAxisZZ * angleAxisXY; angleAxisYY = angleAxisZZ * angleAxisXX - angleAxisZX * angleAxisXZ; angleAxisYZ = angleAxisZX * angleAxisXY - angleAxisZY * angleAxisXX; this._axisXX = angleAxisYY * angleAxisZZ - angleAxisYZ * angleAxisZY; this._axisXY = angleAxisYZ * angleAxisZX - angleAxisYX * angleAxisZZ; this._axisXZ = angleAxisYX * angleAxisZY - angleAxisYY * angleAxisZX; this._axisYX = angleAxisYX; this._axisYY = angleAxisYY; this._axisYZ = angleAxisYZ; this._axisZX = angleAxisXY * angleAxisYZ - angleAxisXZ * angleAxisYY; this._axisZY = angleAxisXZ * angleAxisYX - angleAxisXX * angleAxisYZ; this._axisZZ = angleAxisXX * angleAxisYY - angleAxisXY * angleAxisYX; var l = this._axisXX * this._axisXX + this._axisXY * this._axisXY + this._axisXZ * this._axisXZ; if (l > 0) { l = 1 / Math.sqrt(l); } this._axisXX *= l; this._axisXY *= l; this._axisXZ *= l; var l1 = this._axisYX * this._axisYX + this._axisYY * this._axisYY + this._axisYZ * this._axisYZ; if (l1 > 0) { l1 = 1 / Math.sqrt(l1); } this._axisYX *= l1; this._axisYY *= l1; this._axisYZ *= l1; var l2 = this._axisZX * this._axisZX + this._axisZY * this._axisZY + this._axisZZ * this._axisZZ; if (l2 > 0) { l2 = 1 / Math.sqrt(l2); } this._axisZX *= l2; this._axisZY *= l2; this._axisZZ *= l2; this.xSingular = this._axisXX * this._axisXX + this._axisXY * this._axisXY + this._axisXZ * this._axisXZ == 0; this.ySingular = this._axisYX * this._axisYX + this._axisYY * this._axisYY + this._axisYZ * this._axisYZ == 0; this.zSingular = this._axisZX * this._axisZX + this._axisZY * this._axisZY + this._axisZZ * this._axisZZ == 0; var rot100; var rot101; var rot102; var rot110; var rot111; var rot112; var rot120; var rot121; var rot122; var rot200; var rot201; var rot202; var rot210; var rot211; var rot212; var rot220; var rot221; var rot222; rot100 = this._basisX1X; rot101 = this._basisY1X; rot102 = this._basisZ1X; rot110 = this._basisX1Y; rot111 = this._basisY1Y; rot112 = this._basisZ1Y; rot120 = this._basisX1Z; rot121 = this._basisY1Z; rot122 = this._basisZ1Z; rot200 = this._basisX2X; rot201 = this._basisY2X; rot202 = this._basisZ2X; rot210 = this._basisX2Y; rot211 = this._basisY2Y; rot212 = this._basisZ2Y; rot220 = this._basisX2Z; rot221 = this._basisY2Z; rot222 = this._basisZ2Z; var relRot00; var relRot01; var relRot02; var relRot11; var relRot12; var relRot21; var relRot22; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__11; var __tmp__12; var __tmp__21; var __tmp__22; __tmp__00 = rot100 * rot200 + rot110 * rot210 + rot120 * rot220; __tmp__01 = rot100 * rot201 + rot110 * rot211 + rot120 * rot221; __tmp__02 = rot100 * rot202 + rot110 * rot212 + rot120 * rot222; __tmp__11 = rot101 * rot201 + rot111 * rot211 + rot121 * rot221; __tmp__12 = rot101 * rot202 + rot111 * rot212 + rot121 * rot222; __tmp__21 = rot102 * rot201 + rot112 * rot211 + rot122 * rot221; __tmp__22 = rot102 * rot202 + rot112 * rot212 + rot122 * rot222; relRot00 = __tmp__00; relRot01 = __tmp__01; relRot02 = __tmp__02; relRot11 = __tmp__11; relRot12 = __tmp__12; relRot21 = __tmp__21; relRot22 = __tmp__22; var anglesX; var anglesY; var anglesZ; var sy = relRot02; if (sy <= -1) { var xSubZ = Math.atan2(relRot21, relRot11); anglesX = xSubZ * 0.5; anglesY = -1.570796326794895; anglesZ = -xSubZ * 0.5; } else if (sy >= 1) { var xAddZ = Math.atan2(relRot21, relRot11); anglesX = xAddZ * 0.5; anglesY = 1.570796326794895; anglesZ = xAddZ * 0.5; } else { anglesX = Math.atan2(-relRot12, relRot22); anglesY = Math.asin(sy); anglesZ = Math.atan2(-relRot01, relRot00); } this._angleX = anglesX; this._angleY = anglesY; this._angleZ = anglesZ; var anchorDiffX; var anchorDiffY; var anchorDiffZ; anchorDiffX = this._anchor2X - this._anchor1X; anchorDiffY = this._anchor2Y - this._anchor1Y; anchorDiffZ = this._anchor2Z - this._anchor1Z; this.translationX = anchorDiffX * this._basisX1X + anchorDiffY * this._basisX1Y + anchorDiffZ * this._basisX1Z; this.translationY = anchorDiffX * this._basisY1X + anchorDiffY * this._basisY1Y + anchorDiffZ * this._basisY1Z; this.translationZ = anchorDiffX * this._basisZ1X + anchorDiffY * this._basisZ1Y + anchorDiffZ * this._basisZ1Z; } }, { key: "_getVelocitySolverInfo", value: function _getVelocitySolverInfo(timeStep, info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_GenericJoint.prototype), "_getVelocitySolverInfo", this).call(this, timeStep, info); this.getInfo(info, timeStep, false); } }, { key: "_getPositionSolverInfo", value: function _getPositionSolverInfo(info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_GenericJoint.prototype), "_getPositionSolverInfo", this).call(this, info); this.getInfo(info, null, true); } }, { key: "getAxisX", value: function getAxisX() { var v = new oimo.common.Vec3(); v.x = this._basisX1X; v.y = this._basisX1Y; v.z = this._basisX1Z; return v; } }, { key: "getAxisY", value: function getAxisY() { var v = new oimo.common.Vec3(); v.x = this._axisYX; v.y = this._axisYY; v.z = this._axisYZ; return v; } }, { key: "getAxisZ", value: function getAxisZ() { var v = new oimo.common.Vec3(); v.x = this._basisZ2X; v.y = this._basisZ2Y; v.z = this._basisZ2Z; return v; } }, { key: "getTranslationalSpringDampers", value: function getTranslationalSpringDampers() { return this._translSds.slice(0); } }, { key: "getRotationalSpringDampers", value: function getRotationalSpringDampers() { return this._translSds.slice(0); } }, { key: "getTranslationalLimitMotors", value: function getTranslationalLimitMotors() { return this._translLms.slice(0); } }, { key: "getRotationalLimitMotors", value: function getRotationalLimitMotors() { return this._rotLms.slice(0); } }, { key: "getAngles", value: function getAngles() { return new oimo.common.Vec3(this._angleX, this._angleY, this._angleZ); } }, { key: "getTranslations", value: function getTranslations() { return new oimo.common.Vec3(this.translationX, this.translationY, this.translationZ); } }]); return oimo_dynamics_constraint_joint_GenericJoint; }(oimo.dynamics.constraint.joint.Joint); oimo.dynamics.constraint.joint.GenericJointConfig = /*#__PURE__*/function (_oimo$dynamics$constr4) { _inherits(oimo_dynamics_constraint_joint_GenericJointConfig, _oimo$dynamics$constr4); var _super26 = _createSuper(oimo_dynamics_constraint_joint_GenericJointConfig); function oimo_dynamics_constraint_joint_GenericJointConfig() { var _this226; _classCallCheck(this, oimo_dynamics_constraint_joint_GenericJointConfig); _this226 = _super26.call(this); _this226.localBasis1 = new oimo.common.Mat3(); _this226.localBasis2 = new oimo.common.Mat3(); var _g = []; _g.push(new oimo.dynamics.constraint.joint.TranslationalLimitMotor().setLimits(0, 0)); _g.push(new oimo.dynamics.constraint.joint.TranslationalLimitMotor().setLimits(0, 0)); _g.push(new oimo.dynamics.constraint.joint.TranslationalLimitMotor().setLimits(0, 0)); _this226.translationalLimitMotors = _g; var _g1 = []; _g1.push(new oimo.dynamics.constraint.joint.RotationalLimitMotor().setLimits(0, 0)); _g1.push(new oimo.dynamics.constraint.joint.RotationalLimitMotor().setLimits(0, 0)); _g1.push(new oimo.dynamics.constraint.joint.RotationalLimitMotor().setLimits(0, 0)); _this226.rotationalLimitMotors = _g1; _this226.translationalSpringDampers = [new oimo.dynamics.constraint.joint.SpringDamper(), new oimo.dynamics.constraint.joint.SpringDamper(), new oimo.dynamics.constraint.joint.SpringDamper()]; _this226.rotationalSpringDampers = [new oimo.dynamics.constraint.joint.SpringDamper(), new oimo.dynamics.constraint.joint.SpringDamper(), new oimo.dynamics.constraint.joint.SpringDamper()]; return _this226; } _createClass(oimo_dynamics_constraint_joint_GenericJointConfig, [{ key: "init", value: function init(rigidBody1, rigidBody2, worldAnchor, worldBasis1, worldBasis2) { this._init(rigidBody1, rigidBody2, worldAnchor); var tf1 = rigidBody1._transform; var tf2 = rigidBody2._transform; var wb100; var wb101; var wb102; var wb110; var wb111; var wb112; var wb120; var wb121; var wb122; var wb200; var wb201; var wb202; var wb210; var wb211; var wb212; var wb220; var wb221; var wb222; var lb100; var lb101; var lb102; var lb110; var lb111; var lb112; var lb120; var lb121; var lb122; var lb200; var lb201; var lb202; var lb210; var lb211; var lb212; var lb220; var lb221; var lb222; wb100 = worldBasis1.e00; wb101 = worldBasis1.e01; wb102 = worldBasis1.e02; wb110 = worldBasis1.e10; wb111 = worldBasis1.e11; wb112 = worldBasis1.e12; wb120 = worldBasis1.e20; wb121 = worldBasis1.e21; wb122 = worldBasis1.e22; wb200 = worldBasis2.e00; wb201 = worldBasis2.e01; wb202 = worldBasis2.e02; wb210 = worldBasis2.e10; wb211 = worldBasis2.e11; wb212 = worldBasis2.e12; wb220 = worldBasis2.e20; wb221 = worldBasis2.e21; wb222 = worldBasis2.e22; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = tf1._rotation00 * wb100 + tf1._rotation10 * wb110 + tf1._rotation20 * wb120; __tmp__01 = tf1._rotation00 * wb101 + tf1._rotation10 * wb111 + tf1._rotation20 * wb121; __tmp__02 = tf1._rotation00 * wb102 + tf1._rotation10 * wb112 + tf1._rotation20 * wb122; __tmp__10 = tf1._rotation01 * wb100 + tf1._rotation11 * wb110 + tf1._rotation21 * wb120; __tmp__11 = tf1._rotation01 * wb101 + tf1._rotation11 * wb111 + tf1._rotation21 * wb121; __tmp__12 = tf1._rotation01 * wb102 + tf1._rotation11 * wb112 + tf1._rotation21 * wb122; __tmp__20 = tf1._rotation02 * wb100 + tf1._rotation12 * wb110 + tf1._rotation22 * wb120; __tmp__21 = tf1._rotation02 * wb101 + tf1._rotation12 * wb111 + tf1._rotation22 * wb121; __tmp__22 = tf1._rotation02 * wb102 + tf1._rotation12 * wb112 + tf1._rotation22 * wb122; lb100 = __tmp__00; lb101 = __tmp__01; lb102 = __tmp__02; lb110 = __tmp__10; lb111 = __tmp__11; lb112 = __tmp__12; lb120 = __tmp__20; lb121 = __tmp__21; lb122 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = tf2._rotation00 * wb200 + tf2._rotation10 * wb210 + tf2._rotation20 * wb220; __tmp__011 = tf2._rotation00 * wb201 + tf2._rotation10 * wb211 + tf2._rotation20 * wb221; __tmp__021 = tf2._rotation00 * wb202 + tf2._rotation10 * wb212 + tf2._rotation20 * wb222; __tmp__101 = tf2._rotation01 * wb200 + tf2._rotation11 * wb210 + tf2._rotation21 * wb220; __tmp__111 = tf2._rotation01 * wb201 + tf2._rotation11 * wb211 + tf2._rotation21 * wb221; __tmp__121 = tf2._rotation01 * wb202 + tf2._rotation11 * wb212 + tf2._rotation21 * wb222; __tmp__201 = tf2._rotation02 * wb200 + tf2._rotation12 * wb210 + tf2._rotation22 * wb220; __tmp__211 = tf2._rotation02 * wb201 + tf2._rotation12 * wb211 + tf2._rotation22 * wb221; __tmp__221 = tf2._rotation02 * wb202 + tf2._rotation12 * wb212 + tf2._rotation22 * wb222; lb200 = __tmp__001; lb201 = __tmp__011; lb202 = __tmp__021; lb210 = __tmp__101; lb211 = __tmp__111; lb212 = __tmp__121; lb220 = __tmp__201; lb221 = __tmp__211; lb222 = __tmp__221; var m = this.localBasis1; m.e00 = lb100; m.e01 = lb101; m.e02 = lb102; m.e10 = lb110; m.e11 = lb111; m.e12 = lb112; m.e20 = lb120; m.e21 = lb121; m.e22 = lb122; var m1 = this.localBasis2; m1.e00 = lb200; m1.e01 = lb201; m1.e02 = lb202; m1.e10 = lb210; m1.e11 = lb211; m1.e12 = lb212; m1.e20 = lb220; m1.e21 = lb221; m1.e22 = lb222; return this; } }]); return oimo_dynamics_constraint_joint_GenericJointConfig; }(oimo.dynamics.constraint.joint.JointConfig); oimo.dynamics.constraint.joint.JointImpulse = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_joint_JointImpulse() { _classCallCheck(this, oimo_dynamics_constraint_joint_JointImpulse); this.impulse = 0; this.impulseM = 0; this.impulseP = 0; }); oimo.dynamics.constraint.joint.JointLink = /*#__PURE__*/function () { function oimo_dynamics_constraint_joint_JointLink(joint) { _classCallCheck(this, oimo_dynamics_constraint_joint_JointLink); this._joint = joint; } _createClass(oimo_dynamics_constraint_joint_JointLink, [{ key: "getContact", value: function getContact() { return this._joint; } }, { key: "getOther", value: function getOther() { return this._other; } }, { key: "getPrev", value: function getPrev() { return this._prev; } }, { key: "getNext", value: function getNext() { return this._next; } }]); return oimo_dynamics_constraint_joint_JointLink; }(); oimo.dynamics.constraint.joint.JointMacro = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_joint_JointMacro() { _classCallCheck(this, oimo_dynamics_constraint_joint_JointMacro); }); oimo.dynamics.constraint.joint.JointType = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_joint_JointType() { _classCallCheck(this, oimo_dynamics_constraint_joint_JointType); }); oimo.dynamics.constraint.joint.PrismaticJoint = /*#__PURE__*/function (_oimo$dynamics$constr5) { _inherits(oimo_dynamics_constraint_joint_PrismaticJoint, _oimo$dynamics$constr5); var _super27 = _createSuper(oimo_dynamics_constraint_joint_PrismaticJoint); function oimo_dynamics_constraint_joint_PrismaticJoint(config) { var _this227; _classCallCheck(this, oimo_dynamics_constraint_joint_PrismaticJoint); _this227 = _super27.call(this, config, oimo.dynamics.constraint.joint.JointType.PRISMATIC); var v = config.localAxis1; _this227._localBasisX1X = v.x; _this227._localBasisX1Y = v.y; _this227._localBasisX1Z = v.z; var v1 = config.localAxis2; _this227._localBasisX2X = v1.x; _this227._localBasisX2Y = v1.y; _this227._localBasisX2Z = v1.z; _this227.buildLocalBasesFromX(); _this227._basis = new oimo.dynamics.constraint.joint.BasisTracker(_assertThisInitialized(_this227)); _this227.translation = 0; _this227.linearErrorY = 0; _this227.linearErrorZ = 0; _this227.angularErrorX = 0; _this227.angularErrorY = 0; _this227.angularErrorZ = 0; _this227._sd = config.springDamper.clone(); _this227._lm = config.limitMotor.clone(); return _this227; } _createClass(oimo_dynamics_constraint_joint_PrismaticJoint, [{ key: "getInfo", value: function getInfo(info, timeStep, isPositionPart) { var erp = this.getErp(timeStep, isPositionPart); var linRhsY = this.linearErrorY * erp; var linRhsZ = this.linearErrorZ * erp; var angRhsX = this.angularErrorX * erp; var angRhsY = this.angularErrorY * erp; var angRhsZ = this.angularErrorZ * erp; var j; if (this._sd.frequency <= 0 || !isPositionPart) { var _impulse8 = this._impulses[0]; var _row8 = info.rows[info.numRows++]; var _this228 = _row8.jacobian; _this228.lin1X = 0; _this228.lin1Y = 0; _this228.lin1Z = 0; _this228.lin2X = 0; _this228.lin2Y = 0; _this228.lin2Z = 0; _this228.ang1X = 0; _this228.ang1Y = 0; _this228.ang1Z = 0; _this228.ang2X = 0; _this228.ang2Y = 0; _this228.ang2Z = 0; _row8.rhs = 0; _row8.cfm = 0; _row8.minImpulse = 0; _row8.maxImpulse = 0; _row8.motorSpeed = 0; _row8.motorMaxImpulse = 0; _row8.impulse = null; _row8.impulse = _impulse8; this.setSolverInfoRowLinear(_row8, this.translation, this._lm, 1 / (this._b1._invMass + this._b2._invMass), this._sd, timeStep, isPositionPart); j = _row8.jacobian; j.lin1X = this._basis.xX; j.lin1Y = this._basis.xY; j.lin1Z = this._basis.xZ; j.lin2X = this._basis.xX; j.lin2Y = this._basis.xY; j.lin2Z = this._basis.xZ; j.ang1X = this._relativeAnchor1Y * this._basis.xZ - this._relativeAnchor1Z * this._basis.xY; j.ang1Y = this._relativeAnchor1Z * this._basis.xX - this._relativeAnchor1X * this._basis.xZ; j.ang1Z = this._relativeAnchor1X * this._basis.xY - this._relativeAnchor1Y * this._basis.xX; j.ang2X = this._relativeAnchor2Y * this._basis.xZ - this._relativeAnchor2Z * this._basis.xY; j.ang2Y = this._relativeAnchor2Z * this._basis.xX - this._relativeAnchor2X * this._basis.xZ; j.ang2Z = this._relativeAnchor2X * this._basis.xY - this._relativeAnchor2Y * this._basis.xX; } var impulse = this._impulses[1]; var row = info.rows[info.numRows++]; var _this = row.jacobian; _this.lin1X = 0; _this.lin1Y = 0; _this.lin1Z = 0; _this.lin2X = 0; _this.lin2Y = 0; _this.lin2Z = 0; _this.ang1X = 0; _this.ang1Y = 0; _this.ang1Z = 0; _this.ang2X = 0; _this.ang2Y = 0; _this.ang2Z = 0; row.rhs = 0; row.cfm = 0; row.minImpulse = 0; row.maxImpulse = 0; row.motorSpeed = 0; row.motorMaxImpulse = 0; row.impulse = null; row.impulse = impulse; row.rhs = linRhsY; row.cfm = 0; row.minImpulse = -1e65536; row.maxImpulse = 1e65536; j = row.jacobian; j.lin1X = this._basis.yX; j.lin1Y = this._basis.yY; j.lin1Z = this._basis.yZ; j.lin2X = this._basis.yX; j.lin2Y = this._basis.yY; j.lin2Z = this._basis.yZ; j.ang1X = this._relativeAnchor1Y * this._basis.yZ - this._relativeAnchor1Z * this._basis.yY; j.ang1Y = this._relativeAnchor1Z * this._basis.yX - this._relativeAnchor1X * this._basis.yZ; j.ang1Z = this._relativeAnchor1X * this._basis.yY - this._relativeAnchor1Y * this._basis.yX; j.ang2X = this._relativeAnchor2Y * this._basis.yZ - this._relativeAnchor2Z * this._basis.yY; j.ang2Y = this._relativeAnchor2Z * this._basis.yX - this._relativeAnchor2X * this._basis.yZ; j.ang2Z = this._relativeAnchor2X * this._basis.yY - this._relativeAnchor2Y * this._basis.yX; var impulse1 = this._impulses[2]; var row1 = info.rows[info.numRows++]; var _this1 = row1.jacobian; _this1.lin1X = 0; _this1.lin1Y = 0; _this1.lin1Z = 0; _this1.lin2X = 0; _this1.lin2Y = 0; _this1.lin2Z = 0; _this1.ang1X = 0; _this1.ang1Y = 0; _this1.ang1Z = 0; _this1.ang2X = 0; _this1.ang2Y = 0; _this1.ang2Z = 0; row1.rhs = 0; row1.cfm = 0; row1.minImpulse = 0; row1.maxImpulse = 0; row1.motorSpeed = 0; row1.motorMaxImpulse = 0; row1.impulse = null; row1.impulse = impulse1; row1.rhs = linRhsZ; row1.cfm = 0; row1.minImpulse = -1e65536; row1.maxImpulse = 1e65536; j = row1.jacobian; j.lin1X = this._basis.zX; j.lin1Y = this._basis.zY; j.lin1Z = this._basis.zZ; j.lin2X = this._basis.zX; j.lin2Y = this._basis.zY; j.lin2Z = this._basis.zZ; j.ang1X = this._relativeAnchor1Y * this._basis.zZ - this._relativeAnchor1Z * this._basis.zY; j.ang1Y = this._relativeAnchor1Z * this._basis.zX - this._relativeAnchor1X * this._basis.zZ; j.ang1Z = this._relativeAnchor1X * this._basis.zY - this._relativeAnchor1Y * this._basis.zX; j.ang2X = this._relativeAnchor2Y * this._basis.zZ - this._relativeAnchor2Z * this._basis.zY; j.ang2Y = this._relativeAnchor2Z * this._basis.zX - this._relativeAnchor2X * this._basis.zZ; j.ang2Z = this._relativeAnchor2X * this._basis.zY - this._relativeAnchor2Y * this._basis.zX; var impulse2 = this._impulses[3]; var row2 = info.rows[info.numRows++]; var _this2 = row2.jacobian; _this2.lin1X = 0; _this2.lin1Y = 0; _this2.lin1Z = 0; _this2.lin2X = 0; _this2.lin2Y = 0; _this2.lin2Z = 0; _this2.ang1X = 0; _this2.ang1Y = 0; _this2.ang1Z = 0; _this2.ang2X = 0; _this2.ang2Y = 0; _this2.ang2Z = 0; row2.rhs = 0; row2.cfm = 0; row2.minImpulse = 0; row2.maxImpulse = 0; row2.motorSpeed = 0; row2.motorMaxImpulse = 0; row2.impulse = null; row2.impulse = impulse2; row2.rhs = angRhsX; row2.cfm = 0; row2.minImpulse = -1e65536; row2.maxImpulse = 1e65536; j = row2.jacobian; j.ang1X = 1; j.ang1Y = 0; j.ang1Z = 0; j.ang2X = 1; j.ang2Y = 0; j.ang2Z = 0; var impulse3 = this._impulses[4]; var row3 = info.rows[info.numRows++]; var _this3 = row3.jacobian; _this3.lin1X = 0; _this3.lin1Y = 0; _this3.lin1Z = 0; _this3.lin2X = 0; _this3.lin2Y = 0; _this3.lin2Z = 0; _this3.ang1X = 0; _this3.ang1Y = 0; _this3.ang1Z = 0; _this3.ang2X = 0; _this3.ang2Y = 0; _this3.ang2Z = 0; row3.rhs = 0; row3.cfm = 0; row3.minImpulse = 0; row3.maxImpulse = 0; row3.motorSpeed = 0; row3.motorMaxImpulse = 0; row3.impulse = null; row3.impulse = impulse3; row3.rhs = angRhsY; row3.cfm = 0; row3.minImpulse = -1e65536; row3.maxImpulse = 1e65536; j = row3.jacobian; j.ang1X = 0; j.ang1Y = 1; j.ang1Z = 0; j.ang2X = 0; j.ang2Y = 1; j.ang2Z = 0; var impulse4 = this._impulses[5]; var row4 = info.rows[info.numRows++]; var _this4 = row4.jacobian; _this4.lin1X = 0; _this4.lin1Y = 0; _this4.lin1Z = 0; _this4.lin2X = 0; _this4.lin2Y = 0; _this4.lin2Z = 0; _this4.ang1X = 0; _this4.ang1Y = 0; _this4.ang1Z = 0; _this4.ang2X = 0; _this4.ang2Y = 0; _this4.ang2Z = 0; row4.rhs = 0; row4.cfm = 0; row4.minImpulse = 0; row4.maxImpulse = 0; row4.motorSpeed = 0; row4.motorMaxImpulse = 0; row4.impulse = null; row4.impulse = impulse4; row4.rhs = angRhsZ; row4.cfm = 0; row4.minImpulse = -1e65536; row4.maxImpulse = 1e65536; j = row4.jacobian; j.ang1X = 0; j.ang1Y = 0; j.ang1Z = 1; j.ang2X = 0; j.ang2Y = 0; j.ang2Z = 1; } }, { key: "_syncAnchors", value: function _syncAnchors() { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_PrismaticJoint.prototype), "_syncAnchors", this).call(this); var _this = this._basis; var invM1 = _this.joint._b1._invMass; var invM2 = _this.joint._b2._invMass; var qX; var qY; var qZ; var qW; var idQX; var idQY; var idQZ; var idQW; var slerpQX; var slerpQY; var slerpQZ; var slerpQW; var slerpM00; var slerpM01; var slerpM02; var slerpM10; var slerpM11; var slerpM12; var slerpM20; var slerpM21; var slerpM22; var newXX; var newXY; var newXZ; var newYX; var newYY; var newYZ; var newZX; var newZY; var newZZ; var prevXX; var prevXY; var prevXZ; var prevYX; var prevYY; var prevYZ; var d = _this.joint._basisX1X * _this.joint._basisX2X + _this.joint._basisX1Y * _this.joint._basisX2Y + _this.joint._basisX1Z * _this.joint._basisX2Z; if (d < -0.999999999) { var vX; var vY; var vZ; var _x18 = _this.joint._basisX1X; var _y18 = _this.joint._basisX1Y; var _z18 = _this.joint._basisX1Z; var _x19 = _x18 * _x18; var _y19 = _y18 * _y18; var _z19 = _z18 * _z18; var _d44; if (_x19 < _y19) { if (_x19 < _z19) { _d44 = 1 / Math.sqrt(_y19 + _z19); vX = 0; vY = _z18 * _d44; vZ = -_y18 * _d44; } else { _d44 = 1 / Math.sqrt(_x19 + _y19); vX = _y18 * _d44; vY = -_x18 * _d44; vZ = 0; } } else if (_y19 < _z19) { _d44 = 1 / Math.sqrt(_z19 + _x19); vX = -_z18 * _d44; vY = 0; vZ = _x18 * _d44; } else { _d44 = 1 / Math.sqrt(_x19 + _y19); vX = _y18 * _d44; vY = -_x18 * _d44; vZ = 0; } qX = vX; qY = vY; qZ = vZ; qW = 0; } else { var cX; var cY; var cZ; cX = _this.joint._basisX1Y * _this.joint._basisX2Z - _this.joint._basisX1Z * _this.joint._basisX2Y; cY = _this.joint._basisX1Z * _this.joint._basisX2X - _this.joint._basisX1X * _this.joint._basisX2Z; cZ = _this.joint._basisX1X * _this.joint._basisX2Y - _this.joint._basisX1Y * _this.joint._basisX2X; var _w5 = Math.sqrt((1 + d) * 0.5); d = 0.5 / _w5; cX *= d; cY *= d; cZ *= d; qX = cX; qY = cY; qZ = cZ; qW = _w5; } idQX = 0; idQY = 0; idQZ = 0; idQW = 1; var q1X; var q1Y; var q1Z; var q1W; var q2X; var q2Y; var q2Z; var q2W; q1X = idQX; q1Y = idQY; q1Z = idQZ; q1W = idQW; q2X = qX; q2Y = qY; q2Z = qZ; q2W = qW; var d1 = q1X * q2X + q1Y * q2Y + q1Z * q2Z + q1W * q2W; if (d1 < 0) { d1 = -d1; q2X = -q2X; q2Y = -q2Y; q2Z = -q2Z; q2W = -q2W; } if (d1 > 0.999999) { var dqX; var dqY; var dqZ; var dqW; dqX = q2X - q1X; dqY = q2Y - q1Y; dqZ = q2Z - q1Z; dqW = q2W - q1W; q2X = q1X + dqX * (invM1 / (invM1 + invM2)); q2Y = q1Y + dqY * (invM1 / (invM1 + invM2)); q2Z = q1Z + dqZ * (invM1 / (invM1 + invM2)); q2W = q1W + dqW * (invM1 / (invM1 + invM2)); var _l41 = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W; if (_l41 > 1e-32) { _l41 = 1 / Math.sqrt(_l41); } slerpQX = q2X * _l41; slerpQY = q2Y * _l41; slerpQZ = q2Z * _l41; slerpQW = q2W * _l41; } else { var _theta2 = invM1 / (invM1 + invM2) * Math.acos(d1); q2X += q1X * -d1; q2Y += q1Y * -d1; q2Z += q1Z * -d1; q2W += q1W * -d1; var _l42 = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W; if (_l42 > 1e-32) { _l42 = 1 / Math.sqrt(_l42); } q2X *= _l42; q2Y *= _l42; q2Z *= _l42; q2W *= _l42; var sin = Math.sin(_theta2); var cos = Math.cos(_theta2); q1X *= cos; q1Y *= cos; q1Z *= cos; q1W *= cos; slerpQX = q1X + q2X * sin; slerpQY = q1Y + q2Y * sin; slerpQZ = q1Z + q2Z * sin; slerpQW = q1W + q2W * sin; } var x = slerpQX; var y = slerpQY; var z = slerpQZ; var w = slerpQW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; slerpM00 = 1 - yy - zz; slerpM01 = xy - wz; slerpM02 = xz + wy; slerpM10 = xy + wz; slerpM11 = 1 - xx - zz; slerpM12 = yz - wx; slerpM20 = xz - wy; slerpM21 = yz + wx; slerpM22 = 1 - xx - yy; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = slerpM00 * _this.joint._basisX1X + slerpM01 * _this.joint._basisX1Y + slerpM02 * _this.joint._basisX1Z; __tmp__Y = slerpM10 * _this.joint._basisX1X + slerpM11 * _this.joint._basisX1Y + slerpM12 * _this.joint._basisX1Z; __tmp__Z = slerpM20 * _this.joint._basisX1X + slerpM21 * _this.joint._basisX1Y + slerpM22 * _this.joint._basisX1Z; newXX = __tmp__X; newXY = __tmp__Y; newXZ = __tmp__Z; prevXX = _this.xX; prevXY = _this.xY; prevXZ = _this.xZ; prevYX = _this.yX; prevYY = _this.yY; prevYZ = _this.yZ; var d2 = prevXX * newXX + prevXY * newXY + prevXZ * newXZ; if (d2 < -0.999999999) { var _vX2; var _vY2; var _vZ2; var _x20 = prevXX; var _y20 = prevXY; var _z20 = prevXZ; var _x21 = _x20 * _x20; var _y21 = _y20 * _y20; var _z21 = _z20 * _z20; var _d45; if (_x21 < _y21) { if (_x21 < _z21) { _d45 = 1 / Math.sqrt(_y21 + _z21); _vX2 = 0; _vY2 = _z20 * _d45; _vZ2 = -_y20 * _d45; } else { _d45 = 1 / Math.sqrt(_x21 + _y21); _vX2 = _y20 * _d45; _vY2 = -_x20 * _d45; _vZ2 = 0; } } else if (_y21 < _z21) { _d45 = 1 / Math.sqrt(_z21 + _x21); _vX2 = -_z20 * _d45; _vY2 = 0; _vZ2 = _x20 * _d45; } else { _d45 = 1 / Math.sqrt(_x21 + _y21); _vX2 = _y20 * _d45; _vY2 = -_x20 * _d45; _vZ2 = 0; } slerpQX = _vX2; slerpQY = _vY2; slerpQZ = _vZ2; slerpQW = 0; } else { var _cX2; var _cY2; var _cZ2; _cX2 = prevXY * newXZ - prevXZ * newXY; _cY2 = prevXZ * newXX - prevXX * newXZ; _cZ2 = prevXX * newXY - prevXY * newXX; var _w6 = Math.sqrt((1 + d2) * 0.5); d2 = 0.5 / _w6; _cX2 *= d2; _cY2 *= d2; _cZ2 *= d2; slerpQX = _cX2; slerpQY = _cY2; slerpQZ = _cZ2; slerpQW = _w6; } var x1 = slerpQX; var y1 = slerpQY; var z1 = slerpQZ; var w1 = slerpQW; var x21 = 2 * x1; var y21 = 2 * y1; var z21 = 2 * z1; var xx1 = x1 * x21; var yy1 = y1 * y21; var zz1 = z1 * z21; var xy1 = x1 * y21; var yz1 = y1 * z21; var xz1 = x1 * z21; var wx1 = w1 * x21; var wy1 = w1 * y21; var wz1 = w1 * z21; slerpM00 = 1 - yy1 - zz1; slerpM01 = xy1 - wz1; slerpM02 = xz1 + wy1; slerpM10 = xy1 + wz1; slerpM11 = 1 - xx1 - zz1; slerpM12 = yz1 - wx1; slerpM20 = xz1 - wy1; slerpM21 = yz1 + wx1; slerpM22 = 1 - xx1 - yy1; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = slerpM00 * prevYX + slerpM01 * prevYY + slerpM02 * prevYZ; __tmp__Y1 = slerpM10 * prevYX + slerpM11 * prevYY + slerpM12 * prevYZ; __tmp__Z1 = slerpM20 * prevYX + slerpM21 * prevYY + slerpM22 * prevYZ; newYX = __tmp__X1; newYY = __tmp__Y1; newYZ = __tmp__Z1; newZX = newXY * newYZ - newXZ * newYY; newZY = newXZ * newYX - newXX * newYZ; newZZ = newXX * newYY - newXY * newYX; if (newZX * newZX + newZY * newZY + newZZ * newZZ > 1e-6) { var _l43 = newZX * newZX + newZY * newZY + newZZ * newZZ; if (_l43 > 0) { _l43 = 1 / Math.sqrt(_l43); } newZX *= _l43; newZY *= _l43; newZZ *= _l43; } else { var _x22 = newXX; var _y22 = newXY; var _z22 = newXZ; var _x23 = _x22 * _x22; var _y23 = _y22 * _y22; var _z23 = _z22 * _z22; var _d46; if (_x23 < _y23) { if (_x23 < _z23) { _d46 = 1 / Math.sqrt(_y23 + _z23); newZX = 0; newZY = _z22 * _d46; newZZ = -_y22 * _d46; } else { _d46 = 1 / Math.sqrt(_x23 + _y23); newZX = _y22 * _d46; newZY = -_x22 * _d46; newZZ = 0; } } else if (_y23 < _z23) { _d46 = 1 / Math.sqrt(_z23 + _x23); newZX = -_z22 * _d46; newZY = 0; newZZ = _x22 * _d46; } else { _d46 = 1 / Math.sqrt(_x23 + _y23); newZX = _y22 * _d46; newZY = -_x22 * _d46; newZZ = 0; } } newYX = newZY * newXZ - newZZ * newXY; newYY = newZZ * newXX - newZX * newXZ; newYZ = newZX * newXY - newZY * newXX; _this.xX = newXX; _this.xY = newXY; _this.xZ = newXZ; _this.yX = newYX; _this.yY = newYY; _this.yZ = newYZ; _this.zX = newZX; _this.zY = newZY; _this.zZ = newZZ; var rot100; var rot101; var rot102; var rot110; var rot111; var rot112; var rot120; var rot121; var rot122; var rot200; var rot201; var rot202; var rot210; var rot211; var rot212; var rot220; var rot221; var rot222; rot100 = this._basisX1X; rot101 = this._basisY1X; rot102 = this._basisZ1X; rot110 = this._basisX1Y; rot111 = this._basisY1Y; rot112 = this._basisZ1Y; rot120 = this._basisX1Z; rot121 = this._basisY1Z; rot122 = this._basisZ1Z; rot200 = this._basisX2X; rot201 = this._basisY2X; rot202 = this._basisZ2X; rot210 = this._basisX2Y; rot211 = this._basisY2Y; rot212 = this._basisZ2Y; rot220 = this._basisX2Z; rot221 = this._basisY2Z; rot222 = this._basisZ2Z; var relRot00; var relRot01; var relRot02; var relRot10; var relRot11; var relRot12; var relRot20; var relRot21; var relRot22; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = rot200 * rot100 + rot201 * rot101 + rot202 * rot102; __tmp__01 = rot200 * rot110 + rot201 * rot111 + rot202 * rot112; __tmp__02 = rot200 * rot120 + rot201 * rot121 + rot202 * rot122; __tmp__10 = rot210 * rot100 + rot211 * rot101 + rot212 * rot102; __tmp__11 = rot210 * rot110 + rot211 * rot111 + rot212 * rot112; __tmp__12 = rot210 * rot120 + rot211 * rot121 + rot212 * rot122; __tmp__20 = rot220 * rot100 + rot221 * rot101 + rot222 * rot102; __tmp__21 = rot220 * rot110 + rot221 * rot111 + rot222 * rot112; __tmp__22 = rot220 * rot120 + rot221 * rot121 + rot222 * rot122; relRot00 = __tmp__00; relRot01 = __tmp__01; relRot02 = __tmp__02; relRot10 = __tmp__10; relRot11 = __tmp__11; relRot12 = __tmp__12; relRot20 = __tmp__20; relRot21 = __tmp__21; relRot22 = __tmp__22; var relQX; var relQY; var relQZ; var relQW; var e00 = relRot00; var e11 = relRot11; var e22 = relRot22; var t = e00 + e11 + e22; var s; if (t > 0) { s = Math.sqrt(t + 1); relQW = 0.5 * s; s = 0.5 / s; relQX = (relRot21 - relRot12) * s; relQY = (relRot02 - relRot20) * s; relQZ = (relRot10 - relRot01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); relQX = 0.5 * s; s = 0.5 / s; relQY = (relRot01 + relRot10) * s; relQZ = (relRot02 + relRot20) * s; relQW = (relRot21 - relRot12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); relQZ = 0.5 * s; s = 0.5 / s; relQX = (relRot02 + relRot20) * s; relQY = (relRot12 + relRot21) * s; relQW = (relRot10 - relRot01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); relQY = 0.5 * s; s = 0.5 / s; relQX = (relRot01 + relRot10) * s; relQZ = (relRot12 + relRot21) * s; relQW = (relRot02 - relRot20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); relQZ = 0.5 * s; s = 0.5 / s; relQX = (relRot02 + relRot20) * s; relQY = (relRot12 + relRot21) * s; relQW = (relRot10 - relRot01) * s; } var cosHalfTheta = relQW; var theta = (cosHalfTheta <= -1 ? 3.14159265358979 : cosHalfTheta >= 1 ? 0 : Math.acos(cosHalfTheta)) * 2; this.angularErrorX = relQX; this.angularErrorY = relQY; this.angularErrorZ = relQZ; var l = this.angularErrorX * this.angularErrorX + this.angularErrorY * this.angularErrorY + this.angularErrorZ * this.angularErrorZ; if (l > 0) { l = 1 / Math.sqrt(l); } this.angularErrorX *= l; this.angularErrorY *= l; this.angularErrorZ *= l; this.angularErrorX *= theta; this.angularErrorY *= theta; this.angularErrorZ *= theta; var anchorDiffX; var anchorDiffY; var anchorDiffZ; anchorDiffX = this._anchor2X - this._anchor1X; anchorDiffY = this._anchor2Y - this._anchor1Y; anchorDiffZ = this._anchor2Z - this._anchor1Z; this.translation = anchorDiffX * this._basis.xX + anchorDiffY * this._basis.xY + anchorDiffZ * this._basis.xZ; this.linearErrorY = anchorDiffX * this._basis.yX + anchorDiffY * this._basis.yY + anchorDiffZ * this._basis.yZ; this.linearErrorZ = anchorDiffX * this._basis.zX + anchorDiffY * this._basis.zY + anchorDiffZ * this._basis.zZ; } }, { key: "_getVelocitySolverInfo", value: function _getVelocitySolverInfo(timeStep, info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_PrismaticJoint.prototype), "_getVelocitySolverInfo", this).call(this, timeStep, info); this.getInfo(info, timeStep, false); } }, { key: "_getPositionSolverInfo", value: function _getPositionSolverInfo(info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_PrismaticJoint.prototype), "_getPositionSolverInfo", this).call(this, info); this.getInfo(info, null, true); } }, { key: "getAxis1", value: function getAxis1() { var v = new oimo.common.Vec3(); v.x = this._basisX1X; v.y = this._basisX1Y; v.z = this._basisX1Z; return v; } }, { key: "getAxis2", value: function getAxis2() { var v = new oimo.common.Vec3(); v.x = this._basisX2X; v.y = this._basisX2Y; v.z = this._basisX2Z; return v; } }, { key: "getAxis1To", value: function getAxis1To(axis) { axis.x = this._basisX1X; axis.y = this._basisX1Y; axis.z = this._basisX1Z; } }, { key: "getAxis2To", value: function getAxis2To(axis) { axis.x = this._basisX2X; axis.y = this._basisX2Y; axis.z = this._basisX2Z; } }, { key: "getLocalAxis1", value: function getLocalAxis1() { var v = new oimo.common.Vec3(); v.x = this._localBasisX1X; v.y = this._localBasisX1Y; v.z = this._localBasisX1Z; return v; } }, { key: "getLocalAxis2", value: function getLocalAxis2() { var v = new oimo.common.Vec3(); v.x = this._localBasisX2X; v.y = this._localBasisX2Y; v.z = this._localBasisX2Z; return v; } }, { key: "getLocalAxis1To", value: function getLocalAxis1To(axis) { axis.x = this._localBasisX1X; axis.y = this._localBasisX1Y; axis.z = this._localBasisX1Z; } }, { key: "getLocalAxis2To", value: function getLocalAxis2To(axis) { axis.x = this._localBasisX2X; axis.y = this._localBasisX2Y; axis.z = this._localBasisX2Z; } }, { key: "getSpringDamper", value: function getSpringDamper() { return this._sd; } }, { key: "getLimitMotor", value: function getLimitMotor() { return this._lm; } }, { key: "getTranslation", value: function getTranslation() { return this.translation; } }]); return oimo_dynamics_constraint_joint_PrismaticJoint; }(oimo.dynamics.constraint.joint.Joint); oimo.dynamics.constraint.joint.PrismaticJointConfig = /*#__PURE__*/function (_oimo$dynamics$constr6) { _inherits(oimo_dynamics_constraint_joint_PrismaticJointConfig, _oimo$dynamics$constr6); var _super28 = _createSuper(oimo_dynamics_constraint_joint_PrismaticJointConfig); function oimo_dynamics_constraint_joint_PrismaticJointConfig() { var _this229; _classCallCheck(this, oimo_dynamics_constraint_joint_PrismaticJointConfig); _this229 = _super28.call(this); _this229.localAxis1 = new oimo.common.Vec3(1, 0, 0); _this229.localAxis2 = new oimo.common.Vec3(1, 0, 0); _this229.limitMotor = new oimo.dynamics.constraint.joint.TranslationalLimitMotor(); _this229.springDamper = new oimo.dynamics.constraint.joint.SpringDamper(); return _this229; } _createClass(oimo_dynamics_constraint_joint_PrismaticJointConfig, [{ key: "init", value: function init(rigidBody1, rigidBody2, worldAnchor, worldAxis) { this._init(rigidBody1, rigidBody2, worldAnchor); var localVector = this.localAxis1; var vX; var vY; var vZ; vX = worldAxis.x; vY = worldAxis.y; vZ = worldAxis.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = rigidBody1._transform._rotation00 * vX + rigidBody1._transform._rotation10 * vY + rigidBody1._transform._rotation20 * vZ; __tmp__Y = rigidBody1._transform._rotation01 * vX + rigidBody1._transform._rotation11 * vY + rigidBody1._transform._rotation21 * vZ; __tmp__Z = rigidBody1._transform._rotation02 * vX + rigidBody1._transform._rotation12 * vY + rigidBody1._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; localVector.x = vX; localVector.y = vY; localVector.z = vZ; var localVector1 = this.localAxis2; var vX1; var vY1; var vZ1; vX1 = worldAxis.x; vY1 = worldAxis.y; vZ1 = worldAxis.z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = rigidBody2._transform._rotation00 * vX1 + rigidBody2._transform._rotation10 * vY1 + rigidBody2._transform._rotation20 * vZ1; __tmp__Y1 = rigidBody2._transform._rotation01 * vX1 + rigidBody2._transform._rotation11 * vY1 + rigidBody2._transform._rotation21 * vZ1; __tmp__Z1 = rigidBody2._transform._rotation02 * vX1 + rigidBody2._transform._rotation12 * vY1 + rigidBody2._transform._rotation22 * vZ1; vX1 = __tmp__X1; vY1 = __tmp__Y1; vZ1 = __tmp__Z1; localVector1.x = vX1; localVector1.y = vY1; localVector1.z = vZ1; return this; } }]); return oimo_dynamics_constraint_joint_PrismaticJointConfig; }(oimo.dynamics.constraint.joint.JointConfig); oimo.dynamics.constraint.joint.RagdollJoint = /*#__PURE__*/function (_oimo$dynamics$constr7) { _inherits(oimo_dynamics_constraint_joint_RagdollJoint, _oimo$dynamics$constr7); var _super29 = _createSuper(oimo_dynamics_constraint_joint_RagdollJoint); function oimo_dynamics_constraint_joint_RagdollJoint(config) { var _this230; _classCallCheck(this, oimo_dynamics_constraint_joint_RagdollJoint); _this230 = _super29.call(this, config, oimo.dynamics.constraint.joint.JointType.RAGDOLL); var v = config.localTwistAxis1; _this230._localBasisX1X = v.x; _this230._localBasisX1Y = v.y; _this230._localBasisX1Z = v.z; var v1 = config.localSwingAxis1; _this230._localBasisY1X = v1.x; _this230._localBasisY1Y = v1.y; _this230._localBasisY1Z = v1.z; var v2 = config.localTwistAxis2; _this230._localBasisX2X = v2.x; _this230._localBasisX2Y = v2.y; _this230._localBasisX2Z = v2.z; _this230.buildLocalBasesFromXY1X2(); _this230._twistSd = config.twistSpringDamper.clone(); _this230._twistLm = config.twistLimitMotor.clone(); _this230._swingSd = config.swingSpringDamper.clone(); _this230._maxSwingAngle1 = config.maxSwingAngle1; _this230._maxSwingAngle2 = config.maxSwingAngle2; if (_this230._maxSwingAngle1 < oimo.common.Setting.minRagdollMaxSwingAngle) { _this230._maxSwingAngle1 = oimo.common.Setting.minRagdollMaxSwingAngle; } if (_this230._maxSwingAngle2 < oimo.common.Setting.minRagdollMaxSwingAngle) { _this230._maxSwingAngle2 = oimo.common.Setting.minRagdollMaxSwingAngle; } _this230.dummySwingLm = new oimo.dynamics.constraint.joint.RotationalLimitMotor(); _this230.dummySwingLm.lowerLimit = -1; _this230.dummySwingLm.upperLimit = 0; _this230._swingAngle = 0; _this230._twistAngle = 0; _this230.swingError = 0; _this230.swingAxisX = 0; _this230.swingAxisY = 0; _this230.swingAxisZ = 0; _this230.twistAxisX = 0; _this230.twistAxisY = 0; _this230.twistAxisZ = 0; return _this230; } _createClass(oimo_dynamics_constraint_joint_RagdollJoint, [{ key: "getInfo", value: function getInfo(info, timeStep, isPositionPart) { var erp = this.getErp(timeStep, isPositionPart); var linearRhsX; var linearRhsY; var linearRhsZ; linearRhsX = this.linearErrorX * erp; linearRhsY = this.linearErrorY * erp; linearRhsZ = this.linearErrorZ * erp; var crossR100; var crossR101; var crossR102; var crossR110; var crossR111; var crossR112; var crossR120; var crossR121; var crossR122; var crossR200; var crossR201; var crossR202; var crossR210; var crossR211; var crossR212; var crossR220; var crossR221; var crossR222; crossR100 = 0; crossR101 = -this._relativeAnchor1Z; crossR102 = this._relativeAnchor1Y; crossR110 = this._relativeAnchor1Z; crossR111 = 0; crossR112 = -this._relativeAnchor1X; crossR120 = -this._relativeAnchor1Y; crossR121 = this._relativeAnchor1X; crossR122 = 0; crossR200 = 0; crossR201 = -this._relativeAnchor2Z; crossR202 = this._relativeAnchor2Y; crossR210 = this._relativeAnchor2Z; crossR211 = 0; crossR212 = -this._relativeAnchor2X; crossR220 = -this._relativeAnchor2Y; crossR221 = this._relativeAnchor2X; crossR222 = 0; crossR100 = -crossR100; crossR101 = -crossR101; crossR102 = -crossR102; crossR110 = -crossR110; crossR111 = -crossR111; crossR112 = -crossR112; crossR120 = -crossR120; crossR121 = -crossR121; crossR122 = -crossR122; crossR200 = -crossR200; crossR201 = -crossR201; crossR202 = -crossR202; crossR210 = -crossR210; crossR211 = -crossR211; crossR212 = -crossR212; crossR220 = -crossR220; crossR221 = -crossR221; crossR222 = -crossR222; var swingMass = this.computeEffectiveInertiaMoment(this.swingAxisX, this.swingAxisY, this.swingAxisZ); var twistMass = this.computeEffectiveInertiaMoment(this._basisX2X, this._basisX2Y, this._basisX2Z); var impulse = this._impulses[0]; var row = info.rows[info.numRows++]; var _this = row.jacobian; _this.lin1X = 0; _this.lin1Y = 0; _this.lin1Z = 0; _this.lin2X = 0; _this.lin2Y = 0; _this.lin2Z = 0; _this.ang1X = 0; _this.ang1Y = 0; _this.ang1Z = 0; _this.ang2X = 0; _this.ang2Y = 0; _this.ang2Z = 0; row.rhs = 0; row.cfm = 0; row.minImpulse = 0; row.maxImpulse = 0; row.motorSpeed = 0; row.motorMaxImpulse = 0; row.impulse = null; row.impulse = impulse; row.rhs = linearRhsX; row.cfm = 0; row.minImpulse = -1e65536; row.maxImpulse = 1e65536; var j = row.jacobian; j.lin1X = 1; j.lin1Y = 0; j.lin1Z = 0; j.lin2X = 1; j.lin2Y = 0; j.lin2Z = 0; j.ang1X = crossR100; j.ang1Y = crossR101; j.ang1Z = crossR102; j.ang2X = crossR200; j.ang2Y = crossR201; j.ang2Z = crossR202; var impulse1 = this._impulses[1]; var row1 = info.rows[info.numRows++]; var _this1 = row1.jacobian; _this1.lin1X = 0; _this1.lin1Y = 0; _this1.lin1Z = 0; _this1.lin2X = 0; _this1.lin2Y = 0; _this1.lin2Z = 0; _this1.ang1X = 0; _this1.ang1Y = 0; _this1.ang1Z = 0; _this1.ang2X = 0; _this1.ang2Y = 0; _this1.ang2Z = 0; row1.rhs = 0; row1.cfm = 0; row1.minImpulse = 0; row1.maxImpulse = 0; row1.motorSpeed = 0; row1.motorMaxImpulse = 0; row1.impulse = null; row1.impulse = impulse1; row1.rhs = linearRhsY; row1.cfm = 0; row1.minImpulse = -1e65536; row1.maxImpulse = 1e65536; j = row1.jacobian; j.lin1X = 0; j.lin1Y = 1; j.lin1Z = 0; j.lin2X = 0; j.lin2Y = 1; j.lin2Z = 0; j.ang1X = crossR110; j.ang1Y = crossR111; j.ang1Z = crossR112; j.ang2X = crossR210; j.ang2Y = crossR211; j.ang2Z = crossR212; var impulse2 = this._impulses[2]; var row2 = info.rows[info.numRows++]; var _this2 = row2.jacobian; _this2.lin1X = 0; _this2.lin1Y = 0; _this2.lin1Z = 0; _this2.lin2X = 0; _this2.lin2Y = 0; _this2.lin2Z = 0; _this2.ang1X = 0; _this2.ang1Y = 0; _this2.ang1Z = 0; _this2.ang2X = 0; _this2.ang2Y = 0; _this2.ang2Z = 0; row2.rhs = 0; row2.cfm = 0; row2.minImpulse = 0; row2.maxImpulse = 0; row2.motorSpeed = 0; row2.motorMaxImpulse = 0; row2.impulse = null; row2.impulse = impulse2; row2.rhs = linearRhsZ; row2.cfm = 0; row2.minImpulse = -1e65536; row2.maxImpulse = 1e65536; j = row2.jacobian; j.lin1X = 0; j.lin1Y = 0; j.lin1Z = 1; j.lin2X = 0; j.lin2Y = 0; j.lin2Z = 1; j.ang1X = crossR120; j.ang1Y = crossR121; j.ang1Z = crossR122; j.ang2X = crossR220; j.ang2Y = crossR221; j.ang2Z = crossR222; if (this.swingError > 0 && (this._swingSd.frequency <= 0 || !isPositionPart)) { var _impulse9 = this._impulses[3]; var _row9 = info.rows[info.numRows++]; var _this231 = _row9.jacobian; _this231.lin1X = 0; _this231.lin1Y = 0; _this231.lin1Z = 0; _this231.lin2X = 0; _this231.lin2Y = 0; _this231.lin2Z = 0; _this231.ang1X = 0; _this231.ang1Y = 0; _this231.ang1Z = 0; _this231.ang2X = 0; _this231.ang2Y = 0; _this231.ang2Z = 0; _row9.rhs = 0; _row9.cfm = 0; _row9.minImpulse = 0; _row9.maxImpulse = 0; _row9.motorSpeed = 0; _row9.motorMaxImpulse = 0; _row9.impulse = null; _row9.impulse = _impulse9; this.setSolverInfoRowAngular(_row9, this.swingError, this.dummySwingLm, swingMass, this._swingSd, timeStep, isPositionPart); j = _row9.jacobian; j.ang1X = this.swingAxisX; j.ang1Y = this.swingAxisY; j.ang1Z = this.swingAxisZ; j.ang2X = this.swingAxisX; j.ang2Y = this.swingAxisY; j.ang2Z = this.swingAxisZ; } if (this._twistSd.frequency <= 0 || !isPositionPart) { var _impulse10 = this._impulses[4]; var _row10 = info.rows[info.numRows++]; var _this232 = _row10.jacobian; _this232.lin1X = 0; _this232.lin1Y = 0; _this232.lin1Z = 0; _this232.lin2X = 0; _this232.lin2Y = 0; _this232.lin2Z = 0; _this232.ang1X = 0; _this232.ang1Y = 0; _this232.ang1Z = 0; _this232.ang2X = 0; _this232.ang2Y = 0; _this232.ang2Z = 0; _row10.rhs = 0; _row10.cfm = 0; _row10.minImpulse = 0; _row10.maxImpulse = 0; _row10.motorSpeed = 0; _row10.motorMaxImpulse = 0; _row10.impulse = null; _row10.impulse = _impulse10; this.setSolverInfoRowAngular(_row10, this._twistAngle, this._twistLm, twistMass, this._twistSd, timeStep, isPositionPart); j = _row10.jacobian; j.ang1X = this.twistAxisX; j.ang1Y = this.twistAxisY; j.ang1Z = this.twistAxisZ; j.ang2X = this.twistAxisX; j.ang2Y = this.twistAxisY; j.ang2Z = this.twistAxisZ; } } }, { key: "_syncAnchors", value: function _syncAnchors() { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_RagdollJoint.prototype), "_syncAnchors", this).call(this); var axis1X; var axis1Y; var axis1Z; var axis2X; var axis2Y; var axis2Z; axis1X = this._basisX1X; axis1Y = this._basisX1Y; axis1Z = this._basisX1Z; axis2X = this._basisX2X; axis2Y = this._basisX2Y; axis2Z = this._basisX2Z; var basis1Mat00; var basis1Mat01; var basis1Mat02; var basis1Mat10; var basis1Mat11; var basis1Mat12; var basis1Mat20; var basis1Mat21; var basis1Mat22; basis1Mat00 = this._basisX1X; basis1Mat01 = this._basisY1X; basis1Mat02 = this._basisZ1X; basis1Mat10 = this._basisX1Y; basis1Mat11 = this._basisY1Y; basis1Mat12 = this._basisZ1Y; basis1Mat20 = this._basisX1Z; basis1Mat21 = this._basisY1Z; basis1Mat22 = this._basisZ1Z; var swingQX; var swingQY; var swingQZ; var swingQW; var swingM00; var swingM01; var swingM02; var swingM10; var swingM11; var swingM12; var swingM20; var swingM21; var swingM22; var swingVX; var swingVY; var swingVZ; var d = axis1X * axis2X + axis1Y * axis2Y + axis1Z * axis2Z; if (d < -0.999999999) { var vX; var vY; var vZ; var _x24 = axis1X; var _y24 = axis1Y; var z1 = axis1Z; var _x25 = _x24 * _x24; var _y25 = _y24 * _y24; var _z24 = z1 * z1; var _d47; if (_x25 < _y25) { if (_x25 < _z24) { _d47 = 1 / Math.sqrt(_y25 + _z24); vX = 0; vY = z1 * _d47; vZ = -_y24 * _d47; } else { _d47 = 1 / Math.sqrt(_x25 + _y25); vX = _y24 * _d47; vY = -_x24 * _d47; vZ = 0; } } else if (_y25 < _z24) { _d47 = 1 / Math.sqrt(_z24 + _x25); vX = -z1 * _d47; vY = 0; vZ = _x24 * _d47; } else { _d47 = 1 / Math.sqrt(_x25 + _y25); vX = _y24 * _d47; vY = -_x24 * _d47; vZ = 0; } swingQX = vX; swingQY = vY; swingQZ = vZ; swingQW = 0; } else { var cX; var cY; var cZ; cX = axis1Y * axis2Z - axis1Z * axis2Y; cY = axis1Z * axis2X - axis1X * axis2Z; cZ = axis1X * axis2Y - axis1Y * axis2X; var _w7 = Math.sqrt((1 + d) * 0.5); d = 0.5 / _w7; cX *= d; cY *= d; cZ *= d; swingQX = cX; swingQY = cY; swingQZ = cZ; swingQW = _w7; } var x = swingQX; var y = swingQY; var z = swingQZ; var w = swingQW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; swingM00 = 1 - yy - zz; swingM01 = xy - wz; swingM02 = xz + wy; swingM10 = xy + wz; swingM11 = 1 - xx - zz; swingM12 = yz - wx; swingM20 = xz - wy; swingM21 = yz + wx; swingM22 = 1 - xx - yy; this._swingAngle = (swingQW <= -1 ? 3.14159265358979 : swingQW >= 1 ? 0 : Math.acos(swingQW)) * 2; swingVX = swingQX; swingVY = swingQY; swingVZ = swingQZ; var basisY2In1X; var basisY2In1Y; var basisY2In1Z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = swingM00 * this._basisY2X + swingM10 * this._basisY2Y + swingM20 * this._basisY2Z; __tmp__Y = swingM01 * this._basisY2X + swingM11 * this._basisY2Y + swingM21 * this._basisY2Z; __tmp__Z = swingM02 * this._basisY2X + swingM12 * this._basisY2Y + swingM22 * this._basisY2Z; basisY2In1X = __tmp__X; basisY2In1Y = __tmp__Y; basisY2In1Z = __tmp__Z; this._twistAngle = Math.atan2(this._basisZ1X * basisY2In1X + this._basisZ1Y * basisY2In1Y + this._basisZ1Z * basisY2In1Z, this._basisY1X * basisY2In1X + this._basisY1Y * basisY2In1Y + this._basisY1Z * basisY2In1Z); this.twistAxisX = this._basisX1X + this._basisX2X; this.twistAxisY = this._basisX1Y + this._basisX2Y; this.twistAxisZ = this._basisX1Z + this._basisX2Z; var l = this.twistAxisX * this.twistAxisX + this.twistAxisY * this.twistAxisY + this.twistAxisZ * this.twistAxisZ; if (l > 0) { l = 1 / Math.sqrt(l); } this.twistAxisX *= l; this.twistAxisY *= l; this.twistAxisZ *= l; var invLen = Math.sqrt(swingVX * swingVX + swingVY * swingVY + swingVZ * swingVZ); if (invLen > 0) { invLen = 1 / invLen; } swingVX *= invLen * this._swingAngle; swingVY *= invLen * this._swingAngle; swingVZ *= invLen * this._swingAngle; var __tmp__Y1; var __tmp__Z1; __tmp__Y1 = basis1Mat01 * swingVX + basis1Mat11 * swingVY + basis1Mat21 * swingVZ; __tmp__Z1 = basis1Mat02 * swingVX + basis1Mat12 * swingVY + basis1Mat22 * swingVZ; swingVY = __tmp__Y1; swingVZ = __tmp__Z1; var x1 = swingVY; var y1 = swingVZ; var a = this._maxSwingAngle1; var b = this._maxSwingAngle2; var invA2 = 1 / (a * a); var invB2 = 1 / (b * b); var w1 = x1 * x1 * invA2 + y1 * y1 * invB2; if (w1 == 0) { this.swingAxisX = 0; this.swingAxisY = 0; this.swingAxisZ = 0; this.swingError = 0; } else { var t = Math.sqrt(1 / w1); var x0 = x1 * t; var y0 = y1 * t; var nx = x0 * invA2; var ny = y0 * invB2; invLen = 1 / Math.sqrt(nx * nx + ny * ny); nx *= invLen; ny *= invLen; var depth = (x1 - x0) * nx + (y1 - y0) * ny; if (depth > 0) { this.swingError = depth; this.swingAxisX = 0; this.swingAxisY = nx; this.swingAxisZ = ny; var _tmp__X10; var _tmp__Y10; var _tmp__Z10; _tmp__X10 = basis1Mat00 * this.swingAxisX + basis1Mat01 * this.swingAxisY + basis1Mat02 * this.swingAxisZ; _tmp__Y10 = basis1Mat10 * this.swingAxisX + basis1Mat11 * this.swingAxisY + basis1Mat12 * this.swingAxisZ; _tmp__Z10 = basis1Mat20 * this.swingAxisX + basis1Mat21 * this.swingAxisY + basis1Mat22 * this.swingAxisZ; this.swingAxisX = _tmp__X10; this.swingAxisY = _tmp__Y10; this.swingAxisZ = _tmp__Z10; var __tmp__X1; var _tmp__Y11; var _tmp__Z11; __tmp__X1 = swingM00 * this.swingAxisX + swingM01 * this.swingAxisY + swingM02 * this.swingAxisZ; _tmp__Y11 = swingM10 * this.swingAxisX + swingM11 * this.swingAxisY + swingM12 * this.swingAxisZ; _tmp__Z11 = swingM20 * this.swingAxisX + swingM21 * this.swingAxisY + swingM22 * this.swingAxisZ; this.swingAxisX = __tmp__X1; this.swingAxisY = _tmp__Y11; this.swingAxisZ = _tmp__Z11; } else { this.swingError = 0; } } this.linearErrorX = this._anchor2X - this._anchor1X; this.linearErrorY = this._anchor2Y - this._anchor1Y; this.linearErrorZ = this._anchor2Z - this._anchor1Z; } }, { key: "_getVelocitySolverInfo", value: function _getVelocitySolverInfo(timeStep, info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_RagdollJoint.prototype), "_getVelocitySolverInfo", this).call(this, timeStep, info); this.getInfo(info, timeStep, false); } }, { key: "_getPositionSolverInfo", value: function _getPositionSolverInfo(info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_RagdollJoint.prototype), "_getPositionSolverInfo", this).call(this, info); this.getInfo(info, null, true); } }, { key: "getAxis1", value: function getAxis1() { var v = new oimo.common.Vec3(); v.x = this._basisX1X; v.y = this._basisX1Y; v.z = this._basisX1Z; return v; } }, { key: "getAxis2", value: function getAxis2() { var v = new oimo.common.Vec3(); v.x = this._basisX2X; v.y = this._basisX2Y; v.z = this._basisX2Z; return v; } }, { key: "getAxis1To", value: function getAxis1To(axis) { axis.x = this._basisX1X; axis.y = this._basisX1Y; axis.z = this._basisX1Z; } }, { key: "getAxis2To", value: function getAxis2To(axis) { axis.x = this._basisX2X; axis.y = this._basisX2Y; axis.z = this._basisX2Z; } }, { key: "getLocalAxis1", value: function getLocalAxis1() { var v = new oimo.common.Vec3(); v.x = this._localBasisX1X; v.y = this._localBasisX1Y; v.z = this._localBasisX1Z; return v; } }, { key: "getLocalAxis2", value: function getLocalAxis2() { var v = new oimo.common.Vec3(); v.x = this._localBasisX2X; v.y = this._localBasisX2Y; v.z = this._localBasisX2Z; return v; } }, { key: "getLocalAxis1To", value: function getLocalAxis1To(axis) { axis.x = this._localBasisX1X; axis.y = this._localBasisX1Y; axis.z = this._localBasisX1Z; } }, { key: "getLocalAxis2To", value: function getLocalAxis2To(axis) { axis.x = this._localBasisX2X; axis.y = this._localBasisX2Y; axis.z = this._localBasisX2Z; } }, { key: "getTwistSpringDamper", value: function getTwistSpringDamper() { return this._twistSd; } }, { key: "getTwistLimitMotor", value: function getTwistLimitMotor() { return this._twistLm; } }, { key: "getSwingSpringDamper", value: function getSwingSpringDamper() { return this._swingSd; } }, { key: "getSwingAxis", value: function getSwingAxis() { var v = new oimo.common.Vec3(); v.x = this.swingAxisX; v.y = this.swingAxisY; v.z = this.swingAxisZ; return v; } }, { key: "getSwingAxisTo", value: function getSwingAxisTo(axis) { axis.x = this.swingAxisX; axis.y = this.swingAxisY; axis.z = this.swingAxisZ; } }, { key: "getSwingAngle", value: function getSwingAngle() { return this._swingAngle; } }, { key: "getTwistAngle", value: function getTwistAngle() { return this._twistAngle; } }]); return oimo_dynamics_constraint_joint_RagdollJoint; }(oimo.dynamics.constraint.joint.Joint); oimo.dynamics.constraint.joint.RagdollJointConfig = /*#__PURE__*/function (_oimo$dynamics$constr8) { _inherits(oimo_dynamics_constraint_joint_RagdollJointConfig, _oimo$dynamics$constr8); var _super30 = _createSuper(oimo_dynamics_constraint_joint_RagdollJointConfig); function oimo_dynamics_constraint_joint_RagdollJointConfig() { var _this233; _classCallCheck(this, oimo_dynamics_constraint_joint_RagdollJointConfig); _this233 = _super30.call(this); _this233.localTwistAxis1 = new oimo.common.Vec3(1, 0, 0); _this233.localTwistAxis2 = new oimo.common.Vec3(1, 0, 0); _this233.localSwingAxis1 = new oimo.common.Vec3(0, 1, 0); _this233.twistSpringDamper = new oimo.dynamics.constraint.joint.SpringDamper(); _this233.swingSpringDamper = new oimo.dynamics.constraint.joint.SpringDamper(); _this233.twistLimitMotor = new oimo.dynamics.constraint.joint.RotationalLimitMotor(); _this233.maxSwingAngle1 = 3.14159265358979; _this233.maxSwingAngle2 = 3.14159265358979; return _this233; } _createClass(oimo_dynamics_constraint_joint_RagdollJointConfig, [{ key: "init", value: function init(rigidBody1, rigidBody2, worldAnchor, worldTwistAxis, worldSwingAxis) { this._init(rigidBody1, rigidBody2, worldAnchor); var localVector = this.localTwistAxis1; var vX; var vY; var vZ; vX = worldTwistAxis.x; vY = worldTwistAxis.y; vZ = worldTwistAxis.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = rigidBody1._transform._rotation00 * vX + rigidBody1._transform._rotation10 * vY + rigidBody1._transform._rotation20 * vZ; __tmp__Y = rigidBody1._transform._rotation01 * vX + rigidBody1._transform._rotation11 * vY + rigidBody1._transform._rotation21 * vZ; __tmp__Z = rigidBody1._transform._rotation02 * vX + rigidBody1._transform._rotation12 * vY + rigidBody1._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; localVector.x = vX; localVector.y = vY; localVector.z = vZ; var localVector1 = this.localTwistAxis2; var vX1; var vY1; var vZ1; vX1 = worldTwistAxis.x; vY1 = worldTwistAxis.y; vZ1 = worldTwistAxis.z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = rigidBody2._transform._rotation00 * vX1 + rigidBody2._transform._rotation10 * vY1 + rigidBody2._transform._rotation20 * vZ1; __tmp__Y1 = rigidBody2._transform._rotation01 * vX1 + rigidBody2._transform._rotation11 * vY1 + rigidBody2._transform._rotation21 * vZ1; __tmp__Z1 = rigidBody2._transform._rotation02 * vX1 + rigidBody2._transform._rotation12 * vY1 + rigidBody2._transform._rotation22 * vZ1; vX1 = __tmp__X1; vY1 = __tmp__Y1; vZ1 = __tmp__Z1; localVector1.x = vX1; localVector1.y = vY1; localVector1.z = vZ1; var localVector2 = this.localSwingAxis1; var vX2; var vY2; var vZ2; vX2 = worldSwingAxis.x; vY2 = worldSwingAxis.y; vZ2 = worldSwingAxis.z; var __tmp__X2; var __tmp__Y2; var __tmp__Z2; __tmp__X2 = rigidBody1._transform._rotation00 * vX2 + rigidBody1._transform._rotation10 * vY2 + rigidBody1._transform._rotation20 * vZ2; __tmp__Y2 = rigidBody1._transform._rotation01 * vX2 + rigidBody1._transform._rotation11 * vY2 + rigidBody1._transform._rotation21 * vZ2; __tmp__Z2 = rigidBody1._transform._rotation02 * vX2 + rigidBody1._transform._rotation12 * vY2 + rigidBody1._transform._rotation22 * vZ2; vX2 = __tmp__X2; vY2 = __tmp__Y2; vZ2 = __tmp__Z2; localVector2.x = vX2; localVector2.y = vY2; localVector2.z = vZ2; return this; } }]); return oimo_dynamics_constraint_joint_RagdollJointConfig; }(oimo.dynamics.constraint.joint.JointConfig); oimo.dynamics.constraint.joint.RevoluteJoint = /*#__PURE__*/function (_oimo$dynamics$constr9) { _inherits(oimo_dynamics_constraint_joint_RevoluteJoint, _oimo$dynamics$constr9); var _super31 = _createSuper(oimo_dynamics_constraint_joint_RevoluteJoint); function oimo_dynamics_constraint_joint_RevoluteJoint(config) { var _this234; _classCallCheck(this, oimo_dynamics_constraint_joint_RevoluteJoint); _this234 = _super31.call(this, config, 1); var v = config.localAxis1; _this234._localBasisX1X = v.x; _this234._localBasisX1Y = v.y; _this234._localBasisX1Z = v.z; var v1 = config.localAxis2; _this234._localBasisX2X = v1.x; _this234._localBasisX2Y = v1.y; _this234._localBasisX2Z = v1.z; _this234.buildLocalBasesFromX(); _this234.angle = 0; _this234.angularErrorY = 0; _this234.angularErrorZ = 0; _this234._basis = new oimo.dynamics.constraint.joint.BasisTracker(_assertThisInitialized(_this234)); _this234._sd = config.springDamper.clone(); _this234._lm = config.limitMotor.clone(); return _this234; } _createClass(oimo_dynamics_constraint_joint_RevoluteJoint, [{ key: "getInfo", value: function getInfo(info, timeStep, isPositionPart) { var erp = this.getErp(timeStep, isPositionPart); var linearRhsX; var linearRhsY; var linearRhsZ; linearRhsX = this.linearErrorX * erp; linearRhsY = this.linearErrorY * erp; linearRhsZ = this.linearErrorZ * erp; var angRhsY = this.angularErrorY * erp; var angRhsZ = this.angularErrorZ * erp; var crossR100; var crossR101; var crossR102; var crossR110; var crossR111; var crossR112; var crossR120; var crossR121; var crossR122; var crossR200; var crossR201; var crossR202; var crossR210; var crossR211; var crossR212; var crossR220; var crossR221; var crossR222; crossR100 = 0; crossR101 = -this._relativeAnchor1Z; crossR102 = this._relativeAnchor1Y; crossR110 = this._relativeAnchor1Z; crossR111 = 0; crossR112 = -this._relativeAnchor1X; crossR120 = -this._relativeAnchor1Y; crossR121 = this._relativeAnchor1X; crossR122 = 0; crossR200 = 0; crossR201 = -this._relativeAnchor2Z; crossR202 = this._relativeAnchor2Y; crossR210 = this._relativeAnchor2Z; crossR211 = 0; crossR212 = -this._relativeAnchor2X; crossR220 = -this._relativeAnchor2Y; crossR221 = this._relativeAnchor2X; crossR222 = 0; crossR100 = -crossR100; crossR101 = -crossR101; crossR102 = -crossR102; crossR110 = -crossR110; crossR111 = -crossR111; crossR112 = -crossR112; crossR120 = -crossR120; crossR121 = -crossR121; crossR122 = -crossR122; crossR200 = -crossR200; crossR201 = -crossR201; crossR202 = -crossR202; crossR210 = -crossR210; crossR211 = -crossR211; crossR212 = -crossR212; crossR220 = -crossR220; crossR221 = -crossR221; crossR222 = -crossR222; var motorMass = this.computeEffectiveInertiaMoment(this._basis.xX, this._basis.xY, this._basis.xZ); var impulse = this._impulses[0]; var row = info.rows[info.numRows++]; var _this = row.jacobian; _this.lin1X = 0; _this.lin1Y = 0; _this.lin1Z = 0; _this.lin2X = 0; _this.lin2Y = 0; _this.lin2Z = 0; _this.ang1X = 0; _this.ang1Y = 0; _this.ang1Z = 0; _this.ang2X = 0; _this.ang2Y = 0; _this.ang2Z = 0; row.rhs = 0; row.cfm = 0; row.minImpulse = 0; row.maxImpulse = 0; row.motorSpeed = 0; row.motorMaxImpulse = 0; row.impulse = null; row.impulse = impulse; row.rhs = linearRhsX; row.cfm = 0; row.minImpulse = -1e65536; row.maxImpulse = 1e65536; var j = row.jacobian; j.lin1X = 1; j.lin1Y = 0; j.lin1Z = 0; j.lin2X = 1; j.lin2Y = 0; j.lin2Z = 0; j.ang1X = crossR100; j.ang1Y = crossR101; j.ang1Z = crossR102; j.ang2X = crossR200; j.ang2Y = crossR201; j.ang2Z = crossR202; var impulse1 = this._impulses[1]; var row1 = info.rows[info.numRows++]; var _this1 = row1.jacobian; _this1.lin1X = 0; _this1.lin1Y = 0; _this1.lin1Z = 0; _this1.lin2X = 0; _this1.lin2Y = 0; _this1.lin2Z = 0; _this1.ang1X = 0; _this1.ang1Y = 0; _this1.ang1Z = 0; _this1.ang2X = 0; _this1.ang2Y = 0; _this1.ang2Z = 0; row1.rhs = 0; row1.cfm = 0; row1.minImpulse = 0; row1.maxImpulse = 0; row1.motorSpeed = 0; row1.motorMaxImpulse = 0; row1.impulse = null; row1.impulse = impulse1; row1.rhs = linearRhsY; row1.cfm = 0; row1.minImpulse = -1e65536; row1.maxImpulse = 1e65536; j = row1.jacobian; j.lin1X = 0; j.lin1Y = 1; j.lin1Z = 0; j.lin2X = 0; j.lin2Y = 1; j.lin2Z = 0; j.ang1X = crossR110; j.ang1Y = crossR111; j.ang1Z = crossR112; j.ang2X = crossR210; j.ang2Y = crossR211; j.ang2Z = crossR212; var impulse2 = this._impulses[2]; var row2 = info.rows[info.numRows++]; var _this2 = row2.jacobian; _this2.lin1X = 0; _this2.lin1Y = 0; _this2.lin1Z = 0; _this2.lin2X = 0; _this2.lin2Y = 0; _this2.lin2Z = 0; _this2.ang1X = 0; _this2.ang1Y = 0; _this2.ang1Z = 0; _this2.ang2X = 0; _this2.ang2Y = 0; _this2.ang2Z = 0; row2.rhs = 0; row2.cfm = 0; row2.minImpulse = 0; row2.maxImpulse = 0; row2.motorSpeed = 0; row2.motorMaxImpulse = 0; row2.impulse = null; row2.impulse = impulse2; row2.rhs = linearRhsZ; row2.cfm = 0; row2.minImpulse = -1e65536; row2.maxImpulse = 1e65536; j = row2.jacobian; j.lin1X = 0; j.lin1Y = 0; j.lin1Z = 1; j.lin2X = 0; j.lin2Y = 0; j.lin2Z = 1; j.ang1X = crossR120; j.ang1Y = crossR121; j.ang1Z = crossR122; j.ang2X = crossR220; j.ang2Y = crossR221; j.ang2Z = crossR222; if (this._sd.frequency <= 0 || !isPositionPart) { var _impulse11 = this._impulses[3]; var _row11 = info.rows[info.numRows++]; var _this235 = _row11.jacobian; _this235.lin1X = 0; _this235.lin1Y = 0; _this235.lin1Z = 0; _this235.lin2X = 0; _this235.lin2Y = 0; _this235.lin2Z = 0; _this235.ang1X = 0; _this235.ang1Y = 0; _this235.ang1Z = 0; _this235.ang2X = 0; _this235.ang2Y = 0; _this235.ang2Z = 0; _row11.rhs = 0; _row11.cfm = 0; _row11.minImpulse = 0; _row11.maxImpulse = 0; _row11.motorSpeed = 0; _row11.motorMaxImpulse = 0; _row11.impulse = null; _row11.impulse = _impulse11; this.setSolverInfoRowAngular(_row11, this.angle, this._lm, motorMass, this._sd, timeStep, isPositionPart); j = _row11.jacobian; j.ang1X = this._basis.xX; j.ang1Y = this._basis.xY; j.ang1Z = this._basis.xZ; j.ang2X = this._basis.xX; j.ang2Y = this._basis.xY; j.ang2Z = this._basis.xZ; } var impulse3 = this._impulses[4]; var row3 = info.rows[info.numRows++]; var _this3 = row3.jacobian; _this3.lin1X = 0; _this3.lin1Y = 0; _this3.lin1Z = 0; _this3.lin2X = 0; _this3.lin2Y = 0; _this3.lin2Z = 0; _this3.ang1X = 0; _this3.ang1Y = 0; _this3.ang1Z = 0; _this3.ang2X = 0; _this3.ang2Y = 0; _this3.ang2Z = 0; row3.rhs = 0; row3.cfm = 0; row3.minImpulse = 0; row3.maxImpulse = 0; row3.motorSpeed = 0; row3.motorMaxImpulse = 0; row3.impulse = null; row3.impulse = impulse3; row3.rhs = angRhsY; row3.cfm = 0; row3.minImpulse = -1e65536; row3.maxImpulse = 1e65536; j = row3.jacobian; j.ang1X = this._basis.yX; j.ang1Y = this._basis.yY; j.ang1Z = this._basis.yZ; j.ang2X = this._basis.yX; j.ang2Y = this._basis.yY; j.ang2Z = this._basis.yZ; var impulse4 = this._impulses[5]; var row4 = info.rows[info.numRows++]; var _this4 = row4.jacobian; _this4.lin1X = 0; _this4.lin1Y = 0; _this4.lin1Z = 0; _this4.lin2X = 0; _this4.lin2Y = 0; _this4.lin2Z = 0; _this4.ang1X = 0; _this4.ang1Y = 0; _this4.ang1Z = 0; _this4.ang2X = 0; _this4.ang2Y = 0; _this4.ang2Z = 0; row4.rhs = 0; row4.cfm = 0; row4.minImpulse = 0; row4.maxImpulse = 0; row4.motorSpeed = 0; row4.motorMaxImpulse = 0; row4.impulse = null; row4.impulse = impulse4; row4.rhs = angRhsZ; row4.cfm = 0; row4.minImpulse = -1e65536; row4.maxImpulse = 1e65536; j = row4.jacobian; j.ang1X = this._basis.zX; j.ang1Y = this._basis.zY; j.ang1Z = this._basis.zZ; j.ang2X = this._basis.zX; j.ang2Y = this._basis.zY; j.ang2Z = this._basis.zZ; } }, { key: "_syncAnchors", value: function _syncAnchors() { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_RevoluteJoint.prototype), "_syncAnchors", this).call(this); var _this = this._basis; var invM1 = _this.joint._b1._invMass; var invM2 = _this.joint._b2._invMass; var qX; var qY; var qZ; var qW; var idQX; var idQY; var idQZ; var idQW; var slerpQX; var slerpQY; var slerpQZ; var slerpQW; var slerpM00; var slerpM01; var slerpM02; var slerpM10; var slerpM11; var slerpM12; var slerpM20; var slerpM21; var slerpM22; var newXX; var newXY; var newXZ; var newYX; var newYY; var newYZ; var newZX; var newZY; var newZZ; var prevXX; var prevXY; var prevXZ; var prevYX; var prevYY; var prevYZ; var d = _this.joint._basisX1X * _this.joint._basisX2X + _this.joint._basisX1Y * _this.joint._basisX2Y + _this.joint._basisX1Z * _this.joint._basisX2Z; if (d < -0.999999999) { var vX; var vY; var vZ; var _x26 = _this.joint._basisX1X; var _y26 = _this.joint._basisX1Y; var _z25 = _this.joint._basisX1Z; var _x27 = _x26 * _x26; var _y27 = _y26 * _y26; var _z26 = _z25 * _z25; var _d48; if (_x27 < _y27) { if (_x27 < _z26) { _d48 = 1 / Math.sqrt(_y27 + _z26); vX = 0; vY = _z25 * _d48; vZ = -_y26 * _d48; } else { _d48 = 1 / Math.sqrt(_x27 + _y27); vX = _y26 * _d48; vY = -_x26 * _d48; vZ = 0; } } else if (_y27 < _z26) { _d48 = 1 / Math.sqrt(_z26 + _x27); vX = -_z25 * _d48; vY = 0; vZ = _x26 * _d48; } else { _d48 = 1 / Math.sqrt(_x27 + _y27); vX = _y26 * _d48; vY = -_x26 * _d48; vZ = 0; } qX = vX; qY = vY; qZ = vZ; qW = 0; } else { var cX; var cY; var cZ; cX = _this.joint._basisX1Y * _this.joint._basisX2Z - _this.joint._basisX1Z * _this.joint._basisX2Y; cY = _this.joint._basisX1Z * _this.joint._basisX2X - _this.joint._basisX1X * _this.joint._basisX2Z; cZ = _this.joint._basisX1X * _this.joint._basisX2Y - _this.joint._basisX1Y * _this.joint._basisX2X; var _w8 = Math.sqrt((1 + d) * 0.5); d = 0.5 / _w8; cX *= d; cY *= d; cZ *= d; qX = cX; qY = cY; qZ = cZ; qW = _w8; } idQX = 0; idQY = 0; idQZ = 0; idQW = 1; var q1X; var q1Y; var q1Z; var q1W; var q2X; var q2Y; var q2Z; var q2W; q1X = idQX; q1Y = idQY; q1Z = idQZ; q1W = idQW; q2X = qX; q2Y = qY; q2Z = qZ; q2W = qW; var d1 = q1X * q2X + q1Y * q2Y + q1Z * q2Z + q1W * q2W; if (d1 < 0) { d1 = -d1; q2X = -q2X; q2Y = -q2Y; q2Z = -q2Z; q2W = -q2W; } if (d1 > 0.999999) { var dqX; var dqY; var dqZ; var dqW; dqX = q2X - q1X; dqY = q2Y - q1Y; dqZ = q2Z - q1Z; dqW = q2W - q1W; q2X = q1X + dqX * (invM1 / (invM1 + invM2)); q2Y = q1Y + dqY * (invM1 / (invM1 + invM2)); q2Z = q1Z + dqZ * (invM1 / (invM1 + invM2)); q2W = q1W + dqW * (invM1 / (invM1 + invM2)); var _l44 = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W; if (_l44 > 1e-32) { _l44 = 1 / Math.sqrt(_l44); } slerpQX = q2X * _l44; slerpQY = q2Y * _l44; slerpQZ = q2Z * _l44; slerpQW = q2W * _l44; } else { var _theta3 = invM1 / (invM1 + invM2) * Math.acos(d1); q2X += q1X * -d1; q2Y += q1Y * -d1; q2Z += q1Z * -d1; q2W += q1W * -d1; var _l45 = q2X * q2X + q2Y * q2Y + q2Z * q2Z + q2W * q2W; if (_l45 > 1e-32) { _l45 = 1 / Math.sqrt(_l45); } q2X *= _l45; q2Y *= _l45; q2Z *= _l45; q2W *= _l45; var sin = Math.sin(_theta3); var _cos2 = Math.cos(_theta3); q1X *= _cos2; q1Y *= _cos2; q1Z *= _cos2; q1W *= _cos2; slerpQX = q1X + q2X * sin; slerpQY = q1Y + q2Y * sin; slerpQZ = q1Z + q2Z * sin; slerpQW = q1W + q2W * sin; } var x = slerpQX; var y = slerpQY; var z = slerpQZ; var w = slerpQW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; slerpM00 = 1 - yy - zz; slerpM01 = xy - wz; slerpM02 = xz + wy; slerpM10 = xy + wz; slerpM11 = 1 - xx - zz; slerpM12 = yz - wx; slerpM20 = xz - wy; slerpM21 = yz + wx; slerpM22 = 1 - xx - yy; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = slerpM00 * _this.joint._basisX1X + slerpM01 * _this.joint._basisX1Y + slerpM02 * _this.joint._basisX1Z; __tmp__Y = slerpM10 * _this.joint._basisX1X + slerpM11 * _this.joint._basisX1Y + slerpM12 * _this.joint._basisX1Z; __tmp__Z = slerpM20 * _this.joint._basisX1X + slerpM21 * _this.joint._basisX1Y + slerpM22 * _this.joint._basisX1Z; newXX = __tmp__X; newXY = __tmp__Y; newXZ = __tmp__Z; prevXX = _this.xX; prevXY = _this.xY; prevXZ = _this.xZ; prevYX = _this.yX; prevYY = _this.yY; prevYZ = _this.yZ; var d2 = prevXX * newXX + prevXY * newXY + prevXZ * newXZ; if (d2 < -0.999999999) { var _vX3; var _vY3; var _vZ3; var _x28 = prevXX; var _y28 = prevXY; var _z27 = prevXZ; var _x29 = _x28 * _x28; var _y29 = _y28 * _y28; var _z28 = _z27 * _z27; var _d49; if (_x29 < _y29) { if (_x29 < _z28) { _d49 = 1 / Math.sqrt(_y29 + _z28); _vX3 = 0; _vY3 = _z27 * _d49; _vZ3 = -_y28 * _d49; } else { _d49 = 1 / Math.sqrt(_x29 + _y29); _vX3 = _y28 * _d49; _vY3 = -_x28 * _d49; _vZ3 = 0; } } else if (_y29 < _z28) { _d49 = 1 / Math.sqrt(_z28 + _x29); _vX3 = -_z27 * _d49; _vY3 = 0; _vZ3 = _x28 * _d49; } else { _d49 = 1 / Math.sqrt(_x29 + _y29); _vX3 = _y28 * _d49; _vY3 = -_x28 * _d49; _vZ3 = 0; } slerpQX = _vX3; slerpQY = _vY3; slerpQZ = _vZ3; slerpQW = 0; } else { var _cX3; var _cY3; var _cZ3; _cX3 = prevXY * newXZ - prevXZ * newXY; _cY3 = prevXZ * newXX - prevXX * newXZ; _cZ3 = prevXX * newXY - prevXY * newXX; var _w9 = Math.sqrt((1 + d2) * 0.5); d2 = 0.5 / _w9; _cX3 *= d2; _cY3 *= d2; _cZ3 *= d2; slerpQX = _cX3; slerpQY = _cY3; slerpQZ = _cZ3; slerpQW = _w9; } var x1 = slerpQX; var y1 = slerpQY; var z1 = slerpQZ; var w1 = slerpQW; var x21 = 2 * x1; var y21 = 2 * y1; var z21 = 2 * z1; var xx1 = x1 * x21; var yy1 = y1 * y21; var zz1 = z1 * z21; var xy1 = x1 * y21; var yz1 = y1 * z21; var xz1 = x1 * z21; var wx1 = w1 * x21; var wy1 = w1 * y21; var wz1 = w1 * z21; slerpM00 = 1 - yy1 - zz1; slerpM01 = xy1 - wz1; slerpM02 = xz1 + wy1; slerpM10 = xy1 + wz1; slerpM11 = 1 - xx1 - zz1; slerpM12 = yz1 - wx1; slerpM20 = xz1 - wy1; slerpM21 = yz1 + wx1; slerpM22 = 1 - xx1 - yy1; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = slerpM00 * prevYX + slerpM01 * prevYY + slerpM02 * prevYZ; __tmp__Y1 = slerpM10 * prevYX + slerpM11 * prevYY + slerpM12 * prevYZ; __tmp__Z1 = slerpM20 * prevYX + slerpM21 * prevYY + slerpM22 * prevYZ; newYX = __tmp__X1; newYY = __tmp__Y1; newYZ = __tmp__Z1; newZX = newXY * newYZ - newXZ * newYY; newZY = newXZ * newYX - newXX * newYZ; newZZ = newXX * newYY - newXY * newYX; if (newZX * newZX + newZY * newZY + newZZ * newZZ > 1e-6) { var _l46 = newZX * newZX + newZY * newZY + newZZ * newZZ; if (_l46 > 0) { _l46 = 1 / Math.sqrt(_l46); } newZX *= _l46; newZY *= _l46; newZZ *= _l46; } else { var _x30 = newXX; var _y30 = newXY; var _z29 = newXZ; var _x31 = _x30 * _x30; var _y31 = _y30 * _y30; var _z30 = _z29 * _z29; var _d50; if (_x31 < _y31) { if (_x31 < _z30) { _d50 = 1 / Math.sqrt(_y31 + _z30); newZX = 0; newZY = _z29 * _d50; newZZ = -_y30 * _d50; } else { _d50 = 1 / Math.sqrt(_x31 + _y31); newZX = _y30 * _d50; newZY = -_x30 * _d50; newZZ = 0; } } else if (_y31 < _z30) { _d50 = 1 / Math.sqrt(_z30 + _x31); newZX = -_z29 * _d50; newZY = 0; newZZ = _x30 * _d50; } else { _d50 = 1 / Math.sqrt(_x31 + _y31); newZX = _y30 * _d50; newZY = -_x30 * _d50; newZZ = 0; } } newYX = newZY * newXZ - newZZ * newXY; newYY = newZZ * newXX - newZX * newXZ; newYZ = newZX * newXY - newZY * newXX; _this.xX = newXX; _this.xY = newXY; _this.xZ = newXZ; _this.yX = newYX; _this.yY = newYY; _this.yZ = newYZ; _this.zX = newZX; _this.zY = newZY; _this.zZ = newZZ; var angErrorX; var angErrorY; var angErrorZ; angErrorX = this._basisX1Y * this._basisX2Z - this._basisX1Z * this._basisX2Y; angErrorY = this._basisX1Z * this._basisX2X - this._basisX1X * this._basisX2Z; angErrorZ = this._basisX1X * this._basisX2Y - this._basisX1Y * this._basisX2X; var cos = this._basisX1X * this._basisX2X + this._basisX1Y * this._basisX2Y + this._basisX1Z * this._basisX2Z; var theta = cos <= -1 ? 3.14159265358979 : cos >= 1 ? 0 : Math.acos(cos); var l = angErrorX * angErrorX + angErrorY * angErrorY + angErrorZ * angErrorZ; if (l > 0) { l = 1 / Math.sqrt(l); } angErrorX *= l; angErrorY *= l; angErrorZ *= l; angErrorX *= theta; angErrorY *= theta; angErrorZ *= theta; this.angularErrorY = angErrorX * this._basis.yX + angErrorY * this._basis.yY + angErrorZ * this._basis.yZ; this.angularErrorZ = angErrorX * this._basis.zX + angErrorY * this._basis.zY + angErrorZ * this._basis.zZ; var perpCrossX; var perpCrossY; var perpCrossZ; perpCrossX = this._basisY1Y * this._basisY2Z - this._basisY1Z * this._basisY2Y; perpCrossY = this._basisY1Z * this._basisY2X - this._basisY1X * this._basisY2Z; perpCrossZ = this._basisY1X * this._basisY2Y - this._basisY1Y * this._basisY2X; cos = this._basisY1X * this._basisY2X + this._basisY1Y * this._basisY2Y + this._basisY1Z * this._basisY2Z; this.angle = cos <= -1 ? 3.14159265358979 : cos >= 1 ? 0 : Math.acos(cos); if (perpCrossX * this._basis.xX + perpCrossY * this._basis.xY + perpCrossZ * this._basis.xZ < 0) { this.angle = -this.angle; } this.linearErrorX = this._anchor2X - this._anchor1X; this.linearErrorY = this._anchor2Y - this._anchor1Y; this.linearErrorZ = this._anchor2Z - this._anchor1Z; } }, { key: "_getVelocitySolverInfo", value: function _getVelocitySolverInfo(timeStep, info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_RevoluteJoint.prototype), "_getVelocitySolverInfo", this).call(this, timeStep, info); this.getInfo(info, timeStep, false); } }, { key: "_getPositionSolverInfo", value: function _getPositionSolverInfo(info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_RevoluteJoint.prototype), "_getPositionSolverInfo", this).call(this, info); this.getInfo(info, null, true); } }, { key: "getAxis1", value: function getAxis1() { var v = new oimo.common.Vec3(); v.x = this._basisX1X; v.y = this._basisX1Y; v.z = this._basisX1Z; return v; } }, { key: "getAxis2", value: function getAxis2() { var v = new oimo.common.Vec3(); v.x = this._basisX2X; v.y = this._basisX2Y; v.z = this._basisX2Z; return v; } }, { key: "getAxis1To", value: function getAxis1To(axis) { axis.x = this._basisX1X; axis.y = this._basisX1Y; axis.z = this._basisX1Z; } }, { key: "getAxis2To", value: function getAxis2To(axis) { axis.x = this._basisX2X; axis.y = this._basisX2Y; axis.z = this._basisX2Z; } }, { key: "getLocalAxis1", value: function getLocalAxis1() { var v = new oimo.common.Vec3(); v.x = this._localBasisX1X; v.y = this._localBasisX1Y; v.z = this._localBasisX1Z; return v; } }, { key: "getLocalAxis2", value: function getLocalAxis2() { var v = new oimo.common.Vec3(); v.x = this._localBasisX2X; v.y = this._localBasisX2Y; v.z = this._localBasisX2Z; return v; } }, { key: "getLocalAxis1To", value: function getLocalAxis1To(axis) { axis.x = this._localBasisX1X; axis.y = this._localBasisX1Y; axis.z = this._localBasisX1Z; } }, { key: "getLocalAxis2To", value: function getLocalAxis2To(axis) { axis.x = this._localBasisX2X; axis.y = this._localBasisX2Y; axis.z = this._localBasisX2Z; } }, { key: "getSpringDamper", value: function getSpringDamper() { return this._sd; } }, { key: "getLimitMotor", value: function getLimitMotor() { return this._lm; } }, { key: "getAngle", value: function getAngle() { return this.angle; } }]); return oimo_dynamics_constraint_joint_RevoluteJoint; }(oimo.dynamics.constraint.joint.Joint); oimo.dynamics.constraint.joint.RevoluteJointConfig = /*#__PURE__*/function (_oimo$dynamics$constr10) { _inherits(oimo_dynamics_constraint_joint_RevoluteJointConfig, _oimo$dynamics$constr10); var _super32 = _createSuper(oimo_dynamics_constraint_joint_RevoluteJointConfig); function oimo_dynamics_constraint_joint_RevoluteJointConfig() { var _this236; _classCallCheck(this, oimo_dynamics_constraint_joint_RevoluteJointConfig); _this236 = _super32.call(this); _this236.localAxis1 = new oimo.common.Vec3(1, 0, 0); _this236.localAxis2 = new oimo.common.Vec3(1, 0, 0); _this236.springDamper = new oimo.dynamics.constraint.joint.SpringDamper(); _this236.limitMotor = new oimo.dynamics.constraint.joint.RotationalLimitMotor(); return _this236; } _createClass(oimo_dynamics_constraint_joint_RevoluteJointConfig, [{ key: "init", value: function init(rigidBody1, rigidBody2, worldAnchor, worldAxis) { this._init(rigidBody1, rigidBody2, worldAnchor); var localVector = this.localAxis1; var vX; var vY; var vZ; vX = worldAxis.x; vY = worldAxis.y; vZ = worldAxis.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = rigidBody1._transform._rotation00 * vX + rigidBody1._transform._rotation10 * vY + rigidBody1._transform._rotation20 * vZ; __tmp__Y = rigidBody1._transform._rotation01 * vX + rigidBody1._transform._rotation11 * vY + rigidBody1._transform._rotation21 * vZ; __tmp__Z = rigidBody1._transform._rotation02 * vX + rigidBody1._transform._rotation12 * vY + rigidBody1._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; localVector.x = vX; localVector.y = vY; localVector.z = vZ; var localVector1 = this.localAxis2; var vX1; var vY1; var vZ1; vX1 = worldAxis.x; vY1 = worldAxis.y; vZ1 = worldAxis.z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = rigidBody2._transform._rotation00 * vX1 + rigidBody2._transform._rotation10 * vY1 + rigidBody2._transform._rotation20 * vZ1; __tmp__Y1 = rigidBody2._transform._rotation01 * vX1 + rigidBody2._transform._rotation11 * vY1 + rigidBody2._transform._rotation21 * vZ1; __tmp__Z1 = rigidBody2._transform._rotation02 * vX1 + rigidBody2._transform._rotation12 * vY1 + rigidBody2._transform._rotation22 * vZ1; vX1 = __tmp__X1; vY1 = __tmp__Y1; vZ1 = __tmp__Z1; localVector1.x = vX1; localVector1.y = vY1; localVector1.z = vZ1; return this; } }]); return oimo_dynamics_constraint_joint_RevoluteJointConfig; }(oimo.dynamics.constraint.joint.JointConfig); oimo.dynamics.constraint.joint.RotationalLimitMotor = /*#__PURE__*/function () { function oimo_dynamics_constraint_joint_RotationalLimitMotor() { _classCallCheck(this, oimo_dynamics_constraint_joint_RotationalLimitMotor); this.lowerLimit = 1; this.upperLimit = 0; this.motorTorque = 0; } _createClass(oimo_dynamics_constraint_joint_RotationalLimitMotor, [{ key: "setLimits", value: function setLimits(lower, upper) { this.lowerLimit = lower; this.upperLimit = upper; return this; } }, { key: "setMotor", value: function setMotor(speed, torque) { this.motorSpeed = speed; this.motorTorque = torque; return this; } }, { key: "clone", value: function clone() { var lm = new oimo.dynamics.constraint.joint.RotationalLimitMotor(); lm.lowerLimit = this.lowerLimit; lm.upperLimit = this.upperLimit; lm.motorSpeed = this.motorSpeed; lm.motorTorque = this.motorTorque; return lm; } }]); return oimo_dynamics_constraint_joint_RotationalLimitMotor; }(); oimo.dynamics.constraint.joint.SphericalJoint = /*#__PURE__*/function (_oimo$dynamics$constr11) { _inherits(oimo_dynamics_constraint_joint_SphericalJoint, _oimo$dynamics$constr11); var _super33 = _createSuper(oimo_dynamics_constraint_joint_SphericalJoint); function oimo_dynamics_constraint_joint_SphericalJoint(config) { var _this237; _classCallCheck(this, oimo_dynamics_constraint_joint_SphericalJoint); _this237 = _super33.call(this, config, 0); _this237._sd = config.springDamper.clone(); return _this237; } _createClass(oimo_dynamics_constraint_joint_SphericalJoint, [{ key: "getInfo", value: function getInfo(info, timeStep, isPositionPart) { if (this._sd.frequency > 0 && isPositionPart) { return; } var errorX; var errorY; var errorZ; errorX = this._anchor2X - this._anchor1X; errorY = this._anchor2Y - this._anchor1Y; errorZ = this._anchor2Z - this._anchor1Z; var cfm; var erp; if (this._sd.frequency > 0) { var omega = 6.28318530717958 * this._sd.frequency; var zeta = this._sd.dampingRatio; if (zeta < oimo.common.Setting.minSpringDamperDampingRatio) { zeta = oimo.common.Setting.minSpringDamperDampingRatio; } var h = timeStep.dt; var c = 2 * zeta * omega; var k = omega * omega; if (this._sd.useSymplecticEuler) { cfm = 1 / (h * c); erp = k / c; } else { cfm = 1 / (h * (h * k + c)); erp = k / (h * k + c); } cfm *= this._b1._invMass + this._b2._invMass; } else { cfm = 0; erp = this.getErp(timeStep, isPositionPart); } var linearRhsX; var linearRhsY; var linearRhsZ; linearRhsX = errorX * erp; linearRhsY = errorY * erp; linearRhsZ = errorZ * erp; var crossR100; var crossR101; var crossR102; var crossR110; var crossR111; var crossR112; var crossR120; var crossR121; var crossR122; var crossR200; var crossR201; var crossR202; var crossR210; var crossR211; var crossR212; var crossR220; var crossR221; var crossR222; crossR100 = 0; crossR101 = -this._relativeAnchor1Z; crossR102 = this._relativeAnchor1Y; crossR110 = this._relativeAnchor1Z; crossR111 = 0; crossR112 = -this._relativeAnchor1X; crossR120 = -this._relativeAnchor1Y; crossR121 = this._relativeAnchor1X; crossR122 = 0; crossR200 = 0; crossR201 = -this._relativeAnchor2Z; crossR202 = this._relativeAnchor2Y; crossR210 = this._relativeAnchor2Z; crossR211 = 0; crossR212 = -this._relativeAnchor2X; crossR220 = -this._relativeAnchor2Y; crossR221 = this._relativeAnchor2X; crossR222 = 0; crossR100 = -crossR100; crossR101 = -crossR101; crossR102 = -crossR102; crossR110 = -crossR110; crossR111 = -crossR111; crossR112 = -crossR112; crossR120 = -crossR120; crossR121 = -crossR121; crossR122 = -crossR122; crossR200 = -crossR200; crossR201 = -crossR201; crossR202 = -crossR202; crossR210 = -crossR210; crossR211 = -crossR211; crossR212 = -crossR212; crossR220 = -crossR220; crossR221 = -crossR221; crossR222 = -crossR222; var impulse = this._impulses[0]; var row = info.rows[info.numRows++]; var _this = row.jacobian; _this.lin1X = 0; _this.lin1Y = 0; _this.lin1Z = 0; _this.lin2X = 0; _this.lin2Y = 0; _this.lin2Z = 0; _this.ang1X = 0; _this.ang1Y = 0; _this.ang1Z = 0; _this.ang2X = 0; _this.ang2Y = 0; _this.ang2Z = 0; row.rhs = 0; row.cfm = 0; row.minImpulse = 0; row.maxImpulse = 0; row.motorSpeed = 0; row.motorMaxImpulse = 0; row.impulse = null; row.impulse = impulse; row.rhs = linearRhsX; row.cfm = cfm; row.minImpulse = -1e65536; row.maxImpulse = 1e65536; var j = row.jacobian; j.lin1X = 1; j.lin1Y = 0; j.lin1Z = 0; j.lin2X = 1; j.lin2Y = 0; j.lin2Z = 0; j.ang1X = crossR100; j.ang1Y = crossR101; j.ang1Z = crossR102; j.ang2X = crossR200; j.ang2Y = crossR201; j.ang2Z = crossR202; var impulse1 = this._impulses[1]; var row1 = info.rows[info.numRows++]; var _this1 = row1.jacobian; _this1.lin1X = 0; _this1.lin1Y = 0; _this1.lin1Z = 0; _this1.lin2X = 0; _this1.lin2Y = 0; _this1.lin2Z = 0; _this1.ang1X = 0; _this1.ang1Y = 0; _this1.ang1Z = 0; _this1.ang2X = 0; _this1.ang2Y = 0; _this1.ang2Z = 0; row1.rhs = 0; row1.cfm = 0; row1.minImpulse = 0; row1.maxImpulse = 0; row1.motorSpeed = 0; row1.motorMaxImpulse = 0; row1.impulse = null; row1.impulse = impulse1; row1.rhs = linearRhsY; row1.cfm = cfm; row1.minImpulse = -1e65536; row1.maxImpulse = 1e65536; j = row1.jacobian; j.lin1X = 0; j.lin1Y = 1; j.lin1Z = 0; j.lin2X = 0; j.lin2Y = 1; j.lin2Z = 0; j.ang1X = crossR110; j.ang1Y = crossR111; j.ang1Z = crossR112; j.ang2X = crossR210; j.ang2Y = crossR211; j.ang2Z = crossR212; var impulse2 = this._impulses[2]; var row2 = info.rows[info.numRows++]; var _this2 = row2.jacobian; _this2.lin1X = 0; _this2.lin1Y = 0; _this2.lin1Z = 0; _this2.lin2X = 0; _this2.lin2Y = 0; _this2.lin2Z = 0; _this2.ang1X = 0; _this2.ang1Y = 0; _this2.ang1Z = 0; _this2.ang2X = 0; _this2.ang2Y = 0; _this2.ang2Z = 0; row2.rhs = 0; row2.cfm = 0; row2.minImpulse = 0; row2.maxImpulse = 0; row2.motorSpeed = 0; row2.motorMaxImpulse = 0; row2.impulse = null; row2.impulse = impulse2; row2.rhs = linearRhsZ; row2.cfm = cfm; row2.minImpulse = -1e65536; row2.maxImpulse = 1e65536; j = row2.jacobian; j.lin1X = 0; j.lin1Y = 0; j.lin1Z = 1; j.lin2X = 0; j.lin2Y = 0; j.lin2Z = 1; j.ang1X = crossR120; j.ang1Y = crossR121; j.ang1Z = crossR122; j.ang2X = crossR220; j.ang2Y = crossR221; j.ang2Z = crossR222; } }, { key: "_getVelocitySolverInfo", value: function _getVelocitySolverInfo(timeStep, info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_SphericalJoint.prototype), "_getVelocitySolverInfo", this).call(this, timeStep, info); this.getInfo(info, timeStep, false); } }, { key: "_getPositionSolverInfo", value: function _getPositionSolverInfo(info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_SphericalJoint.prototype), "_getPositionSolverInfo", this).call(this, info); this.getInfo(info, null, true); } }, { key: "getSpringDamper", value: function getSpringDamper() { return this._sd; } }]); return oimo_dynamics_constraint_joint_SphericalJoint; }(oimo.dynamics.constraint.joint.Joint); oimo.dynamics.constraint.joint.SphericalJointConfig = /*#__PURE__*/function (_oimo$dynamics$constr12) { _inherits(oimo_dynamics_constraint_joint_SphericalJointConfig, _oimo$dynamics$constr12); var _super34 = _createSuper(oimo_dynamics_constraint_joint_SphericalJointConfig); function oimo_dynamics_constraint_joint_SphericalJointConfig() { var _this238; _classCallCheck(this, oimo_dynamics_constraint_joint_SphericalJointConfig); _this238 = _super34.call(this); _this238.springDamper = new oimo.dynamics.constraint.joint.SpringDamper(); return _this238; } _createClass(oimo_dynamics_constraint_joint_SphericalJointConfig, [{ key: "init", value: function init(rigidBody1, rigidBody2, worldAnchor) { this._init(rigidBody1, rigidBody2, worldAnchor); return this; } }]); return oimo_dynamics_constraint_joint_SphericalJointConfig; }(oimo.dynamics.constraint.joint.JointConfig); oimo.dynamics.constraint.joint.SpringDamper = /*#__PURE__*/function () { function oimo_dynamics_constraint_joint_SpringDamper() { _classCallCheck(this, oimo_dynamics_constraint_joint_SpringDamper); this.frequency = 0; this.dampingRatio = 0; this.useSymplecticEuler = false; } _createClass(oimo_dynamics_constraint_joint_SpringDamper, [{ key: "setSpring", value: function setSpring(frequency, dampingRatio) { this.frequency = frequency; this.dampingRatio = dampingRatio; return this; } }, { key: "setSymplecticEuler", value: function setSymplecticEuler(useSymplecticEuler) { this.useSymplecticEuler = useSymplecticEuler; return this; } }, { key: "clone", value: function clone() { var sd = new oimo.dynamics.constraint.joint.SpringDamper(); sd.frequency = this.frequency; sd.dampingRatio = this.dampingRatio; sd.useSymplecticEuler = this.useSymplecticEuler; return sd; } }]); return oimo_dynamics_constraint_joint_SpringDamper; }(); oimo.dynamics.constraint.joint.TranslationalLimitMotor = /*#__PURE__*/function () { function oimo_dynamics_constraint_joint_TranslationalLimitMotor() { _classCallCheck(this, oimo_dynamics_constraint_joint_TranslationalLimitMotor); this.lowerLimit = 1; this.upperLimit = 0; this.motorForce = 0; } _createClass(oimo_dynamics_constraint_joint_TranslationalLimitMotor, [{ key: "setLimits", value: function setLimits(lower, upper) { this.lowerLimit = lower; this.upperLimit = upper; return this; } }, { key: "setMotor", value: function setMotor(speed, force) { this.motorSpeed = speed; this.motorForce = force; return this; } }, { key: "clone", value: function clone() { var lm = new oimo.dynamics.constraint.joint.TranslationalLimitMotor(); lm.lowerLimit = this.lowerLimit; lm.upperLimit = this.upperLimit; lm.motorSpeed = this.motorSpeed; lm.motorForce = this.motorForce; return lm; } }]); return oimo_dynamics_constraint_joint_TranslationalLimitMotor; }(); oimo.dynamics.constraint.joint.UniversalJoint = /*#__PURE__*/function (_oimo$dynamics$constr13) { _inherits(oimo_dynamics_constraint_joint_UniversalJoint, _oimo$dynamics$constr13); var _super35 = _createSuper(oimo_dynamics_constraint_joint_UniversalJoint); function oimo_dynamics_constraint_joint_UniversalJoint(config) { var _this239; _classCallCheck(this, oimo_dynamics_constraint_joint_UniversalJoint); _this239 = _super35.call(this, config, oimo.dynamics.constraint.joint.JointType.UNIVERSAL); var v = config.localAxis1; _this239._localBasisX1X = v.x; _this239._localBasisX1Y = v.y; _this239._localBasisX1Z = v.z; var v1 = config.localAxis2; _this239._localBasisZ2X = v1.x; _this239._localBasisZ2Y = v1.y; _this239._localBasisZ2Z = v1.z; _this239.buildLocalBasesFromX1Z2(); _this239._angleX = 0; _this239._angleY = 0; _this239._angleZ = 0; _this239.xSingular = false; _this239.ySingular = false; _this239.zSingular = false; _this239._sd1 = config.springDamper1.clone(); _this239._sd2 = config.springDamper2.clone(); _this239._lm1 = config.limitMotor1.clone(); _this239._lm2 = config.limitMotor2.clone(); return _this239; } _createClass(oimo_dynamics_constraint_joint_UniversalJoint, [{ key: "getInfo", value: function getInfo(info, timeStep, isPositionPart) { var erp = this.getErp(timeStep, isPositionPart); var linearRhsX; var linearRhsY; var linearRhsZ; linearRhsX = this.linearErrorX * erp; linearRhsY = this.linearErrorY * erp; linearRhsZ = this.linearErrorZ * erp; var angRhsY = this._angleY * erp; var crossR100; var crossR101; var crossR102; var crossR110; var crossR111; var crossR112; var crossR120; var crossR121; var crossR122; var crossR200; var crossR201; var crossR202; var crossR210; var crossR211; var crossR212; var crossR220; var crossR221; var crossR222; crossR100 = 0; crossR101 = -this._relativeAnchor1Z; crossR102 = this._relativeAnchor1Y; crossR110 = this._relativeAnchor1Z; crossR111 = 0; crossR112 = -this._relativeAnchor1X; crossR120 = -this._relativeAnchor1Y; crossR121 = this._relativeAnchor1X; crossR122 = 0; crossR200 = 0; crossR201 = -this._relativeAnchor2Z; crossR202 = this._relativeAnchor2Y; crossR210 = this._relativeAnchor2Z; crossR211 = 0; crossR212 = -this._relativeAnchor2X; crossR220 = -this._relativeAnchor2Y; crossR221 = this._relativeAnchor2X; crossR222 = 0; crossR100 = -crossR100; crossR101 = -crossR101; crossR102 = -crossR102; crossR110 = -crossR110; crossR111 = -crossR111; crossR112 = -crossR112; crossR120 = -crossR120; crossR121 = -crossR121; crossR122 = -crossR122; crossR200 = -crossR200; crossR201 = -crossR201; crossR202 = -crossR202; crossR210 = -crossR210; crossR211 = -crossR211; crossR212 = -crossR212; crossR220 = -crossR220; crossR221 = -crossR221; crossR222 = -crossR222; var motorMassX = this.computeEffectiveInertiaMoment(this._axisXX, this._axisXY, this._axisXZ); var motorMassZ = this.computeEffectiveInertiaMoment(this._axisZX, this._axisZY, this._axisZZ); var impulse = this._impulses[0]; var row = info.rows[info.numRows++]; var _this = row.jacobian; _this.lin1X = 0; _this.lin1Y = 0; _this.lin1Z = 0; _this.lin2X = 0; _this.lin2Y = 0; _this.lin2Z = 0; _this.ang1X = 0; _this.ang1Y = 0; _this.ang1Z = 0; _this.ang2X = 0; _this.ang2Y = 0; _this.ang2Z = 0; row.rhs = 0; row.cfm = 0; row.minImpulse = 0; row.maxImpulse = 0; row.motorSpeed = 0; row.motorMaxImpulse = 0; row.impulse = null; row.impulse = impulse; row.rhs = linearRhsX; row.cfm = 0; row.minImpulse = -1e65536; row.maxImpulse = 1e65536; var j = row.jacobian; j.lin1X = 1; j.lin1Y = 0; j.lin1Z = 0; j.lin2X = 1; j.lin2Y = 0; j.lin2Z = 0; j.ang1X = crossR100; j.ang1Y = crossR101; j.ang1Z = crossR102; j.ang2X = crossR200; j.ang2Y = crossR201; j.ang2Z = crossR202; var impulse1 = this._impulses[1]; var row1 = info.rows[info.numRows++]; var _this1 = row1.jacobian; _this1.lin1X = 0; _this1.lin1Y = 0; _this1.lin1Z = 0; _this1.lin2X = 0; _this1.lin2Y = 0; _this1.lin2Z = 0; _this1.ang1X = 0; _this1.ang1Y = 0; _this1.ang1Z = 0; _this1.ang2X = 0; _this1.ang2Y = 0; _this1.ang2Z = 0; row1.rhs = 0; row1.cfm = 0; row1.minImpulse = 0; row1.maxImpulse = 0; row1.motorSpeed = 0; row1.motorMaxImpulse = 0; row1.impulse = null; row1.impulse = impulse1; row1.rhs = linearRhsY; row1.cfm = 0; row1.minImpulse = -1e65536; row1.maxImpulse = 1e65536; j = row1.jacobian; j.lin1X = 0; j.lin1Y = 1; j.lin1Z = 0; j.lin2X = 0; j.lin2Y = 1; j.lin2Z = 0; j.ang1X = crossR110; j.ang1Y = crossR111; j.ang1Z = crossR112; j.ang2X = crossR210; j.ang2Y = crossR211; j.ang2Z = crossR212; var impulse2 = this._impulses[2]; var row2 = info.rows[info.numRows++]; var _this2 = row2.jacobian; _this2.lin1X = 0; _this2.lin1Y = 0; _this2.lin1Z = 0; _this2.lin2X = 0; _this2.lin2Y = 0; _this2.lin2Z = 0; _this2.ang1X = 0; _this2.ang1Y = 0; _this2.ang1Z = 0; _this2.ang2X = 0; _this2.ang2Y = 0; _this2.ang2Z = 0; row2.rhs = 0; row2.cfm = 0; row2.minImpulse = 0; row2.maxImpulse = 0; row2.motorSpeed = 0; row2.motorMaxImpulse = 0; row2.impulse = null; row2.impulse = impulse2; row2.rhs = linearRhsZ; row2.cfm = 0; row2.minImpulse = -1e65536; row2.maxImpulse = 1e65536; j = row2.jacobian; j.lin1X = 0; j.lin1Y = 0; j.lin1Z = 1; j.lin2X = 0; j.lin2Y = 0; j.lin2Z = 1; j.ang1X = crossR120; j.ang1Y = crossR121; j.ang1Z = crossR122; j.ang2X = crossR220; j.ang2Y = crossR221; j.ang2Z = crossR222; if (!this.xSingular && (this._sd1.frequency <= 0 || !isPositionPart)) { var _impulse12 = this._impulses[3]; var _row12 = info.rows[info.numRows++]; var _this240 = _row12.jacobian; _this240.lin1X = 0; _this240.lin1Y = 0; _this240.lin1Z = 0; _this240.lin2X = 0; _this240.lin2Y = 0; _this240.lin2Z = 0; _this240.ang1X = 0; _this240.ang1Y = 0; _this240.ang1Z = 0; _this240.ang2X = 0; _this240.ang2Y = 0; _this240.ang2Z = 0; _row12.rhs = 0; _row12.cfm = 0; _row12.minImpulse = 0; _row12.maxImpulse = 0; _row12.motorSpeed = 0; _row12.motorMaxImpulse = 0; _row12.impulse = null; _row12.impulse = _impulse12; this.setSolverInfoRowAngular(_row12, this._angleX, this._lm1, motorMassX, this._sd1, timeStep, isPositionPart); j = _row12.jacobian; j.ang1X = this._axisXX; j.ang1Y = this._axisXY; j.ang1Z = this._axisXZ; j.ang2X = this._axisXX; j.ang2Y = this._axisXY; j.ang2Z = this._axisXZ; } if (!this.ySingular) { var _impulse13 = this._impulses[4]; var _row13 = info.rows[info.numRows++]; var _this241 = _row13.jacobian; _this241.lin1X = 0; _this241.lin1Y = 0; _this241.lin1Z = 0; _this241.lin2X = 0; _this241.lin2Y = 0; _this241.lin2Z = 0; _this241.ang1X = 0; _this241.ang1Y = 0; _this241.ang1Z = 0; _this241.ang2X = 0; _this241.ang2Y = 0; _this241.ang2Z = 0; _row13.rhs = 0; _row13.cfm = 0; _row13.minImpulse = 0; _row13.maxImpulse = 0; _row13.motorSpeed = 0; _row13.motorMaxImpulse = 0; _row13.impulse = null; _row13.impulse = _impulse13; _row13.rhs = angRhsY; _row13.cfm = 0; _row13.minImpulse = -1e65536; _row13.maxImpulse = 1e65536; j = _row13.jacobian; j.ang1X = this._axisYX; j.ang1Y = this._axisYY; j.ang1Z = this._axisYZ; j.ang2X = this._axisYX; j.ang2Y = this._axisYY; j.ang2Z = this._axisYZ; } if (!this.zSingular && (this._sd2.frequency <= 0 || !isPositionPart)) { var _impulse14 = this._impulses[5]; var _row14 = info.rows[info.numRows++]; var _this242 = _row14.jacobian; _this242.lin1X = 0; _this242.lin1Y = 0; _this242.lin1Z = 0; _this242.lin2X = 0; _this242.lin2Y = 0; _this242.lin2Z = 0; _this242.ang1X = 0; _this242.ang1Y = 0; _this242.ang1Z = 0; _this242.ang2X = 0; _this242.ang2Y = 0; _this242.ang2Z = 0; _row14.rhs = 0; _row14.cfm = 0; _row14.minImpulse = 0; _row14.maxImpulse = 0; _row14.motorSpeed = 0; _row14.motorMaxImpulse = 0; _row14.impulse = null; _row14.impulse = _impulse14; this.setSolverInfoRowAngular(_row14, this._angleZ, this._lm2, motorMassZ, this._sd2, timeStep, isPositionPart); j = _row14.jacobian; j.ang1X = this._axisZX; j.ang1Y = this._axisZY; j.ang1Z = this._axisZZ; j.ang2X = this._axisZX; j.ang2Y = this._axisZY; j.ang2Z = this._axisZZ; } } }, { key: "_syncAnchors", value: function _syncAnchors() { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_UniversalJoint.prototype), "_syncAnchors", this).call(this); var angleAxisXX; var angleAxisXY; var angleAxisXZ; var angleAxisYX; var angleAxisYY; var angleAxisYZ; var angleAxisZX; var angleAxisZY; var angleAxisZZ; angleAxisXX = this._basisX1X; angleAxisXY = this._basisX1Y; angleAxisXZ = this._basisX1Z; angleAxisZX = this._basisZ2X; angleAxisZY = this._basisZ2Y; angleAxisZZ = this._basisZ2Z; angleAxisYX = angleAxisZY * angleAxisXZ - angleAxisZZ * angleAxisXY; angleAxisYY = angleAxisZZ * angleAxisXX - angleAxisZX * angleAxisXZ; angleAxisYZ = angleAxisZX * angleAxisXY - angleAxisZY * angleAxisXX; this._axisXX = angleAxisYY * angleAxisZZ - angleAxisYZ * angleAxisZY; this._axisXY = angleAxisYZ * angleAxisZX - angleAxisYX * angleAxisZZ; this._axisXZ = angleAxisYX * angleAxisZY - angleAxisYY * angleAxisZX; this._axisYX = angleAxisYX; this._axisYY = angleAxisYY; this._axisYZ = angleAxisYZ; this._axisZX = angleAxisXY * angleAxisYZ - angleAxisXZ * angleAxisYY; this._axisZY = angleAxisXZ * angleAxisYX - angleAxisXX * angleAxisYZ; this._axisZZ = angleAxisXX * angleAxisYY - angleAxisXY * angleAxisYX; var l = this._axisXX * this._axisXX + this._axisXY * this._axisXY + this._axisXZ * this._axisXZ; if (l > 0) { l = 1 / Math.sqrt(l); } this._axisXX *= l; this._axisXY *= l; this._axisXZ *= l; var l1 = this._axisYX * this._axisYX + this._axisYY * this._axisYY + this._axisYZ * this._axisYZ; if (l1 > 0) { l1 = 1 / Math.sqrt(l1); } this._axisYX *= l1; this._axisYY *= l1; this._axisYZ *= l1; var l2 = this._axisZX * this._axisZX + this._axisZY * this._axisZY + this._axisZZ * this._axisZZ; if (l2 > 0) { l2 = 1 / Math.sqrt(l2); } this._axisZX *= l2; this._axisZY *= l2; this._axisZZ *= l2; this.xSingular = this._axisXX * this._axisXX + this._axisXY * this._axisXY + this._axisXZ * this._axisXZ == 0; this.ySingular = this._axisYX * this._axisYX + this._axisYY * this._axisYY + this._axisYZ * this._axisYZ == 0; this.zSingular = this._axisZX * this._axisZX + this._axisZY * this._axisZY + this._axisZZ * this._axisZZ == 0; var rot100; var rot101; var rot102; var rot110; var rot111; var rot112; var rot120; var rot121; var rot122; var rot200; var rot201; var rot202; var rot210; var rot211; var rot212; var rot220; var rot221; var rot222; rot100 = this._basisX1X; rot101 = this._basisY1X; rot102 = this._basisZ1X; rot110 = this._basisX1Y; rot111 = this._basisY1Y; rot112 = this._basisZ1Y; rot120 = this._basisX1Z; rot121 = this._basisY1Z; rot122 = this._basisZ1Z; rot200 = this._basisX2X; rot201 = this._basisY2X; rot202 = this._basisZ2X; rot210 = this._basisX2Y; rot211 = this._basisY2Y; rot212 = this._basisZ2Y; rot220 = this._basisX2Z; rot221 = this._basisY2Z; rot222 = this._basisZ2Z; var relRot00; var relRot01; var relRot02; var relRot11; var relRot12; var relRot21; var relRot22; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__11; var __tmp__12; var __tmp__21; var __tmp__22; __tmp__00 = rot100 * rot200 + rot110 * rot210 + rot120 * rot220; __tmp__01 = rot100 * rot201 + rot110 * rot211 + rot120 * rot221; __tmp__02 = rot100 * rot202 + rot110 * rot212 + rot120 * rot222; __tmp__11 = rot101 * rot201 + rot111 * rot211 + rot121 * rot221; __tmp__12 = rot101 * rot202 + rot111 * rot212 + rot121 * rot222; __tmp__21 = rot102 * rot201 + rot112 * rot211 + rot122 * rot221; __tmp__22 = rot102 * rot202 + rot112 * rot212 + rot122 * rot222; relRot00 = __tmp__00; relRot01 = __tmp__01; relRot02 = __tmp__02; relRot11 = __tmp__11; relRot12 = __tmp__12; relRot21 = __tmp__21; relRot22 = __tmp__22; var anglesX; var anglesY; var anglesZ; var sy = relRot02; if (sy <= -1) { var xSubZ = Math.atan2(relRot21, relRot11); anglesX = xSubZ * 0.5; anglesY = -1.570796326794895; anglesZ = -xSubZ * 0.5; } else if (sy >= 1) { var xAddZ = Math.atan2(relRot21, relRot11); anglesX = xAddZ * 0.5; anglesY = 1.570796326794895; anglesZ = xAddZ * 0.5; } else { anglesX = Math.atan2(-relRot12, relRot22); anglesY = Math.asin(sy); anglesZ = Math.atan2(-relRot01, relRot00); } this._angleX = anglesX; this._angleY = anglesY; this._angleZ = anglesZ; this.linearErrorX = this._anchor2X - this._anchor1X; this.linearErrorY = this._anchor2Y - this._anchor1Y; this.linearErrorZ = this._anchor2Z - this._anchor1Z; } }, { key: "_getVelocitySolverInfo", value: function _getVelocitySolverInfo(timeStep, info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_UniversalJoint.prototype), "_getVelocitySolverInfo", this).call(this, timeStep, info); this.getInfo(info, timeStep, false); } }, { key: "_getPositionSolverInfo", value: function _getPositionSolverInfo(info) { _get(_getPrototypeOf(oimo_dynamics_constraint_joint_UniversalJoint.prototype), "_getPositionSolverInfo", this).call(this, info); this.getInfo(info, null, true); } }, { key: "getAxis1", value: function getAxis1() { var v = new oimo.common.Vec3(); v.x = this._basisX1X; v.y = this._basisX1Y; v.z = this._basisX1Z; return v; } }, { key: "getAxis2", value: function getAxis2() { var v = new oimo.common.Vec3(); v.x = this._basisZ2X; v.y = this._basisZ2Y; v.z = this._basisZ2Z; return v; } }, { key: "getAxis1To", value: function getAxis1To(axis) { axis.x = this._basisX1X; axis.y = this._basisX1Y; axis.z = this._basisX1Z; } }, { key: "getAxis2To", value: function getAxis2To(axis) { axis.x = this._basisZ2X; axis.y = this._basisZ2Y; axis.z = this._basisZ2Z; } }, { key: "getLocalAxis1", value: function getLocalAxis1() { var v = new oimo.common.Vec3(); v.x = this._localBasisX1X; v.y = this._localBasisX1Y; v.z = this._localBasisX1Z; return v; } }, { key: "getLocalAxis2", value: function getLocalAxis2() { var v = new oimo.common.Vec3(); v.x = this._localBasisZ2X; v.y = this._localBasisZ2Y; v.z = this._localBasisZ2Z; return v; } }, { key: "getLocalAxis1To", value: function getLocalAxis1To(axis) { axis.x = this._localBasisX1X; axis.y = this._localBasisX1Y; axis.z = this._localBasisX1Z; } }, { key: "getLocalAxis2To", value: function getLocalAxis2To(axis) { axis.x = this._localBasisZ2X; axis.y = this._localBasisZ2Y; axis.z = this._localBasisZ2Z; } }, { key: "getSpringDamper1", value: function getSpringDamper1() { return this._sd1; } }, { key: "getSpringDamper2", value: function getSpringDamper2() { return this._sd2; } }, { key: "getLimitMotor1", value: function getLimitMotor1() { return this._lm1; } }, { key: "getLimitMotor2", value: function getLimitMotor2() { return this._lm2; } }, { key: "getAngle1", value: function getAngle1() { return this._angleX; } }, { key: "getAngle2", value: function getAngle2() { return this._angleZ; } }]); return oimo_dynamics_constraint_joint_UniversalJoint; }(oimo.dynamics.constraint.joint.Joint); oimo.dynamics.constraint.joint.UniversalJointConfig = /*#__PURE__*/function (_oimo$dynamics$constr14) { _inherits(oimo_dynamics_constraint_joint_UniversalJointConfig, _oimo$dynamics$constr14); var _super36 = _createSuper(oimo_dynamics_constraint_joint_UniversalJointConfig); function oimo_dynamics_constraint_joint_UniversalJointConfig() { var _this243; _classCallCheck(this, oimo_dynamics_constraint_joint_UniversalJointConfig); _this243 = _super36.call(this); _this243.localAxis1 = new oimo.common.Vec3(1, 0, 0); _this243.localAxis2 = new oimo.common.Vec3(1, 0, 0); _this243.springDamper1 = new oimo.dynamics.constraint.joint.SpringDamper(); _this243.springDamper2 = new oimo.dynamics.constraint.joint.SpringDamper(); _this243.limitMotor1 = new oimo.dynamics.constraint.joint.RotationalLimitMotor(); _this243.limitMotor2 = new oimo.dynamics.constraint.joint.RotationalLimitMotor(); return _this243; } _createClass(oimo_dynamics_constraint_joint_UniversalJointConfig, [{ key: "init", value: function init(rigidBody1, rigidBody2, worldAnchor, worldAxis1, worldAxis2) { this._init(rigidBody1, rigidBody2, worldAnchor); var localVector = this.localAxis1; var vX; var vY; var vZ; vX = worldAxis1.x; vY = worldAxis1.y; vZ = worldAxis1.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = rigidBody1._transform._rotation00 * vX + rigidBody1._transform._rotation10 * vY + rigidBody1._transform._rotation20 * vZ; __tmp__Y = rigidBody1._transform._rotation01 * vX + rigidBody1._transform._rotation11 * vY + rigidBody1._transform._rotation21 * vZ; __tmp__Z = rigidBody1._transform._rotation02 * vX + rigidBody1._transform._rotation12 * vY + rigidBody1._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; localVector.x = vX; localVector.y = vY; localVector.z = vZ; var localVector1 = this.localAxis2; var vX1; var vY1; var vZ1; vX1 = worldAxis2.x; vY1 = worldAxis2.y; vZ1 = worldAxis2.z; var __tmp__X1; var __tmp__Y1; var __tmp__Z1; __tmp__X1 = rigidBody2._transform._rotation00 * vX1 + rigidBody2._transform._rotation10 * vY1 + rigidBody2._transform._rotation20 * vZ1; __tmp__Y1 = rigidBody2._transform._rotation01 * vX1 + rigidBody2._transform._rotation11 * vY1 + rigidBody2._transform._rotation21 * vZ1; __tmp__Z1 = rigidBody2._transform._rotation02 * vX1 + rigidBody2._transform._rotation12 * vY1 + rigidBody2._transform._rotation22 * vZ1; vX1 = __tmp__X1; vY1 = __tmp__Y1; vZ1 = __tmp__Z1; localVector1.x = vX1; localVector1.y = vY1; localVector1.z = vZ1; return this; } }]); return oimo_dynamics_constraint_joint_UniversalJointConfig; }(oimo.dynamics.constraint.joint.JointConfig); if (!oimo.dynamics.constraint.solver) oimo.dynamics.constraint.solver = {}; oimo.dynamics.constraint.solver.ConstraintSolverType = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_solver_ConstraintSolverType() { _classCallCheck(this, oimo_dynamics_constraint_solver_ConstraintSolverType); }); if (!oimo.dynamics.constraint.solver.common) oimo.dynamics.constraint.solver.common = {}; oimo.dynamics.constraint.solver.common.ContactSolverMassDataRow = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_solver_common_ContactSolverMassDataRow() { _classCallCheck(this, oimo_dynamics_constraint_solver_common_ContactSolverMassDataRow); this.invMLinN1X = 0; this.invMLinN1Y = 0; this.invMLinN1Z = 0; this.invMLinN2X = 0; this.invMLinN2Y = 0; this.invMLinN2Z = 0; this.invMAngN1X = 0; this.invMAngN1Y = 0; this.invMAngN1Z = 0; this.invMAngN2X = 0; this.invMAngN2Y = 0; this.invMAngN2Z = 0; this.invMLinT1X = 0; this.invMLinT1Y = 0; this.invMLinT1Z = 0; this.invMLinT2X = 0; this.invMLinT2Y = 0; this.invMLinT2Z = 0; this.invMAngT1X = 0; this.invMAngT1Y = 0; this.invMAngT1Z = 0; this.invMAngT2X = 0; this.invMAngT2Y = 0; this.invMAngT2Z = 0; this.invMLinB1X = 0; this.invMLinB1Y = 0; this.invMLinB1Z = 0; this.invMLinB2X = 0; this.invMLinB2Y = 0; this.invMLinB2Z = 0; this.invMAngB1X = 0; this.invMAngB1Y = 0; this.invMAngB1Z = 0; this.invMAngB2X = 0; this.invMAngB2Y = 0; this.invMAngB2Z = 0; this.massN = 0; this.massTB00 = 0; this.massTB01 = 0; this.massTB10 = 0; this.massTB11 = 0; }); oimo.dynamics.constraint.solver.common.JointSolverMassDataRow = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_solver_common_JointSolverMassDataRow() { _classCallCheck(this, oimo_dynamics_constraint_solver_common_JointSolverMassDataRow); this.invMLin1X = 0; this.invMLin1Y = 0; this.invMLin1Z = 0; this.invMLin2X = 0; this.invMLin2Y = 0; this.invMLin2Z = 0; this.invMAng1X = 0; this.invMAng1Y = 0; this.invMAng1Z = 0; this.invMAng2X = 0; this.invMAng2Y = 0; this.invMAng2Z = 0; this.mass = 0; this.massWithoutCfm = 0; }); if (!oimo.dynamics.constraint.solver.direct) oimo.dynamics.constraint.solver.direct = {}; oimo.dynamics.constraint.solver.direct.Boundary = /*#__PURE__*/function () { function oimo_dynamics_constraint_solver_direct_Boundary(maxRows) { _classCallCheck(this, oimo_dynamics_constraint_solver_direct_Boundary); this.iBounded = new Array(maxRows); this.iUnbounded = new Array(maxRows); this.signs = new Array(maxRows); this.b = new Array(maxRows); this.numBounded = 0; this.numUnbounded = 0; this.matrixId = 0; } _createClass(oimo_dynamics_constraint_solver_direct_Boundary, [{ key: "init", value: function init(buildInfo) { this.numBounded = buildInfo.numBounded; var _g = 0; var _g1 = this.numBounded; while (_g < _g1) { var i = _g++; this.iBounded[i] = buildInfo.iBounded[i]; this.signs[i] = buildInfo.signs[i]; } this.numUnbounded = buildInfo.numUnbounded; this.matrixId = 0; var _g2 = 0; var _g3 = this.numUnbounded; while (_g2 < _g3) { var _i138 = _g2++; var idx = buildInfo.iUnbounded[_i138]; this.iUnbounded[_i138] = idx; this.matrixId |= 1 << idx; } } }, { key: "computeImpulses", value: function computeImpulses(info, mass, relVels, impulses, dImpulses, impulseFactor, noCheck) { var _g = 0; var _g1 = this.numUnbounded; while (_g < _g1) { var idx = this.iUnbounded[_g++]; var row = info.rows[idx]; this.b[idx] = row.rhs * impulseFactor - relVels[idx] - row.cfm * impulses[idx]; } var invMassWithoutCfm = mass._invMassWithoutCfm; var _g2 = 0; var _g3 = this.numBounded; while (_g2 < _g3) { var i = _g2++; var _idx = this.iBounded[i]; var sign = this.signs[i]; var _row15 = info.rows[_idx]; var dImpulse = (sign < 0 ? _row15.minImpulse : sign > 0 ? _row15.maxImpulse : 0) - impulses[_idx]; dImpulses[_idx] = dImpulse; if (dImpulse != 0) { var _g298 = 0; var _g299 = this.numUnbounded; while (_g298 < _g299) { var idx2 = this.iUnbounded[_g298++]; this.b[idx2] -= invMassWithoutCfm[_idx][idx2] * dImpulse; } } } var indices = this.iUnbounded; var n = this.numUnbounded; var id = 0; var _g4 = 0; while (_g4 < n) { id |= 1 << indices[_g4++]; } var massMatrix; if (mass._cacheComputed[id]) { massMatrix = mass._cachedSubmatrices[id]; } else { mass.computeSubmatrix(id, indices, n); mass._cacheComputed[id] = true; massMatrix = mass._cachedSubmatrices[id]; } var ok = true; var _g5 = 0; var _g6 = this.numUnbounded; while (_g5 < _g6) { var _i139 = _g5++; var _idx2 = this.iUnbounded[_i139]; var _row16 = info.rows[_idx2]; var oldImpulse = impulses[_idx2]; var impulse = oldImpulse; var _g300 = 0; var _g301 = this.numUnbounded; while (_g300 < _g301) { var j = _g300++; impulse += this.b[this.iUnbounded[j]] * massMatrix[_i139][j]; } if (impulse < _row16.minImpulse - oimo.common.Setting.directMlcpSolverEps || impulse > _row16.maxImpulse + oimo.common.Setting.directMlcpSolverEps) { ok = false; break; } dImpulses[_idx2] = impulse - oldImpulse; } if (noCheck) { return true; } if (!ok) { return false; } var _g7 = 0; var _g8 = this.numBounded; while (_g7 < _g8) { var _i140 = _g7++; var _idx3 = this.iBounded[_i140]; var _row17 = info.rows[_idx3]; var _sign = this.signs[_i140]; var error = 0; var newImpulse = impulses[_idx3] + dImpulses[_idx3]; var relVel = relVels[_idx3]; var _g302 = 0; var _g303 = info.numRows; while (_g302 < _g303) { var _j4 = _g302++; relVel += invMassWithoutCfm[_idx3][_j4] * dImpulses[_j4]; } error = _row17.rhs * impulseFactor - relVel - _row17.cfm * newImpulse; if (_sign < 0 && error > oimo.common.Setting.directMlcpSolverEps || _sign > 0 && error < -oimo.common.Setting.directMlcpSolverEps) { ok = false; break; } } return ok; } }]); return oimo_dynamics_constraint_solver_direct_Boundary; }(); oimo.dynamics.constraint.solver.direct.BoundaryBuildInfo = /*#__PURE__*/_createClass(function oimo_dynamics_constraint_solver_direct_BoundaryBuildInfo(size) { _classCallCheck(this, oimo_dynamics_constraint_solver_direct_BoundaryBuildInfo); this.size = size; this.numBounded = 0; this.iBounded = new Array(size); this.signs = new Array(size); this.numUnbounded = 0; this.iUnbounded = new Array(size); }); oimo.dynamics.constraint.solver.direct.BoundaryBuilder = /*#__PURE__*/function () { function oimo_dynamics_constraint_solver_direct_BoundaryBuilder(maxRows) { _classCallCheck(this, oimo_dynamics_constraint_solver_direct_BoundaryBuilder); this.maxRows = maxRows; this.numBoundaries = 0; this.boundaries = new Array(1 << maxRows); this.bbInfo = new oimo.dynamics.constraint.solver.direct.BoundaryBuildInfo(maxRows); } _createClass(oimo_dynamics_constraint_solver_direct_BoundaryBuilder, [{ key: "buildBoundariesRecursive", value: function buildBoundariesRecursive(info, i) { if (i == info.numRows) { if (this.boundaries[this.numBoundaries] == null) { this.boundaries[this.numBoundaries] = new oimo.dynamics.constraint.solver.direct.Boundary(this.maxRows); } this.boundaries[this.numBoundaries++].init(this.bbInfo); return; } var row = info.rows[i]; var lowerLimitEnabled = row.minImpulse > -1e65536; var upperLimitEnabled = row.maxImpulse < 1e65536; if (row.minImpulse == 0 && row.maxImpulse == 0) { var _this244 = this.bbInfo; _this244.iBounded[_this244.numBounded] = i; _this244.signs[_this244.numBounded] = 0; _this244.numBounded++; this.buildBoundariesRecursive(info, i + 1); this.bbInfo.numBounded--; return; } var _this = this.bbInfo; _this.iUnbounded[_this.numUnbounded] = i; _this.numUnbounded++; this.buildBoundariesRecursive(info, i + 1); this.bbInfo.numUnbounded--; if (lowerLimitEnabled) { var _this245 = this.bbInfo; _this245.iBounded[_this245.numBounded] = i; _this245.signs[_this245.numBounded] = -1; _this245.numBounded++; this.buildBoundariesRecursive(info, i + 1); this.bbInfo.numBounded--; } if (upperLimitEnabled) { var _this246 = this.bbInfo; _this246.iBounded[_this246.numBounded] = i; _this246.signs[_this246.numBounded] = 1; _this246.numBounded++; this.buildBoundariesRecursive(info, i + 1); this.bbInfo.numBounded--; } } }, { key: "buildBoundaries", value: function buildBoundaries(info) { this.numBoundaries = 0; var _this = this.bbInfo; _this.numBounded = 0; _this.numUnbounded = 0; this.buildBoundariesRecursive(info, 0); } }]); return oimo_dynamics_constraint_solver_direct_BoundaryBuilder; }(); oimo.dynamics.constraint.solver.direct.BoundarySelector = /*#__PURE__*/function () { function oimo_dynamics_constraint_solver_direct_BoundarySelector(n) { _classCallCheck(this, oimo_dynamics_constraint_solver_direct_BoundarySelector); this.n = n; this.indices = new Array(n); this.tmpIndices = new Array(n); var _g = 0; while (_g < n) { var i = _g++; this.indices[i] = i; } } _createClass(oimo_dynamics_constraint_solver_direct_BoundarySelector, [{ key: "getIndex", value: function getIndex(i) { return this.indices[i]; } }, { key: "select", value: function select(index) { var i = 0; while (this.indices[i] != index) { ++i; } while (i > 0) { var tmp = this.indices[i]; this.indices[i] = this.indices[i - 1]; this.indices[i - 1] = tmp; --i; } } }, { key: "setSize", value: function setSize(size) { var numSmaller = 0; var numGreater = 0; var _g = 0; var _g1 = this.n; while (_g < _g1) { var idx = this.indices[_g++]; if (idx < size) { this.tmpIndices[numSmaller] = idx; ++numSmaller; } else { this.tmpIndices[size + numGreater] = idx; ++numGreater; } } var tmp = this.indices; this.indices = this.tmpIndices; this.tmpIndices = tmp; } }]); return oimo_dynamics_constraint_solver_direct_BoundarySelector; }(); oimo.dynamics.constraint.solver.direct.DirectJointConstraintSolver = /*#__PURE__*/function (_oimo$dynamics$constr15) { _inherits(oimo_dynamics_constraint_solver_direct_DirectJointConstraintSolver, _oimo$dynamics$constr15); var _super37 = _createSuper(oimo_dynamics_constraint_solver_direct_DirectJointConstraintSolver); function oimo_dynamics_constraint_solver_direct_DirectJointConstraintSolver(joint) { var _this247; _classCallCheck(this, oimo_dynamics_constraint_solver_direct_DirectJointConstraintSolver); _this247 = _super37.call(this); _this247.joint = joint; _this247.info = new oimo.dynamics.constraint.info.joint.JointSolverInfo(); var maxRows = oimo.common.Setting.maxJacobianRows; _this247.massMatrix = new oimo.dynamics.constraint.solver.direct.MassMatrix(maxRows); _this247.boundaryBuilder = new oimo.dynamics.constraint.solver.direct.BoundaryBuilder(maxRows); _this247.massData = new Array(maxRows); var _g = 0; var _g1 = _this247.massData.length; while (_g < _g1) { _this247.massData[_g++] = new oimo.dynamics.constraint.solver.common.JointSolverMassDataRow(); } var numMaxBoundaries = _this247.boundaryBuilder.boundaries.length; _this247.velBoundarySelector = new oimo.dynamics.constraint.solver.direct.BoundarySelector(numMaxBoundaries); _this247.posBoundarySelector = new oimo.dynamics.constraint.solver.direct.BoundarySelector(numMaxBoundaries); _this247.relVels = new Array(maxRows); _this247.impulses = new Array(maxRows); _this247.dImpulses = new Array(maxRows); _this247.dTotalImpulses = new Array(maxRows); var _g2 = 0; while (_g2 < maxRows) { var i = _g2++; _this247.relVels[i] = 0; _this247.impulses[i] = 0; _this247.dImpulses[i] = 0; _this247.dTotalImpulses[i] = 0; } return _this247; } _createClass(oimo_dynamics_constraint_solver_direct_DirectJointConstraintSolver, [{ key: "preSolveVelocity", value: function preSolveVelocity(timeStep) { this.joint._syncAnchors(); this.joint._getVelocitySolverInfo(timeStep, this.info); this._b1 = this.info.b1; this._b2 = this.info.b2; this.massMatrix.computeInvMass(this.info, this.massData); var _this = this.boundaryBuilder; _this.numBoundaries = 0; var _this1 = _this.bbInfo; _this1.numBounded = 0; _this1.numUnbounded = 0; _this.buildBoundariesRecursive(this.info, 0); var _this2 = this.velBoundarySelector; var size = this.boundaryBuilder.numBoundaries; var numSmaller = 0; var numGreater = 0; var _g = 0; var _g1 = _this2.n; while (_g < _g1) { var idx = _this2.indices[_g++]; if (idx < size) { _this2.tmpIndices[numSmaller] = idx; ++numSmaller; } else { _this2.tmpIndices[size + numGreater] = idx; ++numGreater; } } var tmp = _this2.indices; _this2.indices = _this2.tmpIndices; _this2.tmpIndices = tmp; } }, { key: "warmStart", value: function warmStart(timeStep) { var factor = this.joint._positionCorrectionAlgorithm == oimo.dynamics.constraint.PositionCorrectionAlgorithm.BAUMGARTE ? oimo.common.Setting.jointWarmStartingFactorForBaungarte : oimo.common.Setting.jointWarmStartingFactor; factor *= timeStep.dtRatio; if (factor <= 0) { var _g304 = 0; var _g305 = this.info.numRows; while (_g304 < _g305) { var _this = this.info.rows[_g304++].impulse; _this.impulse = 0; _this.impulseM = 0; _this.impulseP = 0; } return; } var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var row = this.info.rows[i]; var imp = row.impulse; var impulse = imp.impulse * factor; if (impulse < row.minImpulse) { impulse = row.minImpulse; } else if (impulse > row.maxImpulse) { impulse = row.maxImpulse; } imp.impulse = impulse; if (row.motorMaxImpulse > 0) { var impulseM = imp.impulseM * factor; var max = row.motorMaxImpulse; if (impulseM < -max) { impulseM = -max; } else if (impulseM > max) { impulseM = max; } imp.impulseM = impulseM; } else { imp.impulseM = 0; } this.dImpulses[i] = imp.impulse + imp.impulseM; } var impulses = this.dImpulses; var linearSet = false; var angularSet = false; var lv1X; var lv1Y; var lv1Z; var lv2X; var lv2Y; var lv2Z; var av1X; var av1Y; var av1Z; var av2X; var av2Y; var av2Z; lv1X = this._b1._velX; lv1Y = this._b1._velY; lv1Z = this._b1._velZ; lv2X = this._b2._velX; lv2Y = this._b2._velY; lv2Z = this._b2._velZ; av1X = this._b1._angVelX; av1Y = this._b1._angVelY; av1Z = this._b1._angVelZ; av2X = this._b2._angVelX; av2Y = this._b2._angVelY; av2Z = this._b2._angVelZ; var _g2 = 0; var _g3 = this.info.numRows; while (_g2 < _g3) { var _i141 = _g2++; var j = this.info.rows[_i141].jacobian; var md = this.massData[_i141]; var _imp = impulses[_i141]; if ((j.flag & 1) != 0) { lv1X += md.invMLin1X * _imp; lv1Y += md.invMLin1Y * _imp; lv1Z += md.invMLin1Z * _imp; lv2X += md.invMLin2X * -_imp; lv2Y += md.invMLin2Y * -_imp; lv2Z += md.invMLin2Z * -_imp; linearSet = true; } if ((j.flag & 2) != 0) { av1X += md.invMAng1X * _imp; av1Y += md.invMAng1Y * _imp; av1Z += md.invMAng1Z * _imp; av2X += md.invMAng2X * -_imp; av2Y += md.invMAng2Y * -_imp; av2Z += md.invMAng2Z * -_imp; angularSet = true; } } if (linearSet) { this._b1._velX = lv1X; this._b1._velY = lv1Y; this._b1._velZ = lv1Z; this._b2._velX = lv2X; this._b2._velY = lv2Y; this._b2._velZ = lv2Z; } if (angularSet) { this._b1._angVelX = av1X; this._b1._angVelY = av1Y; this._b1._angVelZ = av1Z; this._b2._angVelX = av2X; this._b2._angVelY = av2Y; this._b2._angVelZ = av2Z; } } }, { key: "solveVelocity", value: function solveVelocity() { var numRows = this.info.numRows; var lv1X; var lv1Y; var lv1Z; var lv2X; var lv2Y; var lv2Z; var av1X; var av1Y; var av1Z; var av2X; var av2Y; var av2Z; lv1X = this._b1._velX; lv1Y = this._b1._velY; lv1Z = this._b1._velZ; lv2X = this._b2._velX; lv2Y = this._b2._velY; lv2Z = this._b2._velZ; av1X = this._b1._angVelX; av1Y = this._b1._angVelY; av1Z = this._b1._angVelZ; av2X = this._b2._angVelX; av2Y = this._b2._angVelY; av2Z = this._b2._angVelZ; var _g = 0; while (_g < numRows) { var i = _g++; var row = this.info.rows[i]; var j = row.jacobian; var relVel = 0; relVel += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z; relVel -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z; relVel += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z; relVel -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z; this.relVels[i] = relVel; this.impulses[i] = row.impulse.impulse; this.dTotalImpulses[i] = 0; } var invMass = this.massMatrix._invMassWithoutCfm; var _g1 = 0; while (_g1 < numRows) { var _i142 = _g1++; var _row18 = this.info.rows[_i142]; var imp = _row18.impulse; if (_row18.motorMaxImpulse > 0) { var oldImpulseM = imp.impulseM; var impulseM = oldImpulseM + this.massData[_i142].massWithoutCfm * (-_row18.motorSpeed - this.relVels[_i142]); var maxImpulseM = _row18.motorMaxImpulse; if (impulseM < -maxImpulseM) { impulseM = -maxImpulseM; } else if (impulseM > maxImpulseM) { impulseM = maxImpulseM; } imp.impulseM = impulseM; var dImpulseM = impulseM - oldImpulseM; this.dTotalImpulses[_i142] = dImpulseM; var _g306 = 0; while (_g306 < numRows) { var _j5 = _g306++; this.relVels[_j5] += dImpulseM * invMass[_i142][_j5]; } } } var solved = false; var _g2 = 0; var _g3 = this.boundaryBuilder.numBoundaries; while (_g2 < _g3) { var idx = this.velBoundarySelector.indices[_g2++]; if (this.boundaryBuilder.boundaries[idx].computeImpulses(this.info, this.massMatrix, this.relVels, this.impulses, this.dImpulses, 1, false)) { var _g307 = 0; while (_g307 < numRows) { var _j6 = _g307++; var dimp = this.dImpulses[_j6]; this.info.rows[_j6].impulse.impulse += dimp; this.dTotalImpulses[_j6] += dimp; } var impulses = this.dTotalImpulses; var linearSet = false; var angularSet = false; var _lv1X = void 0; var _lv1Y = void 0; var _lv1Z = void 0; var _lv2X = void 0; var _lv2Y = void 0; var _lv2Z = void 0; var _av1X = void 0; var _av1Y = void 0; var _av1Z = void 0; var _av2X = void 0; var _av2Y = void 0; var _av2Z = void 0; _lv1X = this._b1._velX; _lv1Y = this._b1._velY; _lv1Z = this._b1._velZ; _lv2X = this._b2._velX; _lv2Y = this._b2._velY; _lv2Z = this._b2._velZ; _av1X = this._b1._angVelX; _av1Y = this._b1._angVelY; _av1Z = this._b1._angVelZ; _av2X = this._b2._angVelX; _av2Y = this._b2._angVelY; _av2Z = this._b2._angVelZ; var _g308 = 0; var _g309 = this.info.numRows; while (_g308 < _g309) { var _i144 = _g308++; var _j7 = this.info.rows[_i144].jacobian; var md = this.massData[_i144]; var _imp2 = impulses[_i144]; if ((_j7.flag & 1) != 0) { _lv1X += md.invMLin1X * _imp2; _lv1Y += md.invMLin1Y * _imp2; _lv1Z += md.invMLin1Z * _imp2; _lv2X += md.invMLin2X * -_imp2; _lv2Y += md.invMLin2Y * -_imp2; _lv2Z += md.invMLin2Z * -_imp2; linearSet = true; } if ((_j7.flag & 2) != 0) { _av1X += md.invMAng1X * _imp2; _av1Y += md.invMAng1Y * _imp2; _av1Z += md.invMAng1Z * _imp2; _av2X += md.invMAng2X * -_imp2; _av2Y += md.invMAng2Y * -_imp2; _av2Z += md.invMAng2Z * -_imp2; angularSet = true; } } if (linearSet) { this._b1._velX = _lv1X; this._b1._velY = _lv1Y; this._b1._velZ = _lv1Z; this._b2._velX = _lv2X; this._b2._velY = _lv2Y; this._b2._velZ = _lv2Z; } if (angularSet) { this._b1._angVelX = _av1X; this._b1._angVelY = _av1Y; this._b1._angVelZ = _av1Z; this._b2._angVelX = _av2X; this._b2._angVelY = _av2Y; this._b2._angVelZ = _av2Z; } var _this = this.velBoundarySelector; var _i143 = 0; while (_this.indices[_i143] != idx) { ++_i143; } while (_i143 > 0) { var tmp = _this.indices[_i143]; _this.indices[_i143] = _this.indices[_i143 - 1]; _this.indices[_i143 - 1] = tmp; --_i143; } solved = true; break; } } if (!solved) { console.log("src/oimo/dynamics/constraint/solver/direct/DirectJointConstraintSolver.hx:335:", "could not find solution. (velocity)"); return; } } }, { key: "postSolveVelocity", value: function postSolveVelocity(timeStep) { var linX; var linY; var linZ; var angX; var angY; var angZ; linX = 0; linY = 0; linZ = 0; angX = 0; angY = 0; angZ = 0; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var row = this.info.rows[_g++]; var imp = row.impulse; var j = row.jacobian; if ((j.flag & 1) != 0) { linX += j.lin1X * imp.impulse; linY += j.lin1Y * imp.impulse; linZ += j.lin1Z * imp.impulse; } else if ((j.flag & 2) != 0) { angX += j.ang1X * imp.impulse; angY += j.ang1Y * imp.impulse; angZ += j.ang1Z * imp.impulse; } } this.joint._appliedForceX = linX * timeStep.invDt; this.joint._appliedForceY = linY * timeStep.invDt; this.joint._appliedForceZ = linZ * timeStep.invDt; this.joint._appliedTorqueX = angX * timeStep.invDt; this.joint._appliedTorqueY = angY * timeStep.invDt; this.joint._appliedTorqueZ = angZ * timeStep.invDt; } }, { key: "preSolvePosition", value: function preSolvePosition(timeStep) { this.joint._syncAnchors(); this.joint._getPositionSolverInfo(this.info); this._b1 = this.info.b1; this._b2 = this.info.b2; this.massMatrix.computeInvMass(this.info, this.massData); var _this = this.boundaryBuilder; _this.numBoundaries = 0; var _this1 = _this.bbInfo; _this1.numBounded = 0; _this1.numUnbounded = 0; _this.buildBoundariesRecursive(this.info, 0); var _this2 = this.posBoundarySelector; var size = this.boundaryBuilder.numBoundaries; var numSmaller = 0; var numGreater = 0; var _g = 0; var _g1 = _this2.n; while (_g < _g1) { var idx = _this2.indices[_g++]; if (idx < size) { _this2.tmpIndices[numSmaller] = idx; ++numSmaller; } else { _this2.tmpIndices[size + numGreater] = idx; ++numGreater; } } var tmp = _this2.indices; _this2.indices = _this2.tmpIndices; _this2.tmpIndices = tmp; var _g2 = 0; var _g3 = this.info.numRows; while (_g2 < _g3) { this.info.rows[_g2++].impulse.impulseP = 0; } } }, { key: "solvePositionSplitImpulse", value: function solvePositionSplitImpulse() { var numRows = this.info.numRows; var lv1X; var lv1Y; var lv1Z; var lv2X; var lv2Y; var lv2Z; var av1X; var av1Y; var av1Z; var av2X; var av2Y; var av2Z; lv1X = this._b1._pseudoVelX; lv1Y = this._b1._pseudoVelY; lv1Z = this._b1._pseudoVelZ; lv2X = this._b2._pseudoVelX; lv2Y = this._b2._pseudoVelY; lv2Z = this._b2._pseudoVelZ; av1X = this._b1._angPseudoVelX; av1Y = this._b1._angPseudoVelY; av1Z = this._b1._angPseudoVelZ; av2X = this._b2._angPseudoVelX; av2Y = this._b2._angPseudoVelY; av2Z = this._b2._angPseudoVelZ; var _g = 0; while (_g < numRows) { var i = _g++; var row = this.info.rows[i]; var j = row.jacobian; var relVel = 0; relVel += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z; relVel -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z; relVel += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z; relVel -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z; this.relVels[i] = relVel; this.impulses[i] = row.impulse.impulseP; } var solved = false; var _g1 = 0; var _g2 = this.boundaryBuilder.numBoundaries; while (_g1 < _g2) { var idx = this.posBoundarySelector.indices[_g1++]; if (this.boundaryBuilder.boundaries[idx].computeImpulses(this.info, this.massMatrix, this.relVels, this.impulses, this.dImpulses, oimo.common.Setting.positionSplitImpulseBaumgarte, false)) { var _g310 = 0; while (_g310 < numRows) { var _j8 = _g310++; this.info.rows[_j8].impulse.impulseP += this.dImpulses[_j8]; } var impulses = this.dImpulses; var linearSet = false; var angularSet = false; var _lv1X2 = void 0; var _lv1Y2 = void 0; var _lv1Z2 = void 0; var _lv2X2 = void 0; var _lv2Y2 = void 0; var _lv2Z2 = void 0; var _av1X2 = void 0; var _av1Y2 = void 0; var _av1Z2 = void 0; var _av2X2 = void 0; var _av2Y2 = void 0; var _av2Z2 = void 0; _lv1X2 = this._b1._pseudoVelX; _lv1Y2 = this._b1._pseudoVelY; _lv1Z2 = this._b1._pseudoVelZ; _lv2X2 = this._b2._pseudoVelX; _lv2Y2 = this._b2._pseudoVelY; _lv2Z2 = this._b2._pseudoVelZ; _av1X2 = this._b1._angPseudoVelX; _av1Y2 = this._b1._angPseudoVelY; _av1Z2 = this._b1._angPseudoVelZ; _av2X2 = this._b2._angPseudoVelX; _av2Y2 = this._b2._angPseudoVelY; _av2Z2 = this._b2._angPseudoVelZ; var _g311 = 0; var _g312 = this.info.numRows; while (_g311 < _g312) { var _i146 = _g311++; var _j9 = this.info.rows[_i146].jacobian; var md = this.massData[_i146]; var imp = impulses[_i146]; if ((_j9.flag & 1) != 0) { _lv1X2 += md.invMLin1X * imp; _lv1Y2 += md.invMLin1Y * imp; _lv1Z2 += md.invMLin1Z * imp; _lv2X2 += md.invMLin2X * -imp; _lv2Y2 += md.invMLin2Y * -imp; _lv2Z2 += md.invMLin2Z * -imp; linearSet = true; } if ((_j9.flag & 2) != 0) { _av1X2 += md.invMAng1X * imp; _av1Y2 += md.invMAng1Y * imp; _av1Z2 += md.invMAng1Z * imp; _av2X2 += md.invMAng2X * -imp; _av2Y2 += md.invMAng2Y * -imp; _av2Z2 += md.invMAng2Z * -imp; angularSet = true; } } if (linearSet) { this._b1._pseudoVelX = _lv1X2; this._b1._pseudoVelY = _lv1Y2; this._b1._pseudoVelZ = _lv1Z2; this._b2._pseudoVelX = _lv2X2; this._b2._pseudoVelY = _lv2Y2; this._b2._pseudoVelZ = _lv2Z2; } if (angularSet) { this._b1._angPseudoVelX = _av1X2; this._b1._angPseudoVelY = _av1Y2; this._b1._angPseudoVelZ = _av1Z2; this._b2._angPseudoVelX = _av2X2; this._b2._angPseudoVelY = _av2Y2; this._b2._angPseudoVelZ = _av2Z2; } var _this = this.posBoundarySelector; var _i145 = 0; while (_this.indices[_i145] != idx) { ++_i145; } while (_i145 > 0) { var tmp = _this.indices[_i145]; _this.indices[_i145] = _this.indices[_i145 - 1]; _this.indices[_i145 - 1] = tmp; --_i145; } solved = true; break; } } if (!solved) { console.log("src/oimo/dynamics/constraint/solver/direct/DirectJointConstraintSolver.hx:450:", "could not find solution. (split impulse)"); return; } } }, { key: "solvePositionNgs", value: function solvePositionNgs(timeStep) { this.joint._syncAnchors(); this.joint._getPositionSolverInfo(this.info); this._b1 = this.info.b1; this._b2 = this.info.b2; this.massMatrix.computeInvMass(this.info, this.massData); var _this = this.boundaryBuilder; _this.numBoundaries = 0; var _this1 = _this.bbInfo; _this1.numBounded = 0; _this1.numUnbounded = 0; _this.buildBoundariesRecursive(this.info, 0); var _this2 = this.posBoundarySelector; var size = this.boundaryBuilder.numBoundaries; var numSmaller = 0; var numGreater = 0; var _g = 0; var _g1 = _this2.n; while (_g < _g1) { var idx = _this2.indices[_g++]; if (idx < size) { _this2.tmpIndices[numSmaller] = idx; ++numSmaller; } else { _this2.tmpIndices[size + numGreater] = idx; ++numGreater; } } var tmp = _this2.indices; _this2.indices = _this2.tmpIndices; _this2.tmpIndices = tmp; var numRows = this.info.numRows; var _g2 = 0; while (_g2 < numRows) { var i = _g2++; var imp = this.info.rows[i].impulse; this.relVels[i] = 0; this.impulses[i] = imp.impulseP; } var solved = false; var _g3 = 0; var _g4 = this.boundaryBuilder.numBoundaries; while (_g3 < _g4) { var _idx4 = this.posBoundarySelector.indices[_g3++]; if (this.boundaryBuilder.boundaries[_idx4].computeImpulses(this.info, this.massMatrix, this.relVels, this.impulses, this.dImpulses, oimo.common.Setting.positionNgsBaumgarte, false)) { var _g313 = 0; while (_g313 < numRows) { var j = _g313++; this.info.rows[j].impulse.impulseP += this.dImpulses[j]; } var impulses = this.dImpulses; var linearSet = false; var angularSet = false; var lv1X = void 0; var lv1Y = void 0; var lv1Z = void 0; var lv2X = void 0; var lv2Y = void 0; var lv2Z = void 0; var av1X = void 0; var av1Y = void 0; var av1Z = void 0; var av2X = void 0; var av2Y = void 0; var av2Z = void 0; lv1X = 0; lv1Y = 0; lv1Z = 0; lv2X = 0; lv2Y = 0; lv2Z = 0; av1X = 0; av1Y = 0; av1Z = 0; av2X = 0; av2Y = 0; av2Z = 0; var _g314 = 0; var _g315 = this.info.numRows; while (_g314 < _g315) { var _i148 = _g314++; var _j10 = this.info.rows[_i148].jacobian; var md = this.massData[_i148]; var _imp3 = impulses[_i148]; if ((_j10.flag & 1) != 0) { lv1X += md.invMLin1X * _imp3; lv1Y += md.invMLin1Y * _imp3; lv1Z += md.invMLin1Z * _imp3; lv2X += md.invMLin2X * -_imp3; lv2Y += md.invMLin2Y * -_imp3; lv2Z += md.invMLin2Z * -_imp3; linearSet = true; } if ((_j10.flag & 2) != 0) { av1X += md.invMAng1X * _imp3; av1Y += md.invMAng1Y * _imp3; av1Z += md.invMAng1Z * _imp3; av2X += md.invMAng2X * -_imp3; av2Y += md.invMAng2Y * -_imp3; av2Z += md.invMAng2Z * -_imp3; angularSet = true; } } if (linearSet) { var _this249 = this._b1; _this249._transform._positionX += lv1X; _this249._transform._positionY += lv1Y; _this249._transform._positionZ += lv1Z; var _this250 = this._b2; _this250._transform._positionX += lv2X; _this250._transform._positionY += lv2Y; _this250._transform._positionZ += lv2Z; } if (angularSet) { var _this251 = this._b1; var theta = Math.sqrt(av1X * av1X + av1Y * av1Y + av1Z * av1Z); var halfTheta = theta * 0.5; var rotationToSinAxisFactor = void 0; var cosHalfTheta = void 0; if (halfTheta < 0.5) { var ht2 = halfTheta * halfTheta; rotationToSinAxisFactor = 0.5 * (1 - ht2 * 0.16666666666666666 + ht2 * ht2 * 0.0083333333333333332); cosHalfTheta = 1 - ht2 * 0.5 + ht2 * ht2 * 0.041666666666666664; } else { rotationToSinAxisFactor = Math.sin(halfTheta) / theta; cosHalfTheta = Math.cos(halfTheta); } var sinAxisX = void 0; var sinAxisY = void 0; var sinAxisZ = void 0; sinAxisX = av1X * rotationToSinAxisFactor; sinAxisY = av1Y * rotationToSinAxisFactor; sinAxisZ = av1Z * rotationToSinAxisFactor; var dqX = void 0; var dqY = void 0; var dqZ = void 0; var dqW = void 0; dqX = sinAxisX; dqY = sinAxisY; dqZ = sinAxisZ; dqW = cosHalfTheta; var qX = void 0; var qY = void 0; var qZ = void 0; var qW = void 0; var e00 = _this251._transform._rotation00; var e11 = _this251._transform._rotation11; var e22 = _this251._transform._rotation22; var t = e00 + e11 + e22; var s = void 0; if (t > 0) { s = Math.sqrt(t + 1); qW = 0.5 * s; s = 0.5 / s; qX = (_this251._transform._rotation21 - _this251._transform._rotation12) * s; qY = (_this251._transform._rotation02 - _this251._transform._rotation20) * s; qZ = (_this251._transform._rotation10 - _this251._transform._rotation01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); qX = 0.5 * s; s = 0.5 / s; qY = (_this251._transform._rotation01 + _this251._transform._rotation10) * s; qZ = (_this251._transform._rotation02 + _this251._transform._rotation20) * s; qW = (_this251._transform._rotation21 - _this251._transform._rotation12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); qZ = 0.5 * s; s = 0.5 / s; qX = (_this251._transform._rotation02 + _this251._transform._rotation20) * s; qY = (_this251._transform._rotation12 + _this251._transform._rotation21) * s; qW = (_this251._transform._rotation10 - _this251._transform._rotation01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); qY = 0.5 * s; s = 0.5 / s; qX = (_this251._transform._rotation01 + _this251._transform._rotation10) * s; qZ = (_this251._transform._rotation12 + _this251._transform._rotation21) * s; qW = (_this251._transform._rotation02 - _this251._transform._rotation20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); qZ = 0.5 * s; s = 0.5 / s; qX = (_this251._transform._rotation02 + _this251._transform._rotation20) * s; qY = (_this251._transform._rotation12 + _this251._transform._rotation21) * s; qW = (_this251._transform._rotation10 - _this251._transform._rotation01) * s; } qX = dqW * qX + dqX * qW + dqY * qZ - dqZ * qY; qY = dqW * qY - dqX * qZ + dqY * qW + dqZ * qX; qZ = dqW * qZ + dqX * qY - dqY * qX + dqZ * qW; qW = dqW * qW - dqX * qX - dqY * qY - dqZ * qZ; var l = qX * qX + qY * qY + qZ * qZ + qW * qW; if (l > 1e-32) { l = 1 / Math.sqrt(l); } qX *= l; qY *= l; qZ *= l; qW *= l; var x = qX; var y = qY; var z = qZ; var w = qW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; _this251._transform._rotation00 = 1 - yy - zz; _this251._transform._rotation01 = xy - wz; _this251._transform._rotation02 = xz + wy; _this251._transform._rotation10 = xy + wz; _this251._transform._rotation11 = 1 - xx - zz; _this251._transform._rotation12 = yz - wx; _this251._transform._rotation20 = xz - wy; _this251._transform._rotation21 = yz + wx; _this251._transform._rotation22 = 1 - xx - yy; var __tmp__00 = void 0; var __tmp__01 = void 0; var __tmp__02 = void 0; var __tmp__10 = void 0; var __tmp__11 = void 0; var __tmp__12 = void 0; var __tmp__20 = void 0; var __tmp__21 = void 0; var __tmp__22 = void 0; __tmp__00 = _this251._transform._rotation00 * _this251._invLocalInertia00 + _this251._transform._rotation01 * _this251._invLocalInertia10 + _this251._transform._rotation02 * _this251._invLocalInertia20; __tmp__01 = _this251._transform._rotation00 * _this251._invLocalInertia01 + _this251._transform._rotation01 * _this251._invLocalInertia11 + _this251._transform._rotation02 * _this251._invLocalInertia21; __tmp__02 = _this251._transform._rotation00 * _this251._invLocalInertia02 + _this251._transform._rotation01 * _this251._invLocalInertia12 + _this251._transform._rotation02 * _this251._invLocalInertia22; __tmp__10 = _this251._transform._rotation10 * _this251._invLocalInertia00 + _this251._transform._rotation11 * _this251._invLocalInertia10 + _this251._transform._rotation12 * _this251._invLocalInertia20; __tmp__11 = _this251._transform._rotation10 * _this251._invLocalInertia01 + _this251._transform._rotation11 * _this251._invLocalInertia11 + _this251._transform._rotation12 * _this251._invLocalInertia21; __tmp__12 = _this251._transform._rotation10 * _this251._invLocalInertia02 + _this251._transform._rotation11 * _this251._invLocalInertia12 + _this251._transform._rotation12 * _this251._invLocalInertia22; __tmp__20 = _this251._transform._rotation20 * _this251._invLocalInertia00 + _this251._transform._rotation21 * _this251._invLocalInertia10 + _this251._transform._rotation22 * _this251._invLocalInertia20; __tmp__21 = _this251._transform._rotation20 * _this251._invLocalInertia01 + _this251._transform._rotation21 * _this251._invLocalInertia11 + _this251._transform._rotation22 * _this251._invLocalInertia21; __tmp__22 = _this251._transform._rotation20 * _this251._invLocalInertia02 + _this251._transform._rotation21 * _this251._invLocalInertia12 + _this251._transform._rotation22 * _this251._invLocalInertia22; _this251._invInertia00 = __tmp__00; _this251._invInertia01 = __tmp__01; _this251._invInertia02 = __tmp__02; _this251._invInertia10 = __tmp__10; _this251._invInertia11 = __tmp__11; _this251._invInertia12 = __tmp__12; _this251._invInertia20 = __tmp__20; _this251._invInertia21 = __tmp__21; _this251._invInertia22 = __tmp__22; var __tmp__001 = void 0; var __tmp__011 = void 0; var __tmp__021 = void 0; var __tmp__101 = void 0; var __tmp__111 = void 0; var __tmp__121 = void 0; var __tmp__201 = void 0; var __tmp__211 = void 0; var __tmp__221 = void 0; __tmp__001 = _this251._invInertia00 * _this251._transform._rotation00 + _this251._invInertia01 * _this251._transform._rotation01 + _this251._invInertia02 * _this251._transform._rotation02; __tmp__011 = _this251._invInertia00 * _this251._transform._rotation10 + _this251._invInertia01 * _this251._transform._rotation11 + _this251._invInertia02 * _this251._transform._rotation12; __tmp__021 = _this251._invInertia00 * _this251._transform._rotation20 + _this251._invInertia01 * _this251._transform._rotation21 + _this251._invInertia02 * _this251._transform._rotation22; __tmp__101 = _this251._invInertia10 * _this251._transform._rotation00 + _this251._invInertia11 * _this251._transform._rotation01 + _this251._invInertia12 * _this251._transform._rotation02; __tmp__111 = _this251._invInertia10 * _this251._transform._rotation10 + _this251._invInertia11 * _this251._transform._rotation11 + _this251._invInertia12 * _this251._transform._rotation12; __tmp__121 = _this251._invInertia10 * _this251._transform._rotation20 + _this251._invInertia11 * _this251._transform._rotation21 + _this251._invInertia12 * _this251._transform._rotation22; __tmp__201 = _this251._invInertia20 * _this251._transform._rotation00 + _this251._invInertia21 * _this251._transform._rotation01 + _this251._invInertia22 * _this251._transform._rotation02; __tmp__211 = _this251._invInertia20 * _this251._transform._rotation10 + _this251._invInertia21 * _this251._transform._rotation11 + _this251._invInertia22 * _this251._transform._rotation12; __tmp__221 = _this251._invInertia20 * _this251._transform._rotation20 + _this251._invInertia21 * _this251._transform._rotation21 + _this251._invInertia22 * _this251._transform._rotation22; _this251._invInertia00 = __tmp__001; _this251._invInertia01 = __tmp__011; _this251._invInertia02 = __tmp__021; _this251._invInertia10 = __tmp__101; _this251._invInertia11 = __tmp__111; _this251._invInertia12 = __tmp__121; _this251._invInertia20 = __tmp__201; _this251._invInertia21 = __tmp__211; _this251._invInertia22 = __tmp__221; _this251._invInertia00 *= _this251._rotFactor.x; _this251._invInertia01 *= _this251._rotFactor.x; _this251._invInertia02 *= _this251._rotFactor.x; _this251._invInertia10 *= _this251._rotFactor.y; _this251._invInertia11 *= _this251._rotFactor.y; _this251._invInertia12 *= _this251._rotFactor.y; _this251._invInertia20 *= _this251._rotFactor.z; _this251._invInertia21 *= _this251._rotFactor.z; _this251._invInertia22 *= _this251._rotFactor.z; var _this252 = this._b2; var theta1 = Math.sqrt(av2X * av2X + av2Y * av2Y + av2Z * av2Z); var halfTheta1 = theta1 * 0.5; var rotationToSinAxisFactor1 = void 0; var cosHalfTheta1 = void 0; if (halfTheta1 < 0.5) { var _ht = halfTheta1 * halfTheta1; rotationToSinAxisFactor1 = 0.5 * (1 - _ht * 0.16666666666666666 + _ht * _ht * 0.0083333333333333332); cosHalfTheta1 = 1 - _ht * 0.5 + _ht * _ht * 0.041666666666666664; } else { rotationToSinAxisFactor1 = Math.sin(halfTheta1) / theta1; cosHalfTheta1 = Math.cos(halfTheta1); } var sinAxisX1 = void 0; var sinAxisY1 = void 0; var sinAxisZ1 = void 0; sinAxisX1 = av2X * rotationToSinAxisFactor1; sinAxisY1 = av2Y * rotationToSinAxisFactor1; sinAxisZ1 = av2Z * rotationToSinAxisFactor1; var dqX1 = void 0; var dqY1 = void 0; var dqZ1 = void 0; var dqW1 = void 0; dqX1 = sinAxisX1; dqY1 = sinAxisY1; dqZ1 = sinAxisZ1; dqW1 = cosHalfTheta1; var qX1 = void 0; var qY1 = void 0; var qZ1 = void 0; var qW1 = void 0; var e001 = _this252._transform._rotation00; var e111 = _this252._transform._rotation11; var e221 = _this252._transform._rotation22; var t1 = e001 + e111 + e221; var s1 = void 0; if (t1 > 0) { s1 = Math.sqrt(t1 + 1); qW1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this252._transform._rotation21 - _this252._transform._rotation12) * s1; qY1 = (_this252._transform._rotation02 - _this252._transform._rotation20) * s1; qZ1 = (_this252._transform._rotation10 - _this252._transform._rotation01) * s1; } else if (e001 > e111) { if (e001 > e221) { s1 = Math.sqrt(e001 - e111 - e221 + 1); qX1 = 0.5 * s1; s1 = 0.5 / s1; qY1 = (_this252._transform._rotation01 + _this252._transform._rotation10) * s1; qZ1 = (_this252._transform._rotation02 + _this252._transform._rotation20) * s1; qW1 = (_this252._transform._rotation21 - _this252._transform._rotation12) * s1; } else { s1 = Math.sqrt(e221 - e001 - e111 + 1); qZ1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this252._transform._rotation02 + _this252._transform._rotation20) * s1; qY1 = (_this252._transform._rotation12 + _this252._transform._rotation21) * s1; qW1 = (_this252._transform._rotation10 - _this252._transform._rotation01) * s1; } } else if (e111 > e221) { s1 = Math.sqrt(e111 - e221 - e001 + 1); qY1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this252._transform._rotation01 + _this252._transform._rotation10) * s1; qZ1 = (_this252._transform._rotation12 + _this252._transform._rotation21) * s1; qW1 = (_this252._transform._rotation02 - _this252._transform._rotation20) * s1; } else { s1 = Math.sqrt(e221 - e001 - e111 + 1); qZ1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this252._transform._rotation02 + _this252._transform._rotation20) * s1; qY1 = (_this252._transform._rotation12 + _this252._transform._rotation21) * s1; qW1 = (_this252._transform._rotation10 - _this252._transform._rotation01) * s1; } qX1 = dqW1 * qX1 + dqX1 * qW1 + dqY1 * qZ1 - dqZ1 * qY1; qY1 = dqW1 * qY1 - dqX1 * qZ1 + dqY1 * qW1 + dqZ1 * qX1; qZ1 = dqW1 * qZ1 + dqX1 * qY1 - dqY1 * qX1 + dqZ1 * qW1; qW1 = dqW1 * qW1 - dqX1 * qX1 - dqY1 * qY1 - dqZ1 * qZ1; var l1 = qX1 * qX1 + qY1 * qY1 + qZ1 * qZ1 + qW1 * qW1; if (l1 > 1e-32) { l1 = 1 / Math.sqrt(l1); } qX1 *= l1; qY1 *= l1; qZ1 *= l1; qW1 *= l1; var x1 = qX1; var y1 = qY1; var z1 = qZ1; var w1 = qW1; var x21 = 2 * x1; var y21 = 2 * y1; var z21 = 2 * z1; var xx1 = x1 * x21; var yy1 = y1 * y21; var zz1 = z1 * z21; var xy1 = x1 * y21; var yz1 = y1 * z21; var xz1 = x1 * z21; var wx1 = w1 * x21; var wy1 = w1 * y21; var wz1 = w1 * z21; _this252._transform._rotation00 = 1 - yy1 - zz1; _this252._transform._rotation01 = xy1 - wz1; _this252._transform._rotation02 = xz1 + wy1; _this252._transform._rotation10 = xy1 + wz1; _this252._transform._rotation11 = 1 - xx1 - zz1; _this252._transform._rotation12 = yz1 - wx1; _this252._transform._rotation20 = xz1 - wy1; _this252._transform._rotation21 = yz1 + wx1; _this252._transform._rotation22 = 1 - xx1 - yy1; var __tmp__002 = void 0; var __tmp__012 = void 0; var __tmp__022 = void 0; var __tmp__102 = void 0; var __tmp__112 = void 0; var __tmp__122 = void 0; var __tmp__202 = void 0; var __tmp__212 = void 0; var __tmp__222 = void 0; __tmp__002 = _this252._transform._rotation00 * _this252._invLocalInertia00 + _this252._transform._rotation01 * _this252._invLocalInertia10 + _this252._transform._rotation02 * _this252._invLocalInertia20; __tmp__012 = _this252._transform._rotation00 * _this252._invLocalInertia01 + _this252._transform._rotation01 * _this252._invLocalInertia11 + _this252._transform._rotation02 * _this252._invLocalInertia21; __tmp__022 = _this252._transform._rotation00 * _this252._invLocalInertia02 + _this252._transform._rotation01 * _this252._invLocalInertia12 + _this252._transform._rotation02 * _this252._invLocalInertia22; __tmp__102 = _this252._transform._rotation10 * _this252._invLocalInertia00 + _this252._transform._rotation11 * _this252._invLocalInertia10 + _this252._transform._rotation12 * _this252._invLocalInertia20; __tmp__112 = _this252._transform._rotation10 * _this252._invLocalInertia01 + _this252._transform._rotation11 * _this252._invLocalInertia11 + _this252._transform._rotation12 * _this252._invLocalInertia21; __tmp__122 = _this252._transform._rotation10 * _this252._invLocalInertia02 + _this252._transform._rotation11 * _this252._invLocalInertia12 + _this252._transform._rotation12 * _this252._invLocalInertia22; __tmp__202 = _this252._transform._rotation20 * _this252._invLocalInertia00 + _this252._transform._rotation21 * _this252._invLocalInertia10 + _this252._transform._rotation22 * _this252._invLocalInertia20; __tmp__212 = _this252._transform._rotation20 * _this252._invLocalInertia01 + _this252._transform._rotation21 * _this252._invLocalInertia11 + _this252._transform._rotation22 * _this252._invLocalInertia21; __tmp__222 = _this252._transform._rotation20 * _this252._invLocalInertia02 + _this252._transform._rotation21 * _this252._invLocalInertia12 + _this252._transform._rotation22 * _this252._invLocalInertia22; _this252._invInertia00 = __tmp__002; _this252._invInertia01 = __tmp__012; _this252._invInertia02 = __tmp__022; _this252._invInertia10 = __tmp__102; _this252._invInertia11 = __tmp__112; _this252._invInertia12 = __tmp__122; _this252._invInertia20 = __tmp__202; _this252._invInertia21 = __tmp__212; _this252._invInertia22 = __tmp__222; var __tmp__003 = void 0; var __tmp__013 = void 0; var __tmp__023 = void 0; var __tmp__103 = void 0; var __tmp__113 = void 0; var __tmp__123 = void 0; var __tmp__203 = void 0; var __tmp__213 = void 0; var __tmp__223 = void 0; __tmp__003 = _this252._invInertia00 * _this252._transform._rotation00 + _this252._invInertia01 * _this252._transform._rotation01 + _this252._invInertia02 * _this252._transform._rotation02; __tmp__013 = _this252._invInertia00 * _this252._transform._rotation10 + _this252._invInertia01 * _this252._transform._rotation11 + _this252._invInertia02 * _this252._transform._rotation12; __tmp__023 = _this252._invInertia00 * _this252._transform._rotation20 + _this252._invInertia01 * _this252._transform._rotation21 + _this252._invInertia02 * _this252._transform._rotation22; __tmp__103 = _this252._invInertia10 * _this252._transform._rotation00 + _this252._invInertia11 * _this252._transform._rotation01 + _this252._invInertia12 * _this252._transform._rotation02; __tmp__113 = _this252._invInertia10 * _this252._transform._rotation10 + _this252._invInertia11 * _this252._transform._rotation11 + _this252._invInertia12 * _this252._transform._rotation12; __tmp__123 = _this252._invInertia10 * _this252._transform._rotation20 + _this252._invInertia11 * _this252._transform._rotation21 + _this252._invInertia12 * _this252._transform._rotation22; __tmp__203 = _this252._invInertia20 * _this252._transform._rotation00 + _this252._invInertia21 * _this252._transform._rotation01 + _this252._invInertia22 * _this252._transform._rotation02; __tmp__213 = _this252._invInertia20 * _this252._transform._rotation10 + _this252._invInertia21 * _this252._transform._rotation11 + _this252._invInertia22 * _this252._transform._rotation12; __tmp__223 = _this252._invInertia20 * _this252._transform._rotation20 + _this252._invInertia21 * _this252._transform._rotation21 + _this252._invInertia22 * _this252._transform._rotation22; _this252._invInertia00 = __tmp__003; _this252._invInertia01 = __tmp__013; _this252._invInertia02 = __tmp__023; _this252._invInertia10 = __tmp__103; _this252._invInertia11 = __tmp__113; _this252._invInertia12 = __tmp__123; _this252._invInertia20 = __tmp__203; _this252._invInertia21 = __tmp__213; _this252._invInertia22 = __tmp__223; _this252._invInertia00 *= _this252._rotFactor.x; _this252._invInertia01 *= _this252._rotFactor.x; _this252._invInertia02 *= _this252._rotFactor.x; _this252._invInertia10 *= _this252._rotFactor.y; _this252._invInertia11 *= _this252._rotFactor.y; _this252._invInertia12 *= _this252._rotFactor.y; _this252._invInertia20 *= _this252._rotFactor.z; _this252._invInertia21 *= _this252._rotFactor.z; _this252._invInertia22 *= _this252._rotFactor.z; } var _this248 = this.posBoundarySelector; var _i147 = 0; while (_this248.indices[_i147] != _idx4) { ++_i147; } while (_i147 > 0) { var _tmp6 = _this248.indices[_i147]; _this248.indices[_i147] = _this248.indices[_i147 - 1]; _this248.indices[_i147 - 1] = _tmp6; --_i147; } solved = true; break; } } if (!solved) { console.log("src/oimo/dynamics/constraint/solver/direct/DirectJointConstraintSolver.hx:502:", "could not find solution. (NGS)"); return; } } }, { key: "postSolve", value: function postSolve() { this.joint._syncAnchors(); this.joint._checkDestruction(); } }]); return oimo_dynamics_constraint_solver_direct_DirectJointConstraintSolver; }(oimo.dynamics.constraint.ConstraintSolver); oimo.dynamics.constraint.solver.direct.MassMatrix = /*#__PURE__*/function () { function oimo_dynamics_constraint_solver_direct_MassMatrix(size) { _classCallCheck(this, oimo_dynamics_constraint_solver_direct_MassMatrix); this._size = size; this.tmpMatrix = new Array(this._size); this._invMass = new Array(this._size); this._invMassWithoutCfm = new Array(this._size); var _g = 0; var _g1 = this._size; while (_g < _g1) { var i = _g++; this.tmpMatrix[i] = new Array(this._size); this._invMass[i] = new Array(this._size); this._invMassWithoutCfm[i] = new Array(this._size); var _g316 = 0; var _g317 = this._size; while (_g316 < _g317) { var j = _g316++; this.tmpMatrix[i][j] = 0; this._invMass[i][j] = 0; this._invMassWithoutCfm[i][j] = 0; } } this._maxSubmatrixId = 1 << this._size; this._cacheComputed = new Array(this._maxSubmatrixId); this._cachedSubmatrices = new Array(this._maxSubmatrixId); var _g2 = 0; var _g3 = this._maxSubmatrixId; while (_g2 < _g3) { var _i149 = _g2++; var t = void 0; t = (_i149 & 85) + (_i149 >> 1 & 85); t = (t & 51) + (t >> 2 & 51); t = (t & 15) + (t >> 4 & 15); var matrixSize = t; var subMatrix = new Array(matrixSize); var _g318 = 0; while (_g318 < matrixSize) { var _j11 = _g318++; subMatrix[_j11] = new Array(matrixSize); var _g319 = 0; while (_g319 < matrixSize) { subMatrix[_j11][_g319++] = 0; } } this._cacheComputed[_i149] = false; this._cachedSubmatrices[_i149] = subMatrix; } } _createClass(oimo_dynamics_constraint_solver_direct_MassMatrix, [{ key: "computeSubmatrix", value: function computeSubmatrix(id, indices, size) { var _g = 0; while (_g < size) { var i = _g++; var ii = indices[i]; var _g1 = 0; while (_g1 < size) { var j = _g1++; this.tmpMatrix[i][j] = this._invMass[ii][indices[j]]; } } var src = this.tmpMatrix; var dst = this._cachedSubmatrices[id]; var srci; var dsti; var srcj; var dstj; var diag; switch (size) { case 4: srci = src[0]; dsti = dst[0]; diag = 1 / srci[0]; dsti[0] = diag; srci[1] *= diag; srci[2] *= diag; srci[3] *= diag; srcj = src[1]; dstj = dst[1]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srcj = src[2]; dstj = dst[2]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srcj = src[3]; dstj = dst[3]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srci = src[1]; dsti = dst[1]; diag = 1 / srci[1]; dsti[1] = diag; dsti[0] *= diag; srci[2] *= diag; srci[3] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srcj = src[2]; dstj = dst[2]; dstj[0] -= dsti[0] * srcj[1]; dstj[1] = -diag * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srcj = src[3]; dstj = dst[3]; dstj[0] -= dsti[0] * srcj[1]; dstj[1] = -diag * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srci = src[2]; dsti = dst[2]; diag = 1 / srci[2]; dsti[2] = diag; dsti[0] *= diag; dsti[1] *= diag; srci[3] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srcj = src[1]; dstj = dst[1]; dstj[0] -= dsti[0] * srcj[2]; dstj[1] -= dsti[1] * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srcj = src[3]; dstj = dst[3]; dstj[0] -= dsti[0] * srcj[2]; dstj[1] -= dsti[1] * srcj[2]; dstj[2] = -diag * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srci = src[3]; dsti = dst[3]; diag = 1 / srci[3]; dsti[3] = diag; dsti[0] *= diag; dsti[1] *= diag; dsti[2] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[3]; srcj = src[1]; dstj = dst[1]; dstj[0] -= dsti[0] * srcj[3]; dstj[1] -= dsti[1] * srcj[3]; srcj = src[2]; dstj = dst[2]; dstj[0] -= dsti[0] * srcj[3]; dstj[1] -= dsti[1] * srcj[3]; dstj[2] -= dsti[2] * srcj[3]; dsti = dst[1]; dst[0][1] = dsti[0]; dsti = dst[2]; dst[0][2] = dsti[0]; dst[1][2] = dsti[1]; dsti = dst[3]; dst[0][3] = dsti[0]; dst[1][3] = dsti[1]; dst[2][3] = dsti[2]; break; case 5: srci = src[0]; dsti = dst[0]; diag = 1 / srci[0]; dsti[0] = diag; srci[1] *= diag; srci[2] *= diag; srci[3] *= diag; srci[4] *= diag; srcj = src[1]; dstj = dst[1]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srcj[4] -= srci[4] * srcj[0]; srcj = src[2]; dstj = dst[2]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srcj[4] -= srci[4] * srcj[0]; srcj = src[3]; dstj = dst[3]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srcj[4] -= srci[4] * srcj[0]; srcj = src[4]; dstj = dst[4]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srcj[4] -= srci[4] * srcj[0]; srci = src[1]; dsti = dst[1]; diag = 1 / srci[1]; dsti[1] = diag; dsti[0] *= diag; srci[2] *= diag; srci[3] *= diag; srci[4] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srcj[4] -= srci[4] * srcj[1]; srcj = src[2]; dstj = dst[2]; dstj[0] -= dsti[0] * srcj[1]; dstj[1] = -diag * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srcj[4] -= srci[4] * srcj[1]; srcj = src[3]; dstj = dst[3]; dstj[0] -= dsti[0] * srcj[1]; dstj[1] = -diag * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srcj[4] -= srci[4] * srcj[1]; srcj = src[4]; dstj = dst[4]; dstj[0] -= dsti[0] * srcj[1]; dstj[1] = -diag * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srcj[4] -= srci[4] * srcj[1]; srci = src[2]; dsti = dst[2]; diag = 1 / srci[2]; dsti[2] = diag; dsti[0] *= diag; dsti[1] *= diag; srci[3] *= diag; srci[4] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srcj[4] -= srci[4] * srcj[2]; srcj = src[1]; dstj = dst[1]; dstj[0] -= dsti[0] * srcj[2]; dstj[1] -= dsti[1] * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srcj[4] -= srci[4] * srcj[2]; srcj = src[3]; dstj = dst[3]; dstj[0] -= dsti[0] * srcj[2]; dstj[1] -= dsti[1] * srcj[2]; dstj[2] = -diag * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srcj[4] -= srci[4] * srcj[2]; srcj = src[4]; dstj = dst[4]; dstj[0] -= dsti[0] * srcj[2]; dstj[1] -= dsti[1] * srcj[2]; dstj[2] = -diag * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srcj[4] -= srci[4] * srcj[2]; srci = src[3]; dsti = dst[3]; diag = 1 / srci[3]; dsti[3] = diag; dsti[0] *= diag; dsti[1] *= diag; dsti[2] *= diag; srci[4] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[3]; srcj[4] -= srci[4] * srcj[3]; srcj = src[1]; dstj = dst[1]; dstj[0] -= dsti[0] * srcj[3]; dstj[1] -= dsti[1] * srcj[3]; srcj[4] -= srci[4] * srcj[3]; srcj = src[2]; dstj = dst[2]; dstj[0] -= dsti[0] * srcj[3]; dstj[1] -= dsti[1] * srcj[3]; dstj[2] -= dsti[2] * srcj[3]; srcj[4] -= srci[4] * srcj[3]; srcj = src[4]; dstj = dst[4]; dstj[0] -= dsti[0] * srcj[3]; dstj[1] -= dsti[1] * srcj[3]; dstj[2] -= dsti[2] * srcj[3]; dstj[3] = -diag * srcj[3]; srcj[4] -= srci[4] * srcj[3]; srci = src[4]; dsti = dst[4]; diag = 1 / srci[4]; dsti[4] = diag; dsti[0] *= diag; dsti[1] *= diag; dsti[2] *= diag; dsti[3] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[4]; srcj = src[1]; dstj = dst[1]; dstj[0] -= dsti[0] * srcj[4]; dstj[1] -= dsti[1] * srcj[4]; srcj = src[2]; dstj = dst[2]; dstj[0] -= dsti[0] * srcj[4]; dstj[1] -= dsti[1] * srcj[4]; dstj[2] -= dsti[2] * srcj[4]; srcj = src[3]; dstj = dst[3]; dstj[0] -= dsti[0] * srcj[4]; dstj[1] -= dsti[1] * srcj[4]; dstj[2] -= dsti[2] * srcj[4]; dstj[3] -= dsti[3] * srcj[4]; dsti = dst[1]; dst[0][1] = dsti[0]; dsti = dst[2]; dst[0][2] = dsti[0]; dst[1][2] = dsti[1]; dsti = dst[3]; dst[0][3] = dsti[0]; dst[1][3] = dsti[1]; dst[2][3] = dsti[2]; dsti = dst[4]; dst[0][4] = dsti[0]; dst[1][4] = dsti[1]; dst[2][4] = dsti[2]; dst[3][4] = dsti[3]; break; case 6: srci = src[0]; dsti = dst[0]; diag = 1 / srci[0]; dsti[0] = diag; srci[1] *= diag; srci[2] *= diag; srci[3] *= diag; srci[4] *= diag; srci[5] *= diag; srcj = src[1]; dstj = dst[1]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srcj[4] -= srci[4] * srcj[0]; srcj[5] -= srci[5] * srcj[0]; srcj = src[2]; dstj = dst[2]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srcj[4] -= srci[4] * srcj[0]; srcj[5] -= srci[5] * srcj[0]; srcj = src[3]; dstj = dst[3]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srcj[4] -= srci[4] * srcj[0]; srcj[5] -= srci[5] * srcj[0]; srcj = src[4]; dstj = dst[4]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srcj[4] -= srci[4] * srcj[0]; srcj[5] -= srci[5] * srcj[0]; srcj = src[5]; dstj = dst[5]; dstj[0] = -diag * srcj[0]; srcj[1] -= srci[1] * srcj[0]; srcj[2] -= srci[2] * srcj[0]; srcj[3] -= srci[3] * srcj[0]; srcj[4] -= srci[4] * srcj[0]; srcj[5] -= srci[5] * srcj[0]; srci = src[1]; dsti = dst[1]; diag = 1 / srci[1]; dsti[1] = diag; dsti[0] *= diag; srci[2] *= diag; srci[3] *= diag; srci[4] *= diag; srci[5] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srcj[4] -= srci[4] * srcj[1]; srcj[5] -= srci[5] * srcj[1]; srcj = src[2]; dstj = dst[2]; dstj[0] -= dsti[0] * srcj[1]; dstj[1] = -diag * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srcj[4] -= srci[4] * srcj[1]; srcj[5] -= srci[5] * srcj[1]; srcj = src[3]; dstj = dst[3]; dstj[0] -= dsti[0] * srcj[1]; dstj[1] = -diag * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srcj[4] -= srci[4] * srcj[1]; srcj[5] -= srci[5] * srcj[1]; srcj = src[4]; dstj = dst[4]; dstj[0] -= dsti[0] * srcj[1]; dstj[1] = -diag * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srcj[4] -= srci[4] * srcj[1]; srcj[5] -= srci[5] * srcj[1]; srcj = src[5]; dstj = dst[5]; dstj[0] -= dsti[0] * srcj[1]; dstj[1] = -diag * srcj[1]; srcj[2] -= srci[2] * srcj[1]; srcj[3] -= srci[3] * srcj[1]; srcj[4] -= srci[4] * srcj[1]; srcj[5] -= srci[5] * srcj[1]; srci = src[2]; dsti = dst[2]; diag = 1 / srci[2]; dsti[2] = diag; dsti[0] *= diag; dsti[1] *= diag; srci[3] *= diag; srci[4] *= diag; srci[5] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srcj[4] -= srci[4] * srcj[2]; srcj[5] -= srci[5] * srcj[2]; srcj = src[1]; dstj = dst[1]; dstj[0] -= dsti[0] * srcj[2]; dstj[1] -= dsti[1] * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srcj[4] -= srci[4] * srcj[2]; srcj[5] -= srci[5] * srcj[2]; srcj = src[3]; dstj = dst[3]; dstj[0] -= dsti[0] * srcj[2]; dstj[1] -= dsti[1] * srcj[2]; dstj[2] = -diag * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srcj[4] -= srci[4] * srcj[2]; srcj[5] -= srci[5] * srcj[2]; srcj = src[4]; dstj = dst[4]; dstj[0] -= dsti[0] * srcj[2]; dstj[1] -= dsti[1] * srcj[2]; dstj[2] = -diag * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srcj[4] -= srci[4] * srcj[2]; srcj[5] -= srci[5] * srcj[2]; srcj = src[5]; dstj = dst[5]; dstj[0] -= dsti[0] * srcj[2]; dstj[1] -= dsti[1] * srcj[2]; dstj[2] = -diag * srcj[2]; srcj[3] -= srci[3] * srcj[2]; srcj[4] -= srci[4] * srcj[2]; srcj[5] -= srci[5] * srcj[2]; srci = src[3]; dsti = dst[3]; diag = 1 / srci[3]; dsti[3] = diag; dsti[0] *= diag; dsti[1] *= diag; dsti[2] *= diag; srci[4] *= diag; srci[5] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[3]; srcj[4] -= srci[4] * srcj[3]; srcj[5] -= srci[5] * srcj[3]; srcj = src[1]; dstj = dst[1]; dstj[0] -= dsti[0] * srcj[3]; dstj[1] -= dsti[1] * srcj[3]; srcj[4] -= srci[4] * srcj[3]; srcj[5] -= srci[5] * srcj[3]; srcj = src[2]; dstj = dst[2]; dstj[0] -= dsti[0] * srcj[3]; dstj[1] -= dsti[1] * srcj[3]; dstj[2] -= dsti[2] * srcj[3]; srcj[4] -= srci[4] * srcj[3]; srcj[5] -= srci[5] * srcj[3]; srcj = src[4]; dstj = dst[4]; dstj[0] -= dsti[0] * srcj[3]; dstj[1] -= dsti[1] * srcj[3]; dstj[2] -= dsti[2] * srcj[3]; dstj[3] = -diag * srcj[3]; srcj[4] -= srci[4] * srcj[3]; srcj[5] -= srci[5] * srcj[3]; srcj = src[5]; dstj = dst[5]; dstj[0] -= dsti[0] * srcj[3]; dstj[1] -= dsti[1] * srcj[3]; dstj[2] -= dsti[2] * srcj[3]; dstj[3] = -diag * srcj[3]; srcj[4] -= srci[4] * srcj[3]; srcj[5] -= srci[5] * srcj[3]; srci = src[4]; dsti = dst[4]; diag = 1 / srci[4]; dsti[4] = diag; dsti[0] *= diag; dsti[1] *= diag; dsti[2] *= diag; dsti[3] *= diag; srci[5] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[4]; srcj[5] -= srci[5] * srcj[4]; srcj = src[1]; dstj = dst[1]; dstj[0] -= dsti[0] * srcj[4]; dstj[1] -= dsti[1] * srcj[4]; srcj[5] -= srci[5] * srcj[4]; srcj = src[2]; dstj = dst[2]; dstj[0] -= dsti[0] * srcj[4]; dstj[1] -= dsti[1] * srcj[4]; dstj[2] -= dsti[2] * srcj[4]; srcj[5] -= srci[5] * srcj[4]; srcj = src[3]; dstj = dst[3]; dstj[0] -= dsti[0] * srcj[4]; dstj[1] -= dsti[1] * srcj[4]; dstj[2] -= dsti[2] * srcj[4]; dstj[3] -= dsti[3] * srcj[4]; srcj[5] -= srci[5] * srcj[4]; srcj = src[5]; dstj = dst[5]; dstj[0] -= dsti[0] * srcj[4]; dstj[1] -= dsti[1] * srcj[4]; dstj[2] -= dsti[2] * srcj[4]; dstj[3] -= dsti[3] * srcj[4]; dstj[4] = -diag * srcj[4]; srcj[5] -= srci[5] * srcj[4]; srci = src[5]; dsti = dst[5]; diag = 1 / srci[5]; dsti[5] = diag; dsti[0] *= diag; dsti[1] *= diag; dsti[2] *= diag; dsti[3] *= diag; dsti[4] *= diag; srcj = src[0]; dstj = dst[0]; dstj[0] -= dsti[0] * srcj[5]; srcj = src[1]; dstj = dst[1]; dstj[0] -= dsti[0] * srcj[5]; dstj[1] -= dsti[1] * srcj[5]; srcj = src[2]; dstj = dst[2]; dstj[0] -= dsti[0] * srcj[5]; dstj[1] -= dsti[1] * srcj[5]; dstj[2] -= dsti[2] * srcj[5]; srcj = src[3]; dstj = dst[3]; dstj[0] -= dsti[0] * srcj[5]; dstj[1] -= dsti[1] * srcj[5]; dstj[2] -= dsti[2] * srcj[5]; dstj[3] -= dsti[3] * srcj[5]; srcj = src[4]; dstj = dst[4]; dstj[0] -= dsti[0] * srcj[5]; dstj[1] -= dsti[1] * srcj[5]; dstj[2] -= dsti[2] * srcj[5]; dstj[3] -= dsti[3] * srcj[5]; dstj[4] -= dsti[4] * srcj[5]; dsti = dst[1]; dst[0][1] = dsti[0]; dsti = dst[2]; dst[0][2] = dsti[0]; dst[1][2] = dsti[1]; dsti = dst[3]; dst[0][3] = dsti[0]; dst[1][3] = dsti[1]; dst[2][3] = dsti[2]; dsti = dst[4]; dst[0][4] = dsti[0]; dst[1][4] = dsti[1]; dst[2][4] = dsti[2]; dst[3][4] = dsti[3]; dsti = dst[5]; dst[0][5] = dsti[0]; dst[1][5] = dsti[1]; dst[2][5] = dsti[2]; dst[3][5] = dsti[3]; dst[4][5] = dsti[4]; break; default: var _g320 = 0; while (_g320 < size) { var _i150 = _g320++; srci = src[_i150]; dsti = dst[_i150]; var _diag = 1 / srci[_i150]; dsti[_i150] = _diag; var _g321 = 0; while (_g321 < _i150) { dsti[_g321++] *= _diag; } var _g322 = _i150 + 1; while (_g322 < size) { srci[_g322++] *= _diag; } var _g3 = 0; while (_g3 < _i150) { var _j12 = _g3++; srcj = src[_j12]; dstj = dst[_j12]; var _g323 = 0; var _g324 = _j12 + 1; while (_g323 < _g324) { var k = _g323++; dstj[k] -= dsti[k] * srcj[_i150]; } var _g325 = _i150 + 1; while (_g325 < size) { var _k = _g325++; srcj[_k] -= srci[_k] * srcj[_i150]; } } var _g4 = _i150 + 1; while (_g4 < size) { var _j13 = _g4++; srcj = src[_j13]; dstj = dst[_j13]; var _g326 = 0; while (_g326 < _i150) { var _k2 = _g326++; dstj[_k2] -= dsti[_k2] * srcj[_i150]; } dstj[_i150] = -_diag * srcj[_i150]; var _g327 = _i150 + 1; while (_g327 < size) { var _k3 = _g327++; srcj[_k3] -= srci[_k3] * srcj[_i150]; } } } var _g2 = 1; while (_g2 < size) { var _i151 = _g2++; dsti = dst[_i151]; var _g328 = 0; while (_g328 < _i151) { var _j14 = _g328++; dst[_j14][_i151] = dsti[_j14]; } } } } }, { key: "computeInvMass", value: function computeInvMass(info, massData) { var invMass = this._invMass; var invMassWithoutCfm = this._invMassWithoutCfm; var numRows = info.numRows; var b1 = info.b1; var b2 = info.b2; var invM1 = b1._invMass; var invM2 = b2._invMass; var invI100; var invI101; var invI102; var invI110; var invI111; var invI112; var invI120; var invI121; var invI122; var invI200; var invI201; var invI202; var invI210; var invI211; var invI212; var invI220; var invI221; var invI222; invI100 = b1._invInertia00; invI101 = b1._invInertia01; invI102 = b1._invInertia02; invI110 = b1._invInertia10; invI111 = b1._invInertia11; invI112 = b1._invInertia12; invI120 = b1._invInertia20; invI121 = b1._invInertia21; invI122 = b1._invInertia22; invI200 = b2._invInertia00; invI201 = b2._invInertia01; invI202 = b2._invInertia02; invI210 = b2._invInertia10; invI211 = b2._invInertia11; invI212 = b2._invInertia12; invI220 = b2._invInertia20; invI221 = b2._invInertia21; invI222 = b2._invInertia22; var _g = 0; while (_g < numRows) { var i = _g++; var j = info.rows[i].jacobian; var md = massData[i]; j.updateSparsity(); if ((j.flag & 1) != 0) { md.invMLin1X = j.lin1X * invM1; md.invMLin1Y = j.lin1Y * invM1; md.invMLin1Z = j.lin1Z * invM1; md.invMLin2X = j.lin2X * invM2; md.invMLin2Y = j.lin2Y * invM2; md.invMLin2Z = j.lin2Z * invM2; } else { md.invMLin1X = 0; md.invMLin1Y = 0; md.invMLin1Z = 0; md.invMLin2X = 0; md.invMLin2Y = 0; md.invMLin2Z = 0; } if ((j.flag & 2) != 0) { var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z; __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z; __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z; md.invMAng1X = __tmp__X; md.invMAng1Y = __tmp__Y; md.invMAng1Z = __tmp__Z; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z; __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z; __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z; md.invMAng2X = __tmp__X1; md.invMAng2Y = __tmp__Y1; md.invMAng2Z = __tmp__Z1; } else { md.invMAng1X = 0; md.invMAng1Y = 0; md.invMAng1Z = 0; md.invMAng2X = 0; md.invMAng2Y = 0; md.invMAng2Z = 0; } } var _g1 = 0; while (_g1 < numRows) { var _i152 = _g1++; var j1 = info.rows[_i152].jacobian; var _g329 = _i152; while (_g329 < numRows) { var _j15 = _g329++; var md2 = massData[_j15]; var val = j1.lin1X * md2.invMLin1X + j1.lin1Y * md2.invMLin1Y + j1.lin1Z * md2.invMLin1Z + (j1.ang1X * md2.invMAng1X + j1.ang1Y * md2.invMAng1Y + j1.ang1Z * md2.invMAng1Z) + (j1.lin2X * md2.invMLin2X + j1.lin2Y * md2.invMLin2Y + j1.lin2Z * md2.invMLin2Z) + (j1.ang2X * md2.invMAng2X + j1.ang2Y * md2.invMAng2Y + j1.ang2Z * md2.invMAng2Z); if (_i152 == _j15) { invMass[_i152][_j15] = val + info.rows[_i152].cfm; invMassWithoutCfm[_i152][_j15] = val; md2.mass = val + info.rows[_i152].cfm; md2.massWithoutCfm = val; if (md2.mass != 0) { md2.mass = 1 / md2.mass; } if (md2.massWithoutCfm != 0) { md2.massWithoutCfm = 1 / md2.massWithoutCfm; } } else { invMass[_i152][_j15] = val; invMass[_j15][_i152] = val; invMassWithoutCfm[_i152][_j15] = val; invMassWithoutCfm[_j15][_i152] = val; } } } var _g2 = 0; var _g3 = this._maxSubmatrixId; while (_g2 < _g3) { this._cacheComputed[_g2++] = false; } } }]); return oimo_dynamics_constraint_solver_direct_MassMatrix; }(); if (!oimo.dynamics.constraint.solver.pgs) oimo.dynamics.constraint.solver.pgs = {}; oimo.dynamics.constraint.solver.pgs.PgsContactConstraintSolver = /*#__PURE__*/function (_oimo$dynamics$constr16) { _inherits(oimo_dynamics_constraint_solver_pgs_PgsContactConstraintSolver, _oimo$dynamics$constr16); var _super38 = _createSuper(oimo_dynamics_constraint_solver_pgs_PgsContactConstraintSolver); function oimo_dynamics_constraint_solver_pgs_PgsContactConstraintSolver(constraint) { var _this253; _classCallCheck(this, oimo_dynamics_constraint_solver_pgs_PgsContactConstraintSolver); _this253 = _super38.call(this); _this253.constraint = constraint; _this253.info = new oimo.dynamics.constraint.info.contact.ContactSolverInfo(); _this253.massData = new Array(oimo.common.Setting.maxManifoldPoints); var _g = 0; var _g1 = _this253.massData.length; while (_g < _g1) { _this253.massData[_g++] = new oimo.dynamics.constraint.solver.common.ContactSolverMassDataRow(); } return _this253; } _createClass(oimo_dynamics_constraint_solver_pgs_PgsContactConstraintSolver, [{ key: "preSolveVelocity", value: function preSolveVelocity(timeStep) { this.constraint._getVelocitySolverInfo(timeStep, this.info); this._b1 = this.info.b1; this._b2 = this.info.b2; var invM1 = this._b1._invMass; var invM2 = this._b2._invMass; var invI100; var invI101; var invI102; var invI110; var invI111; var invI112; var invI120; var invI121; var invI122; var invI200; var invI201; var invI202; var invI210; var invI211; var invI212; var invI220; var invI221; var invI222; invI100 = this._b1._invInertia00; invI101 = this._b1._invInertia01; invI102 = this._b1._invInertia02; invI110 = this._b1._invInertia10; invI111 = this._b1._invInertia11; invI112 = this._b1._invInertia12; invI120 = this._b1._invInertia20; invI121 = this._b1._invInertia21; invI122 = this._b1._invInertia22; invI200 = this._b2._invInertia00; invI201 = this._b2._invInertia01; invI202 = this._b2._invInertia02; invI210 = this._b2._invInertia10; invI211 = this._b2._invInertia11; invI212 = this._b2._invInertia12; invI220 = this._b2._invInertia20; invI221 = this._b2._invInertia21; invI222 = this._b2._invInertia22; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var row = this.info.rows[i]; var md = this.massData[i]; var j = row.jacobianN; md.invMLinN1X = j.lin1X * invM1; md.invMLinN1Y = j.lin1Y * invM1; md.invMLinN1Z = j.lin1Z * invM1; md.invMLinN2X = j.lin2X * invM2; md.invMLinN2Y = j.lin2Y * invM2; md.invMLinN2Z = j.lin2Z * invM2; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z; __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z; __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z; md.invMAngN1X = __tmp__X; md.invMAngN1Y = __tmp__Y; md.invMAngN1Z = __tmp__Z; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z; __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z; __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z; md.invMAngN2X = __tmp__X1; md.invMAngN2Y = __tmp__Y1; md.invMAngN2Z = __tmp__Z1; md.massN = invM1 + invM2 + (md.invMAngN1X * j.ang1X + md.invMAngN1Y * j.ang1Y + md.invMAngN1Z * j.ang1Z) + (md.invMAngN2X * j.ang2X + md.invMAngN2Y * j.ang2Y + md.invMAngN2Z * j.ang2Z); if (md.massN != 0) { md.massN = 1 / md.massN; } var jt = row.jacobianT; var jb = row.jacobianB; md.invMLinT1X = jt.lin1X * invM1; md.invMLinT1Y = jt.lin1Y * invM1; md.invMLinT1Z = jt.lin1Z * invM1; md.invMLinT2X = jt.lin2X * invM2; md.invMLinT2Y = jt.lin2Y * invM2; md.invMLinT2Z = jt.lin2Z * invM2; md.invMLinB1X = jb.lin1X * invM1; md.invMLinB1Y = jb.lin1Y * invM1; md.invMLinB1Z = jb.lin1Z * invM1; md.invMLinB2X = jb.lin2X * invM2; md.invMLinB2Y = jb.lin2Y * invM2; md.invMLinB2Z = jb.lin2Z * invM2; var __tmp__X2 = void 0; var __tmp__Y2 = void 0; var __tmp__Z2 = void 0; __tmp__X2 = invI100 * jt.ang1X + invI101 * jt.ang1Y + invI102 * jt.ang1Z; __tmp__Y2 = invI110 * jt.ang1X + invI111 * jt.ang1Y + invI112 * jt.ang1Z; __tmp__Z2 = invI120 * jt.ang1X + invI121 * jt.ang1Y + invI122 * jt.ang1Z; md.invMAngT1X = __tmp__X2; md.invMAngT1Y = __tmp__Y2; md.invMAngT1Z = __tmp__Z2; var __tmp__X3 = void 0; var __tmp__Y3 = void 0; var __tmp__Z3 = void 0; __tmp__X3 = invI200 * jt.ang2X + invI201 * jt.ang2Y + invI202 * jt.ang2Z; __tmp__Y3 = invI210 * jt.ang2X + invI211 * jt.ang2Y + invI212 * jt.ang2Z; __tmp__Z3 = invI220 * jt.ang2X + invI221 * jt.ang2Y + invI222 * jt.ang2Z; md.invMAngT2X = __tmp__X3; md.invMAngT2Y = __tmp__Y3; md.invMAngT2Z = __tmp__Z3; var __tmp__X4 = void 0; var __tmp__Y4 = void 0; var __tmp__Z4 = void 0; __tmp__X4 = invI100 * jb.ang1X + invI101 * jb.ang1Y + invI102 * jb.ang1Z; __tmp__Y4 = invI110 * jb.ang1X + invI111 * jb.ang1Y + invI112 * jb.ang1Z; __tmp__Z4 = invI120 * jb.ang1X + invI121 * jb.ang1Y + invI122 * jb.ang1Z; md.invMAngB1X = __tmp__X4; md.invMAngB1Y = __tmp__Y4; md.invMAngB1Z = __tmp__Z4; var __tmp__X5 = void 0; var __tmp__Y5 = void 0; var __tmp__Z5 = void 0; __tmp__X5 = invI200 * jb.ang2X + invI201 * jb.ang2Y + invI202 * jb.ang2Z; __tmp__Y5 = invI210 * jb.ang2X + invI211 * jb.ang2Y + invI212 * jb.ang2Z; __tmp__Z5 = invI220 * jb.ang2X + invI221 * jb.ang2Y + invI222 * jb.ang2Z; md.invMAngB2X = __tmp__X5; md.invMAngB2Y = __tmp__Y5; md.invMAngB2Z = __tmp__Z5; var invMassTB00 = invM1 + invM2 + (md.invMAngT1X * jt.ang1X + md.invMAngT1Y * jt.ang1Y + md.invMAngT1Z * jt.ang1Z) + (md.invMAngT2X * jt.ang2X + md.invMAngT2Y * jt.ang2Y + md.invMAngT2Z * jt.ang2Z); var invMassTB01 = md.invMAngT1X * jb.ang1X + md.invMAngT1Y * jb.ang1Y + md.invMAngT1Z * jb.ang1Z + (md.invMAngT2X * jb.ang2X + md.invMAngT2Y * jb.ang2Y + md.invMAngT2Z * jb.ang2Z); var invMassTB11 = invM1 + invM2 + (md.invMAngB1X * jb.ang1X + md.invMAngB1Y * jb.ang1Y + md.invMAngB1Z * jb.ang1Z) + (md.invMAngB2X * jb.ang2X + md.invMAngB2Y * jb.ang2Y + md.invMAngB2Z * jb.ang2Z); var invDet = invMassTB00 * invMassTB11 - invMassTB01 * invMassTB01; if (invDet != 0) { invDet = 1 / invDet; } md.massTB00 = invMassTB11 * invDet; md.massTB01 = -invMassTB01 * invDet; md.massTB10 = -invMassTB01 * invDet; md.massTB11 = invMassTB00 * invDet; } } }, { key: "warmStart", value: function warmStart(timeStep) { var lv1X; var lv1Y; var lv1Z; var lv2X; var lv2Y; var lv2Z; var av1X; var av1Y; var av1Z; var av2X; var av2Y; var av2Z; lv1X = this._b1._velX; lv1Y = this._b1._velY; lv1Z = this._b1._velZ; lv2X = this._b2._velX; lv2Y = this._b2._velY; lv2Z = this._b2._velZ; av1X = this._b1._angVelX; av1Y = this._b1._angVelY; av1Z = this._b1._angVelZ; av2X = this._b2._angVelX; av2Y = this._b2._angVelY; av2Z = this._b2._angVelZ; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var row = this.info.rows[i]; var imp = row.impulse; var md = this.massData[i]; var jt = row.jacobianT; var jb = row.jacobianB; var impulseN = imp.impulseN; var impulseT = imp.impulseLX * jt.lin1X + imp.impulseLY * jt.lin1Y + imp.impulseLZ * jt.lin1Z; var impulseB = imp.impulseLX * jb.lin1X + imp.impulseLY * jb.lin1Y + imp.impulseLZ * jb.lin1Z; imp.impulseT = impulseT; imp.impulseB = impulseB; imp.impulseN *= timeStep.dtRatio; imp.impulseT *= timeStep.dtRatio; imp.impulseB *= timeStep.dtRatio; lv1X += md.invMLinN1X * impulseN; lv1Y += md.invMLinN1Y * impulseN; lv1Z += md.invMLinN1Z * impulseN; lv1X += md.invMLinT1X * impulseT; lv1Y += md.invMLinT1Y * impulseT; lv1Z += md.invMLinT1Z * impulseT; lv1X += md.invMLinB1X * impulseB; lv1Y += md.invMLinB1Y * impulseB; lv1Z += md.invMLinB1Z * impulseB; lv2X += md.invMLinN2X * -impulseN; lv2Y += md.invMLinN2Y * -impulseN; lv2Z += md.invMLinN2Z * -impulseN; lv2X += md.invMLinT2X * -impulseT; lv2Y += md.invMLinT2Y * -impulseT; lv2Z += md.invMLinT2Z * -impulseT; lv2X += md.invMLinB2X * -impulseB; lv2Y += md.invMLinB2Y * -impulseB; lv2Z += md.invMLinB2Z * -impulseB; av1X += md.invMAngN1X * impulseN; av1Y += md.invMAngN1Y * impulseN; av1Z += md.invMAngN1Z * impulseN; av1X += md.invMAngT1X * impulseT; av1Y += md.invMAngT1Y * impulseT; av1Z += md.invMAngT1Z * impulseT; av1X += md.invMAngB1X * impulseB; av1Y += md.invMAngB1Y * impulseB; av1Z += md.invMAngB1Z * impulseB; av2X += md.invMAngN2X * -impulseN; av2Y += md.invMAngN2Y * -impulseN; av2Z += md.invMAngN2Z * -impulseN; av2X += md.invMAngT2X * -impulseT; av2Y += md.invMAngT2Y * -impulseT; av2Z += md.invMAngT2Z * -impulseT; av2X += md.invMAngB2X * -impulseB; av2Y += md.invMAngB2Y * -impulseB; av2Z += md.invMAngB2Z * -impulseB; } this._b1._velX = lv1X; this._b1._velY = lv1Y; this._b1._velZ = lv1Z; this._b2._velX = lv2X; this._b2._velY = lv2Y; this._b2._velZ = lv2Z; this._b1._angVelX = av1X; this._b1._angVelY = av1Y; this._b1._angVelZ = av1Z; this._b2._angVelX = av2X; this._b2._angVelY = av2Y; this._b2._angVelZ = av2Z; } }, { key: "solveVelocity", value: function solveVelocity() { var lv1X; var lv1Y; var lv1Z; var lv2X; var lv2Y; var lv2Z; var av1X; var av1Y; var av1Z; var av2X; var av2Y; var av2Z; lv1X = this._b1._velX; lv1Y = this._b1._velY; lv1Z = this._b1._velZ; lv2X = this._b2._velX; lv2Y = this._b2._velY; lv2Z = this._b2._velZ; av1X = this._b1._angVelX; av1Y = this._b1._angVelY; av1Z = this._b1._angVelZ; av2X = this._b2._angVelX; av2Y = this._b2._angVelY; av2Z = this._b2._angVelZ; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var row = this.info.rows[i]; var md = this.massData[i]; var imp = row.impulse; var rvt = 0; var j = row.jacobianT; rvt += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z; rvt -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z; rvt += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z; rvt -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z; var rvb = 0; j = row.jacobianB; rvb += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z; rvb -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z; rvb += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z; rvb -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z; var impulseT = -(rvt * md.massTB00 + rvb * md.massTB01); var impulseB = -(rvt * md.massTB10 + rvb * md.massTB11); var oldImpulseT = imp.impulseT; var oldImpulseB = imp.impulseB; imp.impulseT += impulseT; imp.impulseB += impulseB; var maxImpulse = row.friction * imp.impulseN; if (maxImpulse == 0) { imp.impulseT = 0; imp.impulseB = 0; } else { var impulseLengthSq = imp.impulseT * imp.impulseT + imp.impulseB * imp.impulseB; if (impulseLengthSq > maxImpulse * maxImpulse) { var invL = maxImpulse / Math.sqrt(impulseLengthSq); imp.impulseT *= invL; imp.impulseB *= invL; } } impulseT = imp.impulseT - oldImpulseT; impulseB = imp.impulseB - oldImpulseB; lv1X += md.invMLinT1X * impulseT; lv1Y += md.invMLinT1Y * impulseT; lv1Z += md.invMLinT1Z * impulseT; lv1X += md.invMLinB1X * impulseB; lv1Y += md.invMLinB1Y * impulseB; lv1Z += md.invMLinB1Z * impulseB; lv2X += md.invMLinT2X * -impulseT; lv2Y += md.invMLinT2Y * -impulseT; lv2Z += md.invMLinT2Z * -impulseT; lv2X += md.invMLinB2X * -impulseB; lv2Y += md.invMLinB2Y * -impulseB; lv2Z += md.invMLinB2Z * -impulseB; av1X += md.invMAngT1X * impulseT; av1Y += md.invMAngT1Y * impulseT; av1Z += md.invMAngT1Z * impulseT; av1X += md.invMAngB1X * impulseB; av1Y += md.invMAngB1Y * impulseB; av1Z += md.invMAngB1Z * impulseB; av2X += md.invMAngT2X * -impulseT; av2Y += md.invMAngT2Y * -impulseT; av2Z += md.invMAngT2Z * -impulseT; av2X += md.invMAngB2X * -impulseB; av2Y += md.invMAngB2Y * -impulseB; av2Z += md.invMAngB2Z * -impulseB; } var _g2 = 0; var _g3 = this.info.numRows; while (_g2 < _g3) { var _i153 = _g2++; var _row19 = this.info.rows[_i153]; var _md = this.massData[_i153]; var _imp4 = _row19.impulse; var rvn = 0; var _j16 = _row19.jacobianN; rvn += lv1X * _j16.lin1X + lv1Y * _j16.lin1Y + lv1Z * _j16.lin1Z; rvn -= lv2X * _j16.lin2X + lv2Y * _j16.lin2Y + lv2Z * _j16.lin2Z; rvn += av1X * _j16.ang1X + av1Y * _j16.ang1Y + av1Z * _j16.ang1Z; rvn -= av2X * _j16.ang2X + av2Y * _j16.ang2Y + av2Z * _j16.ang2Z; var impulseN = (_row19.rhs - rvn) * _md.massN; var oldImpulseN = _imp4.impulseN; _imp4.impulseN += impulseN; if (_imp4.impulseN < 0) { _imp4.impulseN = 0; } impulseN = _imp4.impulseN - oldImpulseN; lv1X += _md.invMLinN1X * impulseN; lv1Y += _md.invMLinN1Y * impulseN; lv1Z += _md.invMLinN1Z * impulseN; lv2X += _md.invMLinN2X * -impulseN; lv2Y += _md.invMLinN2Y * -impulseN; lv2Z += _md.invMLinN2Z * -impulseN; av1X += _md.invMAngN1X * impulseN; av1Y += _md.invMAngN1Y * impulseN; av1Z += _md.invMAngN1Z * impulseN; av2X += _md.invMAngN2X * -impulseN; av2Y += _md.invMAngN2Y * -impulseN; av2Z += _md.invMAngN2Z * -impulseN; } this._b1._velX = lv1X; this._b1._velY = lv1Y; this._b1._velZ = lv1Z; this._b2._velX = lv2X; this._b2._velY = lv2Y; this._b2._velZ = lv2Z; this._b1._angVelX = av1X; this._b1._angVelY = av1Y; this._b1._angVelZ = av1Z; this._b2._angVelX = av2X; this._b2._angVelY = av2Y; this._b2._angVelZ = av2Z; } }, { key: "preSolvePosition", value: function preSolvePosition(timeStep) { this.constraint._syncManifold(); this.constraint._getPositionSolverInfo(this.info); var invM1 = this._b1._invMass; var invM2 = this._b2._invMass; var invI100; var invI101; var invI102; var invI110; var invI111; var invI112; var invI120; var invI121; var invI122; var invI200; var invI201; var invI202; var invI210; var invI211; var invI212; var invI220; var invI221; var invI222; invI100 = this._b1._invInertia00; invI101 = this._b1._invInertia01; invI102 = this._b1._invInertia02; invI110 = this._b1._invInertia10; invI111 = this._b1._invInertia11; invI112 = this._b1._invInertia12; invI120 = this._b1._invInertia20; invI121 = this._b1._invInertia21; invI122 = this._b1._invInertia22; invI200 = this._b2._invInertia00; invI201 = this._b2._invInertia01; invI202 = this._b2._invInertia02; invI210 = this._b2._invInertia10; invI211 = this._b2._invInertia11; invI212 = this._b2._invInertia12; invI220 = this._b2._invInertia20; invI221 = this._b2._invInertia21; invI222 = this._b2._invInertia22; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var md = this.massData[i]; var j = this.info.rows[i].jacobianN; md.invMLinN1X = j.lin1X * invM1; md.invMLinN1Y = j.lin1Y * invM1; md.invMLinN1Z = j.lin1Z * invM1; md.invMLinN2X = j.lin2X * invM2; md.invMLinN2Y = j.lin2Y * invM2; md.invMLinN2Z = j.lin2Z * invM2; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z; __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z; __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z; md.invMAngN1X = __tmp__X; md.invMAngN1Y = __tmp__Y; md.invMAngN1Z = __tmp__Z; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z; __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z; __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z; md.invMAngN2X = __tmp__X1; md.invMAngN2Y = __tmp__Y1; md.invMAngN2Z = __tmp__Z1; md.massN = invM1 + invM2 + (md.invMAngN1X * j.ang1X + md.invMAngN1Y * j.ang1Y + md.invMAngN1Z * j.ang1Z) + (md.invMAngN2X * j.ang2X + md.invMAngN2Y * j.ang2Y + md.invMAngN2Z * j.ang2Z); if (md.massN != 0) { md.massN = 1 / md.massN; } } var _g2 = 0; var _g3 = this.info.numRows; while (_g2 < _g3) { this.info.rows[_g2++].impulse.impulseP = 0; } } }, { key: "solvePositionSplitImpulse", value: function solvePositionSplitImpulse() { var lv1X; var lv1Y; var lv1Z; var lv2X; var lv2Y; var lv2Z; var av1X; var av1Y; var av1Z; var av2X; var av2Y; var av2Z; lv1X = this._b1._pseudoVelX; lv1Y = this._b1._pseudoVelY; lv1Z = this._b1._pseudoVelZ; lv2X = this._b2._pseudoVelX; lv2Y = this._b2._pseudoVelY; lv2Z = this._b2._pseudoVelZ; av1X = this._b1._angPseudoVelX; av1Y = this._b1._angPseudoVelY; av1Z = this._b1._angPseudoVelZ; av2X = this._b2._angPseudoVelX; av2Y = this._b2._angPseudoVelY; av2Z = this._b2._angPseudoVelZ; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var row = this.info.rows[i]; var md = this.massData[i]; var imp = row.impulse; var j = row.jacobianN; var rvn = 0; rvn += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z; rvn -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z; rvn += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z; rvn -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z; var impulseP = (row.rhs - rvn) * md.massN * oimo.common.Setting.positionSplitImpulseBaumgarte; var oldImpulseP = imp.impulseP; imp.impulseP += impulseP; if (imp.impulseP < 0) { imp.impulseP = 0; } impulseP = imp.impulseP - oldImpulseP; lv1X += md.invMLinN1X * impulseP; lv1Y += md.invMLinN1Y * impulseP; lv1Z += md.invMLinN1Z * impulseP; lv2X += md.invMLinN2X * -impulseP; lv2Y += md.invMLinN2Y * -impulseP; lv2Z += md.invMLinN2Z * -impulseP; av1X += md.invMAngN1X * impulseP; av1Y += md.invMAngN1Y * impulseP; av1Z += md.invMAngN1Z * impulseP; av2X += md.invMAngN2X * -impulseP; av2Y += md.invMAngN2Y * -impulseP; av2Z += md.invMAngN2Z * -impulseP; } this._b1._pseudoVelX = lv1X; this._b1._pseudoVelY = lv1Y; this._b1._pseudoVelZ = lv1Z; this._b2._pseudoVelX = lv2X; this._b2._pseudoVelY = lv2Y; this._b2._pseudoVelZ = lv2Z; this._b1._angPseudoVelX = av1X; this._b1._angPseudoVelY = av1Y; this._b1._angPseudoVelZ = av1Z; this._b2._angPseudoVelX = av2X; this._b2._angPseudoVelY = av2Y; this._b2._angPseudoVelZ = av2Z; } }, { key: "solvePositionNgs", value: function solvePositionNgs(timeStep) { this.constraint._syncManifold(); this.constraint._getPositionSolverInfo(this.info); var invM1 = this._b1._invMass; var invM2 = this._b2._invMass; var invI100; var invI101; var invI102; var invI110; var invI111; var invI112; var invI120; var invI121; var invI122; var invI200; var invI201; var invI202; var invI210; var invI211; var invI212; var invI220; var invI221; var invI222; invI100 = this._b1._invInertia00; invI101 = this._b1._invInertia01; invI102 = this._b1._invInertia02; invI110 = this._b1._invInertia10; invI111 = this._b1._invInertia11; invI112 = this._b1._invInertia12; invI120 = this._b1._invInertia20; invI121 = this._b1._invInertia21; invI122 = this._b1._invInertia22; invI200 = this._b2._invInertia00; invI201 = this._b2._invInertia01; invI202 = this._b2._invInertia02; invI210 = this._b2._invInertia10; invI211 = this._b2._invInertia11; invI212 = this._b2._invInertia12; invI220 = this._b2._invInertia20; invI221 = this._b2._invInertia21; invI222 = this._b2._invInertia22; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var md = this.massData[i]; var j = this.info.rows[i].jacobianN; md.invMLinN1X = j.lin1X * invM1; md.invMLinN1Y = j.lin1Y * invM1; md.invMLinN1Z = j.lin1Z * invM1; md.invMLinN2X = j.lin2X * invM2; md.invMLinN2Y = j.lin2Y * invM2; md.invMLinN2Z = j.lin2Z * invM2; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z; __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z; __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z; md.invMAngN1X = __tmp__X; md.invMAngN1Y = __tmp__Y; md.invMAngN1Z = __tmp__Z; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z; __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z; __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z; md.invMAngN2X = __tmp__X1; md.invMAngN2Y = __tmp__Y1; md.invMAngN2Z = __tmp__Z1; md.massN = invM1 + invM2 + (md.invMAngN1X * j.ang1X + md.invMAngN1Y * j.ang1Y + md.invMAngN1Z * j.ang1Z) + (md.invMAngN2X * j.ang2X + md.invMAngN2Y * j.ang2Y + md.invMAngN2Z * j.ang2Z); if (md.massN != 0) { md.massN = 1 / md.massN; } } var lv1X; var lv1Y; var lv1Z; var lv2X; var lv2Y; var lv2Z; var av1X; var av1Y; var av1Z; var av2X; var av2Y; var av2Z; lv1X = 0; lv1Y = 0; lv1Z = 0; lv2X = 0; lv2Y = 0; lv2Z = 0; av1X = 0; av1Y = 0; av1Z = 0; av2X = 0; av2Y = 0; av2Z = 0; var _g2 = 0; var _g3 = this.info.numRows; while (_g2 < _g3) { var _i154 = _g2++; var row = this.info.rows[_i154]; var _md2 = this.massData[_i154]; var imp = row.impulse; var _j17 = row.jacobianN; var rvn = 0; rvn += lv1X * _j17.lin1X + lv1Y * _j17.lin1Y + lv1Z * _j17.lin1Z; rvn -= lv2X * _j17.lin2X + lv2Y * _j17.lin2Y + lv2Z * _j17.lin2Z; rvn += av1X * _j17.ang1X + av1Y * _j17.ang1Y + av1Z * _j17.ang1Z; rvn -= av2X * _j17.ang2X + av2Y * _j17.ang2Y + av2Z * _j17.ang2Z; var impulseP = (row.rhs - rvn) * _md2.massN * oimo.common.Setting.positionNgsBaumgarte; var oldImpulseP = imp.impulseP; imp.impulseP += impulseP; if (imp.impulseP < 0) { imp.impulseP = 0; } impulseP = imp.impulseP - oldImpulseP; lv1X += _md2.invMLinN1X * impulseP; lv1Y += _md2.invMLinN1Y * impulseP; lv1Z += _md2.invMLinN1Z * impulseP; lv2X += _md2.invMLinN2X * -impulseP; lv2Y += _md2.invMLinN2Y * -impulseP; lv2Z += _md2.invMLinN2Z * -impulseP; av1X += _md2.invMAngN1X * impulseP; av1Y += _md2.invMAngN1Y * impulseP; av1Z += _md2.invMAngN1Z * impulseP; av2X += _md2.invMAngN2X * -impulseP; av2Y += _md2.invMAngN2Y * -impulseP; av2Z += _md2.invMAngN2Z * -impulseP; } var _this = this._b1; _this._transform._positionX += lv1X; _this._transform._positionY += lv1Y; _this._transform._positionZ += lv1Z; var _this1 = this._b2; _this1._transform._positionX += lv2X; _this1._transform._positionY += lv2Y; _this1._transform._positionZ += lv2Z; var _this2 = this._b1; var theta = Math.sqrt(av1X * av1X + av1Y * av1Y + av1Z * av1Z); var halfTheta = theta * 0.5; var rotationToSinAxisFactor; var cosHalfTheta; if (halfTheta < 0.5) { var ht2 = halfTheta * halfTheta; rotationToSinAxisFactor = 0.5 * (1 - ht2 * 0.16666666666666666 + ht2 * ht2 * 0.0083333333333333332); cosHalfTheta = 1 - ht2 * 0.5 + ht2 * ht2 * 0.041666666666666664; } else { rotationToSinAxisFactor = Math.sin(halfTheta) / theta; cosHalfTheta = Math.cos(halfTheta); } var sinAxisX; var sinAxisY; var sinAxisZ; sinAxisX = av1X * rotationToSinAxisFactor; sinAxisY = av1Y * rotationToSinAxisFactor; sinAxisZ = av1Z * rotationToSinAxisFactor; var dqX; var dqY; var dqZ; var dqW; dqX = sinAxisX; dqY = sinAxisY; dqZ = sinAxisZ; dqW = cosHalfTheta; var qX; var qY; var qZ; var qW; var e00 = _this2._transform._rotation00; var e11 = _this2._transform._rotation11; var e22 = _this2._transform._rotation22; var t = e00 + e11 + e22; var s; if (t > 0) { s = Math.sqrt(t + 1); qW = 0.5 * s; s = 0.5 / s; qX = (_this2._transform._rotation21 - _this2._transform._rotation12) * s; qY = (_this2._transform._rotation02 - _this2._transform._rotation20) * s; qZ = (_this2._transform._rotation10 - _this2._transform._rotation01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); qX = 0.5 * s; s = 0.5 / s; qY = (_this2._transform._rotation01 + _this2._transform._rotation10) * s; qZ = (_this2._transform._rotation02 + _this2._transform._rotation20) * s; qW = (_this2._transform._rotation21 - _this2._transform._rotation12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); qZ = 0.5 * s; s = 0.5 / s; qX = (_this2._transform._rotation02 + _this2._transform._rotation20) * s; qY = (_this2._transform._rotation12 + _this2._transform._rotation21) * s; qW = (_this2._transform._rotation10 - _this2._transform._rotation01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); qY = 0.5 * s; s = 0.5 / s; qX = (_this2._transform._rotation01 + _this2._transform._rotation10) * s; qZ = (_this2._transform._rotation12 + _this2._transform._rotation21) * s; qW = (_this2._transform._rotation02 - _this2._transform._rotation20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); qZ = 0.5 * s; s = 0.5 / s; qX = (_this2._transform._rotation02 + _this2._transform._rotation20) * s; qY = (_this2._transform._rotation12 + _this2._transform._rotation21) * s; qW = (_this2._transform._rotation10 - _this2._transform._rotation01) * s; } qX = dqW * qX + dqX * qW + dqY * qZ - dqZ * qY; qY = dqW * qY - dqX * qZ + dqY * qW + dqZ * qX; qZ = dqW * qZ + dqX * qY - dqY * qX + dqZ * qW; qW = dqW * qW - dqX * qX - dqY * qY - dqZ * qZ; var l = qX * qX + qY * qY + qZ * qZ + qW * qW; if (l > 1e-32) { l = 1 / Math.sqrt(l); } qX *= l; qY *= l; qZ *= l; qW *= l; var x = qX; var y = qY; var z = qZ; var w = qW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; _this2._transform._rotation00 = 1 - yy - zz; _this2._transform._rotation01 = xy - wz; _this2._transform._rotation02 = xz + wy; _this2._transform._rotation10 = xy + wz; _this2._transform._rotation11 = 1 - xx - zz; _this2._transform._rotation12 = yz - wx; _this2._transform._rotation20 = xz - wy; _this2._transform._rotation21 = yz + wx; _this2._transform._rotation22 = 1 - xx - yy; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = _this2._transform._rotation00 * _this2._invLocalInertia00 + _this2._transform._rotation01 * _this2._invLocalInertia10 + _this2._transform._rotation02 * _this2._invLocalInertia20; __tmp__01 = _this2._transform._rotation00 * _this2._invLocalInertia01 + _this2._transform._rotation01 * _this2._invLocalInertia11 + _this2._transform._rotation02 * _this2._invLocalInertia21; __tmp__02 = _this2._transform._rotation00 * _this2._invLocalInertia02 + _this2._transform._rotation01 * _this2._invLocalInertia12 + _this2._transform._rotation02 * _this2._invLocalInertia22; __tmp__10 = _this2._transform._rotation10 * _this2._invLocalInertia00 + _this2._transform._rotation11 * _this2._invLocalInertia10 + _this2._transform._rotation12 * _this2._invLocalInertia20; __tmp__11 = _this2._transform._rotation10 * _this2._invLocalInertia01 + _this2._transform._rotation11 * _this2._invLocalInertia11 + _this2._transform._rotation12 * _this2._invLocalInertia21; __tmp__12 = _this2._transform._rotation10 * _this2._invLocalInertia02 + _this2._transform._rotation11 * _this2._invLocalInertia12 + _this2._transform._rotation12 * _this2._invLocalInertia22; __tmp__20 = _this2._transform._rotation20 * _this2._invLocalInertia00 + _this2._transform._rotation21 * _this2._invLocalInertia10 + _this2._transform._rotation22 * _this2._invLocalInertia20; __tmp__21 = _this2._transform._rotation20 * _this2._invLocalInertia01 + _this2._transform._rotation21 * _this2._invLocalInertia11 + _this2._transform._rotation22 * _this2._invLocalInertia21; __tmp__22 = _this2._transform._rotation20 * _this2._invLocalInertia02 + _this2._transform._rotation21 * _this2._invLocalInertia12 + _this2._transform._rotation22 * _this2._invLocalInertia22; _this2._invInertia00 = __tmp__00; _this2._invInertia01 = __tmp__01; _this2._invInertia02 = __tmp__02; _this2._invInertia10 = __tmp__10; _this2._invInertia11 = __tmp__11; _this2._invInertia12 = __tmp__12; _this2._invInertia20 = __tmp__20; _this2._invInertia21 = __tmp__21; _this2._invInertia22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = _this2._invInertia00 * _this2._transform._rotation00 + _this2._invInertia01 * _this2._transform._rotation01 + _this2._invInertia02 * _this2._transform._rotation02; __tmp__011 = _this2._invInertia00 * _this2._transform._rotation10 + _this2._invInertia01 * _this2._transform._rotation11 + _this2._invInertia02 * _this2._transform._rotation12; __tmp__021 = _this2._invInertia00 * _this2._transform._rotation20 + _this2._invInertia01 * _this2._transform._rotation21 + _this2._invInertia02 * _this2._transform._rotation22; __tmp__101 = _this2._invInertia10 * _this2._transform._rotation00 + _this2._invInertia11 * _this2._transform._rotation01 + _this2._invInertia12 * _this2._transform._rotation02; __tmp__111 = _this2._invInertia10 * _this2._transform._rotation10 + _this2._invInertia11 * _this2._transform._rotation11 + _this2._invInertia12 * _this2._transform._rotation12; __tmp__121 = _this2._invInertia10 * _this2._transform._rotation20 + _this2._invInertia11 * _this2._transform._rotation21 + _this2._invInertia12 * _this2._transform._rotation22; __tmp__201 = _this2._invInertia20 * _this2._transform._rotation00 + _this2._invInertia21 * _this2._transform._rotation01 + _this2._invInertia22 * _this2._transform._rotation02; __tmp__211 = _this2._invInertia20 * _this2._transform._rotation10 + _this2._invInertia21 * _this2._transform._rotation11 + _this2._invInertia22 * _this2._transform._rotation12; __tmp__221 = _this2._invInertia20 * _this2._transform._rotation20 + _this2._invInertia21 * _this2._transform._rotation21 + _this2._invInertia22 * _this2._transform._rotation22; _this2._invInertia00 = __tmp__001; _this2._invInertia01 = __tmp__011; _this2._invInertia02 = __tmp__021; _this2._invInertia10 = __tmp__101; _this2._invInertia11 = __tmp__111; _this2._invInertia12 = __tmp__121; _this2._invInertia20 = __tmp__201; _this2._invInertia21 = __tmp__211; _this2._invInertia22 = __tmp__221; _this2._invInertia00 *= _this2._rotFactor.x; _this2._invInertia01 *= _this2._rotFactor.x; _this2._invInertia02 *= _this2._rotFactor.x; _this2._invInertia10 *= _this2._rotFactor.y; _this2._invInertia11 *= _this2._rotFactor.y; _this2._invInertia12 *= _this2._rotFactor.y; _this2._invInertia20 *= _this2._rotFactor.z; _this2._invInertia21 *= _this2._rotFactor.z; _this2._invInertia22 *= _this2._rotFactor.z; var _this3 = this._b2; var theta1 = Math.sqrt(av2X * av2X + av2Y * av2Y + av2Z * av2Z); var halfTheta1 = theta1 * 0.5; var rotationToSinAxisFactor1; var cosHalfTheta1; if (halfTheta1 < 0.5) { var _ht2 = halfTheta1 * halfTheta1; rotationToSinAxisFactor1 = 0.5 * (1 - _ht2 * 0.16666666666666666 + _ht2 * _ht2 * 0.0083333333333333332); cosHalfTheta1 = 1 - _ht2 * 0.5 + _ht2 * _ht2 * 0.041666666666666664; } else { rotationToSinAxisFactor1 = Math.sin(halfTheta1) / theta1; cosHalfTheta1 = Math.cos(halfTheta1); } var sinAxisX1; var sinAxisY1; var sinAxisZ1; sinAxisX1 = av2X * rotationToSinAxisFactor1; sinAxisY1 = av2Y * rotationToSinAxisFactor1; sinAxisZ1 = av2Z * rotationToSinAxisFactor1; var dqX1; var dqY1; var dqZ1; var dqW1; dqX1 = sinAxisX1; dqY1 = sinAxisY1; dqZ1 = sinAxisZ1; dqW1 = cosHalfTheta1; var qX1; var qY1; var qZ1; var qW1; var e001 = _this3._transform._rotation00; var e111 = _this3._transform._rotation11; var e221 = _this3._transform._rotation22; var t1 = e001 + e111 + e221; var s1; if (t1 > 0) { s1 = Math.sqrt(t1 + 1); qW1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this3._transform._rotation21 - _this3._transform._rotation12) * s1; qY1 = (_this3._transform._rotation02 - _this3._transform._rotation20) * s1; qZ1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1; } else if (e001 > e111) { if (e001 > e221) { s1 = Math.sqrt(e001 - e111 - e221 + 1); qX1 = 0.5 * s1; s1 = 0.5 / s1; qY1 = (_this3._transform._rotation01 + _this3._transform._rotation10) * s1; qZ1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1; qW1 = (_this3._transform._rotation21 - _this3._transform._rotation12) * s1; } else { s1 = Math.sqrt(e221 - e001 - e111 + 1); qZ1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1; qY1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1; qW1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1; } } else if (e111 > e221) { s1 = Math.sqrt(e111 - e221 - e001 + 1); qY1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this3._transform._rotation01 + _this3._transform._rotation10) * s1; qZ1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1; qW1 = (_this3._transform._rotation02 - _this3._transform._rotation20) * s1; } else { s1 = Math.sqrt(e221 - e001 - e111 + 1); qZ1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1; qY1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1; qW1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1; } qX1 = dqW1 * qX1 + dqX1 * qW1 + dqY1 * qZ1 - dqZ1 * qY1; qY1 = dqW1 * qY1 - dqX1 * qZ1 + dqY1 * qW1 + dqZ1 * qX1; qZ1 = dqW1 * qZ1 + dqX1 * qY1 - dqY1 * qX1 + dqZ1 * qW1; qW1 = dqW1 * qW1 - dqX1 * qX1 - dqY1 * qY1 - dqZ1 * qZ1; var l1 = qX1 * qX1 + qY1 * qY1 + qZ1 * qZ1 + qW1 * qW1; if (l1 > 1e-32) { l1 = 1 / Math.sqrt(l1); } qX1 *= l1; qY1 *= l1; qZ1 *= l1; qW1 *= l1; var x1 = qX1; var y1 = qY1; var z1 = qZ1; var w1 = qW1; var x21 = 2 * x1; var y21 = 2 * y1; var z21 = 2 * z1; var xx1 = x1 * x21; var yy1 = y1 * y21; var zz1 = z1 * z21; var xy1 = x1 * y21; var yz1 = y1 * z21; var xz1 = x1 * z21; var wx1 = w1 * x21; var wy1 = w1 * y21; var wz1 = w1 * z21; _this3._transform._rotation00 = 1 - yy1 - zz1; _this3._transform._rotation01 = xy1 - wz1; _this3._transform._rotation02 = xz1 + wy1; _this3._transform._rotation10 = xy1 + wz1; _this3._transform._rotation11 = 1 - xx1 - zz1; _this3._transform._rotation12 = yz1 - wx1; _this3._transform._rotation20 = xz1 - wy1; _this3._transform._rotation21 = yz1 + wx1; _this3._transform._rotation22 = 1 - xx1 - yy1; var __tmp__002; var __tmp__012; var __tmp__022; var __tmp__102; var __tmp__112; var __tmp__122; var __tmp__202; var __tmp__212; var __tmp__222; __tmp__002 = _this3._transform._rotation00 * _this3._invLocalInertia00 + _this3._transform._rotation01 * _this3._invLocalInertia10 + _this3._transform._rotation02 * _this3._invLocalInertia20; __tmp__012 = _this3._transform._rotation00 * _this3._invLocalInertia01 + _this3._transform._rotation01 * _this3._invLocalInertia11 + _this3._transform._rotation02 * _this3._invLocalInertia21; __tmp__022 = _this3._transform._rotation00 * _this3._invLocalInertia02 + _this3._transform._rotation01 * _this3._invLocalInertia12 + _this3._transform._rotation02 * _this3._invLocalInertia22; __tmp__102 = _this3._transform._rotation10 * _this3._invLocalInertia00 + _this3._transform._rotation11 * _this3._invLocalInertia10 + _this3._transform._rotation12 * _this3._invLocalInertia20; __tmp__112 = _this3._transform._rotation10 * _this3._invLocalInertia01 + _this3._transform._rotation11 * _this3._invLocalInertia11 + _this3._transform._rotation12 * _this3._invLocalInertia21; __tmp__122 = _this3._transform._rotation10 * _this3._invLocalInertia02 + _this3._transform._rotation11 * _this3._invLocalInertia12 + _this3._transform._rotation12 * _this3._invLocalInertia22; __tmp__202 = _this3._transform._rotation20 * _this3._invLocalInertia00 + _this3._transform._rotation21 * _this3._invLocalInertia10 + _this3._transform._rotation22 * _this3._invLocalInertia20; __tmp__212 = _this3._transform._rotation20 * _this3._invLocalInertia01 + _this3._transform._rotation21 * _this3._invLocalInertia11 + _this3._transform._rotation22 * _this3._invLocalInertia21; __tmp__222 = _this3._transform._rotation20 * _this3._invLocalInertia02 + _this3._transform._rotation21 * _this3._invLocalInertia12 + _this3._transform._rotation22 * _this3._invLocalInertia22; _this3._invInertia00 = __tmp__002; _this3._invInertia01 = __tmp__012; _this3._invInertia02 = __tmp__022; _this3._invInertia10 = __tmp__102; _this3._invInertia11 = __tmp__112; _this3._invInertia12 = __tmp__122; _this3._invInertia20 = __tmp__202; _this3._invInertia21 = __tmp__212; _this3._invInertia22 = __tmp__222; var __tmp__003; var __tmp__013; var __tmp__023; var __tmp__103; var __tmp__113; var __tmp__123; var __tmp__203; var __tmp__213; var __tmp__223; __tmp__003 = _this3._invInertia00 * _this3._transform._rotation00 + _this3._invInertia01 * _this3._transform._rotation01 + _this3._invInertia02 * _this3._transform._rotation02; __tmp__013 = _this3._invInertia00 * _this3._transform._rotation10 + _this3._invInertia01 * _this3._transform._rotation11 + _this3._invInertia02 * _this3._transform._rotation12; __tmp__023 = _this3._invInertia00 * _this3._transform._rotation20 + _this3._invInertia01 * _this3._transform._rotation21 + _this3._invInertia02 * _this3._transform._rotation22; __tmp__103 = _this3._invInertia10 * _this3._transform._rotation00 + _this3._invInertia11 * _this3._transform._rotation01 + _this3._invInertia12 * _this3._transform._rotation02; __tmp__113 = _this3._invInertia10 * _this3._transform._rotation10 + _this3._invInertia11 * _this3._transform._rotation11 + _this3._invInertia12 * _this3._transform._rotation12; __tmp__123 = _this3._invInertia10 * _this3._transform._rotation20 + _this3._invInertia11 * _this3._transform._rotation21 + _this3._invInertia12 * _this3._transform._rotation22; __tmp__203 = _this3._invInertia20 * _this3._transform._rotation00 + _this3._invInertia21 * _this3._transform._rotation01 + _this3._invInertia22 * _this3._transform._rotation02; __tmp__213 = _this3._invInertia20 * _this3._transform._rotation10 + _this3._invInertia21 * _this3._transform._rotation11 + _this3._invInertia22 * _this3._transform._rotation12; __tmp__223 = _this3._invInertia20 * _this3._transform._rotation20 + _this3._invInertia21 * _this3._transform._rotation21 + _this3._invInertia22 * _this3._transform._rotation22; _this3._invInertia00 = __tmp__003; _this3._invInertia01 = __tmp__013; _this3._invInertia02 = __tmp__023; _this3._invInertia10 = __tmp__103; _this3._invInertia11 = __tmp__113; _this3._invInertia12 = __tmp__123; _this3._invInertia20 = __tmp__203; _this3._invInertia21 = __tmp__213; _this3._invInertia22 = __tmp__223; _this3._invInertia00 *= _this3._rotFactor.x; _this3._invInertia01 *= _this3._rotFactor.x; _this3._invInertia02 *= _this3._rotFactor.x; _this3._invInertia10 *= _this3._rotFactor.y; _this3._invInertia11 *= _this3._rotFactor.y; _this3._invInertia12 *= _this3._rotFactor.y; _this3._invInertia20 *= _this3._rotFactor.z; _this3._invInertia21 *= _this3._rotFactor.z; _this3._invInertia22 *= _this3._rotFactor.z; } }, { key: "postSolve", value: function postSolve() { var lin1X; var lin1Y; var lin1Z; var ang1X; var ang1Y; var ang1Z; var ang2X; var ang2Y; var ang2Z; lin1X = 0; lin1Y = 0; lin1Z = 0; ang1X = 0; ang1Y = 0; ang1Z = 0; ang2X = 0; ang2Y = 0; ang2Z = 0; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var row = this.info.rows[_g++]; var imp = row.impulse; var jn = row.jacobianN; var jt = row.jacobianT; var jb = row.jacobianB; var impN = imp.impulseN; var impT = imp.impulseT; var impB = imp.impulseB; var impulseLX = void 0; var impulseLY = void 0; var impulseLZ = void 0; impulseLX = 0; impulseLY = 0; impulseLZ = 0; impulseLX += jt.lin1X * impT; impulseLY += jt.lin1Y * impT; impulseLZ += jt.lin1Z * impT; impulseLX += jb.lin1X * impB; impulseLY += jb.lin1Y * impB; impulseLZ += jb.lin1Z * impB; imp.impulseLX = impulseLX; imp.impulseLY = impulseLY; imp.impulseLZ = impulseLZ; lin1X += jn.lin1X * impN; lin1Y += jn.lin1Y * impN; lin1Z += jn.lin1Z * impN; ang1X += jn.ang1X * impN; ang1Y += jn.ang1Y * impN; ang1Z += jn.ang1Z * impN; ang2X += jn.ang2X * impN; ang2Y += jn.ang2Y * impN; ang2Z += jn.ang2Z * impN; lin1X += jt.lin1X * impT; lin1Y += jt.lin1Y * impT; lin1Z += jt.lin1Z * impT; ang1X += jt.ang1X * impT; ang1Y += jt.ang1Y * impT; ang1Z += jt.ang1Z * impT; ang2X += jt.ang2X * impT; ang2Y += jt.ang2Y * impT; ang2Z += jt.ang2Z * impT; lin1X += jb.lin1X * impB; lin1Y += jb.lin1Y * impB; lin1Z += jb.lin1Z * impB; ang1X += jb.ang1X * impB; ang1Y += jb.ang1Y * impB; ang1Z += jb.ang1Z * impB; ang2X += jb.ang2X * impB; ang2Y += jb.ang2Y * impB; ang2Z += jb.ang2Z * impB; } this._b1._linearContactImpulseX += lin1X; this._b1._linearContactImpulseY += lin1Y; this._b1._linearContactImpulseZ += lin1Z; this._b1._angularContactImpulseX += ang1X; this._b1._angularContactImpulseY += ang1Y; this._b1._angularContactImpulseZ += ang1Z; this._b2._linearContactImpulseX -= lin1X; this._b2._linearContactImpulseY -= lin1Y; this._b2._linearContactImpulseZ -= lin1Z; this._b2._angularContactImpulseX -= ang2X; this._b2._angularContactImpulseY -= ang2Y; this._b2._angularContactImpulseZ -= ang2Z; this.constraint._syncManifold(); } }]); return oimo_dynamics_constraint_solver_pgs_PgsContactConstraintSolver; }(oimo.dynamics.constraint.ConstraintSolver); oimo.dynamics.constraint.solver.pgs.PgsJointConstraintSolver = /*#__PURE__*/function (_oimo$dynamics$constr17) { _inherits(oimo_dynamics_constraint_solver_pgs_PgsJointConstraintSolver, _oimo$dynamics$constr17); var _super39 = _createSuper(oimo_dynamics_constraint_solver_pgs_PgsJointConstraintSolver); function oimo_dynamics_constraint_solver_pgs_PgsJointConstraintSolver(joint) { var _this254; _classCallCheck(this, oimo_dynamics_constraint_solver_pgs_PgsJointConstraintSolver); _this254 = _super39.call(this); _this254.joint = joint; _this254.info = new oimo.dynamics.constraint.info.joint.JointSolverInfo(); _this254.massData = new Array(oimo.common.Setting.maxJacobianRows); var _g = 0; var _g1 = _this254.massData.length; while (_g < _g1) { _this254.massData[_g++] = new oimo.dynamics.constraint.solver.common.JointSolverMassDataRow(); } return _this254; } _createClass(oimo_dynamics_constraint_solver_pgs_PgsJointConstraintSolver, [{ key: "preSolveVelocity", value: function preSolveVelocity(timeStep) { this.joint._syncAnchors(); this.joint._getVelocitySolverInfo(timeStep, this.info); this._b1 = this.info.b1; this._b2 = this.info.b2; var invM1 = this._b1._invMass; var invM2 = this._b2._invMass; var invI100; var invI101; var invI102; var invI110; var invI111; var invI112; var invI120; var invI121; var invI122; var invI200; var invI201; var invI202; var invI210; var invI211; var invI212; var invI220; var invI221; var invI222; invI100 = this._b1._invInertia00; invI101 = this._b1._invInertia01; invI102 = this._b1._invInertia02; invI110 = this._b1._invInertia10; invI111 = this._b1._invInertia11; invI112 = this._b1._invInertia12; invI120 = this._b1._invInertia20; invI121 = this._b1._invInertia21; invI122 = this._b1._invInertia22; invI200 = this._b2._invInertia00; invI201 = this._b2._invInertia01; invI202 = this._b2._invInertia02; invI210 = this._b2._invInertia10; invI211 = this._b2._invInertia11; invI212 = this._b2._invInertia12; invI220 = this._b2._invInertia20; invI221 = this._b2._invInertia21; invI222 = this._b2._invInertia22; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var row = this.info.rows[i]; var md = this.massData[i]; var j = row.jacobian; j.updateSparsity(); if ((j.flag & 1) != 0) { md.invMLin1X = j.lin1X * invM1; md.invMLin1Y = j.lin1Y * invM1; md.invMLin1Z = j.lin1Z * invM1; md.invMLin2X = j.lin2X * invM2; md.invMLin2Y = j.lin2Y * invM2; md.invMLin2Z = j.lin2Z * invM2; } else { md.invMLin1X = 0; md.invMLin1Y = 0; md.invMLin1Z = 0; md.invMLin2X = 0; md.invMLin2Y = 0; md.invMLin2Z = 0; } if ((j.flag & 2) != 0) { var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z; __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z; __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z; md.invMAng1X = __tmp__X; md.invMAng1Y = __tmp__Y; md.invMAng1Z = __tmp__Z; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z; __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z; __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z; md.invMAng2X = __tmp__X1; md.invMAng2Y = __tmp__Y1; md.invMAng2Z = __tmp__Z1; } else { md.invMAng1X = 0; md.invMAng1Y = 0; md.invMAng1Z = 0; md.invMAng2X = 0; md.invMAng2Y = 0; md.invMAng2Z = 0; } md.massWithoutCfm = md.invMLin1X * j.lin1X + md.invMLin1Y * j.lin1Y + md.invMLin1Z * j.lin1Z + (md.invMLin2X * j.lin2X + md.invMLin2Y * j.lin2Y + md.invMLin2Z * j.lin2Z) + (md.invMAng1X * j.ang1X + md.invMAng1Y * j.ang1Y + md.invMAng1Z * j.ang1Z) + (md.invMAng2X * j.ang2X + md.invMAng2Y * j.ang2Y + md.invMAng2Z * j.ang2Z); md.mass = md.massWithoutCfm + row.cfm; if (md.massWithoutCfm != 0) { md.massWithoutCfm = 1 / md.massWithoutCfm; } if (md.mass != 0) { md.mass = 1 / md.mass; } } } }, { key: "warmStart", value: function warmStart(timeStep) { var factor = this.joint._positionCorrectionAlgorithm == oimo.dynamics.constraint.PositionCorrectionAlgorithm.BAUMGARTE ? oimo.common.Setting.jointWarmStartingFactorForBaungarte : oimo.common.Setting.jointWarmStartingFactor; factor *= timeStep.dtRatio; if (factor <= 0) { var _g330 = 0; var _g331 = this.info.numRows; while (_g330 < _g331) { var _this = this.info.rows[_g330++].impulse; _this.impulse = 0; _this.impulseM = 0; _this.impulseP = 0; } return; } var lv1X; var lv1Y; var lv1Z; var lv2X; var lv2Y; var lv2Z; var av1X; var av1Y; var av1Z; var av2X; var av2Y; var av2Z; lv1X = this._b1._velX; lv1Y = this._b1._velY; lv1Z = this._b1._velZ; lv2X = this._b2._velX; lv2Y = this._b2._velY; lv2Z = this._b2._velZ; av1X = this._b1._angVelX; av1Y = this._b1._angVelY; av1Z = this._b1._angVelZ; av2X = this._b2._angVelX; av2Y = this._b2._angVelY; av2Z = this._b2._angVelZ; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var md = this.massData[i]; var imp = this.info.rows[i].impulse; imp.impulse *= factor; imp.impulseM *= factor; var impulse = imp.impulse + imp.impulseM; lv1X += md.invMLin1X * impulse; lv1Y += md.invMLin1Y * impulse; lv1Z += md.invMLin1Z * impulse; lv2X += md.invMLin2X * -impulse; lv2Y += md.invMLin2Y * -impulse; lv2Z += md.invMLin2Z * -impulse; av1X += md.invMAng1X * impulse; av1Y += md.invMAng1Y * impulse; av1Z += md.invMAng1Z * impulse; av2X += md.invMAng2X * -impulse; av2Y += md.invMAng2Y * -impulse; av2Z += md.invMAng2Z * -impulse; } this._b1._velX = lv1X; this._b1._velY = lv1Y; this._b1._velZ = lv1Z; this._b2._velX = lv2X; this._b2._velY = lv2Y; this._b2._velZ = lv2Z; this._b1._angVelX = av1X; this._b1._angVelY = av1Y; this._b1._angVelZ = av1Z; this._b2._angVelX = av2X; this._b2._angVelY = av2Y; this._b2._angVelZ = av2Z; } }, { key: "solveVelocity", value: function solveVelocity() { var lv1X; var lv1Y; var lv1Z; var lv2X; var lv2Y; var lv2Z; var av1X; var av1Y; var av1Z; var av2X; var av2Y; var av2Z; lv1X = this._b1._velX; lv1Y = this._b1._velY; lv1Z = this._b1._velZ; lv2X = this._b2._velX; lv2Y = this._b2._velY; lv2Z = this._b2._velZ; av1X = this._b1._angVelX; av1Y = this._b1._angVelY; av1Z = this._b1._angVelZ; av2X = this._b2._angVelX; av2Y = this._b2._angVelY; av2Z = this._b2._angVelZ; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var row = this.info.rows[i]; var md = this.massData[i]; var imp = row.impulse; var j = row.jacobian; if (row.motorMaxImpulse == 0) { continue; } var rv = 0; rv += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z; rv -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z; rv += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z; rv -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z; var impulseM = (-row.motorSpeed - rv) * md.massWithoutCfm; var oldImpulseM = imp.impulseM; imp.impulseM += impulseM; if (imp.impulseM < -row.motorMaxImpulse) { imp.impulseM = -row.motorMaxImpulse; } else if (imp.impulseM > row.motorMaxImpulse) { imp.impulseM = row.motorMaxImpulse; } impulseM = imp.impulseM - oldImpulseM; if ((j.flag & 1) != 0) { lv1X += md.invMLin1X * impulseM; lv1Y += md.invMLin1Y * impulseM; lv1Z += md.invMLin1Z * impulseM; lv2X += md.invMLin2X * -impulseM; lv2Y += md.invMLin2Y * -impulseM; lv2Z += md.invMLin2Z * -impulseM; } if ((j.flag & 2) != 0) { av1X += md.invMAng1X * impulseM; av1Y += md.invMAng1Y * impulseM; av1Z += md.invMAng1Z * impulseM; av2X += md.invMAng2X * -impulseM; av2Y += md.invMAng2Y * -impulseM; av2Z += md.invMAng2Z * -impulseM; } } var _g2 = 0; var _g3 = this.info.numRows; while (_g2 < _g3) { var _i155 = _g2++; var _row20 = this.info.rows[_i155]; var _md3 = this.massData[_i155]; var _imp5 = _row20.impulse; var _j18 = _row20.jacobian; var _rv = 0; _rv += lv1X * _j18.lin1X + lv1Y * _j18.lin1Y + lv1Z * _j18.lin1Z; _rv -= lv2X * _j18.lin2X + lv2Y * _j18.lin2Y + lv2Z * _j18.lin2Z; _rv += av1X * _j18.ang1X + av1Y * _j18.ang1Y + av1Z * _j18.ang1Z; _rv -= av2X * _j18.ang2X + av2Y * _j18.ang2Y + av2Z * _j18.ang2Z; var impulse = (_row20.rhs - _rv - _imp5.impulse * _row20.cfm) * _md3.mass; var oldImpulse = _imp5.impulse; _imp5.impulse += impulse; if (_imp5.impulse < _row20.minImpulse) { _imp5.impulse = _row20.minImpulse; } else if (_imp5.impulse > _row20.maxImpulse) { _imp5.impulse = _row20.maxImpulse; } impulse = _imp5.impulse - oldImpulse; if ((_j18.flag & 1) != 0) { lv1X += _md3.invMLin1X * impulse; lv1Y += _md3.invMLin1Y * impulse; lv1Z += _md3.invMLin1Z * impulse; lv2X += _md3.invMLin2X * -impulse; lv2Y += _md3.invMLin2Y * -impulse; lv2Z += _md3.invMLin2Z * -impulse; } if ((_j18.flag & 2) != 0) { av1X += _md3.invMAng1X * impulse; av1Y += _md3.invMAng1Y * impulse; av1Z += _md3.invMAng1Z * impulse; av2X += _md3.invMAng2X * -impulse; av2Y += _md3.invMAng2Y * -impulse; av2Z += _md3.invMAng2Z * -impulse; } } this._b1._velX = lv1X; this._b1._velY = lv1Y; this._b1._velZ = lv1Z; this._b2._velX = lv2X; this._b2._velY = lv2Y; this._b2._velZ = lv2Z; this._b1._angVelX = av1X; this._b1._angVelY = av1Y; this._b1._angVelZ = av1Z; this._b2._angVelX = av2X; this._b2._angVelY = av2Y; this._b2._angVelZ = av2Z; } }, { key: "postSolveVelocity", value: function postSolveVelocity(timeStep) { var linX; var linY; var linZ; var angX; var angY; var angZ; linX = 0; linY = 0; linZ = 0; angX = 0; angY = 0; angZ = 0; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var row = this.info.rows[_g++]; var imp = row.impulse; var j = row.jacobian; if ((j.flag & 1) != 0) { linX += j.lin1X * imp.impulse; linY += j.lin1Y * imp.impulse; linZ += j.lin1Z * imp.impulse; } else if ((j.flag & 2) != 0) { angX += j.ang1X * imp.impulse; angY += j.ang1Y * imp.impulse; angZ += j.ang1Z * imp.impulse; } } this.joint._appliedForceX = linX * timeStep.invDt; this.joint._appliedForceY = linY * timeStep.invDt; this.joint._appliedForceZ = linZ * timeStep.invDt; this.joint._appliedTorqueX = angX * timeStep.invDt; this.joint._appliedTorqueY = angY * timeStep.invDt; this.joint._appliedTorqueZ = angZ * timeStep.invDt; } }, { key: "preSolvePosition", value: function preSolvePosition(timeStep) { this.joint._syncAnchors(); this.joint._getPositionSolverInfo(this.info); this._b1 = this.info.b1; this._b2 = this.info.b2; var invM1 = this._b1._invMass; var invM2 = this._b2._invMass; var invI100; var invI101; var invI102; var invI110; var invI111; var invI112; var invI120; var invI121; var invI122; var invI200; var invI201; var invI202; var invI210; var invI211; var invI212; var invI220; var invI221; var invI222; invI100 = this._b1._invInertia00; invI101 = this._b1._invInertia01; invI102 = this._b1._invInertia02; invI110 = this._b1._invInertia10; invI111 = this._b1._invInertia11; invI112 = this._b1._invInertia12; invI120 = this._b1._invInertia20; invI121 = this._b1._invInertia21; invI122 = this._b1._invInertia22; invI200 = this._b2._invInertia00; invI201 = this._b2._invInertia01; invI202 = this._b2._invInertia02; invI210 = this._b2._invInertia10; invI211 = this._b2._invInertia11; invI212 = this._b2._invInertia12; invI220 = this._b2._invInertia20; invI221 = this._b2._invInertia21; invI222 = this._b2._invInertia22; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var md = this.massData[i]; var j = this.info.rows[i].jacobian; md.invMLin1X = j.lin1X * invM1; md.invMLin1Y = j.lin1Y * invM1; md.invMLin1Z = j.lin1Z * invM1; md.invMLin2X = j.lin2X * invM2; md.invMLin2Y = j.lin2Y * invM2; md.invMLin2Z = j.lin2Z * invM2; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z; __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z; __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z; md.invMAng1X = __tmp__X; md.invMAng1Y = __tmp__Y; md.invMAng1Z = __tmp__Z; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z; __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z; __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z; md.invMAng2X = __tmp__X1; md.invMAng2Y = __tmp__Y1; md.invMAng2Z = __tmp__Z1; md.mass = md.invMLin1X * j.lin1X + md.invMLin1Y * j.lin1Y + md.invMLin1Z * j.lin1Z + (md.invMLin2X * j.lin2X + md.invMLin2Y * j.lin2Y + md.invMLin2Z * j.lin2Z) + (md.invMAng1X * j.ang1X + md.invMAng1Y * j.ang1Y + md.invMAng1Z * j.ang1Z) + (md.invMAng2X * j.ang2X + md.invMAng2Y * j.ang2Y + md.invMAng2Z * j.ang2Z); if (md.mass != 0) { md.mass = 1 / md.mass; } } var _g2 = 0; var _g3 = this.info.numRows; while (_g2 < _g3) { this.info.rows[_g2++].impulse.impulseP = 0; } } }, { key: "solvePositionSplitImpulse", value: function solvePositionSplitImpulse() { var lv1X; var lv1Y; var lv1Z; var lv2X; var lv2Y; var lv2Z; var av1X; var av1Y; var av1Z; var av2X; var av2Y; var av2Z; lv1X = this._b1._pseudoVelX; lv1Y = this._b1._pseudoVelY; lv1Z = this._b1._pseudoVelZ; lv2X = this._b2._pseudoVelX; lv2Y = this._b2._pseudoVelY; lv2Z = this._b2._pseudoVelZ; av1X = this._b1._angPseudoVelX; av1Y = this._b1._angPseudoVelY; av1Z = this._b1._angPseudoVelZ; av2X = this._b2._angPseudoVelX; av2Y = this._b2._angPseudoVelY; av2Z = this._b2._angPseudoVelZ; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var row = this.info.rows[i]; var md = this.massData[i]; var imp = row.impulse; var j = row.jacobian; var rv = 0; rv += lv1X * j.lin1X + lv1Y * j.lin1Y + lv1Z * j.lin1Z; rv -= lv2X * j.lin2X + lv2Y * j.lin2Y + lv2Z * j.lin2Z; rv += av1X * j.ang1X + av1Y * j.ang1Y + av1Z * j.ang1Z; rv -= av2X * j.ang2X + av2Y * j.ang2Y + av2Z * j.ang2Z; var impulseP = (row.rhs * oimo.common.Setting.positionSplitImpulseBaumgarte - rv) * md.mass; var oldImpulseP = imp.impulseP; imp.impulseP += impulseP; if (imp.impulseP < row.minImpulse) { imp.impulseP = row.minImpulse; } else if (imp.impulseP > row.maxImpulse) { imp.impulseP = row.maxImpulse; } impulseP = imp.impulseP - oldImpulseP; lv1X += md.invMLin1X * impulseP; lv1Y += md.invMLin1Y * impulseP; lv1Z += md.invMLin1Z * impulseP; lv2X += md.invMLin2X * -impulseP; lv2Y += md.invMLin2Y * -impulseP; lv2Z += md.invMLin2Z * -impulseP; av1X += md.invMAng1X * impulseP; av1Y += md.invMAng1Y * impulseP; av1Z += md.invMAng1Z * impulseP; av2X += md.invMAng2X * -impulseP; av2Y += md.invMAng2Y * -impulseP; av2Z += md.invMAng2Z * -impulseP; } this._b1._pseudoVelX = lv1X; this._b1._pseudoVelY = lv1Y; this._b1._pseudoVelZ = lv1Z; this._b2._pseudoVelX = lv2X; this._b2._pseudoVelY = lv2Y; this._b2._pseudoVelZ = lv2Z; this._b1._angPseudoVelX = av1X; this._b1._angPseudoVelY = av1Y; this._b1._angPseudoVelZ = av1Z; this._b2._angPseudoVelX = av2X; this._b2._angPseudoVelY = av2Y; this._b2._angPseudoVelZ = av2Z; } }, { key: "solvePositionNgs", value: function solvePositionNgs(timeStep) { this.joint._syncAnchors(); this.joint._getPositionSolverInfo(this.info); this._b1 = this.info.b1; this._b2 = this.info.b2; var invM1 = this._b1._invMass; var invM2 = this._b2._invMass; var invI100; var invI101; var invI102; var invI110; var invI111; var invI112; var invI120; var invI121; var invI122; var invI200; var invI201; var invI202; var invI210; var invI211; var invI212; var invI220; var invI221; var invI222; invI100 = this._b1._invInertia00; invI101 = this._b1._invInertia01; invI102 = this._b1._invInertia02; invI110 = this._b1._invInertia10; invI111 = this._b1._invInertia11; invI112 = this._b1._invInertia12; invI120 = this._b1._invInertia20; invI121 = this._b1._invInertia21; invI122 = this._b1._invInertia22; invI200 = this._b2._invInertia00; invI201 = this._b2._invInertia01; invI202 = this._b2._invInertia02; invI210 = this._b2._invInertia10; invI211 = this._b2._invInertia11; invI212 = this._b2._invInertia12; invI220 = this._b2._invInertia20; invI221 = this._b2._invInertia21; invI222 = this._b2._invInertia22; var _g = 0; var _g1 = this.info.numRows; while (_g < _g1) { var i = _g++; var md = this.massData[i]; var j = this.info.rows[i].jacobian; md.invMLin1X = j.lin1X * invM1; md.invMLin1Y = j.lin1Y * invM1; md.invMLin1Z = j.lin1Z * invM1; md.invMLin2X = j.lin2X * invM2; md.invMLin2Y = j.lin2Y * invM2; md.invMLin2Z = j.lin2Z * invM2; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = invI100 * j.ang1X + invI101 * j.ang1Y + invI102 * j.ang1Z; __tmp__Y = invI110 * j.ang1X + invI111 * j.ang1Y + invI112 * j.ang1Z; __tmp__Z = invI120 * j.ang1X + invI121 * j.ang1Y + invI122 * j.ang1Z; md.invMAng1X = __tmp__X; md.invMAng1Y = __tmp__Y; md.invMAng1Z = __tmp__Z; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = invI200 * j.ang2X + invI201 * j.ang2Y + invI202 * j.ang2Z; __tmp__Y1 = invI210 * j.ang2X + invI211 * j.ang2Y + invI212 * j.ang2Z; __tmp__Z1 = invI220 * j.ang2X + invI221 * j.ang2Y + invI222 * j.ang2Z; md.invMAng2X = __tmp__X1; md.invMAng2Y = __tmp__Y1; md.invMAng2Z = __tmp__Z1; md.mass = md.invMLin1X * j.lin1X + md.invMLin1Y * j.lin1Y + md.invMLin1Z * j.lin1Z + (md.invMLin2X * j.lin2X + md.invMLin2Y * j.lin2Y + md.invMLin2Z * j.lin2Z) + (md.invMAng1X * j.ang1X + md.invMAng1Y * j.ang1Y + md.invMAng1Z * j.ang1Z) + (md.invMAng2X * j.ang2X + md.invMAng2Y * j.ang2Y + md.invMAng2Z * j.ang2Z); if (md.mass != 0) { md.mass = 1 / md.mass; } } var lv1X; var lv1Y; var lv1Z; var lv2X; var lv2Y; var lv2Z; var av1X; var av1Y; var av1Z; var av2X; var av2Y; var av2Z; lv1X = 0; lv1Y = 0; lv1Z = 0; lv2X = 0; lv2Y = 0; lv2Z = 0; av1X = 0; av1Y = 0; av1Z = 0; av2X = 0; av2Y = 0; av2Z = 0; var _g2 = 0; var _g3 = this.info.numRows; while (_g2 < _g3) { var _i156 = _g2++; var row = this.info.rows[_i156]; var _md4 = this.massData[_i156]; var imp = row.impulse; var _j19 = row.jacobian; var rv = 0; rv += lv1X * _j19.lin1X + lv1Y * _j19.lin1Y + lv1Z * _j19.lin1Z; rv -= lv2X * _j19.lin2X + lv2Y * _j19.lin2Y + lv2Z * _j19.lin2Z; rv += av1X * _j19.ang1X + av1Y * _j19.ang1Y + av1Z * _j19.ang1Z; rv -= av2X * _j19.ang2X + av2Y * _j19.ang2Y + av2Z * _j19.ang2Z; var impulseP = (row.rhs * oimo.common.Setting.positionNgsBaumgarte - rv) * _md4.mass; var oldImpulseP = imp.impulseP; imp.impulseP += impulseP; if (imp.impulseP < row.minImpulse) { imp.impulseP = row.minImpulse; } else if (imp.impulseP > row.maxImpulse) { imp.impulseP = row.maxImpulse; } impulseP = imp.impulseP - oldImpulseP; lv1X += _md4.invMLin1X * impulseP; lv1Y += _md4.invMLin1Y * impulseP; lv1Z += _md4.invMLin1Z * impulseP; lv2X += _md4.invMLin2X * -impulseP; lv2Y += _md4.invMLin2Y * -impulseP; lv2Z += _md4.invMLin2Z * -impulseP; av1X += _md4.invMAng1X * impulseP; av1Y += _md4.invMAng1Y * impulseP; av1Z += _md4.invMAng1Z * impulseP; av2X += _md4.invMAng2X * -impulseP; av2Y += _md4.invMAng2Y * -impulseP; av2Z += _md4.invMAng2Z * -impulseP; } var _this = this._b1; _this._transform._positionX += lv1X; _this._transform._positionY += lv1Y; _this._transform._positionZ += lv1Z; var _this1 = this._b2; _this1._transform._positionX += lv2X; _this1._transform._positionY += lv2Y; _this1._transform._positionZ += lv2Z; var _this2 = this._b1; var theta = Math.sqrt(av1X * av1X + av1Y * av1Y + av1Z * av1Z); var halfTheta = theta * 0.5; var rotationToSinAxisFactor; var cosHalfTheta; if (halfTheta < 0.5) { var ht2 = halfTheta * halfTheta; rotationToSinAxisFactor = 0.5 * (1 - ht2 * 0.16666666666666666 + ht2 * ht2 * 0.0083333333333333332); cosHalfTheta = 1 - ht2 * 0.5 + ht2 * ht2 * 0.041666666666666664; } else { rotationToSinAxisFactor = Math.sin(halfTheta) / theta; cosHalfTheta = Math.cos(halfTheta); } var sinAxisX; var sinAxisY; var sinAxisZ; sinAxisX = av1X * rotationToSinAxisFactor; sinAxisY = av1Y * rotationToSinAxisFactor; sinAxisZ = av1Z * rotationToSinAxisFactor; var dqX; var dqY; var dqZ; var dqW; dqX = sinAxisX; dqY = sinAxisY; dqZ = sinAxisZ; dqW = cosHalfTheta; var qX; var qY; var qZ; var qW; var e00 = _this2._transform._rotation00; var e11 = _this2._transform._rotation11; var e22 = _this2._transform._rotation22; var t = e00 + e11 + e22; var s; if (t > 0) { s = Math.sqrt(t + 1); qW = 0.5 * s; s = 0.5 / s; qX = (_this2._transform._rotation21 - _this2._transform._rotation12) * s; qY = (_this2._transform._rotation02 - _this2._transform._rotation20) * s; qZ = (_this2._transform._rotation10 - _this2._transform._rotation01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); qX = 0.5 * s; s = 0.5 / s; qY = (_this2._transform._rotation01 + _this2._transform._rotation10) * s; qZ = (_this2._transform._rotation02 + _this2._transform._rotation20) * s; qW = (_this2._transform._rotation21 - _this2._transform._rotation12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); qZ = 0.5 * s; s = 0.5 / s; qX = (_this2._transform._rotation02 + _this2._transform._rotation20) * s; qY = (_this2._transform._rotation12 + _this2._transform._rotation21) * s; qW = (_this2._transform._rotation10 - _this2._transform._rotation01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); qY = 0.5 * s; s = 0.5 / s; qX = (_this2._transform._rotation01 + _this2._transform._rotation10) * s; qZ = (_this2._transform._rotation12 + _this2._transform._rotation21) * s; qW = (_this2._transform._rotation02 - _this2._transform._rotation20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); qZ = 0.5 * s; s = 0.5 / s; qX = (_this2._transform._rotation02 + _this2._transform._rotation20) * s; qY = (_this2._transform._rotation12 + _this2._transform._rotation21) * s; qW = (_this2._transform._rotation10 - _this2._transform._rotation01) * s; } qX = dqW * qX + dqX * qW + dqY * qZ - dqZ * qY; qY = dqW * qY - dqX * qZ + dqY * qW + dqZ * qX; qZ = dqW * qZ + dqX * qY - dqY * qX + dqZ * qW; qW = dqW * qW - dqX * qX - dqY * qY - dqZ * qZ; var l = qX * qX + qY * qY + qZ * qZ + qW * qW; if (l > 1e-32) { l = 1 / Math.sqrt(l); } qX *= l; qY *= l; qZ *= l; qW *= l; var x = qX; var y = qY; var z = qZ; var w = qW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; _this2._transform._rotation00 = 1 - yy - zz; _this2._transform._rotation01 = xy - wz; _this2._transform._rotation02 = xz + wy; _this2._transform._rotation10 = xy + wz; _this2._transform._rotation11 = 1 - xx - zz; _this2._transform._rotation12 = yz - wx; _this2._transform._rotation20 = xz - wy; _this2._transform._rotation21 = yz + wx; _this2._transform._rotation22 = 1 - xx - yy; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = _this2._transform._rotation00 * _this2._invLocalInertia00 + _this2._transform._rotation01 * _this2._invLocalInertia10 + _this2._transform._rotation02 * _this2._invLocalInertia20; __tmp__01 = _this2._transform._rotation00 * _this2._invLocalInertia01 + _this2._transform._rotation01 * _this2._invLocalInertia11 + _this2._transform._rotation02 * _this2._invLocalInertia21; __tmp__02 = _this2._transform._rotation00 * _this2._invLocalInertia02 + _this2._transform._rotation01 * _this2._invLocalInertia12 + _this2._transform._rotation02 * _this2._invLocalInertia22; __tmp__10 = _this2._transform._rotation10 * _this2._invLocalInertia00 + _this2._transform._rotation11 * _this2._invLocalInertia10 + _this2._transform._rotation12 * _this2._invLocalInertia20; __tmp__11 = _this2._transform._rotation10 * _this2._invLocalInertia01 + _this2._transform._rotation11 * _this2._invLocalInertia11 + _this2._transform._rotation12 * _this2._invLocalInertia21; __tmp__12 = _this2._transform._rotation10 * _this2._invLocalInertia02 + _this2._transform._rotation11 * _this2._invLocalInertia12 + _this2._transform._rotation12 * _this2._invLocalInertia22; __tmp__20 = _this2._transform._rotation20 * _this2._invLocalInertia00 + _this2._transform._rotation21 * _this2._invLocalInertia10 + _this2._transform._rotation22 * _this2._invLocalInertia20; __tmp__21 = _this2._transform._rotation20 * _this2._invLocalInertia01 + _this2._transform._rotation21 * _this2._invLocalInertia11 + _this2._transform._rotation22 * _this2._invLocalInertia21; __tmp__22 = _this2._transform._rotation20 * _this2._invLocalInertia02 + _this2._transform._rotation21 * _this2._invLocalInertia12 + _this2._transform._rotation22 * _this2._invLocalInertia22; _this2._invInertia00 = __tmp__00; _this2._invInertia01 = __tmp__01; _this2._invInertia02 = __tmp__02; _this2._invInertia10 = __tmp__10; _this2._invInertia11 = __tmp__11; _this2._invInertia12 = __tmp__12; _this2._invInertia20 = __tmp__20; _this2._invInertia21 = __tmp__21; _this2._invInertia22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = _this2._invInertia00 * _this2._transform._rotation00 + _this2._invInertia01 * _this2._transform._rotation01 + _this2._invInertia02 * _this2._transform._rotation02; __tmp__011 = _this2._invInertia00 * _this2._transform._rotation10 + _this2._invInertia01 * _this2._transform._rotation11 + _this2._invInertia02 * _this2._transform._rotation12; __tmp__021 = _this2._invInertia00 * _this2._transform._rotation20 + _this2._invInertia01 * _this2._transform._rotation21 + _this2._invInertia02 * _this2._transform._rotation22; __tmp__101 = _this2._invInertia10 * _this2._transform._rotation00 + _this2._invInertia11 * _this2._transform._rotation01 + _this2._invInertia12 * _this2._transform._rotation02; __tmp__111 = _this2._invInertia10 * _this2._transform._rotation10 + _this2._invInertia11 * _this2._transform._rotation11 + _this2._invInertia12 * _this2._transform._rotation12; __tmp__121 = _this2._invInertia10 * _this2._transform._rotation20 + _this2._invInertia11 * _this2._transform._rotation21 + _this2._invInertia12 * _this2._transform._rotation22; __tmp__201 = _this2._invInertia20 * _this2._transform._rotation00 + _this2._invInertia21 * _this2._transform._rotation01 + _this2._invInertia22 * _this2._transform._rotation02; __tmp__211 = _this2._invInertia20 * _this2._transform._rotation10 + _this2._invInertia21 * _this2._transform._rotation11 + _this2._invInertia22 * _this2._transform._rotation12; __tmp__221 = _this2._invInertia20 * _this2._transform._rotation20 + _this2._invInertia21 * _this2._transform._rotation21 + _this2._invInertia22 * _this2._transform._rotation22; _this2._invInertia00 = __tmp__001; _this2._invInertia01 = __tmp__011; _this2._invInertia02 = __tmp__021; _this2._invInertia10 = __tmp__101; _this2._invInertia11 = __tmp__111; _this2._invInertia12 = __tmp__121; _this2._invInertia20 = __tmp__201; _this2._invInertia21 = __tmp__211; _this2._invInertia22 = __tmp__221; _this2._invInertia00 *= _this2._rotFactor.x; _this2._invInertia01 *= _this2._rotFactor.x; _this2._invInertia02 *= _this2._rotFactor.x; _this2._invInertia10 *= _this2._rotFactor.y; _this2._invInertia11 *= _this2._rotFactor.y; _this2._invInertia12 *= _this2._rotFactor.y; _this2._invInertia20 *= _this2._rotFactor.z; _this2._invInertia21 *= _this2._rotFactor.z; _this2._invInertia22 *= _this2._rotFactor.z; var _this3 = this._b2; var theta1 = Math.sqrt(av2X * av2X + av2Y * av2Y + av2Z * av2Z); var halfTheta1 = theta1 * 0.5; var rotationToSinAxisFactor1; var cosHalfTheta1; if (halfTheta1 < 0.5) { var _ht3 = halfTheta1 * halfTheta1; rotationToSinAxisFactor1 = 0.5 * (1 - _ht3 * 0.16666666666666666 + _ht3 * _ht3 * 0.0083333333333333332); cosHalfTheta1 = 1 - _ht3 * 0.5 + _ht3 * _ht3 * 0.041666666666666664; } else { rotationToSinAxisFactor1 = Math.sin(halfTheta1) / theta1; cosHalfTheta1 = Math.cos(halfTheta1); } var sinAxisX1; var sinAxisY1; var sinAxisZ1; sinAxisX1 = av2X * rotationToSinAxisFactor1; sinAxisY1 = av2Y * rotationToSinAxisFactor1; sinAxisZ1 = av2Z * rotationToSinAxisFactor1; var dqX1; var dqY1; var dqZ1; var dqW1; dqX1 = sinAxisX1; dqY1 = sinAxisY1; dqZ1 = sinAxisZ1; dqW1 = cosHalfTheta1; var qX1; var qY1; var qZ1; var qW1; var e001 = _this3._transform._rotation00; var e111 = _this3._transform._rotation11; var e221 = _this3._transform._rotation22; var t1 = e001 + e111 + e221; var s1; if (t1 > 0) { s1 = Math.sqrt(t1 + 1); qW1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this3._transform._rotation21 - _this3._transform._rotation12) * s1; qY1 = (_this3._transform._rotation02 - _this3._transform._rotation20) * s1; qZ1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1; } else if (e001 > e111) { if (e001 > e221) { s1 = Math.sqrt(e001 - e111 - e221 + 1); qX1 = 0.5 * s1; s1 = 0.5 / s1; qY1 = (_this3._transform._rotation01 + _this3._transform._rotation10) * s1; qZ1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1; qW1 = (_this3._transform._rotation21 - _this3._transform._rotation12) * s1; } else { s1 = Math.sqrt(e221 - e001 - e111 + 1); qZ1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1; qY1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1; qW1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1; } } else if (e111 > e221) { s1 = Math.sqrt(e111 - e221 - e001 + 1); qY1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this3._transform._rotation01 + _this3._transform._rotation10) * s1; qZ1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1; qW1 = (_this3._transform._rotation02 - _this3._transform._rotation20) * s1; } else { s1 = Math.sqrt(e221 - e001 - e111 + 1); qZ1 = 0.5 * s1; s1 = 0.5 / s1; qX1 = (_this3._transform._rotation02 + _this3._transform._rotation20) * s1; qY1 = (_this3._transform._rotation12 + _this3._transform._rotation21) * s1; qW1 = (_this3._transform._rotation10 - _this3._transform._rotation01) * s1; } qX1 = dqW1 * qX1 + dqX1 * qW1 + dqY1 * qZ1 - dqZ1 * qY1; qY1 = dqW1 * qY1 - dqX1 * qZ1 + dqY1 * qW1 + dqZ1 * qX1; qZ1 = dqW1 * qZ1 + dqX1 * qY1 - dqY1 * qX1 + dqZ1 * qW1; qW1 = dqW1 * qW1 - dqX1 * qX1 - dqY1 * qY1 - dqZ1 * qZ1; var l1 = qX1 * qX1 + qY1 * qY1 + qZ1 * qZ1 + qW1 * qW1; if (l1 > 1e-32) { l1 = 1 / Math.sqrt(l1); } qX1 *= l1; qY1 *= l1; qZ1 *= l1; qW1 *= l1; var x1 = qX1; var y1 = qY1; var z1 = qZ1; var w1 = qW1; var x21 = 2 * x1; var y21 = 2 * y1; var z21 = 2 * z1; var xx1 = x1 * x21; var yy1 = y1 * y21; var zz1 = z1 * z21; var xy1 = x1 * y21; var yz1 = y1 * z21; var xz1 = x1 * z21; var wx1 = w1 * x21; var wy1 = w1 * y21; var wz1 = w1 * z21; _this3._transform._rotation00 = 1 - yy1 - zz1; _this3._transform._rotation01 = xy1 - wz1; _this3._transform._rotation02 = xz1 + wy1; _this3._transform._rotation10 = xy1 + wz1; _this3._transform._rotation11 = 1 - xx1 - zz1; _this3._transform._rotation12 = yz1 - wx1; _this3._transform._rotation20 = xz1 - wy1; _this3._transform._rotation21 = yz1 + wx1; _this3._transform._rotation22 = 1 - xx1 - yy1; var __tmp__002; var __tmp__012; var __tmp__022; var __tmp__102; var __tmp__112; var __tmp__122; var __tmp__202; var __tmp__212; var __tmp__222; __tmp__002 = _this3._transform._rotation00 * _this3._invLocalInertia00 + _this3._transform._rotation01 * _this3._invLocalInertia10 + _this3._transform._rotation02 * _this3._invLocalInertia20; __tmp__012 = _this3._transform._rotation00 * _this3._invLocalInertia01 + _this3._transform._rotation01 * _this3._invLocalInertia11 + _this3._transform._rotation02 * _this3._invLocalInertia21; __tmp__022 = _this3._transform._rotation00 * _this3._invLocalInertia02 + _this3._transform._rotation01 * _this3._invLocalInertia12 + _this3._transform._rotation02 * _this3._invLocalInertia22; __tmp__102 = _this3._transform._rotation10 * _this3._invLocalInertia00 + _this3._transform._rotation11 * _this3._invLocalInertia10 + _this3._transform._rotation12 * _this3._invLocalInertia20; __tmp__112 = _this3._transform._rotation10 * _this3._invLocalInertia01 + _this3._transform._rotation11 * _this3._invLocalInertia11 + _this3._transform._rotation12 * _this3._invLocalInertia21; __tmp__122 = _this3._transform._rotation10 * _this3._invLocalInertia02 + _this3._transform._rotation11 * _this3._invLocalInertia12 + _this3._transform._rotation12 * _this3._invLocalInertia22; __tmp__202 = _this3._transform._rotation20 * _this3._invLocalInertia00 + _this3._transform._rotation21 * _this3._invLocalInertia10 + _this3._transform._rotation22 * _this3._invLocalInertia20; __tmp__212 = _this3._transform._rotation20 * _this3._invLocalInertia01 + _this3._transform._rotation21 * _this3._invLocalInertia11 + _this3._transform._rotation22 * _this3._invLocalInertia21; __tmp__222 = _this3._transform._rotation20 * _this3._invLocalInertia02 + _this3._transform._rotation21 * _this3._invLocalInertia12 + _this3._transform._rotation22 * _this3._invLocalInertia22; _this3._invInertia00 = __tmp__002; _this3._invInertia01 = __tmp__012; _this3._invInertia02 = __tmp__022; _this3._invInertia10 = __tmp__102; _this3._invInertia11 = __tmp__112; _this3._invInertia12 = __tmp__122; _this3._invInertia20 = __tmp__202; _this3._invInertia21 = __tmp__212; _this3._invInertia22 = __tmp__222; var __tmp__003; var __tmp__013; var __tmp__023; var __tmp__103; var __tmp__113; var __tmp__123; var __tmp__203; var __tmp__213; var __tmp__223; __tmp__003 = _this3._invInertia00 * _this3._transform._rotation00 + _this3._invInertia01 * _this3._transform._rotation01 + _this3._invInertia02 * _this3._transform._rotation02; __tmp__013 = _this3._invInertia00 * _this3._transform._rotation10 + _this3._invInertia01 * _this3._transform._rotation11 + _this3._invInertia02 * _this3._transform._rotation12; __tmp__023 = _this3._invInertia00 * _this3._transform._rotation20 + _this3._invInertia01 * _this3._transform._rotation21 + _this3._invInertia02 * _this3._transform._rotation22; __tmp__103 = _this3._invInertia10 * _this3._transform._rotation00 + _this3._invInertia11 * _this3._transform._rotation01 + _this3._invInertia12 * _this3._transform._rotation02; __tmp__113 = _this3._invInertia10 * _this3._transform._rotation10 + _this3._invInertia11 * _this3._transform._rotation11 + _this3._invInertia12 * _this3._transform._rotation12; __tmp__123 = _this3._invInertia10 * _this3._transform._rotation20 + _this3._invInertia11 * _this3._transform._rotation21 + _this3._invInertia12 * _this3._transform._rotation22; __tmp__203 = _this3._invInertia20 * _this3._transform._rotation00 + _this3._invInertia21 * _this3._transform._rotation01 + _this3._invInertia22 * _this3._transform._rotation02; __tmp__213 = _this3._invInertia20 * _this3._transform._rotation10 + _this3._invInertia21 * _this3._transform._rotation11 + _this3._invInertia22 * _this3._transform._rotation12; __tmp__223 = _this3._invInertia20 * _this3._transform._rotation20 + _this3._invInertia21 * _this3._transform._rotation21 + _this3._invInertia22 * _this3._transform._rotation22; _this3._invInertia00 = __tmp__003; _this3._invInertia01 = __tmp__013; _this3._invInertia02 = __tmp__023; _this3._invInertia10 = __tmp__103; _this3._invInertia11 = __tmp__113; _this3._invInertia12 = __tmp__123; _this3._invInertia20 = __tmp__203; _this3._invInertia21 = __tmp__213; _this3._invInertia22 = __tmp__223; _this3._invInertia00 *= _this3._rotFactor.x; _this3._invInertia01 *= _this3._rotFactor.x; _this3._invInertia02 *= _this3._rotFactor.x; _this3._invInertia10 *= _this3._rotFactor.y; _this3._invInertia11 *= _this3._rotFactor.y; _this3._invInertia12 *= _this3._rotFactor.y; _this3._invInertia20 *= _this3._rotFactor.z; _this3._invInertia21 *= _this3._rotFactor.z; _this3._invInertia22 *= _this3._rotFactor.z; } }, { key: "postSolve", value: function postSolve() { this.joint._syncAnchors(); this.joint._checkDestruction(); } }]); return oimo_dynamics_constraint_solver_pgs_PgsJointConstraintSolver; }(oimo.dynamics.constraint.ConstraintSolver); if (!oimo.dynamics.rigidbody) oimo.dynamics.rigidbody = {}; oimo.dynamics.rigidbody.MassData = /*#__PURE__*/_createClass(function oimo_dynamics_rigidbody_MassData() { _classCallCheck(this, oimo_dynamics_rigidbody_MassData); this.mass = 0; this.localInertia = new oimo.common.Mat3(); }); oimo.dynamics.rigidbody.RigidBody = /*#__PURE__*/function () { function oimo_dynamics_rigidbody_RigidBody(config) { _classCallCheck(this, oimo_dynamics_rigidbody_RigidBody); this._next = null; this._prev = null; this._shapeList = null; this._shapeListLast = null; this._numShapes = 0; this._contactLinkList = null; this._contactLinkListLast = null; this._numContactLinks = 0; this._jointLinkList = null; this._jointLinkListLast = null; this._numJointLinks = 0; var v = config.linearVelocity; this._velX = v.x; this._velY = v.y; this._velZ = v.z; var v1 = config.angularVelocity; this._angVelX = v1.x; this._angVelY = v1.y; this._angVelZ = v1.z; this._pseudoVelX = 0; this._pseudoVelY = 0; this._pseudoVelZ = 0; this._angPseudoVelX = 0; this._angPseudoVelY = 0; this._angPseudoVelZ = 0; this._ptransform = new oimo.common.Transform(); this._transform = new oimo.common.Transform(); var v2 = config.position; this._ptransform._positionX = v2.x; this._ptransform._positionY = v2.y; this._ptransform._positionZ = v2.z; var m = config.rotation; this._ptransform._rotation00 = m.e00; this._ptransform._rotation01 = m.e01; this._ptransform._rotation02 = m.e02; this._ptransform._rotation10 = m.e10; this._ptransform._rotation11 = m.e11; this._ptransform._rotation12 = m.e12; this._ptransform._rotation20 = m.e20; this._ptransform._rotation21 = m.e21; this._ptransform._rotation22 = m.e22; var dst = this._transform; var src = this._ptransform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; this._type = config.type; this._sleepTime = 0; this._sleeping = false; this._autoSleep = config.autoSleep; this._mass = 0; this._invMass = 0; this._localInertia00 = 0; this._localInertia01 = 0; this._localInertia02 = 0; this._localInertia10 = 0; this._localInertia11 = 0; this._localInertia12 = 0; this._localInertia20 = 0; this._localInertia21 = 0; this._localInertia22 = 0; this._invLocalInertia00 = 0; this._invLocalInertia01 = 0; this._invLocalInertia02 = 0; this._invLocalInertia10 = 0; this._invLocalInertia11 = 0; this._invLocalInertia12 = 0; this._invLocalInertia20 = 0; this._invLocalInertia21 = 0; this._invLocalInertia22 = 0; this._invLocalInertiaWithoutRotFactor00 = 0; this._invLocalInertiaWithoutRotFactor01 = 0; this._invLocalInertiaWithoutRotFactor02 = 0; this._invLocalInertiaWithoutRotFactor10 = 0; this._invLocalInertiaWithoutRotFactor11 = 0; this._invLocalInertiaWithoutRotFactor12 = 0; this._invLocalInertiaWithoutRotFactor20 = 0; this._invLocalInertiaWithoutRotFactor21 = 0; this._invLocalInertiaWithoutRotFactor22 = 0; this._invInertia00 = 0; this._invInertia01 = 0; this._invInertia02 = 0; this._invInertia10 = 0; this._invInertia11 = 0; this._invInertia12 = 0; this._invInertia20 = 0; this._invInertia21 = 0; this._invInertia22 = 0; this._linearDamping = config.linearDamping; this._angularDamping = config.angularDamping; this._forceX = 0; this._forceY = 0; this._forceZ = 0; this._torqueX = 0; this._torqueY = 0; this._torqueZ = 0; this._linearContactImpulseX = 0; this._linearContactImpulseY = 0; this._linearContactImpulseZ = 0; this._angularContactImpulseX = 0; this._angularContactImpulseY = 0; this._angularContactImpulseZ = 0; this._rotFactor = new oimo.common.Vec3(1, 1, 1); this._addedToIsland = false; this._gravityScale = 1; this._world = null; } _createClass(oimo_dynamics_rigidbody_RigidBody, [{ key: "_integrate", value: function _integrate(dt) { switch (this._type) { case 1: this._velX = 0; this._velY = 0; this._velZ = 0; this._angVelX = 0; this._angVelY = 0; this._angVelZ = 0; this._pseudoVelX = 0; this._pseudoVelY = 0; this._pseudoVelZ = 0; this._angPseudoVelX = 0; this._angPseudoVelY = 0; this._angPseudoVelZ = 0; break; case 0: case 2: var translationX; var translationY; var translationZ; var rotationX; var rotationY; var rotationZ; translationX = this._velX * dt; translationY = this._velY * dt; translationZ = this._velZ * dt; rotationX = this._angVelX * dt; rotationY = this._angVelY * dt; rotationZ = this._angVelZ * dt; var translationLengthSq = translationX * translationX + translationY * translationY + translationZ * translationZ; var rotationLengthSq = rotationX * rotationX + rotationY * rotationY + rotationZ * rotationZ; if (translationLengthSq == 0 && rotationLengthSq == 0) { return; } if (translationLengthSq > oimo.common.Setting.maxTranslationPerStep * oimo.common.Setting.maxTranslationPerStep) { var _l47 = oimo.common.Setting.maxTranslationPerStep / Math.sqrt(translationLengthSq); this._velX *= _l47; this._velY *= _l47; this._velZ *= _l47; translationX *= _l47; translationY *= _l47; translationZ *= _l47; } if (rotationLengthSq > oimo.common.Setting.maxRotationPerStep * oimo.common.Setting.maxRotationPerStep) { var _l48 = oimo.common.Setting.maxRotationPerStep / Math.sqrt(rotationLengthSq); this._angVelX *= _l48; this._angVelY *= _l48; this._angVelZ *= _l48; rotationX *= _l48; rotationY *= _l48; rotationZ *= _l48; } this._transform._positionX += translationX; this._transform._positionY += translationY; this._transform._positionZ += translationZ; var theta = Math.sqrt(rotationX * rotationX + rotationY * rotationY + rotationZ * rotationZ); var halfTheta = theta * 0.5; var rotationToSinAxisFactor; var cosHalfTheta; if (halfTheta < 0.5) { var ht2 = halfTheta * halfTheta; rotationToSinAxisFactor = 0.5 * (1 - ht2 * 0.16666666666666666 + ht2 * ht2 * 0.0083333333333333332); cosHalfTheta = 1 - ht2 * 0.5 + ht2 * ht2 * 0.041666666666666664; } else { rotationToSinAxisFactor = Math.sin(halfTheta) / theta; cosHalfTheta = Math.cos(halfTheta); } var sinAxisX; var sinAxisY; var sinAxisZ; sinAxisX = rotationX * rotationToSinAxisFactor; sinAxisY = rotationY * rotationToSinAxisFactor; sinAxisZ = rotationZ * rotationToSinAxisFactor; var dqX; var dqY; var dqZ; var dqW; dqX = sinAxisX; dqY = sinAxisY; dqZ = sinAxisZ; dqW = cosHalfTheta; var qX; var qY; var qZ; var qW; var e00 = this._transform._rotation00; var e11 = this._transform._rotation11; var e22 = this._transform._rotation22; var t = e00 + e11 + e22; var s; if (t > 0) { s = Math.sqrt(t + 1); qW = 0.5 * s; s = 0.5 / s; qX = (this._transform._rotation21 - this._transform._rotation12) * s; qY = (this._transform._rotation02 - this._transform._rotation20) * s; qZ = (this._transform._rotation10 - this._transform._rotation01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); qX = 0.5 * s; s = 0.5 / s; qY = (this._transform._rotation01 + this._transform._rotation10) * s; qZ = (this._transform._rotation02 + this._transform._rotation20) * s; qW = (this._transform._rotation21 - this._transform._rotation12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); qZ = 0.5 * s; s = 0.5 / s; qX = (this._transform._rotation02 + this._transform._rotation20) * s; qY = (this._transform._rotation12 + this._transform._rotation21) * s; qW = (this._transform._rotation10 - this._transform._rotation01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); qY = 0.5 * s; s = 0.5 / s; qX = (this._transform._rotation01 + this._transform._rotation10) * s; qZ = (this._transform._rotation12 + this._transform._rotation21) * s; qW = (this._transform._rotation02 - this._transform._rotation20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); qZ = 0.5 * s; s = 0.5 / s; qX = (this._transform._rotation02 + this._transform._rotation20) * s; qY = (this._transform._rotation12 + this._transform._rotation21) * s; qW = (this._transform._rotation10 - this._transform._rotation01) * s; } qX = dqW * qX + dqX * qW + dqY * qZ - dqZ * qY; qY = dqW * qY - dqX * qZ + dqY * qW + dqZ * qX; qZ = dqW * qZ + dqX * qY - dqY * qX + dqZ * qW; qW = dqW * qW - dqX * qX - dqY * qY - dqZ * qZ; var l = qX * qX + qY * qY + qZ * qZ + qW * qW; if (l > 1e-32) { l = 1 / Math.sqrt(l); } qX *= l; qY *= l; qZ *= l; qW *= l; var x = qX; var y = qY; var z = qZ; var w = qW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; this._transform._rotation00 = 1 - yy - zz; this._transform._rotation01 = xy - wz; this._transform._rotation02 = xz + wy; this._transform._rotation10 = xy + wz; this._transform._rotation11 = 1 - xx - zz; this._transform._rotation12 = yz - wx; this._transform._rotation20 = xz - wy; this._transform._rotation21 = yz + wx; this._transform._rotation22 = 1 - xx - yy; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20; __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21; __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22; __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20; __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21; __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22; __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20; __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21; __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22; this._invInertia00 = __tmp__00; this._invInertia01 = __tmp__01; this._invInertia02 = __tmp__02; this._invInertia10 = __tmp__10; this._invInertia11 = __tmp__11; this._invInertia12 = __tmp__12; this._invInertia20 = __tmp__20; this._invInertia21 = __tmp__21; this._invInertia22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02; __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12; __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22; __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02; __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12; __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22; __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02; __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12; __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22; this._invInertia00 = __tmp__001; this._invInertia01 = __tmp__011; this._invInertia02 = __tmp__021; this._invInertia10 = __tmp__101; this._invInertia11 = __tmp__111; this._invInertia12 = __tmp__121; this._invInertia20 = __tmp__201; this._invInertia21 = __tmp__211; this._invInertia22 = __tmp__221; this._invInertia00 *= this._rotFactor.x; this._invInertia01 *= this._rotFactor.x; this._invInertia02 *= this._rotFactor.x; this._invInertia10 *= this._rotFactor.y; this._invInertia11 *= this._rotFactor.y; this._invInertia12 *= this._rotFactor.y; this._invInertia20 *= this._rotFactor.z; this._invInertia21 *= this._rotFactor.z; this._invInertia22 *= this._rotFactor.z; break; } } }, { key: "_integratePseudoVelocity", value: function _integratePseudoVelocity() { if (this._pseudoVelX * this._pseudoVelX + this._pseudoVelY * this._pseudoVelY + this._pseudoVelZ * this._pseudoVelZ == 0 && this._angPseudoVelX * this._angPseudoVelX + this._angPseudoVelY * this._angPseudoVelY + this._angPseudoVelZ * this._angPseudoVelZ == 0) { return; } switch (this._type) { case 1: this._pseudoVelX = 0; this._pseudoVelY = 0; this._pseudoVelZ = 0; this._angPseudoVelX = 0; this._angPseudoVelY = 0; this._angPseudoVelZ = 0; break; case 0: case 2: var translationX; var translationY; var translationZ; var rotationX; var rotationY; var rotationZ; translationX = this._pseudoVelX; translationY = this._pseudoVelY; translationZ = this._pseudoVelZ; rotationX = this._angPseudoVelX; rotationY = this._angPseudoVelY; rotationZ = this._angPseudoVelZ; this._pseudoVelX = 0; this._pseudoVelY = 0; this._pseudoVelZ = 0; this._angPseudoVelX = 0; this._angPseudoVelY = 0; this._angPseudoVelZ = 0; this._transform._positionX += translationX; this._transform._positionY += translationY; this._transform._positionZ += translationZ; var theta = Math.sqrt(rotationX * rotationX + rotationY * rotationY + rotationZ * rotationZ); var halfTheta = theta * 0.5; var rotationToSinAxisFactor; var cosHalfTheta; if (halfTheta < 0.5) { var ht2 = halfTheta * halfTheta; rotationToSinAxisFactor = 0.5 * (1 - ht2 * 0.16666666666666666 + ht2 * ht2 * 0.0083333333333333332); cosHalfTheta = 1 - ht2 * 0.5 + ht2 * ht2 * 0.041666666666666664; } else { rotationToSinAxisFactor = Math.sin(halfTheta) / theta; cosHalfTheta = Math.cos(halfTheta); } var sinAxisX; var sinAxisY; var sinAxisZ; sinAxisX = rotationX * rotationToSinAxisFactor; sinAxisY = rotationY * rotationToSinAxisFactor; sinAxisZ = rotationZ * rotationToSinAxisFactor; var dqX; var dqY; var dqZ; var dqW; dqX = sinAxisX; dqY = sinAxisY; dqZ = sinAxisZ; dqW = cosHalfTheta; var qX; var qY; var qZ; var qW; var e00 = this._transform._rotation00; var e11 = this._transform._rotation11; var e22 = this._transform._rotation22; var t = e00 + e11 + e22; var s; if (t > 0) { s = Math.sqrt(t + 1); qW = 0.5 * s; s = 0.5 / s; qX = (this._transform._rotation21 - this._transform._rotation12) * s; qY = (this._transform._rotation02 - this._transform._rotation20) * s; qZ = (this._transform._rotation10 - this._transform._rotation01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); qX = 0.5 * s; s = 0.5 / s; qY = (this._transform._rotation01 + this._transform._rotation10) * s; qZ = (this._transform._rotation02 + this._transform._rotation20) * s; qW = (this._transform._rotation21 - this._transform._rotation12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); qZ = 0.5 * s; s = 0.5 / s; qX = (this._transform._rotation02 + this._transform._rotation20) * s; qY = (this._transform._rotation12 + this._transform._rotation21) * s; qW = (this._transform._rotation10 - this._transform._rotation01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); qY = 0.5 * s; s = 0.5 / s; qX = (this._transform._rotation01 + this._transform._rotation10) * s; qZ = (this._transform._rotation12 + this._transform._rotation21) * s; qW = (this._transform._rotation02 - this._transform._rotation20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); qZ = 0.5 * s; s = 0.5 / s; qX = (this._transform._rotation02 + this._transform._rotation20) * s; qY = (this._transform._rotation12 + this._transform._rotation21) * s; qW = (this._transform._rotation10 - this._transform._rotation01) * s; } qX = dqW * qX + dqX * qW + dqY * qZ - dqZ * qY; qY = dqW * qY - dqX * qZ + dqY * qW + dqZ * qX; qZ = dqW * qZ + dqX * qY - dqY * qX + dqZ * qW; qW = dqW * qW - dqX * qX - dqY * qY - dqZ * qZ; var l = qX * qX + qY * qY + qZ * qZ + qW * qW; if (l > 1e-32) { l = 1 / Math.sqrt(l); } qX *= l; qY *= l; qZ *= l; qW *= l; var x = qX; var y = qY; var z = qZ; var w = qW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; this._transform._rotation00 = 1 - yy - zz; this._transform._rotation01 = xy - wz; this._transform._rotation02 = xz + wy; this._transform._rotation10 = xy + wz; this._transform._rotation11 = 1 - xx - zz; this._transform._rotation12 = yz - wx; this._transform._rotation20 = xz - wy; this._transform._rotation21 = yz + wx; this._transform._rotation22 = 1 - xx - yy; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20; __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21; __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22; __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20; __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21; __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22; __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20; __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21; __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22; this._invInertia00 = __tmp__00; this._invInertia01 = __tmp__01; this._invInertia02 = __tmp__02; this._invInertia10 = __tmp__10; this._invInertia11 = __tmp__11; this._invInertia12 = __tmp__12; this._invInertia20 = __tmp__20; this._invInertia21 = __tmp__21; this._invInertia22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02; __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12; __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22; __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02; __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12; __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22; __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02; __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12; __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22; this._invInertia00 = __tmp__001; this._invInertia01 = __tmp__011; this._invInertia02 = __tmp__021; this._invInertia10 = __tmp__101; this._invInertia11 = __tmp__111; this._invInertia12 = __tmp__121; this._invInertia20 = __tmp__201; this._invInertia21 = __tmp__211; this._invInertia22 = __tmp__221; this._invInertia00 *= this._rotFactor.x; this._invInertia01 *= this._rotFactor.x; this._invInertia02 *= this._rotFactor.x; this._invInertia10 *= this._rotFactor.y; this._invInertia11 *= this._rotFactor.y; this._invInertia12 *= this._rotFactor.y; this._invInertia20 *= this._rotFactor.z; this._invInertia21 *= this._rotFactor.z; this._invInertia22 *= this._rotFactor.z; break; } } }, { key: "updateMass", value: function updateMass() { var totalInertia00; var totalInertia01; var totalInertia02; var totalInertia10; var totalInertia11; var totalInertia12; var totalInertia20; var totalInertia21; var totalInertia22; totalInertia00 = 0; totalInertia01 = 0; totalInertia02 = 0; totalInertia10 = 0; totalInertia11 = 0; totalInertia12 = 0; totalInertia20 = 0; totalInertia21 = 0; totalInertia22 = 0; var totalMass = 0; var s = this._shapeList; while (s != null) { var n = s._next; var g = s._geom; g._updateMass(); var mass = s._density * g._volume; var inertia00 = void 0; var inertia01 = void 0; var inertia02 = void 0; var inertia10 = void 0; var inertia11 = void 0; var inertia12 = void 0; var inertia20 = void 0; var inertia21 = void 0; var inertia22 = void 0; var _tmp__ = void 0; var _tmp__2 = void 0; var _tmp__3 = void 0; var _tmp__4 = void 0; var _tmp__5 = void 0; var _tmp__6 = void 0; var _tmp__7 = void 0; var _tmp__8 = void 0; var _tmp__9 = void 0; _tmp__ = s._localTransform._rotation00 * g._inertiaCoeff00 + s._localTransform._rotation01 * g._inertiaCoeff10 + s._localTransform._rotation02 * g._inertiaCoeff20; _tmp__2 = s._localTransform._rotation00 * g._inertiaCoeff01 + s._localTransform._rotation01 * g._inertiaCoeff11 + s._localTransform._rotation02 * g._inertiaCoeff21; _tmp__3 = s._localTransform._rotation00 * g._inertiaCoeff02 + s._localTransform._rotation01 * g._inertiaCoeff12 + s._localTransform._rotation02 * g._inertiaCoeff22; _tmp__4 = s._localTransform._rotation10 * g._inertiaCoeff00 + s._localTransform._rotation11 * g._inertiaCoeff10 + s._localTransform._rotation12 * g._inertiaCoeff20; _tmp__5 = s._localTransform._rotation10 * g._inertiaCoeff01 + s._localTransform._rotation11 * g._inertiaCoeff11 + s._localTransform._rotation12 * g._inertiaCoeff21; _tmp__6 = s._localTransform._rotation10 * g._inertiaCoeff02 + s._localTransform._rotation11 * g._inertiaCoeff12 + s._localTransform._rotation12 * g._inertiaCoeff22; _tmp__7 = s._localTransform._rotation20 * g._inertiaCoeff00 + s._localTransform._rotation21 * g._inertiaCoeff10 + s._localTransform._rotation22 * g._inertiaCoeff20; _tmp__8 = s._localTransform._rotation20 * g._inertiaCoeff01 + s._localTransform._rotation21 * g._inertiaCoeff11 + s._localTransform._rotation22 * g._inertiaCoeff21; _tmp__9 = s._localTransform._rotation20 * g._inertiaCoeff02 + s._localTransform._rotation21 * g._inertiaCoeff12 + s._localTransform._rotation22 * g._inertiaCoeff22; inertia00 = _tmp__; inertia01 = _tmp__2; inertia02 = _tmp__3; inertia10 = _tmp__4; inertia11 = _tmp__5; inertia12 = _tmp__6; inertia20 = _tmp__7; inertia21 = _tmp__8; inertia22 = _tmp__9; var _tmp__10 = void 0; var _tmp__11 = void 0; var _tmp__12 = void 0; var _tmp__13 = void 0; var _tmp__14 = void 0; var _tmp__15 = void 0; var _tmp__16 = void 0; var _tmp__17 = void 0; var _tmp__18 = void 0; _tmp__10 = inertia00 * s._localTransform._rotation00 + inertia01 * s._localTransform._rotation01 + inertia02 * s._localTransform._rotation02; _tmp__11 = inertia00 * s._localTransform._rotation10 + inertia01 * s._localTransform._rotation11 + inertia02 * s._localTransform._rotation12; _tmp__12 = inertia00 * s._localTransform._rotation20 + inertia01 * s._localTransform._rotation21 + inertia02 * s._localTransform._rotation22; _tmp__13 = inertia10 * s._localTransform._rotation00 + inertia11 * s._localTransform._rotation01 + inertia12 * s._localTransform._rotation02; _tmp__14 = inertia10 * s._localTransform._rotation10 + inertia11 * s._localTransform._rotation11 + inertia12 * s._localTransform._rotation12; _tmp__15 = inertia10 * s._localTransform._rotation20 + inertia11 * s._localTransform._rotation21 + inertia12 * s._localTransform._rotation22; _tmp__16 = inertia20 * s._localTransform._rotation00 + inertia21 * s._localTransform._rotation01 + inertia22 * s._localTransform._rotation02; _tmp__17 = inertia20 * s._localTransform._rotation10 + inertia21 * s._localTransform._rotation11 + inertia22 * s._localTransform._rotation12; _tmp__18 = inertia20 * s._localTransform._rotation20 + inertia21 * s._localTransform._rotation21 + inertia22 * s._localTransform._rotation22; inertia00 = _tmp__10; inertia01 = _tmp__11; inertia02 = _tmp__12; inertia10 = _tmp__13; inertia11 = _tmp__14; inertia12 = _tmp__15; inertia20 = _tmp__16; inertia21 = _tmp__17; inertia22 = _tmp__18; inertia00 *= mass; inertia01 *= mass; inertia02 *= mass; inertia10 *= mass; inertia11 *= mass; inertia12 *= mass; inertia20 *= mass; inertia21 *= mass; inertia22 *= mass; var cogInertia00 = void 0; var cogInertia01 = void 0; var cogInertia02 = void 0; var cogInertia10 = void 0; var cogInertia11 = void 0; var cogInertia12 = void 0; var cogInertia20 = void 0; var cogInertia21 = void 0; var cogInertia22 = void 0; var xx = s._localTransform._positionX * s._localTransform._positionX; var yy = s._localTransform._positionY * s._localTransform._positionY; var zz = s._localTransform._positionZ * s._localTransform._positionZ; var xy = -s._localTransform._positionX * s._localTransform._positionY; var yz = -s._localTransform._positionY * s._localTransform._positionZ; var zx = -s._localTransform._positionZ * s._localTransform._positionX; cogInertia00 = yy + zz; cogInertia01 = xy; cogInertia02 = zx; cogInertia10 = xy; cogInertia11 = xx + zz; cogInertia12 = yz; cogInertia20 = zx; cogInertia21 = yz; cogInertia22 = xx + yy; inertia00 += cogInertia00 * mass; inertia01 += cogInertia01 * mass; inertia02 += cogInertia02 * mass; inertia10 += cogInertia10 * mass; inertia11 += cogInertia11 * mass; inertia12 += cogInertia12 * mass; inertia20 += cogInertia20 * mass; inertia21 += cogInertia21 * mass; inertia22 += cogInertia22 * mass; totalMass += mass; totalInertia00 += inertia00; totalInertia01 += inertia01; totalInertia02 += inertia02; totalInertia10 += inertia10; totalInertia11 += inertia11; totalInertia12 += inertia12; totalInertia20 += inertia20; totalInertia21 += inertia21; totalInertia22 += inertia22; s = n; } this._mass = totalMass; this._localInertia00 = totalInertia00; this._localInertia01 = totalInertia01; this._localInertia02 = totalInertia02; this._localInertia10 = totalInertia10; this._localInertia11 = totalInertia11; this._localInertia12 = totalInertia12; this._localInertia20 = totalInertia20; this._localInertia21 = totalInertia21; this._localInertia22 = totalInertia22; if (this._mass > 0 && this._localInertia00 * (this._localInertia11 * this._localInertia22 - this._localInertia12 * this._localInertia21) - this._localInertia01 * (this._localInertia10 * this._localInertia22 - this._localInertia12 * this._localInertia20) + this._localInertia02 * (this._localInertia10 * this._localInertia21 - this._localInertia11 * this._localInertia20) > 0 && this._type == 0) { this._invMass = 1 / this._mass; var d00 = this._localInertia11 * this._localInertia22 - this._localInertia12 * this._localInertia21; var d01 = this._localInertia10 * this._localInertia22 - this._localInertia12 * this._localInertia20; var d02 = this._localInertia10 * this._localInertia21 - this._localInertia11 * this._localInertia20; var d = this._localInertia00 * d00 - this._localInertia01 * d01 + this._localInertia02 * d02; if (d < -1e-32 || d > 1e-32) { d = 1 / d; } this._invLocalInertia00 = d00 * d; this._invLocalInertia01 = -(this._localInertia01 * this._localInertia22 - this._localInertia02 * this._localInertia21) * d; this._invLocalInertia02 = (this._localInertia01 * this._localInertia12 - this._localInertia02 * this._localInertia11) * d; this._invLocalInertia10 = -d01 * d; this._invLocalInertia11 = (this._localInertia00 * this._localInertia22 - this._localInertia02 * this._localInertia20) * d; this._invLocalInertia12 = -(this._localInertia00 * this._localInertia12 - this._localInertia02 * this._localInertia10) * d; this._invLocalInertia20 = d02 * d; this._invLocalInertia21 = -(this._localInertia00 * this._localInertia21 - this._localInertia01 * this._localInertia20) * d; this._invLocalInertia22 = (this._localInertia00 * this._localInertia11 - this._localInertia01 * this._localInertia10) * d; this._invLocalInertiaWithoutRotFactor00 = this._invLocalInertia00; this._invLocalInertiaWithoutRotFactor01 = this._invLocalInertia01; this._invLocalInertiaWithoutRotFactor02 = this._invLocalInertia02; this._invLocalInertiaWithoutRotFactor10 = this._invLocalInertia10; this._invLocalInertiaWithoutRotFactor11 = this._invLocalInertia11; this._invLocalInertiaWithoutRotFactor12 = this._invLocalInertia12; this._invLocalInertiaWithoutRotFactor20 = this._invLocalInertia20; this._invLocalInertiaWithoutRotFactor21 = this._invLocalInertia21; this._invLocalInertiaWithoutRotFactor22 = this._invLocalInertia22; this._invLocalInertia00 = this._invLocalInertiaWithoutRotFactor00 * this._rotFactor.x; this._invLocalInertia01 = this._invLocalInertiaWithoutRotFactor01 * this._rotFactor.x; this._invLocalInertia02 = this._invLocalInertiaWithoutRotFactor02 * this._rotFactor.x; this._invLocalInertia10 = this._invLocalInertiaWithoutRotFactor10 * this._rotFactor.y; this._invLocalInertia11 = this._invLocalInertiaWithoutRotFactor11 * this._rotFactor.y; this._invLocalInertia12 = this._invLocalInertiaWithoutRotFactor12 * this._rotFactor.y; this._invLocalInertia20 = this._invLocalInertiaWithoutRotFactor20 * this._rotFactor.z; this._invLocalInertia21 = this._invLocalInertiaWithoutRotFactor21 * this._rotFactor.z; this._invLocalInertia22 = this._invLocalInertiaWithoutRotFactor22 * this._rotFactor.z; } else { this._invMass = 0; this._invLocalInertia00 = 0; this._invLocalInertia01 = 0; this._invLocalInertia02 = 0; this._invLocalInertia10 = 0; this._invLocalInertia11 = 0; this._invLocalInertia12 = 0; this._invLocalInertia20 = 0; this._invLocalInertia21 = 0; this._invLocalInertia22 = 0; this._invLocalInertiaWithoutRotFactor00 = 0; this._invLocalInertiaWithoutRotFactor01 = 0; this._invLocalInertiaWithoutRotFactor02 = 0; this._invLocalInertiaWithoutRotFactor10 = 0; this._invLocalInertiaWithoutRotFactor11 = 0; this._invLocalInertiaWithoutRotFactor12 = 0; this._invLocalInertiaWithoutRotFactor20 = 0; this._invLocalInertiaWithoutRotFactor21 = 0; this._invLocalInertiaWithoutRotFactor22 = 0; if (this._type == 0) { this._type = 1; } } var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20; __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21; __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22; __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20; __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21; __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22; __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20; __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21; __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22; this._invInertia00 = __tmp__00; this._invInertia01 = __tmp__01; this._invInertia02 = __tmp__02; this._invInertia10 = __tmp__10; this._invInertia11 = __tmp__11; this._invInertia12 = __tmp__12; this._invInertia20 = __tmp__20; this._invInertia21 = __tmp__21; this._invInertia22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02; __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12; __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22; __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02; __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12; __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22; __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02; __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12; __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22; this._invInertia00 = __tmp__001; this._invInertia01 = __tmp__011; this._invInertia02 = __tmp__021; this._invInertia10 = __tmp__101; this._invInertia11 = __tmp__111; this._invInertia12 = __tmp__121; this._invInertia20 = __tmp__201; this._invInertia21 = __tmp__211; this._invInertia22 = __tmp__221; this._invInertia00 *= this._rotFactor.x; this._invInertia01 *= this._rotFactor.x; this._invInertia02 *= this._rotFactor.x; this._invInertia10 *= this._rotFactor.y; this._invInertia11 *= this._rotFactor.y; this._invInertia12 *= this._rotFactor.y; this._invInertia20 *= this._rotFactor.z; this._invInertia21 *= this._rotFactor.z; this._invInertia22 *= this._rotFactor.z; this._sleeping = false; this._sleepTime = 0; } }, { key: "getPosition", value: function getPosition() { var v = new oimo.common.Vec3(); v.x = this._transform._positionX; v.y = this._transform._positionY; v.z = this._transform._positionZ; return v; } }, { key: "getPositionTo", value: function getPositionTo(position) { position.x = this._transform._positionX; position.y = this._transform._positionY; position.z = this._transform._positionZ; } }, { key: "setPosition", value: function setPosition(position) { this._transform._positionX = position.x; this._transform._positionY = position.y; this._transform._positionZ = position.z; var dst = this._ptransform; var src = this._transform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; var s = this._shapeList; while (s != null) { var n = s._next; var tf1 = this._ptransform; var tf2 = this._transform; var _dst3 = s._ptransform; var src1 = s._localTransform; var __tmp__00 = void 0; var __tmp__01 = void 0; var __tmp__02 = void 0; var __tmp__10 = void 0; var __tmp__11 = void 0; var __tmp__12 = void 0; var __tmp__20 = void 0; var __tmp__21 = void 0; var __tmp__22 = void 0; __tmp__00 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; __tmp__01 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; __tmp__02 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; __tmp__10 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; __tmp__11 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; __tmp__12 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; __tmp__20 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; __tmp__21 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; __tmp__22 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; _dst3._rotation00 = __tmp__00; _dst3._rotation01 = __tmp__01; _dst3._rotation02 = __tmp__02; _dst3._rotation10 = __tmp__10; _dst3._rotation11 = __tmp__11; _dst3._rotation12 = __tmp__12; _dst3._rotation20 = __tmp__20; _dst3._rotation21 = __tmp__21; _dst3._rotation22 = __tmp__22; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; _dst3._positionX = __tmp__X; _dst3._positionY = __tmp__Y; _dst3._positionZ = __tmp__Z; _dst3._positionX += tf1._positionX; _dst3._positionY += tf1._positionY; _dst3._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var __tmp__001 = void 0; var __tmp__011 = void 0; var __tmp__021 = void 0; var __tmp__101 = void 0; var __tmp__111 = void 0; var __tmp__121 = void 0; var __tmp__201 = void 0; var __tmp__211 = void 0; var __tmp__221 = void 0; __tmp__001 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; __tmp__011 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; __tmp__021 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; __tmp__101 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; __tmp__111 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; __tmp__121 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; __tmp__201 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; __tmp__211 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; __tmp__221 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = __tmp__001; dst1._rotation01 = __tmp__011; dst1._rotation02 = __tmp__021; dst1._rotation10 = __tmp__101; dst1._rotation11 = __tmp__111; dst1._rotation12 = __tmp__121; dst1._rotation20 = __tmp__201; dst1._rotation21 = __tmp__211; dst1._rotation22 = __tmp__221; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } this._sleeping = false; this._sleepTime = 0; } }, { key: "translate", value: function translate(translation) { var diffX; var diffY; var diffZ; diffX = translation.x; diffY = translation.y; diffZ = translation.z; this._transform._positionX += diffX; this._transform._positionY += diffY; this._transform._positionZ += diffZ; var dst = this._ptransform; var src = this._transform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; var s = this._shapeList; while (s != null) { var n = s._next; var tf1 = this._ptransform; var tf2 = this._transform; var _dst4 = s._ptransform; var src1 = s._localTransform; var __tmp__00 = void 0; var __tmp__01 = void 0; var __tmp__02 = void 0; var __tmp__10 = void 0; var __tmp__11 = void 0; var __tmp__12 = void 0; var __tmp__20 = void 0; var __tmp__21 = void 0; var __tmp__22 = void 0; __tmp__00 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; __tmp__01 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; __tmp__02 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; __tmp__10 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; __tmp__11 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; __tmp__12 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; __tmp__20 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; __tmp__21 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; __tmp__22 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; _dst4._rotation00 = __tmp__00; _dst4._rotation01 = __tmp__01; _dst4._rotation02 = __tmp__02; _dst4._rotation10 = __tmp__10; _dst4._rotation11 = __tmp__11; _dst4._rotation12 = __tmp__12; _dst4._rotation20 = __tmp__20; _dst4._rotation21 = __tmp__21; _dst4._rotation22 = __tmp__22; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; _dst4._positionX = __tmp__X; _dst4._positionY = __tmp__Y; _dst4._positionZ = __tmp__Z; _dst4._positionX += tf1._positionX; _dst4._positionY += tf1._positionY; _dst4._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var __tmp__001 = void 0; var __tmp__011 = void 0; var __tmp__021 = void 0; var __tmp__101 = void 0; var __tmp__111 = void 0; var __tmp__121 = void 0; var __tmp__201 = void 0; var __tmp__211 = void 0; var __tmp__221 = void 0; __tmp__001 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; __tmp__011 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; __tmp__021 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; __tmp__101 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; __tmp__111 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; __tmp__121 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; __tmp__201 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; __tmp__211 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; __tmp__221 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = __tmp__001; dst1._rotation01 = __tmp__011; dst1._rotation02 = __tmp__021; dst1._rotation10 = __tmp__101; dst1._rotation11 = __tmp__111; dst1._rotation12 = __tmp__121; dst1._rotation20 = __tmp__201; dst1._rotation21 = __tmp__211; dst1._rotation22 = __tmp__221; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } this._sleeping = false; this._sleepTime = 0; } }, { key: "getRotation", value: function getRotation() { var m = new oimo.common.Mat3(); m.e00 = this._transform._rotation00; m.e01 = this._transform._rotation01; m.e02 = this._transform._rotation02; m.e10 = this._transform._rotation10; m.e11 = this._transform._rotation11; m.e12 = this._transform._rotation12; m.e20 = this._transform._rotation20; m.e21 = this._transform._rotation21; m.e22 = this._transform._rotation22; return m; } }, { key: "getRotationTo", value: function getRotationTo(rotation) { rotation.e00 = this._transform._rotation00; rotation.e01 = this._transform._rotation01; rotation.e02 = this._transform._rotation02; rotation.e10 = this._transform._rotation10; rotation.e11 = this._transform._rotation11; rotation.e12 = this._transform._rotation12; rotation.e20 = this._transform._rotation20; rotation.e21 = this._transform._rotation21; rotation.e22 = this._transform._rotation22; } }, { key: "setRotation", value: function setRotation(rotation) { this._transform._rotation00 = rotation.e00; this._transform._rotation01 = rotation.e01; this._transform._rotation02 = rotation.e02; this._transform._rotation10 = rotation.e10; this._transform._rotation11 = rotation.e11; this._transform._rotation12 = rotation.e12; this._transform._rotation20 = rotation.e20; this._transform._rotation21 = rotation.e21; this._transform._rotation22 = rotation.e22; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20; __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21; __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22; __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20; __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21; __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22; __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20; __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21; __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22; this._invInertia00 = __tmp__00; this._invInertia01 = __tmp__01; this._invInertia02 = __tmp__02; this._invInertia10 = __tmp__10; this._invInertia11 = __tmp__11; this._invInertia12 = __tmp__12; this._invInertia20 = __tmp__20; this._invInertia21 = __tmp__21; this._invInertia22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02; __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12; __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22; __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02; __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12; __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22; __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02; __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12; __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22; this._invInertia00 = __tmp__001; this._invInertia01 = __tmp__011; this._invInertia02 = __tmp__021; this._invInertia10 = __tmp__101; this._invInertia11 = __tmp__111; this._invInertia12 = __tmp__121; this._invInertia20 = __tmp__201; this._invInertia21 = __tmp__211; this._invInertia22 = __tmp__221; this._invInertia00 *= this._rotFactor.x; this._invInertia01 *= this._rotFactor.x; this._invInertia02 *= this._rotFactor.x; this._invInertia10 *= this._rotFactor.y; this._invInertia11 *= this._rotFactor.y; this._invInertia12 *= this._rotFactor.y; this._invInertia20 *= this._rotFactor.z; this._invInertia21 *= this._rotFactor.z; this._invInertia22 *= this._rotFactor.z; var dst = this._ptransform; var src = this._transform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; var s = this._shapeList; while (s != null) { var n = s._next; var tf1 = this._ptransform; var tf2 = this._transform; var _dst5 = s._ptransform; var src1 = s._localTransform; var _tmp__19 = void 0; var _tmp__20 = void 0; var _tmp__21 = void 0; var _tmp__22 = void 0; var _tmp__23 = void 0; var _tmp__24 = void 0; var _tmp__25 = void 0; var _tmp__26 = void 0; var _tmp__27 = void 0; _tmp__19 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; _tmp__20 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; _tmp__21 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; _tmp__22 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; _tmp__23 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; _tmp__24 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; _tmp__25 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; _tmp__26 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; _tmp__27 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; _dst5._rotation00 = _tmp__19; _dst5._rotation01 = _tmp__20; _dst5._rotation02 = _tmp__21; _dst5._rotation10 = _tmp__22; _dst5._rotation11 = _tmp__23; _dst5._rotation12 = _tmp__24; _dst5._rotation20 = _tmp__25; _dst5._rotation21 = _tmp__26; _dst5._rotation22 = _tmp__27; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; _dst5._positionX = __tmp__X; _dst5._positionY = __tmp__Y; _dst5._positionZ = __tmp__Z; _dst5._positionX += tf1._positionX; _dst5._positionY += tf1._positionY; _dst5._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var _tmp__28 = void 0; var _tmp__29 = void 0; var _tmp__30 = void 0; var _tmp__31 = void 0; var _tmp__32 = void 0; var _tmp__33 = void 0; var _tmp__34 = void 0; var _tmp__35 = void 0; var _tmp__36 = void 0; _tmp__28 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; _tmp__29 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; _tmp__30 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; _tmp__31 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; _tmp__32 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; _tmp__33 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; _tmp__34 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; _tmp__35 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; _tmp__36 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = _tmp__28; dst1._rotation01 = _tmp__29; dst1._rotation02 = _tmp__30; dst1._rotation10 = _tmp__31; dst1._rotation11 = _tmp__32; dst1._rotation12 = _tmp__33; dst1._rotation20 = _tmp__34; dst1._rotation21 = _tmp__35; dst1._rotation22 = _tmp__36; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } this._sleeping = false; this._sleepTime = 0; } }, { key: "setRotationXyz", value: function setRotationXyz(eulerAngles) { var xyzX; var xyzY; var xyzZ; xyzX = eulerAngles.x; xyzY = eulerAngles.y; xyzZ = eulerAngles.z; var sx = Math.sin(xyzX); var sy = Math.sin(xyzY); var sz = Math.sin(xyzZ); var cx = Math.cos(xyzX); var cy = Math.cos(xyzY); var cz = Math.cos(xyzZ); this._transform._rotation00 = cy * cz; this._transform._rotation01 = -cy * sz; this._transform._rotation02 = sy; this._transform._rotation10 = cx * sz + cz * sx * sy; this._transform._rotation11 = cx * cz - sx * sy * sz; this._transform._rotation12 = -cy * sx; this._transform._rotation20 = sx * sz - cx * cz * sy; this._transform._rotation21 = cz * sx + cx * sy * sz; this._transform._rotation22 = cx * cy; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20; __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21; __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22; __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20; __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21; __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22; __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20; __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21; __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22; this._invInertia00 = __tmp__00; this._invInertia01 = __tmp__01; this._invInertia02 = __tmp__02; this._invInertia10 = __tmp__10; this._invInertia11 = __tmp__11; this._invInertia12 = __tmp__12; this._invInertia20 = __tmp__20; this._invInertia21 = __tmp__21; this._invInertia22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02; __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12; __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22; __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02; __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12; __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22; __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02; __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12; __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22; this._invInertia00 = __tmp__001; this._invInertia01 = __tmp__011; this._invInertia02 = __tmp__021; this._invInertia10 = __tmp__101; this._invInertia11 = __tmp__111; this._invInertia12 = __tmp__121; this._invInertia20 = __tmp__201; this._invInertia21 = __tmp__211; this._invInertia22 = __tmp__221; this._invInertia00 *= this._rotFactor.x; this._invInertia01 *= this._rotFactor.x; this._invInertia02 *= this._rotFactor.x; this._invInertia10 *= this._rotFactor.y; this._invInertia11 *= this._rotFactor.y; this._invInertia12 *= this._rotFactor.y; this._invInertia20 *= this._rotFactor.z; this._invInertia21 *= this._rotFactor.z; this._invInertia22 *= this._rotFactor.z; var dst = this._ptransform; var src = this._transform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; var s = this._shapeList; while (s != null) { var n = s._next; var tf1 = this._ptransform; var tf2 = this._transform; var _dst6 = s._ptransform; var src1 = s._localTransform; var _tmp__37 = void 0; var _tmp__38 = void 0; var _tmp__39 = void 0; var _tmp__40 = void 0; var _tmp__41 = void 0; var _tmp__42 = void 0; var _tmp__43 = void 0; var _tmp__44 = void 0; var _tmp__45 = void 0; _tmp__37 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; _tmp__38 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; _tmp__39 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; _tmp__40 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; _tmp__41 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; _tmp__42 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; _tmp__43 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; _tmp__44 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; _tmp__45 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; _dst6._rotation00 = _tmp__37; _dst6._rotation01 = _tmp__38; _dst6._rotation02 = _tmp__39; _dst6._rotation10 = _tmp__40; _dst6._rotation11 = _tmp__41; _dst6._rotation12 = _tmp__42; _dst6._rotation20 = _tmp__43; _dst6._rotation21 = _tmp__44; _dst6._rotation22 = _tmp__45; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; _dst6._positionX = __tmp__X; _dst6._positionY = __tmp__Y; _dst6._positionZ = __tmp__Z; _dst6._positionX += tf1._positionX; _dst6._positionY += tf1._positionY; _dst6._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var _tmp__46 = void 0; var _tmp__47 = void 0; var _tmp__48 = void 0; var _tmp__49 = void 0; var _tmp__50 = void 0; var _tmp__51 = void 0; var _tmp__52 = void 0; var _tmp__53 = void 0; var _tmp__54 = void 0; _tmp__46 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; _tmp__47 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; _tmp__48 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; _tmp__49 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; _tmp__50 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; _tmp__51 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; _tmp__52 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; _tmp__53 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; _tmp__54 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = _tmp__46; dst1._rotation01 = _tmp__47; dst1._rotation02 = _tmp__48; dst1._rotation10 = _tmp__49; dst1._rotation11 = _tmp__50; dst1._rotation12 = _tmp__51; dst1._rotation20 = _tmp__52; dst1._rotation21 = _tmp__53; dst1._rotation22 = _tmp__54; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } this._sleeping = false; this._sleepTime = 0; } }, { key: "rotate", value: function rotate(rotation) { var rot00; var rot01; var rot02; var rot10; var rot11; var rot12; var rot20; var rot21; var rot22; rot00 = rotation.e00; rot01 = rotation.e01; rot02 = rotation.e02; rot10 = rotation.e10; rot11 = rotation.e11; rot12 = rotation.e12; rot20 = rotation.e20; rot21 = rotation.e21; rot22 = rotation.e22; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = rot00 * this._transform._rotation00 + rot01 * this._transform._rotation10 + rot02 * this._transform._rotation20; __tmp__01 = rot00 * this._transform._rotation01 + rot01 * this._transform._rotation11 + rot02 * this._transform._rotation21; __tmp__02 = rot00 * this._transform._rotation02 + rot01 * this._transform._rotation12 + rot02 * this._transform._rotation22; __tmp__10 = rot10 * this._transform._rotation00 + rot11 * this._transform._rotation10 + rot12 * this._transform._rotation20; __tmp__11 = rot10 * this._transform._rotation01 + rot11 * this._transform._rotation11 + rot12 * this._transform._rotation21; __tmp__12 = rot10 * this._transform._rotation02 + rot11 * this._transform._rotation12 + rot12 * this._transform._rotation22; __tmp__20 = rot20 * this._transform._rotation00 + rot21 * this._transform._rotation10 + rot22 * this._transform._rotation20; __tmp__21 = rot20 * this._transform._rotation01 + rot21 * this._transform._rotation11 + rot22 * this._transform._rotation21; __tmp__22 = rot20 * this._transform._rotation02 + rot21 * this._transform._rotation12 + rot22 * this._transform._rotation22; this._transform._rotation00 = __tmp__00; this._transform._rotation01 = __tmp__01; this._transform._rotation02 = __tmp__02; this._transform._rotation10 = __tmp__10; this._transform._rotation11 = __tmp__11; this._transform._rotation12 = __tmp__12; this._transform._rotation20 = __tmp__20; this._transform._rotation21 = __tmp__21; this._transform._rotation22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20; __tmp__011 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21; __tmp__021 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22; __tmp__101 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20; __tmp__111 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21; __tmp__121 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22; __tmp__201 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20; __tmp__211 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21; __tmp__221 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22; this._invInertia00 = __tmp__001; this._invInertia01 = __tmp__011; this._invInertia02 = __tmp__021; this._invInertia10 = __tmp__101; this._invInertia11 = __tmp__111; this._invInertia12 = __tmp__121; this._invInertia20 = __tmp__201; this._invInertia21 = __tmp__211; this._invInertia22 = __tmp__221; var __tmp__002; var __tmp__012; var __tmp__022; var __tmp__102; var __tmp__112; var __tmp__122; var __tmp__202; var __tmp__212; var __tmp__222; __tmp__002 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02; __tmp__012 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12; __tmp__022 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22; __tmp__102 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02; __tmp__112 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12; __tmp__122 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22; __tmp__202 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02; __tmp__212 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12; __tmp__222 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22; this._invInertia00 = __tmp__002; this._invInertia01 = __tmp__012; this._invInertia02 = __tmp__022; this._invInertia10 = __tmp__102; this._invInertia11 = __tmp__112; this._invInertia12 = __tmp__122; this._invInertia20 = __tmp__202; this._invInertia21 = __tmp__212; this._invInertia22 = __tmp__222; this._invInertia00 *= this._rotFactor.x; this._invInertia01 *= this._rotFactor.x; this._invInertia02 *= this._rotFactor.x; this._invInertia10 *= this._rotFactor.y; this._invInertia11 *= this._rotFactor.y; this._invInertia12 *= this._rotFactor.y; this._invInertia20 *= this._rotFactor.z; this._invInertia21 *= this._rotFactor.z; this._invInertia22 *= this._rotFactor.z; var dst = this._ptransform; var src = this._transform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; var s = this._shapeList; while (s != null) { var n = s._next; var tf1 = this._ptransform; var tf2 = this._transform; var _dst7 = s._ptransform; var src1 = s._localTransform; var _tmp__55 = void 0; var _tmp__56 = void 0; var _tmp__57 = void 0; var _tmp__58 = void 0; var _tmp__59 = void 0; var _tmp__60 = void 0; var _tmp__61 = void 0; var _tmp__62 = void 0; var _tmp__63 = void 0; _tmp__55 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; _tmp__56 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; _tmp__57 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; _tmp__58 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; _tmp__59 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; _tmp__60 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; _tmp__61 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; _tmp__62 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; _tmp__63 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; _dst7._rotation00 = _tmp__55; _dst7._rotation01 = _tmp__56; _dst7._rotation02 = _tmp__57; _dst7._rotation10 = _tmp__58; _dst7._rotation11 = _tmp__59; _dst7._rotation12 = _tmp__60; _dst7._rotation20 = _tmp__61; _dst7._rotation21 = _tmp__62; _dst7._rotation22 = _tmp__63; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; _dst7._positionX = __tmp__X; _dst7._positionY = __tmp__Y; _dst7._positionZ = __tmp__Z; _dst7._positionX += tf1._positionX; _dst7._positionY += tf1._positionY; _dst7._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var _tmp__64 = void 0; var _tmp__65 = void 0; var _tmp__66 = void 0; var _tmp__67 = void 0; var _tmp__68 = void 0; var _tmp__69 = void 0; var _tmp__70 = void 0; var _tmp__71 = void 0; var _tmp__72 = void 0; _tmp__64 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; _tmp__65 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; _tmp__66 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; _tmp__67 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; _tmp__68 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; _tmp__69 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; _tmp__70 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; _tmp__71 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; _tmp__72 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = _tmp__64; dst1._rotation01 = _tmp__65; dst1._rotation02 = _tmp__66; dst1._rotation10 = _tmp__67; dst1._rotation11 = _tmp__68; dst1._rotation12 = _tmp__69; dst1._rotation20 = _tmp__70; dst1._rotation21 = _tmp__71; dst1._rotation22 = _tmp__72; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } this._sleeping = false; this._sleepTime = 0; } }, { key: "rotateXyz", value: function rotateXyz(eulerAngles) { var xyzX; var xyzY; var xyzZ; var rot00; var rot01; var rot02; var rot10; var rot11; var rot12; var rot20; var rot21; var rot22; xyzX = eulerAngles.x; xyzY = eulerAngles.y; xyzZ = eulerAngles.z; var sx = Math.sin(xyzX); var sy = Math.sin(xyzY); var sz = Math.sin(xyzZ); var cx = Math.cos(xyzX); var cy = Math.cos(xyzY); var cz = Math.cos(xyzZ); rot00 = cy * cz; rot01 = -cy * sz; rot02 = sy; rot10 = cx * sz + cz * sx * sy; rot11 = cx * cz - sx * sy * sz; rot12 = -cy * sx; rot20 = sx * sz - cx * cz * sy; rot21 = cz * sx + cx * sy * sz; rot22 = cx * cy; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = rot00 * this._transform._rotation00 + rot01 * this._transform._rotation10 + rot02 * this._transform._rotation20; __tmp__01 = rot00 * this._transform._rotation01 + rot01 * this._transform._rotation11 + rot02 * this._transform._rotation21; __tmp__02 = rot00 * this._transform._rotation02 + rot01 * this._transform._rotation12 + rot02 * this._transform._rotation22; __tmp__10 = rot10 * this._transform._rotation00 + rot11 * this._transform._rotation10 + rot12 * this._transform._rotation20; __tmp__11 = rot10 * this._transform._rotation01 + rot11 * this._transform._rotation11 + rot12 * this._transform._rotation21; __tmp__12 = rot10 * this._transform._rotation02 + rot11 * this._transform._rotation12 + rot12 * this._transform._rotation22; __tmp__20 = rot20 * this._transform._rotation00 + rot21 * this._transform._rotation10 + rot22 * this._transform._rotation20; __tmp__21 = rot20 * this._transform._rotation01 + rot21 * this._transform._rotation11 + rot22 * this._transform._rotation21; __tmp__22 = rot20 * this._transform._rotation02 + rot21 * this._transform._rotation12 + rot22 * this._transform._rotation22; this._transform._rotation00 = __tmp__00; this._transform._rotation01 = __tmp__01; this._transform._rotation02 = __tmp__02; this._transform._rotation10 = __tmp__10; this._transform._rotation11 = __tmp__11; this._transform._rotation12 = __tmp__12; this._transform._rotation20 = __tmp__20; this._transform._rotation21 = __tmp__21; this._transform._rotation22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20; __tmp__011 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21; __tmp__021 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22; __tmp__101 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20; __tmp__111 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21; __tmp__121 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22; __tmp__201 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20; __tmp__211 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21; __tmp__221 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22; this._invInertia00 = __tmp__001; this._invInertia01 = __tmp__011; this._invInertia02 = __tmp__021; this._invInertia10 = __tmp__101; this._invInertia11 = __tmp__111; this._invInertia12 = __tmp__121; this._invInertia20 = __tmp__201; this._invInertia21 = __tmp__211; this._invInertia22 = __tmp__221; var __tmp__002; var __tmp__012; var __tmp__022; var __tmp__102; var __tmp__112; var __tmp__122; var __tmp__202; var __tmp__212; var __tmp__222; __tmp__002 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02; __tmp__012 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12; __tmp__022 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22; __tmp__102 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02; __tmp__112 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12; __tmp__122 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22; __tmp__202 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02; __tmp__212 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12; __tmp__222 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22; this._invInertia00 = __tmp__002; this._invInertia01 = __tmp__012; this._invInertia02 = __tmp__022; this._invInertia10 = __tmp__102; this._invInertia11 = __tmp__112; this._invInertia12 = __tmp__122; this._invInertia20 = __tmp__202; this._invInertia21 = __tmp__212; this._invInertia22 = __tmp__222; this._invInertia00 *= this._rotFactor.x; this._invInertia01 *= this._rotFactor.x; this._invInertia02 *= this._rotFactor.x; this._invInertia10 *= this._rotFactor.y; this._invInertia11 *= this._rotFactor.y; this._invInertia12 *= this._rotFactor.y; this._invInertia20 *= this._rotFactor.z; this._invInertia21 *= this._rotFactor.z; this._invInertia22 *= this._rotFactor.z; var dst = this._ptransform; var src = this._transform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; var s = this._shapeList; while (s != null) { var n = s._next; var tf1 = this._ptransform; var tf2 = this._transform; var _dst8 = s._ptransform; var src1 = s._localTransform; var _tmp__73 = void 0; var _tmp__74 = void 0; var _tmp__75 = void 0; var _tmp__76 = void 0; var _tmp__77 = void 0; var _tmp__78 = void 0; var _tmp__79 = void 0; var _tmp__80 = void 0; var _tmp__81 = void 0; _tmp__73 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; _tmp__74 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; _tmp__75 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; _tmp__76 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; _tmp__77 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; _tmp__78 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; _tmp__79 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; _tmp__80 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; _tmp__81 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; _dst8._rotation00 = _tmp__73; _dst8._rotation01 = _tmp__74; _dst8._rotation02 = _tmp__75; _dst8._rotation10 = _tmp__76; _dst8._rotation11 = _tmp__77; _dst8._rotation12 = _tmp__78; _dst8._rotation20 = _tmp__79; _dst8._rotation21 = _tmp__80; _dst8._rotation22 = _tmp__81; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; _dst8._positionX = __tmp__X; _dst8._positionY = __tmp__Y; _dst8._positionZ = __tmp__Z; _dst8._positionX += tf1._positionX; _dst8._positionY += tf1._positionY; _dst8._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var _tmp__82 = void 0; var _tmp__83 = void 0; var _tmp__84 = void 0; var _tmp__85 = void 0; var _tmp__86 = void 0; var _tmp__87 = void 0; var _tmp__88 = void 0; var _tmp__89 = void 0; var _tmp__90 = void 0; _tmp__82 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; _tmp__83 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; _tmp__84 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; _tmp__85 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; _tmp__86 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; _tmp__87 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; _tmp__88 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; _tmp__89 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; _tmp__90 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = _tmp__82; dst1._rotation01 = _tmp__83; dst1._rotation02 = _tmp__84; dst1._rotation10 = _tmp__85; dst1._rotation11 = _tmp__86; dst1._rotation12 = _tmp__87; dst1._rotation20 = _tmp__88; dst1._rotation21 = _tmp__89; dst1._rotation22 = _tmp__90; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } this._sleeping = false; this._sleepTime = 0; } }, { key: "getOrientation", value: function getOrientation() { var q = new oimo.common.Quat(); var iqX; var iqY; var iqZ; var iqW; var e00 = this._transform._rotation00; var e11 = this._transform._rotation11; var e22 = this._transform._rotation22; var t = e00 + e11 + e22; var s; if (t > 0) { s = Math.sqrt(t + 1); iqW = 0.5 * s; s = 0.5 / s; iqX = (this._transform._rotation21 - this._transform._rotation12) * s; iqY = (this._transform._rotation02 - this._transform._rotation20) * s; iqZ = (this._transform._rotation10 - this._transform._rotation01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); iqX = 0.5 * s; s = 0.5 / s; iqY = (this._transform._rotation01 + this._transform._rotation10) * s; iqZ = (this._transform._rotation02 + this._transform._rotation20) * s; iqW = (this._transform._rotation21 - this._transform._rotation12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); iqZ = 0.5 * s; s = 0.5 / s; iqX = (this._transform._rotation02 + this._transform._rotation20) * s; iqY = (this._transform._rotation12 + this._transform._rotation21) * s; iqW = (this._transform._rotation10 - this._transform._rotation01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); iqY = 0.5 * s; s = 0.5 / s; iqX = (this._transform._rotation01 + this._transform._rotation10) * s; iqZ = (this._transform._rotation12 + this._transform._rotation21) * s; iqW = (this._transform._rotation02 - this._transform._rotation20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); iqZ = 0.5 * s; s = 0.5 / s; iqX = (this._transform._rotation02 + this._transform._rotation20) * s; iqY = (this._transform._rotation12 + this._transform._rotation21) * s; iqW = (this._transform._rotation10 - this._transform._rotation01) * s; } q.x = iqX; q.y = iqY; q.z = iqZ; q.w = iqW; return q; } }, { key: "getOrientationTo", value: function getOrientationTo(orientation) { var iqX; var iqY; var iqZ; var iqW; var e00 = this._transform._rotation00; var e11 = this._transform._rotation11; var e22 = this._transform._rotation22; var t = e00 + e11 + e22; var s; if (t > 0) { s = Math.sqrt(t + 1); iqW = 0.5 * s; s = 0.5 / s; iqX = (this._transform._rotation21 - this._transform._rotation12) * s; iqY = (this._transform._rotation02 - this._transform._rotation20) * s; iqZ = (this._transform._rotation10 - this._transform._rotation01) * s; } else if (e00 > e11) { if (e00 > e22) { s = Math.sqrt(e00 - e11 - e22 + 1); iqX = 0.5 * s; s = 0.5 / s; iqY = (this._transform._rotation01 + this._transform._rotation10) * s; iqZ = (this._transform._rotation02 + this._transform._rotation20) * s; iqW = (this._transform._rotation21 - this._transform._rotation12) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); iqZ = 0.5 * s; s = 0.5 / s; iqX = (this._transform._rotation02 + this._transform._rotation20) * s; iqY = (this._transform._rotation12 + this._transform._rotation21) * s; iqW = (this._transform._rotation10 - this._transform._rotation01) * s; } } else if (e11 > e22) { s = Math.sqrt(e11 - e22 - e00 + 1); iqY = 0.5 * s; s = 0.5 / s; iqX = (this._transform._rotation01 + this._transform._rotation10) * s; iqZ = (this._transform._rotation12 + this._transform._rotation21) * s; iqW = (this._transform._rotation02 - this._transform._rotation20) * s; } else { s = Math.sqrt(e22 - e00 - e11 + 1); iqZ = 0.5 * s; s = 0.5 / s; iqX = (this._transform._rotation02 + this._transform._rotation20) * s; iqY = (this._transform._rotation12 + this._transform._rotation21) * s; iqW = (this._transform._rotation10 - this._transform._rotation01) * s; } orientation.x = iqX; orientation.y = iqY; orientation.z = iqZ; orientation.w = iqW; } }, { key: "setOrientation", value: function setOrientation(quaternion) { var qX; var qY; var qZ; var qW; qX = quaternion.x; qY = quaternion.y; qZ = quaternion.z; qW = quaternion.w; var x = qX; var y = qY; var z = qZ; var w = qW; var x2 = 2 * x; var y2 = 2 * y; var z2 = 2 * z; var xx = x * x2; var yy = y * y2; var zz = z * z2; var xy = x * y2; var yz = y * z2; var xz = x * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; this._transform._rotation00 = 1 - yy - zz; this._transform._rotation01 = xy - wz; this._transform._rotation02 = xz + wy; this._transform._rotation10 = xy + wz; this._transform._rotation11 = 1 - xx - zz; this._transform._rotation12 = yz - wx; this._transform._rotation20 = xz - wy; this._transform._rotation21 = yz + wx; this._transform._rotation22 = 1 - xx - yy; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20; __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21; __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22; __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20; __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21; __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22; __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20; __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21; __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22; this._invInertia00 = __tmp__00; this._invInertia01 = __tmp__01; this._invInertia02 = __tmp__02; this._invInertia10 = __tmp__10; this._invInertia11 = __tmp__11; this._invInertia12 = __tmp__12; this._invInertia20 = __tmp__20; this._invInertia21 = __tmp__21; this._invInertia22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02; __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12; __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22; __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02; __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12; __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22; __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02; __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12; __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22; this._invInertia00 = __tmp__001; this._invInertia01 = __tmp__011; this._invInertia02 = __tmp__021; this._invInertia10 = __tmp__101; this._invInertia11 = __tmp__111; this._invInertia12 = __tmp__121; this._invInertia20 = __tmp__201; this._invInertia21 = __tmp__211; this._invInertia22 = __tmp__221; this._invInertia00 *= this._rotFactor.x; this._invInertia01 *= this._rotFactor.x; this._invInertia02 *= this._rotFactor.x; this._invInertia10 *= this._rotFactor.y; this._invInertia11 *= this._rotFactor.y; this._invInertia12 *= this._rotFactor.y; this._invInertia20 *= this._rotFactor.z; this._invInertia21 *= this._rotFactor.z; this._invInertia22 *= this._rotFactor.z; var dst = this._ptransform; var src = this._transform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; var s = this._shapeList; while (s != null) { var n = s._next; var tf1 = this._ptransform; var tf2 = this._transform; var _dst9 = s._ptransform; var src1 = s._localTransform; var _tmp__91 = void 0; var _tmp__92 = void 0; var _tmp__93 = void 0; var _tmp__94 = void 0; var _tmp__95 = void 0; var _tmp__96 = void 0; var _tmp__97 = void 0; var _tmp__98 = void 0; var _tmp__99 = void 0; _tmp__91 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; _tmp__92 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; _tmp__93 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; _tmp__94 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; _tmp__95 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; _tmp__96 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; _tmp__97 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; _tmp__98 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; _tmp__99 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; _dst9._rotation00 = _tmp__91; _dst9._rotation01 = _tmp__92; _dst9._rotation02 = _tmp__93; _dst9._rotation10 = _tmp__94; _dst9._rotation11 = _tmp__95; _dst9._rotation12 = _tmp__96; _dst9._rotation20 = _tmp__97; _dst9._rotation21 = _tmp__98; _dst9._rotation22 = _tmp__99; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; _dst9._positionX = __tmp__X; _dst9._positionY = __tmp__Y; _dst9._positionZ = __tmp__Z; _dst9._positionX += tf1._positionX; _dst9._positionY += tf1._positionY; _dst9._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var _tmp__100 = void 0; var _tmp__101 = void 0; var _tmp__102 = void 0; var _tmp__103 = void 0; var _tmp__104 = void 0; var _tmp__105 = void 0; var _tmp__106 = void 0; var _tmp__107 = void 0; var _tmp__108 = void 0; _tmp__100 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; _tmp__101 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; _tmp__102 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; _tmp__103 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; _tmp__104 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; _tmp__105 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; _tmp__106 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; _tmp__107 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; _tmp__108 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = _tmp__100; dst1._rotation01 = _tmp__101; dst1._rotation02 = _tmp__102; dst1._rotation10 = _tmp__103; dst1._rotation11 = _tmp__104; dst1._rotation12 = _tmp__105; dst1._rotation20 = _tmp__106; dst1._rotation21 = _tmp__107; dst1._rotation22 = _tmp__108; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } this._sleeping = false; this._sleepTime = 0; } }, { key: "getTransform", value: function getTransform() { var _this = this._transform; var tf = new oimo.common.Transform(); tf._positionX = _this._positionX; tf._positionY = _this._positionY; tf._positionZ = _this._positionZ; tf._rotation00 = _this._rotation00; tf._rotation01 = _this._rotation01; tf._rotation02 = _this._rotation02; tf._rotation10 = _this._rotation10; tf._rotation11 = _this._rotation11; tf._rotation12 = _this._rotation12; tf._rotation20 = _this._rotation20; tf._rotation21 = _this._rotation21; tf._rotation22 = _this._rotation22; return tf; } }, { key: "getTransformTo", value: function getTransformTo(transform) { var transform1 = this._transform; transform._positionX = transform1._positionX; transform._positionY = transform1._positionY; transform._positionZ = transform1._positionZ; transform._rotation00 = transform1._rotation00; transform._rotation01 = transform1._rotation01; transform._rotation02 = transform1._rotation02; transform._rotation10 = transform1._rotation10; transform._rotation11 = transform1._rotation11; transform._rotation12 = transform1._rotation12; transform._rotation20 = transform1._rotation20; transform._rotation21 = transform1._rotation21; transform._rotation22 = transform1._rotation22; } }, { key: "setTransform", value: function setTransform(transform) { this._transform._positionX = transform._positionX; this._transform._positionY = transform._positionY; this._transform._positionZ = transform._positionZ; this._transform._rotation00 = transform._rotation00; this._transform._rotation01 = transform._rotation01; this._transform._rotation02 = transform._rotation02; this._transform._rotation10 = transform._rotation10; this._transform._rotation11 = transform._rotation11; this._transform._rotation12 = transform._rotation12; this._transform._rotation20 = transform._rotation20; this._transform._rotation21 = transform._rotation21; this._transform._rotation22 = transform._rotation22; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20; __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21; __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22; __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20; __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21; __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22; __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20; __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21; __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22; this._invInertia00 = __tmp__00; this._invInertia01 = __tmp__01; this._invInertia02 = __tmp__02; this._invInertia10 = __tmp__10; this._invInertia11 = __tmp__11; this._invInertia12 = __tmp__12; this._invInertia20 = __tmp__20; this._invInertia21 = __tmp__21; this._invInertia22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02; __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12; __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22; __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02; __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12; __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22; __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02; __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12; __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22; this._invInertia00 = __tmp__001; this._invInertia01 = __tmp__011; this._invInertia02 = __tmp__021; this._invInertia10 = __tmp__101; this._invInertia11 = __tmp__111; this._invInertia12 = __tmp__121; this._invInertia20 = __tmp__201; this._invInertia21 = __tmp__211; this._invInertia22 = __tmp__221; this._invInertia00 *= this._rotFactor.x; this._invInertia01 *= this._rotFactor.x; this._invInertia02 *= this._rotFactor.x; this._invInertia10 *= this._rotFactor.y; this._invInertia11 *= this._rotFactor.y; this._invInertia12 *= this._rotFactor.y; this._invInertia20 *= this._rotFactor.z; this._invInertia21 *= this._rotFactor.z; this._invInertia22 *= this._rotFactor.z; var dst = this._ptransform; var src = this._transform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; var s = this._shapeList; while (s != null) { var n = s._next; var tf1 = this._ptransform; var tf2 = this._transform; var _dst10 = s._ptransform; var src1 = s._localTransform; var _tmp__109 = void 0; var _tmp__110 = void 0; var _tmp__111 = void 0; var _tmp__112 = void 0; var _tmp__113 = void 0; var _tmp__114 = void 0; var _tmp__115 = void 0; var _tmp__116 = void 0; var _tmp__117 = void 0; _tmp__109 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; _tmp__110 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; _tmp__111 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; _tmp__112 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; _tmp__113 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; _tmp__114 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; _tmp__115 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; _tmp__116 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; _tmp__117 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; _dst10._rotation00 = _tmp__109; _dst10._rotation01 = _tmp__110; _dst10._rotation02 = _tmp__111; _dst10._rotation10 = _tmp__112; _dst10._rotation11 = _tmp__113; _dst10._rotation12 = _tmp__114; _dst10._rotation20 = _tmp__115; _dst10._rotation21 = _tmp__116; _dst10._rotation22 = _tmp__117; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; _dst10._positionX = __tmp__X; _dst10._positionY = __tmp__Y; _dst10._positionZ = __tmp__Z; _dst10._positionX += tf1._positionX; _dst10._positionY += tf1._positionY; _dst10._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var _tmp__118 = void 0; var _tmp__119 = void 0; var _tmp__120 = void 0; var _tmp__121 = void 0; var _tmp__122 = void 0; var _tmp__123 = void 0; var _tmp__124 = void 0; var _tmp__125 = void 0; var _tmp__126 = void 0; _tmp__118 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; _tmp__119 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; _tmp__120 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; _tmp__121 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; _tmp__122 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; _tmp__123 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; _tmp__124 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; _tmp__125 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; _tmp__126 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = _tmp__118; dst1._rotation01 = _tmp__119; dst1._rotation02 = _tmp__120; dst1._rotation10 = _tmp__121; dst1._rotation11 = _tmp__122; dst1._rotation12 = _tmp__123; dst1._rotation20 = _tmp__124; dst1._rotation21 = _tmp__125; dst1._rotation22 = _tmp__126; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } this._sleeping = false; this._sleepTime = 0; } }, { key: "getMass", value: function getMass() { return this._mass; } }, { key: "getLocalInertia", value: function getLocalInertia() { var m = new oimo.common.Mat3(); m.e00 = this._localInertia00; m.e01 = this._localInertia01; m.e02 = this._localInertia02; m.e10 = this._localInertia10; m.e11 = this._localInertia11; m.e12 = this._localInertia12; m.e20 = this._localInertia20; m.e21 = this._localInertia21; m.e22 = this._localInertia22; return m; } }, { key: "getLocalInertiaTo", value: function getLocalInertiaTo(inertia) { inertia.e00 = this._localInertia00; inertia.e01 = this._localInertia01; inertia.e02 = this._localInertia02; inertia.e10 = this._localInertia10; inertia.e11 = this._localInertia11; inertia.e12 = this._localInertia12; inertia.e20 = this._localInertia20; inertia.e21 = this._localInertia21; inertia.e22 = this._localInertia22; } }, { key: "getMassData", value: function getMassData() { var md = new oimo.dynamics.rigidbody.MassData(); md.mass = this._mass; var m = md.localInertia; m.e00 = this._localInertia00; m.e01 = this._localInertia01; m.e02 = this._localInertia02; m.e10 = this._localInertia10; m.e11 = this._localInertia11; m.e12 = this._localInertia12; m.e20 = this._localInertia20; m.e21 = this._localInertia21; m.e22 = this._localInertia22; return md; } }, { key: "getMassDataTo", value: function getMassDataTo(massData) { massData.mass = this._mass; var m = massData.localInertia; m.e00 = this._localInertia00; m.e01 = this._localInertia01; m.e02 = this._localInertia02; m.e10 = this._localInertia10; m.e11 = this._localInertia11; m.e12 = this._localInertia12; m.e20 = this._localInertia20; m.e21 = this._localInertia21; m.e22 = this._localInertia22; } }, { key: "setMassData", value: function setMassData(massData) { this._mass = massData.mass; var m = massData.localInertia; this._localInertia00 = m.e00; this._localInertia01 = m.e01; this._localInertia02 = m.e02; this._localInertia10 = m.e10; this._localInertia11 = m.e11; this._localInertia12 = m.e12; this._localInertia20 = m.e20; this._localInertia21 = m.e21; this._localInertia22 = m.e22; if (this._mass > 0 && this._localInertia00 * (this._localInertia11 * this._localInertia22 - this._localInertia12 * this._localInertia21) - this._localInertia01 * (this._localInertia10 * this._localInertia22 - this._localInertia12 * this._localInertia20) + this._localInertia02 * (this._localInertia10 * this._localInertia21 - this._localInertia11 * this._localInertia20) > 0 && this._type == 0) { this._invMass = 1 / this._mass; var d00 = this._localInertia11 * this._localInertia22 - this._localInertia12 * this._localInertia21; var d01 = this._localInertia10 * this._localInertia22 - this._localInertia12 * this._localInertia20; var d02 = this._localInertia10 * this._localInertia21 - this._localInertia11 * this._localInertia20; var d = this._localInertia00 * d00 - this._localInertia01 * d01 + this._localInertia02 * d02; if (d < -1e-32 || d > 1e-32) { d = 1 / d; } this._invLocalInertia00 = d00 * d; this._invLocalInertia01 = -(this._localInertia01 * this._localInertia22 - this._localInertia02 * this._localInertia21) * d; this._invLocalInertia02 = (this._localInertia01 * this._localInertia12 - this._localInertia02 * this._localInertia11) * d; this._invLocalInertia10 = -d01 * d; this._invLocalInertia11 = (this._localInertia00 * this._localInertia22 - this._localInertia02 * this._localInertia20) * d; this._invLocalInertia12 = -(this._localInertia00 * this._localInertia12 - this._localInertia02 * this._localInertia10) * d; this._invLocalInertia20 = d02 * d; this._invLocalInertia21 = -(this._localInertia00 * this._localInertia21 - this._localInertia01 * this._localInertia20) * d; this._invLocalInertia22 = (this._localInertia00 * this._localInertia11 - this._localInertia01 * this._localInertia10) * d; this._invLocalInertiaWithoutRotFactor00 = this._invLocalInertia00; this._invLocalInertiaWithoutRotFactor01 = this._invLocalInertia01; this._invLocalInertiaWithoutRotFactor02 = this._invLocalInertia02; this._invLocalInertiaWithoutRotFactor10 = this._invLocalInertia10; this._invLocalInertiaWithoutRotFactor11 = this._invLocalInertia11; this._invLocalInertiaWithoutRotFactor12 = this._invLocalInertia12; this._invLocalInertiaWithoutRotFactor20 = this._invLocalInertia20; this._invLocalInertiaWithoutRotFactor21 = this._invLocalInertia21; this._invLocalInertiaWithoutRotFactor22 = this._invLocalInertia22; this._invLocalInertia00 = this._invLocalInertiaWithoutRotFactor00 * this._rotFactor.x; this._invLocalInertia01 = this._invLocalInertiaWithoutRotFactor01 * this._rotFactor.x; this._invLocalInertia02 = this._invLocalInertiaWithoutRotFactor02 * this._rotFactor.x; this._invLocalInertia10 = this._invLocalInertiaWithoutRotFactor10 * this._rotFactor.y; this._invLocalInertia11 = this._invLocalInertiaWithoutRotFactor11 * this._rotFactor.y; this._invLocalInertia12 = this._invLocalInertiaWithoutRotFactor12 * this._rotFactor.y; this._invLocalInertia20 = this._invLocalInertiaWithoutRotFactor20 * this._rotFactor.z; this._invLocalInertia21 = this._invLocalInertiaWithoutRotFactor21 * this._rotFactor.z; this._invLocalInertia22 = this._invLocalInertiaWithoutRotFactor22 * this._rotFactor.z; } else { this._invMass = 0; this._invLocalInertia00 = 0; this._invLocalInertia01 = 0; this._invLocalInertia02 = 0; this._invLocalInertia10 = 0; this._invLocalInertia11 = 0; this._invLocalInertia12 = 0; this._invLocalInertia20 = 0; this._invLocalInertia21 = 0; this._invLocalInertia22 = 0; this._invLocalInertiaWithoutRotFactor00 = 0; this._invLocalInertiaWithoutRotFactor01 = 0; this._invLocalInertiaWithoutRotFactor02 = 0; this._invLocalInertiaWithoutRotFactor10 = 0; this._invLocalInertiaWithoutRotFactor11 = 0; this._invLocalInertiaWithoutRotFactor12 = 0; this._invLocalInertiaWithoutRotFactor20 = 0; this._invLocalInertiaWithoutRotFactor21 = 0; this._invLocalInertiaWithoutRotFactor22 = 0; if (this._type == 0) { this._type = 1; } } var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20; __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21; __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22; __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20; __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21; __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22; __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20; __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21; __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22; this._invInertia00 = __tmp__00; this._invInertia01 = __tmp__01; this._invInertia02 = __tmp__02; this._invInertia10 = __tmp__10; this._invInertia11 = __tmp__11; this._invInertia12 = __tmp__12; this._invInertia20 = __tmp__20; this._invInertia21 = __tmp__21; this._invInertia22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02; __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12; __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22; __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02; __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12; __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22; __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02; __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12; __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22; this._invInertia00 = __tmp__001; this._invInertia01 = __tmp__011; this._invInertia02 = __tmp__021; this._invInertia10 = __tmp__101; this._invInertia11 = __tmp__111; this._invInertia12 = __tmp__121; this._invInertia20 = __tmp__201; this._invInertia21 = __tmp__211; this._invInertia22 = __tmp__221; this._invInertia00 *= this._rotFactor.x; this._invInertia01 *= this._rotFactor.x; this._invInertia02 *= this._rotFactor.x; this._invInertia10 *= this._rotFactor.y; this._invInertia11 *= this._rotFactor.y; this._invInertia12 *= this._rotFactor.y; this._invInertia20 *= this._rotFactor.z; this._invInertia21 *= this._rotFactor.z; this._invInertia22 *= this._rotFactor.z; this._sleeping = false; this._sleepTime = 0; } }, { key: "getRotationFactor", value: function getRotationFactor() { var _this = this._rotFactor; return new oimo.common.Vec3(_this.x, _this.y, _this.z); } }, { key: "setRotationFactor", value: function setRotationFactor(rotationFactor) { var _this = this._rotFactor; _this.x = rotationFactor.x; _this.y = rotationFactor.y; _this.z = rotationFactor.z; var __tmp__00; var __tmp__01; var __tmp__02; var __tmp__10; var __tmp__11; var __tmp__12; var __tmp__20; var __tmp__21; var __tmp__22; __tmp__00 = this._transform._rotation00 * this._invLocalInertia00 + this._transform._rotation01 * this._invLocalInertia10 + this._transform._rotation02 * this._invLocalInertia20; __tmp__01 = this._transform._rotation00 * this._invLocalInertia01 + this._transform._rotation01 * this._invLocalInertia11 + this._transform._rotation02 * this._invLocalInertia21; __tmp__02 = this._transform._rotation00 * this._invLocalInertia02 + this._transform._rotation01 * this._invLocalInertia12 + this._transform._rotation02 * this._invLocalInertia22; __tmp__10 = this._transform._rotation10 * this._invLocalInertia00 + this._transform._rotation11 * this._invLocalInertia10 + this._transform._rotation12 * this._invLocalInertia20; __tmp__11 = this._transform._rotation10 * this._invLocalInertia01 + this._transform._rotation11 * this._invLocalInertia11 + this._transform._rotation12 * this._invLocalInertia21; __tmp__12 = this._transform._rotation10 * this._invLocalInertia02 + this._transform._rotation11 * this._invLocalInertia12 + this._transform._rotation12 * this._invLocalInertia22; __tmp__20 = this._transform._rotation20 * this._invLocalInertia00 + this._transform._rotation21 * this._invLocalInertia10 + this._transform._rotation22 * this._invLocalInertia20; __tmp__21 = this._transform._rotation20 * this._invLocalInertia01 + this._transform._rotation21 * this._invLocalInertia11 + this._transform._rotation22 * this._invLocalInertia21; __tmp__22 = this._transform._rotation20 * this._invLocalInertia02 + this._transform._rotation21 * this._invLocalInertia12 + this._transform._rotation22 * this._invLocalInertia22; this._invInertia00 = __tmp__00; this._invInertia01 = __tmp__01; this._invInertia02 = __tmp__02; this._invInertia10 = __tmp__10; this._invInertia11 = __tmp__11; this._invInertia12 = __tmp__12; this._invInertia20 = __tmp__20; this._invInertia21 = __tmp__21; this._invInertia22 = __tmp__22; var __tmp__001; var __tmp__011; var __tmp__021; var __tmp__101; var __tmp__111; var __tmp__121; var __tmp__201; var __tmp__211; var __tmp__221; __tmp__001 = this._invInertia00 * this._transform._rotation00 + this._invInertia01 * this._transform._rotation01 + this._invInertia02 * this._transform._rotation02; __tmp__011 = this._invInertia00 * this._transform._rotation10 + this._invInertia01 * this._transform._rotation11 + this._invInertia02 * this._transform._rotation12; __tmp__021 = this._invInertia00 * this._transform._rotation20 + this._invInertia01 * this._transform._rotation21 + this._invInertia02 * this._transform._rotation22; __tmp__101 = this._invInertia10 * this._transform._rotation00 + this._invInertia11 * this._transform._rotation01 + this._invInertia12 * this._transform._rotation02; __tmp__111 = this._invInertia10 * this._transform._rotation10 + this._invInertia11 * this._transform._rotation11 + this._invInertia12 * this._transform._rotation12; __tmp__121 = this._invInertia10 * this._transform._rotation20 + this._invInertia11 * this._transform._rotation21 + this._invInertia12 * this._transform._rotation22; __tmp__201 = this._invInertia20 * this._transform._rotation00 + this._invInertia21 * this._transform._rotation01 + this._invInertia22 * this._transform._rotation02; __tmp__211 = this._invInertia20 * this._transform._rotation10 + this._invInertia21 * this._transform._rotation11 + this._invInertia22 * this._transform._rotation12; __tmp__221 = this._invInertia20 * this._transform._rotation20 + this._invInertia21 * this._transform._rotation21 + this._invInertia22 * this._transform._rotation22; this._invInertia00 = __tmp__001; this._invInertia01 = __tmp__011; this._invInertia02 = __tmp__021; this._invInertia10 = __tmp__101; this._invInertia11 = __tmp__111; this._invInertia12 = __tmp__121; this._invInertia20 = __tmp__201; this._invInertia21 = __tmp__211; this._invInertia22 = __tmp__221; this._invInertia00 *= this._rotFactor.x; this._invInertia01 *= this._rotFactor.x; this._invInertia02 *= this._rotFactor.x; this._invInertia10 *= this._rotFactor.y; this._invInertia11 *= this._rotFactor.y; this._invInertia12 *= this._rotFactor.y; this._invInertia20 *= this._rotFactor.z; this._invInertia21 *= this._rotFactor.z; this._invInertia22 *= this._rotFactor.z; this._sleeping = false; this._sleepTime = 0; } }, { key: "getLinearVelocity", value: function getLinearVelocity() { var v = new oimo.common.Vec3(); v.x = this._velX; v.y = this._velY; v.z = this._velZ; return v; } }, { key: "getLinearVelocityTo", value: function getLinearVelocityTo(linearVelocity) { linearVelocity.x = this._velX; linearVelocity.y = this._velY; linearVelocity.z = this._velZ; } }, { key: "setLinearVelocity", value: function setLinearVelocity(linearVelocity) { if (this._type == 1) { this._velX = 0; this._velY = 0; this._velZ = 0; } else { this._velX = linearVelocity.x; this._velY = linearVelocity.y; this._velZ = linearVelocity.z; } this._sleeping = false; this._sleepTime = 0; } }, { key: "getAngularVelocity", value: function getAngularVelocity() { var v = new oimo.common.Vec3(); v.x = this._angVelX; v.y = this._angVelY; v.z = this._angVelZ; return v; } }, { key: "getAngularVelocityTo", value: function getAngularVelocityTo(angularVelocity) { angularVelocity.x = this._velX; angularVelocity.y = this._velY; angularVelocity.z = this._velZ; } }, { key: "setAngularVelocity", value: function setAngularVelocity(angularVelocity) { if (this._type == 1) { this._angVelX = 0; this._angVelY = 0; this._angVelZ = 0; } else { this._angVelX = angularVelocity.x; this._angVelY = angularVelocity.y; this._angVelZ = angularVelocity.z; } this._sleeping = false; this._sleepTime = 0; } }, { key: "addLinearVelocity", value: function addLinearVelocity(linearVelocityChange) { if (this._type != 1) { var dX; var dY; var dZ; dX = linearVelocityChange.x; dY = linearVelocityChange.y; dZ = linearVelocityChange.z; this._velX += dX; this._velY += dY; this._velZ += dZ; } this._sleeping = false; this._sleepTime = 0; } }, { key: "addAngularVelocity", value: function addAngularVelocity(angularVelocityChange) { if (this._type != 1) { var dX; var dY; var dZ; dX = angularVelocityChange.x; dY = angularVelocityChange.y; dZ = angularVelocityChange.z; this._angVelX += dX; this._angVelY += dY; this._angVelZ += dZ; } this._sleeping = false; this._sleepTime = 0; } }, { key: "applyImpulse", value: function applyImpulse(impulse, positionInWorld) { var impX; var impY; var impZ; impX = impulse.x; impY = impulse.y; impZ = impulse.z; this._velX += impX * this._invMass; this._velY += impY * this._invMass; this._velZ += impZ * this._invMass; var aimpX; var aimpY; var aimpZ; var posX; var posY; var posZ; posX = positionInWorld.x; posY = positionInWorld.y; posZ = positionInWorld.z; posX -= this._transform._positionX; posY -= this._transform._positionY; posZ -= this._transform._positionZ; aimpX = posY * impZ - posZ * impY; aimpY = posZ * impX - posX * impZ; aimpZ = posX * impY - posY * impX; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._invInertia00 * aimpX + this._invInertia01 * aimpY + this._invInertia02 * aimpZ; __tmp__Y = this._invInertia10 * aimpX + this._invInertia11 * aimpY + this._invInertia12 * aimpZ; __tmp__Z = this._invInertia20 * aimpX + this._invInertia21 * aimpY + this._invInertia22 * aimpZ; aimpX = __tmp__X; aimpY = __tmp__Y; aimpZ = __tmp__Z; this._angVelX += aimpX; this._angVelY += aimpY; this._angVelZ += aimpZ; this._sleeping = false; this._sleepTime = 0; } }, { key: "applyLinearImpulse", value: function applyLinearImpulse(impulse) { var impX; var impY; var impZ; impX = impulse.x; impY = impulse.y; impZ = impulse.z; this._velX += impX * this._invMass; this._velY += impY * this._invMass; this._velZ += impZ * this._invMass; this._sleeping = false; this._sleepTime = 0; } }, { key: "applyAngularImpulse", value: function applyAngularImpulse(impulse) { var impX; var impY; var impZ; impX = impulse.x; impY = impulse.y; impZ = impulse.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._invInertia00 * impX + this._invInertia01 * impY + this._invInertia02 * impZ; __tmp__Y = this._invInertia10 * impX + this._invInertia11 * impY + this._invInertia12 * impZ; __tmp__Z = this._invInertia20 * impX + this._invInertia21 * impY + this._invInertia22 * impZ; impX = __tmp__X; impY = __tmp__Y; impZ = __tmp__Z; this._angVelX += impX; this._angVelY += impY; this._angVelZ += impZ; this._sleeping = false; this._sleepTime = 0; } }, { key: "applyForce", value: function applyForce(force, positionInWorld) { var iforceX; var iforceY; var iforceZ; iforceX = force.x; iforceY = force.y; iforceZ = force.z; this._forceX += iforceX; this._forceY += iforceY; this._forceZ += iforceZ; var itorqueX; var itorqueY; var itorqueZ; var posX; var posY; var posZ; posX = positionInWorld.x; posY = positionInWorld.y; posZ = positionInWorld.z; posX -= this._transform._positionX; posY -= this._transform._positionY; posZ -= this._transform._positionZ; itorqueX = posY * iforceZ - posZ * iforceY; itorqueY = posZ * iforceX - posX * iforceZ; itorqueZ = posX * iforceY - posY * iforceX; this._torqueX += itorqueX; this._torqueY += itorqueY; this._torqueZ += itorqueZ; this._sleeping = false; this._sleepTime = 0; } }, { key: "applyForceToCenter", value: function applyForceToCenter(force) { var iforceX; var iforceY; var iforceZ; iforceX = force.x; iforceY = force.y; iforceZ = force.z; this._forceX += iforceX; this._forceY += iforceY; this._forceZ += iforceZ; this._sleeping = false; this._sleepTime = 0; } }, { key: "applyTorque", value: function applyTorque(torque) { var itorqueX; var itorqueY; var itorqueZ; itorqueX = torque.x; itorqueY = torque.y; itorqueZ = torque.z; this._torqueX += itorqueX; this._torqueY += itorqueY; this._torqueZ += itorqueZ; this._sleeping = false; this._sleepTime = 0; } }, { key: "getLinearContactImpulse", value: function getLinearContactImpulse() { var res = new oimo.common.Vec3(); res.x = this._linearContactImpulseX; res.y = this._linearContactImpulseY; res.z = this._linearContactImpulseZ; return res; } }, { key: "getLinearContactImpulseTo", value: function getLinearContactImpulseTo(linearContactImpulse) { linearContactImpulse.x = this._linearContactImpulseX; linearContactImpulse.y = this._linearContactImpulseY; linearContactImpulse.z = this._linearContactImpulseZ; } }, { key: "getAngularContactImpulse", value: function getAngularContactImpulse() { var res = new oimo.common.Vec3(); res.x = this._angularContactImpulseX; res.y = this._angularContactImpulseY; res.z = this._angularContactImpulseZ; return res; } }, { key: "getAngularContactImpulseTo", value: function getAngularContactImpulseTo(angularContactImpulse) { angularContactImpulse.x = this._angularContactImpulseX; angularContactImpulse.y = this._angularContactImpulseY; angularContactImpulse.z = this._angularContactImpulseZ; } }, { key: "getGravityScale", value: function getGravityScale() { return this._gravityScale; } }, { key: "setGravityScale", value: function setGravityScale(gravityScale) { this._gravityScale = gravityScale; this._sleeping = false; this._sleepTime = 0; } }, { key: "getLocalPoint", value: function getLocalPoint(worldPoint) { var vX; var vY; var vZ; vX = worldPoint.x; vY = worldPoint.y; vZ = worldPoint.z; vX -= this._transform._positionX; vY -= this._transform._positionY; vZ -= this._transform._positionZ; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._transform._rotation00 * vX + this._transform._rotation10 * vY + this._transform._rotation20 * vZ; __tmp__Y = this._transform._rotation01 * vX + this._transform._rotation11 * vY + this._transform._rotation21 * vZ; __tmp__Z = this._transform._rotation02 * vX + this._transform._rotation12 * vY + this._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; var res = new oimo.common.Vec3(); res.x = vX; res.y = vY; res.z = vZ; return res; } }, { key: "getLocalPointTo", value: function getLocalPointTo(worldPoint, localPoint) { var vX; var vY; var vZ; vX = worldPoint.x; vY = worldPoint.y; vZ = worldPoint.z; vX -= this._transform._positionX; vY -= this._transform._positionY; vZ -= this._transform._positionZ; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._transform._rotation00 * vX + this._transform._rotation10 * vY + this._transform._rotation20 * vZ; __tmp__Y = this._transform._rotation01 * vX + this._transform._rotation11 * vY + this._transform._rotation21 * vZ; __tmp__Z = this._transform._rotation02 * vX + this._transform._rotation12 * vY + this._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; localPoint.x = vX; localPoint.y = vY; localPoint.z = vZ; } }, { key: "getLocalVector", value: function getLocalVector(worldVector) { var vX; var vY; var vZ; vX = worldVector.x; vY = worldVector.y; vZ = worldVector.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._transform._rotation00 * vX + this._transform._rotation10 * vY + this._transform._rotation20 * vZ; __tmp__Y = this._transform._rotation01 * vX + this._transform._rotation11 * vY + this._transform._rotation21 * vZ; __tmp__Z = this._transform._rotation02 * vX + this._transform._rotation12 * vY + this._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; var res = new oimo.common.Vec3(); res.x = vX; res.y = vY; res.z = vZ; return res; } }, { key: "getLocalVectorTo", value: function getLocalVectorTo(worldVector, localVector) { var vX; var vY; var vZ; vX = worldVector.x; vY = worldVector.y; vZ = worldVector.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._transform._rotation00 * vX + this._transform._rotation10 * vY + this._transform._rotation20 * vZ; __tmp__Y = this._transform._rotation01 * vX + this._transform._rotation11 * vY + this._transform._rotation21 * vZ; __tmp__Z = this._transform._rotation02 * vX + this._transform._rotation12 * vY + this._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; localVector.x = vX; localVector.y = vY; localVector.z = vZ; } }, { key: "getWorldPoint", value: function getWorldPoint(localPoint) { var vX; var vY; var vZ; vX = localPoint.x; vY = localPoint.y; vZ = localPoint.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._transform._rotation00 * vX + this._transform._rotation01 * vY + this._transform._rotation02 * vZ; __tmp__Y = this._transform._rotation10 * vX + this._transform._rotation11 * vY + this._transform._rotation12 * vZ; __tmp__Z = this._transform._rotation20 * vX + this._transform._rotation21 * vY + this._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; vX += this._transform._positionX; vY += this._transform._positionY; vZ += this._transform._positionZ; var res = new oimo.common.Vec3(); res.x = vX; res.y = vY; res.z = vZ; return res; } }, { key: "getWorldPointTo", value: function getWorldPointTo(localPoint, worldPoint) { var vX; var vY; var vZ; vX = localPoint.x; vY = localPoint.y; vZ = localPoint.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._transform._rotation00 * vX + this._transform._rotation01 * vY + this._transform._rotation02 * vZ; __tmp__Y = this._transform._rotation10 * vX + this._transform._rotation11 * vY + this._transform._rotation12 * vZ; __tmp__Z = this._transform._rotation20 * vX + this._transform._rotation21 * vY + this._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; vX += this._transform._positionX; vY += this._transform._positionY; vZ += this._transform._positionZ; worldPoint.x = vX; worldPoint.y = vY; worldPoint.z = vZ; } }, { key: "getWorldVector", value: function getWorldVector(localVector) { var vX; var vY; var vZ; vX = localVector.x; vY = localVector.y; vZ = localVector.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._transform._rotation00 * vX + this._transform._rotation01 * vY + this._transform._rotation02 * vZ; __tmp__Y = this._transform._rotation10 * vX + this._transform._rotation11 * vY + this._transform._rotation12 * vZ; __tmp__Z = this._transform._rotation20 * vX + this._transform._rotation21 * vY + this._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; var res = new oimo.common.Vec3(); res.x = vX; res.y = vY; res.z = vZ; return res; } }, { key: "getWorldVectorTo", value: function getWorldVectorTo(localVector, worldVector) { var vX; var vY; var vZ; vX = localVector.x; vY = localVector.y; vZ = localVector.z; var __tmp__X; var __tmp__Y; var __tmp__Z; __tmp__X = this._transform._rotation00 * vX + this._transform._rotation01 * vY + this._transform._rotation02 * vZ; __tmp__Y = this._transform._rotation10 * vX + this._transform._rotation11 * vY + this._transform._rotation12 * vZ; __tmp__Z = this._transform._rotation20 * vX + this._transform._rotation21 * vY + this._transform._rotation22 * vZ; vX = __tmp__X; vY = __tmp__Y; vZ = __tmp__Z; worldVector.x = vX; worldVector.y = vY; worldVector.z = vZ; } }, { key: "getNumShapes", value: function getNumShapes() { return this._numShapes; } }, { key: "getShapeList", value: function getShapeList() { return this._shapeList; } }, { key: "getNumContectLinks", value: function getNumContectLinks() { return this._numContactLinks; } }, { key: "getContactLinkList", value: function getContactLinkList() { return this._contactLinkList; } }, { key: "getNumJointLinks", value: function getNumJointLinks() { return this._numJointLinks; } }, { key: "getJointLinkList", value: function getJointLinkList() { return this._jointLinkList; } }, { key: "addShape", value: function addShape(shape) { if (this._shapeList == null) { this._shapeList = shape; this._shapeListLast = shape; } else { this._shapeListLast._next = shape; shape._prev = this._shapeListLast; this._shapeListLast = shape; } this._numShapes++; shape._rigidBody = this; if (this._world != null) { var _this = this._world; shape._proxy = _this._broadPhase.createProxy(shape, shape._aabb); shape._id = _this._shapeIdCount++; _this._numShapes++; } this.updateMass(); var s = this._shapeList; while (s != null) { var n = s._next; var tf1 = this._ptransform; var tf2 = this._transform; var dst = s._ptransform; var src1 = s._localTransform; var __tmp__00 = void 0; var __tmp__01 = void 0; var __tmp__02 = void 0; var __tmp__10 = void 0; var __tmp__11 = void 0; var __tmp__12 = void 0; var __tmp__20 = void 0; var __tmp__21 = void 0; var __tmp__22 = void 0; __tmp__00 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; __tmp__01 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; __tmp__02 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; __tmp__10 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; __tmp__11 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; __tmp__12 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; __tmp__20 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; __tmp__21 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; __tmp__22 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; dst._rotation00 = __tmp__00; dst._rotation01 = __tmp__01; dst._rotation02 = __tmp__02; dst._rotation10 = __tmp__10; dst._rotation11 = __tmp__11; dst._rotation12 = __tmp__12; dst._rotation20 = __tmp__20; dst._rotation21 = __tmp__21; dst._rotation22 = __tmp__22; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; dst._positionX = __tmp__X; dst._positionY = __tmp__Y; dst._positionZ = __tmp__Z; dst._positionX += tf1._positionX; dst._positionY += tf1._positionY; dst._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var __tmp__001 = void 0; var __tmp__011 = void 0; var __tmp__021 = void 0; var __tmp__101 = void 0; var __tmp__111 = void 0; var __tmp__121 = void 0; var __tmp__201 = void 0; var __tmp__211 = void 0; var __tmp__221 = void 0; __tmp__001 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; __tmp__011 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; __tmp__021 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; __tmp__101 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; __tmp__111 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; __tmp__121 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; __tmp__201 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; __tmp__211 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; __tmp__221 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = __tmp__001; dst1._rotation01 = __tmp__011; dst1._rotation02 = __tmp__021; dst1._rotation10 = __tmp__101; dst1._rotation11 = __tmp__111; dst1._rotation12 = __tmp__121; dst1._rotation20 = __tmp__201; dst1._rotation21 = __tmp__211; dst1._rotation22 = __tmp__221; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } } }, { key: "removeShape", value: function removeShape(shape) { var prev = shape._prev; var next = shape._next; if (prev != null) { prev._next = next; } if (next != null) { next._prev = prev; } if (shape == this._shapeList) { this._shapeList = this._shapeList._next; } if (shape == this._shapeListLast) { this._shapeListLast = this._shapeListLast._prev; } shape._next = null; shape._prev = null; this._numShapes--; shape._rigidBody = null; if (this._world != null) { var _this = this._world; _this._broadPhase.destroyProxy(shape._proxy); shape._proxy = null; shape._id = -1; var cl = shape._rigidBody._contactLinkList; while (cl != null) { var n = cl._next; var c = cl._contact; if (c._s1 == shape || c._s2 == shape) { var _this1 = cl._other; _this1._sleeping = false; _this1._sleepTime = 0; var _this2 = _this._contactManager; var _prev5 = c._prev; var _next5 = c._next; if (_prev5 != null) { _prev5._next = _next5; } if (_next5 != null) { _next5._prev = _prev5; } if (c == _this2._contactList) { _this2._contactList = _this2._contactList._next; } if (c == _this2._contactListLast) { _this2._contactListLast = _this2._contactListLast._prev; } c._next = null; c._prev = null; if (c._touching) { var cc1 = c._s1._contactCallback; var cc2 = c._s2._contactCallback; if (cc1 == cc2) { cc2 = null; } if (cc1 != null) { cc1.endContact(c); } if (cc2 != null) { cc2.endContact(c); } } var prev1 = c._link1._prev; var next1 = c._link1._next; if (prev1 != null) { prev1._next = next1; } if (next1 != null) { next1._prev = prev1; } if (c._link1 == c._b1._contactLinkList) { c._b1._contactLinkList = c._b1._contactLinkList._next; } if (c._link1 == c._b1._contactLinkListLast) { c._b1._contactLinkListLast = c._b1._contactLinkListLast._prev; } c._link1._next = null; c._link1._prev = null; var prev2 = c._link2._prev; var next2 = c._link2._next; if (prev2 != null) { prev2._next = next2; } if (next2 != null) { next2._prev = prev2; } if (c._link2 == c._b2._contactLinkList) { c._b2._contactLinkList = c._b2._contactLinkList._next; } if (c._link2 == c._b2._contactLinkListLast) { c._b2._contactLinkListLast = c._b2._contactLinkListLast._prev; } c._link2._next = null; c._link2._prev = null; c._b1._numContactLinks--; c._b2._numContactLinks--; c._link1._other = null; c._link2._other = null; c._link1._contact = null; c._link2._contact = null; c._s1 = null; c._s2 = null; c._b1 = null; c._b2 = null; c._touching = false; c._cachedDetectorData._clear(); c._manifold._clear(); c._detector = null; var _this3 = c._contactConstraint; _this3._s1 = null; _this3._s2 = null; _this3._b1 = null; _this3._b2 = null; _this3._tf1 = null; _this3._tf2 = null; c._next = _this2._contactPool; _this2._contactPool = c; _this2._numContacts--; } cl = n; } _this._numShapes--; } this.updateMass(); var s = this._shapeList; while (s != null) { var _n11 = s._next; var tf1 = this._ptransform; var tf2 = this._transform; var dst = s._ptransform; var src1 = s._localTransform; var __tmp__00 = void 0; var __tmp__01 = void 0; var __tmp__02 = void 0; var __tmp__10 = void 0; var __tmp__11 = void 0; var __tmp__12 = void 0; var __tmp__20 = void 0; var __tmp__21 = void 0; var __tmp__22 = void 0; __tmp__00 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; __tmp__01 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; __tmp__02 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; __tmp__10 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; __tmp__11 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; __tmp__12 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; __tmp__20 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; __tmp__21 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; __tmp__22 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; dst._rotation00 = __tmp__00; dst._rotation01 = __tmp__01; dst._rotation02 = __tmp__02; dst._rotation10 = __tmp__10; dst._rotation11 = __tmp__11; dst._rotation12 = __tmp__12; dst._rotation20 = __tmp__20; dst._rotation21 = __tmp__21; dst._rotation22 = __tmp__22; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; dst._positionX = __tmp__X; dst._positionY = __tmp__Y; dst._positionZ = __tmp__Z; dst._positionX += tf1._positionX; dst._positionY += tf1._positionY; dst._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var __tmp__001 = void 0; var __tmp__011 = void 0; var __tmp__021 = void 0; var __tmp__101 = void 0; var __tmp__111 = void 0; var __tmp__121 = void 0; var __tmp__201 = void 0; var __tmp__211 = void 0; var __tmp__221 = void 0; __tmp__001 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; __tmp__011 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; __tmp__021 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; __tmp__101 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; __tmp__111 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; __tmp__121 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; __tmp__201 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; __tmp__211 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; __tmp__221 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = __tmp__001; dst1._rotation01 = __tmp__011; dst1._rotation02 = __tmp__021; dst1._rotation10 = __tmp__101; dst1._rotation11 = __tmp__111; dst1._rotation12 = __tmp__121; dst1._rotation20 = __tmp__201; dst1._rotation21 = __tmp__211; dst1._rotation22 = __tmp__221; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = _n11; } } }, { key: "getType", value: function getType() { return this._type; } }, { key: "setType", value: function setType(type) { this._type = type; this.updateMass(); } }, { key: "wakeUp", value: function wakeUp() { this._sleeping = false; this._sleepTime = 0; } }, { key: "sleep", value: function sleep() { this._sleeping = true; this._sleepTime = 0; } }, { key: "isSleeping", value: function isSleeping() { return this._sleeping; } }, { key: "getSleepTime", value: function getSleepTime() { return this._sleepTime; } }, { key: "setAutoSleep", value: function setAutoSleep(autoSleepEnabled) { this._autoSleep = autoSleepEnabled; this._sleeping = false; this._sleepTime = 0; } }, { key: "getLinearDamping", value: function getLinearDamping() { return this._linearDamping; } }, { key: "setLinearDamping", value: function setLinearDamping(damping) { this._linearDamping = damping; } }, { key: "getAngularDamping", value: function getAngularDamping() { return this._angularDamping; } }, { key: "setAngularDamping", value: function setAngularDamping(damping) { this._angularDamping = damping; } }, { key: "getPrev", value: function getPrev() { return this._prev; } }, { key: "getNext", value: function getNext() { return this._next; } }]); return oimo_dynamics_rigidbody_RigidBody; }(); oimo.dynamics.rigidbody.RigidBodyConfig = /*#__PURE__*/_createClass(function oimo_dynamics_rigidbody_RigidBodyConfig() { _classCallCheck(this, oimo_dynamics_rigidbody_RigidBodyConfig); this.position = new oimo.common.Vec3(); this.rotation = new oimo.common.Mat3(); this.linearVelocity = new oimo.common.Vec3(); this.angularVelocity = new oimo.common.Vec3(); this.type = 0; this.autoSleep = true; this.linearDamping = 0; this.angularDamping = 0; }); oimo.dynamics.rigidbody.RigidBodyType = /*#__PURE__*/_createClass(function oimo_dynamics_rigidbody_RigidBodyType() { _classCallCheck(this, oimo_dynamics_rigidbody_RigidBodyType); }); oimo.dynamics.rigidbody.Shape = /*#__PURE__*/function () { function oimo_dynamics_rigidbody_Shape(config) { _classCallCheck(this, oimo_dynamics_rigidbody_Shape); this._id = -1; this._localTransform = new oimo.common.Transform(); this._ptransform = new oimo.common.Transform(); this._transform = new oimo.common.Transform(); var v = config.position; this._localTransform._positionX = v.x; this._localTransform._positionY = v.y; this._localTransform._positionZ = v.z; var m = config.rotation; this._localTransform._rotation00 = m.e00; this._localTransform._rotation01 = m.e01; this._localTransform._rotation02 = m.e02; this._localTransform._rotation10 = m.e10; this._localTransform._rotation11 = m.e11; this._localTransform._rotation12 = m.e12; this._localTransform._rotation20 = m.e20; this._localTransform._rotation21 = m.e21; this._localTransform._rotation22 = m.e22; var dst = this._ptransform; var src = this._localTransform; dst._positionX = src._positionX; dst._positionY = src._positionY; dst._positionZ = src._positionZ; dst._rotation00 = src._rotation00; dst._rotation01 = src._rotation01; dst._rotation02 = src._rotation02; dst._rotation10 = src._rotation10; dst._rotation11 = src._rotation11; dst._rotation12 = src._rotation12; dst._rotation20 = src._rotation20; dst._rotation21 = src._rotation21; dst._rotation22 = src._rotation22; var dst1 = this._transform; var src1 = this._localTransform; dst1._positionX = src1._positionX; dst1._positionY = src1._positionY; dst1._positionZ = src1._positionZ; dst1._rotation00 = src1._rotation00; dst1._rotation01 = src1._rotation01; dst1._rotation02 = src1._rotation02; dst1._rotation10 = src1._rotation10; dst1._rotation11 = src1._rotation11; dst1._rotation12 = src1._rotation12; dst1._rotation20 = src1._rotation20; dst1._rotation21 = src1._rotation21; dst1._rotation22 = src1._rotation22; this._restitution = config.restitution; this._friction = config.friction; this._density = config.density; this._geom = config.geometry; this._collisionGroup = config.collisionGroup; this._collisionMask = config.collisionMask; this._contactCallback = config.contactCallback; this._aabb = new oimo.collision.geometry.Aabb(); this._proxy = null; this.displacement = new oimo.common.Vec3(); } _createClass(oimo_dynamics_rigidbody_Shape, [{ key: "getFriction", value: function getFriction() { return this._friction; } }, { key: "setFriction", value: function setFriction(friction) { this._friction = friction; } }, { key: "getRestitution", value: function getRestitution() { return this._restitution; } }, { key: "setRestitution", value: function setRestitution(restitution) { this._restitution = restitution; } }, { key: "getLocalTransform", value: function getLocalTransform() { var _this = this._localTransform; var tf = new oimo.common.Transform(); tf._positionX = _this._positionX; tf._positionY = _this._positionY; tf._positionZ = _this._positionZ; tf._rotation00 = _this._rotation00; tf._rotation01 = _this._rotation01; tf._rotation02 = _this._rotation02; tf._rotation10 = _this._rotation10; tf._rotation11 = _this._rotation11; tf._rotation12 = _this._rotation12; tf._rotation20 = _this._rotation20; tf._rotation21 = _this._rotation21; tf._rotation22 = _this._rotation22; return tf; } }, { key: "getLocalTransformTo", value: function getLocalTransformTo(transform) { var transform1 = this._localTransform; transform._positionX = transform1._positionX; transform._positionY = transform1._positionY; transform._positionZ = transform1._positionZ; transform._rotation00 = transform1._rotation00; transform._rotation01 = transform1._rotation01; transform._rotation02 = transform1._rotation02; transform._rotation10 = transform1._rotation10; transform._rotation11 = transform1._rotation11; transform._rotation12 = transform1._rotation12; transform._rotation20 = transform1._rotation20; transform._rotation21 = transform1._rotation21; transform._rotation22 = transform1._rotation22; } }, { key: "getTransform", value: function getTransform() { var _this = this._transform; var tf = new oimo.common.Transform(); tf._positionX = _this._positionX; tf._positionY = _this._positionY; tf._positionZ = _this._positionZ; tf._rotation00 = _this._rotation00; tf._rotation01 = _this._rotation01; tf._rotation02 = _this._rotation02; tf._rotation10 = _this._rotation10; tf._rotation11 = _this._rotation11; tf._rotation12 = _this._rotation12; tf._rotation20 = _this._rotation20; tf._rotation21 = _this._rotation21; tf._rotation22 = _this._rotation22; return tf; } }, { key: "getTransformTo", value: function getTransformTo(transform) { var transform1 = this._transform; transform._positionX = transform1._positionX; transform._positionY = transform1._positionY; transform._positionZ = transform1._positionZ; transform._rotation00 = transform1._rotation00; transform._rotation01 = transform1._rotation01; transform._rotation02 = transform1._rotation02; transform._rotation10 = transform1._rotation10; transform._rotation11 = transform1._rotation11; transform._rotation12 = transform1._rotation12; transform._rotation20 = transform1._rotation20; transform._rotation21 = transform1._rotation21; transform._rotation22 = transform1._rotation22; } }, { key: "setLocalTransform", value: function setLocalTransform(transform) { var _this = this._localTransform; _this._positionX = transform._positionX; _this._positionY = transform._positionY; _this._positionZ = transform._positionZ; _this._rotation00 = transform._rotation00; _this._rotation01 = transform._rotation01; _this._rotation02 = transform._rotation02; _this._rotation10 = transform._rotation10; _this._rotation11 = transform._rotation11; _this._rotation12 = transform._rotation12; _this._rotation20 = transform._rotation20; _this._rotation21 = transform._rotation21; _this._rotation22 = transform._rotation22; if (this._rigidBody != null) { var _this255 = this._rigidBody; _this255.updateMass(); var s = _this255._shapeList; while (s != null) { var n = s._next; var tf1 = _this255._ptransform; var tf2 = _this255._transform; var dst = s._ptransform; var src1 = s._localTransform; var __tmp__00 = void 0; var __tmp__01 = void 0; var __tmp__02 = void 0; var __tmp__10 = void 0; var __tmp__11 = void 0; var __tmp__12 = void 0; var __tmp__20 = void 0; var __tmp__21 = void 0; var __tmp__22 = void 0; __tmp__00 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; __tmp__01 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; __tmp__02 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; __tmp__10 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; __tmp__11 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; __tmp__12 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; __tmp__20 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; __tmp__21 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; __tmp__22 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; dst._rotation00 = __tmp__00; dst._rotation01 = __tmp__01; dst._rotation02 = __tmp__02; dst._rotation10 = __tmp__10; dst._rotation11 = __tmp__11; dst._rotation12 = __tmp__12; dst._rotation20 = __tmp__20; dst._rotation21 = __tmp__21; dst._rotation22 = __tmp__22; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; dst._positionX = __tmp__X; dst._positionY = __tmp__Y; dst._positionZ = __tmp__Z; dst._positionX += tf1._positionX; dst._positionY += tf1._positionY; dst._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var __tmp__001 = void 0; var __tmp__011 = void 0; var __tmp__021 = void 0; var __tmp__101 = void 0; var __tmp__111 = void 0; var __tmp__121 = void 0; var __tmp__201 = void 0; var __tmp__211 = void 0; var __tmp__221 = void 0; __tmp__001 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; __tmp__011 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; __tmp__021 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; __tmp__101 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; __tmp__111 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; __tmp__121 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; __tmp__201 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; __tmp__211 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; __tmp__221 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = __tmp__001; dst1._rotation01 = __tmp__011; dst1._rotation02 = __tmp__021; dst1._rotation10 = __tmp__101; dst1._rotation11 = __tmp__111; dst1._rotation12 = __tmp__121; dst1._rotation20 = __tmp__201; dst1._rotation21 = __tmp__211; dst1._rotation22 = __tmp__221; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } } } }, { key: "getDensity", value: function getDensity() { return this._density; } }, { key: "setDensity", value: function setDensity(density) { this._density = density; if (this._rigidBody != null) { var _this = this._rigidBody; _this.updateMass(); var s = _this._shapeList; while (s != null) { var n = s._next; var tf1 = _this._ptransform; var tf2 = _this._transform; var dst = s._ptransform; var src1 = s._localTransform; var __tmp__00 = void 0; var __tmp__01 = void 0; var __tmp__02 = void 0; var __tmp__10 = void 0; var __tmp__11 = void 0; var __tmp__12 = void 0; var __tmp__20 = void 0; var __tmp__21 = void 0; var __tmp__22 = void 0; __tmp__00 = tf1._rotation00 * src1._rotation00 + tf1._rotation01 * src1._rotation10 + tf1._rotation02 * src1._rotation20; __tmp__01 = tf1._rotation00 * src1._rotation01 + tf1._rotation01 * src1._rotation11 + tf1._rotation02 * src1._rotation21; __tmp__02 = tf1._rotation00 * src1._rotation02 + tf1._rotation01 * src1._rotation12 + tf1._rotation02 * src1._rotation22; __tmp__10 = tf1._rotation10 * src1._rotation00 + tf1._rotation11 * src1._rotation10 + tf1._rotation12 * src1._rotation20; __tmp__11 = tf1._rotation10 * src1._rotation01 + tf1._rotation11 * src1._rotation11 + tf1._rotation12 * src1._rotation21; __tmp__12 = tf1._rotation10 * src1._rotation02 + tf1._rotation11 * src1._rotation12 + tf1._rotation12 * src1._rotation22; __tmp__20 = tf1._rotation20 * src1._rotation00 + tf1._rotation21 * src1._rotation10 + tf1._rotation22 * src1._rotation20; __tmp__21 = tf1._rotation20 * src1._rotation01 + tf1._rotation21 * src1._rotation11 + tf1._rotation22 * src1._rotation21; __tmp__22 = tf1._rotation20 * src1._rotation02 + tf1._rotation21 * src1._rotation12 + tf1._rotation22 * src1._rotation22; dst._rotation00 = __tmp__00; dst._rotation01 = __tmp__01; dst._rotation02 = __tmp__02; dst._rotation10 = __tmp__10; dst._rotation11 = __tmp__11; dst._rotation12 = __tmp__12; dst._rotation20 = __tmp__20; dst._rotation21 = __tmp__21; dst._rotation22 = __tmp__22; var __tmp__X = void 0; var __tmp__Y = void 0; var __tmp__Z = void 0; __tmp__X = tf1._rotation00 * src1._positionX + tf1._rotation01 * src1._positionY + tf1._rotation02 * src1._positionZ; __tmp__Y = tf1._rotation10 * src1._positionX + tf1._rotation11 * src1._positionY + tf1._rotation12 * src1._positionZ; __tmp__Z = tf1._rotation20 * src1._positionX + tf1._rotation21 * src1._positionY + tf1._rotation22 * src1._positionZ; dst._positionX = __tmp__X; dst._positionY = __tmp__Y; dst._positionZ = __tmp__Z; dst._positionX += tf1._positionX; dst._positionY += tf1._positionY; dst._positionZ += tf1._positionZ; var dst1 = s._transform; var src11 = s._localTransform; var __tmp__001 = void 0; var __tmp__011 = void 0; var __tmp__021 = void 0; var __tmp__101 = void 0; var __tmp__111 = void 0; var __tmp__121 = void 0; var __tmp__201 = void 0; var __tmp__211 = void 0; var __tmp__221 = void 0; __tmp__001 = tf2._rotation00 * src11._rotation00 + tf2._rotation01 * src11._rotation10 + tf2._rotation02 * src11._rotation20; __tmp__011 = tf2._rotation00 * src11._rotation01 + tf2._rotation01 * src11._rotation11 + tf2._rotation02 * src11._rotation21; __tmp__021 = tf2._rotation00 * src11._rotation02 + tf2._rotation01 * src11._rotation12 + tf2._rotation02 * src11._rotation22; __tmp__101 = tf2._rotation10 * src11._rotation00 + tf2._rotation11 * src11._rotation10 + tf2._rotation12 * src11._rotation20; __tmp__111 = tf2._rotation10 * src11._rotation01 + tf2._rotation11 * src11._rotation11 + tf2._rotation12 * src11._rotation21; __tmp__121 = tf2._rotation10 * src11._rotation02 + tf2._rotation11 * src11._rotation12 + tf2._rotation12 * src11._rotation22; __tmp__201 = tf2._rotation20 * src11._rotation00 + tf2._rotation21 * src11._rotation10 + tf2._rotation22 * src11._rotation20; __tmp__211 = tf2._rotation20 * src11._rotation01 + tf2._rotation21 * src11._rotation11 + tf2._rotation22 * src11._rotation21; __tmp__221 = tf2._rotation20 * src11._rotation02 + tf2._rotation21 * src11._rotation12 + tf2._rotation22 * src11._rotation22; dst1._rotation00 = __tmp__001; dst1._rotation01 = __tmp__011; dst1._rotation02 = __tmp__021; dst1._rotation10 = __tmp__101; dst1._rotation11 = __tmp__111; dst1._rotation12 = __tmp__121; dst1._rotation20 = __tmp__201; dst1._rotation21 = __tmp__211; dst1._rotation22 = __tmp__221; var __tmp__X1 = void 0; var __tmp__Y1 = void 0; var __tmp__Z1 = void 0; __tmp__X1 = tf2._rotation00 * src11._positionX + tf2._rotation01 * src11._positionY + tf2._rotation02 * src11._positionZ; __tmp__Y1 = tf2._rotation10 * src11._positionX + tf2._rotation11 * src11._positionY + tf2._rotation12 * src11._positionZ; __tmp__Z1 = tf2._rotation20 * src11._positionX + tf2._rotation21 * src11._positionY + tf2._rotation22 * src11._positionZ; dst1._positionX = __tmp__X1; dst1._positionY = __tmp__Y1; dst1._positionZ = __tmp__Z1; dst1._positionX += tf2._positionX; dst1._positionY += tf2._positionY; dst1._positionZ += tf2._positionZ; var minX = void 0; var minY = void 0; var minZ = void 0; var maxX = void 0; var maxY = void 0; var maxZ = void 0; s._geom._computeAabb(s._aabb, s._ptransform); minX = s._aabb._minX; minY = s._aabb._minY; minZ = s._aabb._minZ; maxX = s._aabb._maxX; maxY = s._aabb._maxY; maxZ = s._aabb._maxZ; s._geom._computeAabb(s._aabb, s._transform); s._aabb._minX = minX < s._aabb._minX ? minX : s._aabb._minX; s._aabb._minY = minY < s._aabb._minY ? minY : s._aabb._minY; s._aabb._minZ = minZ < s._aabb._minZ ? minZ : s._aabb._minZ; s._aabb._maxX = maxX > s._aabb._maxX ? maxX : s._aabb._maxX; s._aabb._maxY = maxY > s._aabb._maxY ? maxY : s._aabb._maxY; s._aabb._maxZ = maxZ > s._aabb._maxZ ? maxZ : s._aabb._maxZ; if (s._proxy != null) { var dX = void 0; var dY = void 0; var dZ = void 0; dX = s._transform._positionX - s._ptransform._positionX; dY = s._transform._positionY - s._ptransform._positionY; dZ = s._transform._positionZ - s._ptransform._positionZ; var v = s.displacement; v.x = dX; v.y = dY; v.z = dZ; s._rigidBody._world._broadPhase.moveProxy(s._proxy, s._aabb, s.displacement); } s = n; } } } }, { key: "getAabb", value: function getAabb() { return this._aabb.clone(); } }, { key: "getAabbTo", value: function getAabbTo(aabb) { aabb.copyFrom(this._aabb); } }, { key: "getGeometry", value: function getGeometry() { return this._geom; } }, { key: "getRigidBody", value: function getRigidBody() { return this._rigidBody; } }, { key: "getCollisionGroup", value: function getCollisionGroup() { return this._collisionGroup; } }, { key: "setCollisionGroup", value: function setCollisionGroup(collisionGroup) { this._collisionGroup = collisionGroup; } }, { key: "getCollisionMask", value: function getCollisionMask() { return this._collisionMask; } }, { key: "setCollisionMask", value: function setCollisionMask(collisionMask) { this._collisionMask = collisionMask; } }, { key: "getContactCallback", value: function getContactCallback() { return this._contactCallback; } }, { key: "setContactCallback", value: function setContactCallback(callback) { this._contactCallback = callback; } }, { key: "getPrev", value: function getPrev() { return this._prev; } }, { key: "getNext", value: function getNext() { return this._next; } }]); return oimo_dynamics_rigidbody_Shape; }(); oimo.dynamics.rigidbody.ShapeConfig = /*#__PURE__*/_createClass(function oimo_dynamics_rigidbody_ShapeConfig() { _classCallCheck(this, oimo_dynamics_rigidbody_ShapeConfig); this.position = new oimo.common.Vec3(); this.rotation = new oimo.common.Mat3(); this.friction = oimo.common.Setting.defaultFriction; this.restitution = oimo.common.Setting.defaultRestitution; this.density = oimo.common.Setting.defaultDensity; this.collisionGroup = oimo.common.Setting.defaultCollisionGroup; this.collisionMask = oimo.common.Setting.defaultCollisionMask; this.geometry = null; this.contactCallback = null; }); if (!oimo.m) oimo.m = {}; oimo.m.M = /*#__PURE__*/_createClass(function oimo_m_M() { _classCallCheck(this, oimo_m_M); }); oimo.collision.broadphase.BroadPhaseType._BRUTE_FORCE = 1; oimo.collision.broadphase.BroadPhaseType._BVH = 2; oimo.collision.broadphase.BroadPhaseType.BRUTE_FORCE = 1; oimo.collision.broadphase.BroadPhaseType.BVH = 2; oimo.collision.broadphase.bvh.BvhInsertionStrategy.SIMPLE = 0; oimo.collision.broadphase.bvh.BvhInsertionStrategy.MINIMIZE_SURFACE_AREA = 1; oimo.collision.geometry.GeometryType._SPHERE = 0; oimo.collision.geometry.GeometryType._BOX = 1; oimo.collision.geometry.GeometryType._CYLINDER = 2; oimo.collision.geometry.GeometryType._CONE = 3; oimo.collision.geometry.GeometryType._CAPSULE = 4; oimo.collision.geometry.GeometryType._CONVEX_HULL = 5; oimo.collision.geometry.GeometryType._CONVEX_MIN = 0; oimo.collision.geometry.GeometryType._CONVEX_MAX = 5; oimo.collision.geometry.GeometryType.SPHERE = 0; oimo.collision.geometry.GeometryType.BOX = 1; oimo.collision.geometry.GeometryType.CYLINDER = 2; oimo.collision.geometry.GeometryType.CONE = 3; oimo.collision.geometry.GeometryType.CAPSULE = 4; oimo.collision.geometry.GeometryType.CONVEX_HULL = 5; oimo.collision.narrowphase.detector.BoxBoxDetector.EDGE_BIAS_MULT = 1.0; oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.OK = 0; oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.INVALID_TRIANGLE = 1; oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.NO_ADJACENT_PAIR_INDEX = 2; oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.NO_ADJACENT_TRIANGLE = 3; oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.EDGE_LOOP_BROKEN = 4; oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.NO_OUTER_TRIANGLE = 5; oimo.collision.narrowphase.detector.gjkepa.EpaPolyhedronState.TRIANGLE_INVISIBLE = 6; oimo.collision.narrowphase.detector.gjkepa.EpaTriangle.count = 0; oimo.common.Vec3.numCreations = 0; oimo.common.Setting.defaultFriction = 0.2; oimo.common.Setting.defaultRestitution = 0.2; oimo.common.Setting.defaultDensity = 1; oimo.common.Setting.defaultCollisionGroup = 1; oimo.common.Setting.defaultCollisionMask = 1; oimo.common.Setting.maxTranslationPerStep = 20; oimo.common.Setting.maxRotationPerStep = 3.14159265358979; oimo.common.Setting.bvhProxyPadding = 0.1; oimo.common.Setting.bvhIncrementalCollisionThreshold = 0.45; oimo.common.Setting.defaultGJKMargin = 0.05; oimo.common.Setting.enableGJKCaching = true; oimo.common.Setting.maxEPAVertices = 128; oimo.common.Setting.maxEPAPolyhedronFaces = 128; oimo.common.Setting.contactEnableBounceThreshold = 0.5; oimo.common.Setting.velocityBaumgarte = 0.2; oimo.common.Setting.positionSplitImpulseBaumgarte = 0.4; oimo.common.Setting.positionNgsBaumgarte = 1.0; oimo.common.Setting.contactUseAlternativePositionCorrectionAlgorithmDepthThreshold = 0.05; oimo.common.Setting.defaultContactPositionCorrectionAlgorithm = 0; oimo.common.Setting.alternativeContactPositionCorrectionAlgorithm = 1; oimo.common.Setting.contactPersistenceThreshold = 0.05; oimo.common.Setting.maxManifoldPoints = 4; oimo.common.Setting.defaultJointConstraintSolverType = 0; oimo.common.Setting.defaultJointPositionCorrectionAlgorithm = 0; oimo.common.Setting.jointWarmStartingFactorForBaungarte = 0.8; oimo.common.Setting.jointWarmStartingFactor = 0.95; oimo.common.Setting.minSpringDamperDampingRatio = 1e-6; oimo.common.Setting.minRagdollMaxSwingAngle = 1e-6; oimo.common.Setting.maxJacobianRows = 6; oimo.common.Setting.directMlcpSolverEps = 1e-9; oimo.common.Setting.islandInitialRigidBodyArraySize = 128; oimo.common.Setting.islandInitialConstraintArraySize = 128; oimo.common.Setting.sleepingVelocityThreshold = 0.2; oimo.common.Setting.sleepingAngularVelocityThreshold = 0.5; oimo.common.Setting.sleepingTimeThreshold = 1.0; oimo.common.Setting.disableSleeping = false; oimo.common.Setting.linearSlop = 0.005; oimo.common.Setting.angularSlop = 0.017453292519943278; oimo.collision.narrowphase.detector.gjkepa.GjkEpa.instance = new oimo.collision.narrowphase.detector.gjkepa.GjkEpa(); oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._SUCCEEDED = 0; oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._GJK_FAILED_TO_MAKE_TETRAHEDRON = 1; oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._GJK_DID_NOT_CONVERGE = 2; oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._EPA_FAILED_TO_INIT = 257; oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._EPA_FAILED_TO_ADD_VERTEX = 258; oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState._EPA_DID_NOT_CONVERGE = 259; oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.SUCCEEDED = 0; oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.GJK_FAILED_TO_MAKE_TETRAHEDRON = 1; oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.GJK_DID_NOT_CONVERGE = 2; oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_FAILED_TO_INIT = 257; oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_FAILED_TO_ADD_VERTEX = 258; oimo.collision.narrowphase.detector.gjkepa.GjkEpaResultState.EPA_DID_NOT_CONVERGE = 259; oimo.common.Mat3.numCreations = 0; oimo.common.Mat4.numCreations = 0; oimo.common.MathUtil.POSITIVE_INFINITY = 1e65536; oimo.common.MathUtil.NEGATIVE_INFINITY = -1e65536; oimo.common.MathUtil.PI = 3.14159265358979; oimo.common.MathUtil.TWO_PI = 6.28318530717958; oimo.common.MathUtil.HALF_PI = 1.570796326794895; oimo.common.MathUtil.TO_RADIANS = 0.017453292519943278; oimo.common.MathUtil.TO_DEGREES = 57.29577951308238; oimo.common.Quat.numCreations = 0; oimo.dynamics.common.DebugDraw.SPHERE_PHI_DIVISION = 8; oimo.dynamics.common.DebugDraw.SPHERE_THETA_DIVISION = 4; oimo.dynamics.common.DebugDraw.CIRCLE_THETA_DIVISION = 8; oimo.dynamics.common.Performance.broadPhaseCollisionTime = 0; oimo.dynamics.common.Performance.narrowPhaseCollisionTime = 0; oimo.dynamics.common.Performance.dynamicsTime = 0; oimo.dynamics.common.Performance.totalTime = 0; oimo.dynamics.constraint.PositionCorrectionAlgorithm._BAUMGARTE = 0; oimo.dynamics.constraint.PositionCorrectionAlgorithm._SPLIT_IMPULSE = 1; oimo.dynamics.constraint.PositionCorrectionAlgorithm._NGS = 2; oimo.dynamics.constraint.PositionCorrectionAlgorithm.BAUMGARTE = 0; oimo.dynamics.constraint.PositionCorrectionAlgorithm.SPLIT_IMPULSE = 1; oimo.dynamics.constraint.PositionCorrectionAlgorithm.NGS = 2; oimo.dynamics.constraint.info.JacobianRow.BIT_LINEAR_SET = 1; oimo.dynamics.constraint.info.JacobianRow.BIT_ANGULAR_SET = 2; oimo.dynamics.constraint.joint.JointType._SPHERICAL = 0; oimo.dynamics.constraint.joint.JointType._REVOLUTE = 1; oimo.dynamics.constraint.joint.JointType._CYLINDRICAL = 2; oimo.dynamics.constraint.joint.JointType._PRISMATIC = 3; oimo.dynamics.constraint.joint.JointType._UNIVERSAL = 4; oimo.dynamics.constraint.joint.JointType._RAGDOLL = 5; oimo.dynamics.constraint.joint.JointType._GENERIC = 6; oimo.dynamics.constraint.joint.JointType.SPHERICAL = 0; oimo.dynamics.constraint.joint.JointType.REVOLUTE = 1; oimo.dynamics.constraint.joint.JointType.CYLINDRICAL = 2; oimo.dynamics.constraint.joint.JointType.PRISMATIC = 3; oimo.dynamics.constraint.joint.JointType.UNIVERSAL = 4; oimo.dynamics.constraint.joint.JointType.RAGDOLL = 5; oimo.dynamics.constraint.joint.JointType.GENERIC = 6; oimo.dynamics.constraint.solver.ConstraintSolverType._ITERATIVE = 0; oimo.dynamics.constraint.solver.ConstraintSolverType._DIRECT = 1; oimo.dynamics.constraint.solver.ConstraintSolverType.ITERATIVE = 0; oimo.dynamics.constraint.solver.ConstraintSolverType.DIRECT = 1; oimo.dynamics.rigidbody.RigidBodyType._DYNAMIC = 0; oimo.dynamics.rigidbody.RigidBodyType._STATIC = 1; oimo.dynamics.rigidbody.RigidBodyType._KINEMATIC = 2; oimo.dynamics.rigidbody.RigidBodyType.DYNAMIC = 0; oimo.dynamics.rigidbody.RigidBodyType.STATIC = 1; oimo.dynamics.rigidbody.RigidBodyType.KINEMATIC = 2; });